Skip to content

Commit

Permalink
Netgame stuff for H1 scenario exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
General-101 committed Dec 7, 2024
1 parent e0a98d9 commit 0f10310
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 2 deletions.
15 changes: 14 additions & 1 deletion io_scene_halo/file_tag/build_scene/generate_h1_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from ...global_functions import global_functions
from ...global_functions.parse_tags import parse_tag
from ..h1.file_scenario.mesh_helper.build_mesh import get_object
from ..h1.file_scenario.format import DataTypesEnum, ObjectFlags, UnitFlags, VehicleFlags, ItemFlags, DeviceFlags, MachineFlags, ControlFlags
from ..h1.file_scenario.format import DataTypesEnum, ObjectFlags, UnitFlags, VehicleFlags, ItemFlags, DeviceFlags, MachineFlags, ControlFlags, NetGameEquipment

def generate_skies(context, level_root, tag_block, report):
asset_collection = bpy.data.collections.get("Skies")
Expand Down Expand Up @@ -239,9 +239,22 @@ def get_data_type(collection_name, root, tag_path, element, object_name_tag_bloc

elif collection_name == "Netgame Flags":
root.tag_view.data_type_enum = str(DataTypesEnum.netgame_flags.value)
root.tag_view.netgame_type = str(element.type)
root.tag_view.usage_id = element.usage_id
root.tag_view.tag_path = element.weapon_group.name

elif collection_name == "Netgame Equipment":
element_flags = NetGameEquipment(element.flags)

root.tag_view.data_type_enum = str(DataTypesEnum.netgame_equipment.value)
root.tag_view.levitate = NetGameEquipment.levitate in element_flags
root.tag_view.type_0 = str(element.type_0)
root.tag_view.type_1 = str(element.type_1)
root.tag_view.type_2 = str(element.type_2)
root.tag_view.type_3 = str(element.type_3)
root.tag_view.team_index = element.team_index
root.tag_view.spawn_time = element.spawn_time
root.tag_view.tag_path = element.item_collection.name

def generate_object_elements(level_root, collection_name, object_name_tag_block, palette, tag_block, context, game_version, file_version, fix_rotations, report, random_color_gen):
objects_list = []
Expand Down
53 changes: 52 additions & 1 deletion io_scene_halo/file_tag/h1/file_scenario/process_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import bpy

from math import degrees
from .format import ScenarioAsset, ObjectFlags, UnitFlags, VehicleFlags, ItemFlags, DeviceFlags, MachineFlags, ControlFlags
from .format import ScenarioAsset, ObjectFlags, UnitFlags, VehicleFlags, ItemFlags, DeviceFlags, MachineFlags, ControlFlags, NetGameEquipment
from ....global_functions import global_functions, tag_format

def get_palette_index(TAG, SCENARIO, tag_group, tag_path, palette_tag_block):
Expand Down Expand Up @@ -161,6 +161,12 @@ def get_control_flags(ob):
control_flags += ControlFlags.usable_from_both_sides.value
return control_flags

def get_netgame_equipment_flags(ob):
netgame_equipment_flags = 0
if ob.tag_view.levitate:
netgame_equipment_flags += NetGameEquipment.levitate.value
return netgame_equipment_flags

def generate_comments(TAG, SCENARIO):
comment_collection = bpy.data.collections.get("Comments")
blender_comments = []
Expand Down Expand Up @@ -411,6 +417,47 @@ def generate_trigger_volumes(TAG, SCENARIO):

SCENARIO.trigger_volumes = blender_trigger_volumes

def generate_netgame_flags(TAG, SCENARIO):
netgame_flags_collection = bpy.data.collections.get("Netgame Flags")
blender_netgame_flags = []
if netgame_flags_collection:
for ob in netgame_flags_collection.objects:
netgame_flag = SCENARIO.NetGameFlag()
rot = ob.rotation_euler

netgame_flag.position = ob.location / 100
netgame_flag.facing = get_half_angle(degrees(rot[2]))
netgame_flag.type = int(ob.tag_view.netgame_type)
netgame_flag.usage_id = ob.tag_view.usage_id
netgame_flag.weapon_group = TAG.TagRef("weap", ob.tag_view.tag_path, len(ob.tag_view.tag_path))

blender_netgame_flags.append(netgame_flag)

SCENARIO.netgame_flags = blender_netgame_flags

def generate_netgame_equipment(TAG, SCENARIO):
netgame_equipment_collection = bpy.data.collections.get("Netgame Equipment")
blender_netgame_equipment = []
if netgame_equipment_collection:
for ob in netgame_equipment_collection.objects:
netgame_equipment = SCENARIO.NetGameEquipment()
rot = ob.rotation_euler

netgame_equipment.flags = get_netgame_equipment_flags(ob)
netgame_equipment.type_0 = int(ob.tag_view.type_0)
netgame_equipment.type_1 = int(ob.tag_view.type_1)
netgame_equipment.type_2 = int(ob.tag_view.type_2)
netgame_equipment.type_3 = int(ob.tag_view.type_3)
netgame_equipment.team_index = ob.tag_view.team_index
netgame_equipment.spawn_time = ob.tag_view.spawn_time
netgame_equipment.position = ob.location / 100
netgame_equipment.facing = get_half_angle(degrees(rot[2]))
netgame_equipment.item_collection = TAG.TagRef("itmc", ob.tag_view.tag_path, len(ob.tag_view.tag_path))

blender_netgame_equipment.append(netgame_equipment)

SCENARIO.netgame_equipment = blender_netgame_equipment

def create_tag(TAG):
SCENARIO = ScenarioAsset()
TAG.is_legacy = False
Expand Down Expand Up @@ -568,6 +615,8 @@ def generate_scenario_scene(DONOR_ASSET):
generate_sound_scenery(TAG, DONOR_ASSET)
generate_player_starting_locations(TAG, DONOR_ASSET)
generate_trigger_volumes(TAG, DONOR_ASSET)
generate_netgame_flags(TAG, DONOR_ASSET)
generate_netgame_equipment(TAG, DONOR_ASSET)

DONOR_ASSET.comments_tag_block = TAG.TagBlock(len(DONOR_ASSET.comments))
DONOR_ASSET.object_names_tag_block = TAG.TagBlock(len(DONOR_ASSET.object_names))
Expand All @@ -591,5 +640,7 @@ def generate_scenario_scene(DONOR_ASSET):
DONOR_ASSET.sound_scenery_palette_tag_block = TAG.TagBlock(len(DONOR_ASSET.sound_scenery_palette))
DONOR_ASSET.player_starting_locations_tag_block = TAG.TagBlock(len(DONOR_ASSET.player_starting_locations))
DONOR_ASSET.trigger_volumes_tag_block = TAG.TagBlock(len(DONOR_ASSET.trigger_volumes))
DONOR_ASSET.netgame_flags_tag_block = TAG.TagBlock(len(DONOR_ASSET.netgame_flags))
DONOR_ASSET.netgame_equipment_tag_block = TAG.TagBlock(len(DONOR_ASSET.netgame_equipment))

return DONOR_ASSET
85 changes: 85 additions & 0 deletions io_scene_halo/global_ui/tag_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,38 @@ class HALO_PropertiesGroup(PropertyGroup):
items=type_options
)

netgame_type: EnumProperty(
name="Type",
description="Type",
items = ( ('0', "CTF - Flag", "CTF - Flag"),
('1', "Unused1", "Unused1"),
('2', "Oddball - Ball Spawn", "Oddball - Ball Spawn"),
('3', "Race - Track", "Race - Track"),
('4', "Race - Vehicle", "Race - Vehicle"),
('5', "Unused5", "Unused5"),
('6', "Teleport From", "Teleport From"),
('7', "Teleport To", "Teleport To"),
('8', "Hill - Flag", "Hill - Flag"),
)
)

usage_id: IntProperty(
name = "Usage ID",
description = "Usage ID",
min = 0
)

levitate: BoolProperty(
name ="Levitate",
description = "Levitate",
default = False,
)

spawn_time: IntProperty(
name="Spawn Time",
description="Spawn Time"
)

def render_cluster(layout, tag_view):
box = layout.split()
col = box.column(align=True)
Expand Down Expand Up @@ -680,6 +712,54 @@ def render_player_starting_location(layout, tag_view):
row.label(text='Type 3')
row.prop(tag_view, "type_3", text='')

def render_netgame_flags(layout, tag_view):
box = layout.split()
col = box.column(align=True)

row = col.row()
row.label(text='Type')
row.prop(tag_view, "netgame_type", text='')
row = col.row()
row.label(text='Usage ID')
row.prop(tag_view, "usage_id", text='')
row = col.row()
row.label(text='Weapon Group')
row.prop(tag_view, "tag_path", text='')

def render_netgame_equipment(layout, tag_view):
box = layout.split()
col = box.column(align=True)

box_flags = layout.box()
box_flags.label(text="Flags")
col_flags = box_flags.column(align=True)
row_flags = col_flags.row()
row_flags.prop(tag_view, "levitate")

box = layout.split()
col = box.column(align=True)
row = col.row()
row.label(text='Type 0')
row.prop(tag_view, "type_0", text='')
row = col.row()
row.label(text='Type 1')
row.prop(tag_view, "type_1", text='')
row = col.row()
row.label(text='Type 2')
row.prop(tag_view, "type_2", text='')
row = col.row()
row.label(text='Type 3')
row.prop(tag_view, "type_3", text='')
row = col.row()
row.label(text='Team Index')
row.prop(tag_view, "team_index", text='')
row = col.row()
row.label(text='Spawn Time')
row.prop(tag_view, "spawn_time", text='')
row = col.row()
row.label(text='Item Collection')
row.prop(tag_view, "tag_path", text='')

class Halo_TagView(Panel):
bl_label = "Halo Tag View"
bl_idname = "HALO_PT_TagView"
Expand Down Expand Up @@ -733,5 +813,10 @@ def draw(self, context):
render_light_fixture(layout, tag_view)
elif data_type_value == DataTypesEnum.player_starting_locations.value:
render_player_starting_location(layout, tag_view)
elif data_type_value == DataTypesEnum.netgame_flags.value:
render_netgame_flags(layout, tag_view)
elif data_type_value == DataTypesEnum.netgame_equipment.value:
render_netgame_equipment(layout, tag_view)
elif data_type_value == DataTypesEnum.instances.value:
render_instance(layout, tag_view)

0 comments on commit 0f10310

Please sign in to comment.