Hello folks, been a few years since I last did stuff for Warband so I'd appreciate some help in what I'm missing here.
My goal: Create a heraldic banner/flag/standard system of flags as items which are carried around, but if dropped they keep the tableau mesh/banner of the player that dropped them. The flags cannot be sheathed, they are dropped upon sheathing.
Current status:
- The flags automatically drop on unsheathing. The flags are correctly placed and rotated when dropped/unsheathed.
- The heraldic status is preserved on item unsheathe, but not on item dropped.
- There is a multiplayer event but I am not sure I coded it right.
Issues:
- The game crashes if a player picks up a banner dropped by another player.
- The global variable isn't correctly cleared on e.g. team swap if the player is using faction banners instead of a specific one. On first item selection the old faction banner will be displayed, spawning however correctly assigns new tableaus.
- The heraldic status isn't preserved on ti_item_dropped, I can't seem to be able to influence the prop tableau.
- Sometimes dropping a shield also causes it to have applied heraldry which is not intentional and a side effect of bad global var clearing.
Code:
Module_scripts
First, I set this to 0.
The MP event, under ###SERVER EVENTS###
The modified shield_item_set_banner script taking into account the global var state.
So, I know my logic in approaching clearing the global var is bad but I'm not sure how the agent IDs behave and when because when I was testing with some display messages I sometimes found myself picking up an item and both the agent_no > -1 and the agent_no <= -1 firing. Lemme know how bad this is
My goal: Create a heraldic banner/flag/standard system of flags as items which are carried around, but if dropped they keep the tableau mesh/banner of the player that dropped them. The flags cannot be sheathed, they are dropped upon sheathing.
Current status:
- The flags automatically drop on unsheathing. The flags are correctly placed and rotated when dropped/unsheathed.
- The heraldic status is preserved on item unsheathe, but not on item dropped.
- There is a multiplayer event but I am not sure I coded it right.
Issues:
- The game crashes if a player picks up a banner dropped by another player.
- The global variable isn't correctly cleared on e.g. team swap if the player is using faction banners instead of a specific one. On first item selection the old faction banner will be displayed, spawning however correctly assigns new tableaus.
- The heraldic status isn't preserved on ti_item_dropped, I can't seem to be able to influence the prop tableau.
- Sometimes dropping a shield also causes it to have applied heraldry which is not intentional and a side effect of bad global var clearing.
Code:
Python:
multiplayer_event_standard = 117
Python:
toc_standard_unwielded = (
ti_on_item_unwielded, 0.1, 0,
[(this_or_next|multiplayer_is_server),
(neg|game_in_multiplayer_mode)],
[
(store_trigger_param_1,":agent_no"),
(store_trigger_param_2,":item_id"),
(try_begin),
(gt,":item_id",-1),
(item_slot_eq, ":item_id", slot_item_multiplayer_item_class, multi_item_class_type_standard),
(agent_is_active,":agent_no"),
(agent_get_position, pos63,":agent_no"),
(position_move_y, pos63, 30),
(agent_get_horse, ":agent_horse", ":agent_no"),
(try_begin),
(gt, ":agent_horse", -1),
(position_move_x, pos63, 50),
(else_try),
(position_move_z, pos63, 40),
(try_end),
(position_rotate_x, pos63, 90),
(set_spawn_position, pos63),
#Marko begin
(call_script, "script_agent_troop_get_banner_mesh", ":agent_no", 0), #Find player's banner
(multiplayer_send_int_to_server, multiplayer_event_standard, reg0),
(spawn_item,":item_id",0,0), #Never remove
#Marko end
(assign, ":end_cond", ek_head),
(try_for_range,":equipment_slot", ek_item_0, ":end_cond"),
(agent_get_item_slot, ":cur_item_id", ":agent_no", ":equipment_slot"),
(eq, ":cur_item_id", ":item_id"),
(val_add,":equipment_slot",1),
(agent_unequip_item, ":agent_no", ":item_id", ":equipment_slot"),
(assign,":end_cond",0),
(try_end),
(agent_unequip_item,":agent_no",":item_id"),
(try_end),
])
toc_standard_dropped = (
ti_on_item_dropped, 0, 0,
[(this_or_next|multiplayer_is_server),
(neg|game_in_multiplayer_mode)],
[
(store_trigger_param_2, ":item_id"),
(try_begin),
(gt,":item_id",-1),
(store_trigger_param_1, ":agent_no"),
(agent_is_active,":agent_no"),
#Marko begin
(call_script, "script_agent_troop_get_banner_mesh", ":agent_no", 0), #Find player's banner
(multiplayer_send_int_to_server, multiplayer_event_standard, reg0),
#Marko end
(try_begin),
(item_slot_eq, ":item_id", slot_item_multiplayer_item_class, multi_item_class_type_standard),
(store_trigger_param_3, ":dropped_prop"),
(prop_instance_get_position, pos63, ":dropped_prop"),
#Marko begin
(cur_scene_prop_set_tableau_material, "tableau_heraldic_banner", "$standard_tableau"),
#Marko end
(agent_get_horse, ":agent_horse", ":agent_no"),
(try_begin),
(gt, ":agent_horse", -1),
(position_move_x, pos63, 50),
(else_try),
(position_move_z, pos63, 40),
(try_end),
(position_rotate_x, pos63, 90),
(prop_instance_set_position, ":dropped_prop", pos63),
(try_end),
])
Module_scripts
First, I set this to 0.
Python:
(assign, "$standard_tableau", 0), #Assign banner mesh to global
The MP event, under ###SERVER EVENTS###
Python:
(else_try),
(eq, ":event_type", multiplayer_event_standard),
(store_script_param, ":tableau_mesh", 3),
#(assign, reg1, ":tableau_mesh"),
#(display_message, "@multiplayer_event_standard, {reg1}"), #The correct banner is passed via :tableau_mesh - tested
(try_begin), #If the receiver is server, send mesh to players for updating
(multiplayer_is_dedicated_server),
(try_for_players,":i",1),
(multiplayer_send_int_to_player, ":i", multiplayer_event_standard, ":tableau_mesh"),
(try_end),
(else_try), #If the receiver is player, update global variable
(assign, "$standard_tableau", ":tableau_mesh"), #Assign banner mesh to global variable
(try_end),
The modified shield_item_set_banner script taking into account the global var state.
Python:
(else_try),
("shield_item_set_banner",
[
(store_script_param, ":tableau_no",1),
(store_script_param, ":agent_no", 2),
(store_script_param, ":troop_no", 3),
(call_script, "script_agent_troop_get_banner_mesh", ":agent_no", ":troop_no"),
#Marko begin
(try_begin), #Global not overriden
(eq, "$standard_tableau", 0),
(cur_item_set_tableau_material, ":tableau_no", reg0),
(else_try),
(cur_item_set_tableau_material, ":tableau_no", "$standard_tableau"),
(try_end),
(try_begin), #Clear global
(gt, ":agent_no", -1),
(assign, "$standard_tableau", 0),
(try_end),
]),
#Marko end
Python:
["heraldic_banner", "Banner", [("heraldic_banner" ,0),("heraldic_banner_inventory", ixmesh_inventory)], itp_type_two_handed_wpn|itp_two_handed|itp_primary|itp_wooden_parry|itp_no_blur, itc_standard,
140, weight(3)|difficulty(10)|spd_rtng(88)|weapon_length(99)|swing_damage(0,cut)|thrust_damage(0,blunt), imodbits_none, [(ti_on_init_item, [(store_trigger_param_1, ":agent_no"),(store_trigger_param_2, ":troop_no"),(call_script, "script_shield_item_set_banner", "tableau_heraldic_banner", ":agent_no", ":troop_no"),(cur_item_add_mesh, "@heraldic_banner_base", 0, 0),])] ],
So, I know my logic in approaching clearing the global var is bad but I'm not sure how the agent IDs behave and when because when I was testing with some display messages I sometimes found myself picking up an item and both the agent_no > -1 and the agent_no <= -1 firing. Lemme know how bad this is
Last edited: