# Starting trigger for fixing/unfixing bayonet
multiplayer_client_start_fixing_bayonet = (
0, 0.05, 0, [(neg|multiplayer_is_dedicated_server),
(neg|is_presentation_active, "prsnt_multiplayer_admin_chat"),
(key_clicked,key_b),
],
[
(multiplayer_get_my_player, ":cur_player"),
(player_is_active,":cur_player"),
# Fix/Unfix bayonet
(store_mission_timer_a_msec,":cur_time"),
(store_sub, ":elapsed_time", ":cur_time", "$g_last_time_bayonet_was_fixed"),
# Player has to wait 5 seconds between fixing/unfixing bayonet
(ge,":elapsed_time",5000),
(player_get_agent_id, ":cur_player_agent", ":cur_player"),
(agent_get_wielded_item,":cur_wielded_weapon",":cur_player_agent", 0),
(assign, ":continue", 1),
# INCOMPLETE SECTION
# Write your musket type detection code here
(assign, ":musket_type", 0),
(try_begin),
(eq,":musket_type",0),
#Bayonet will be unfixed after 1.5s
(assign,"$g_bayonet_equip_timer", 1500),
(else_try),
(eq,":musket_type",1),
#Bayonet will be unfixed after 2.6s
(assign,"$g_bayonet_equip_timer", 2600),
(else_try),
(assign, ":continue", 0),
(try_end),
(eq, ":continue", 1),
(assign,"$g_last_time_bayonet_was_fixed",":cur_time"),
(assign,"$g_bayonet_is_being_fixed", 1),
(assign,"$g_current_weapon", ":cur_wielded_weapon"),
(multiplayer_send_2_int_to_server, multiplayer_event_fix_bayonet, ":cur_player_agent",":cur_wielded_weapon"),
])
# This gets triggered after multiplayer_client_start_fixing_bayonet
# Equips the player with fixed/unfixed musket while the animation is playing
multiplayer_client_equip_item = (
0, 0, 0, [(neg|multiplayer_is_dedicated_server),
(eq,"$g_bayonet_is_being_fixed",1),
],
[
(multiplayer_get_my_player, ":cur_player"),
(player_is_active,":cur_player"),
(store_mission_timer_a_msec,":cur_time"),
(store_sub, ":elapsed_time", ":cur_time", "$g_last_time_bayonet_was_fixed"),
(ge,":elapsed_time","$g_bayonet_equip_timer"),
(player_get_agent_id, ":cur_player_agent", ":cur_player"),
(assign,":continue",1),
(try_begin),
# Stop fixing/unfixing if the player switched to a different weapon
(agent_get_wielded_item,":cur_player_item",":cur_player_agent",0),
(neq,":cur_player_item","$g_current_weapon"),
(multiplayer_send_int_to_server, multiplayer_event_stop_fixing_bayonet, ":cur_player_agent"),
(assign,"$g_bayonet_is_being_fixed",0),
(assign,":continue",0),
(try_end),
(eq,":continue",1),
(assign,":player_new_item", "$g_current_weapon"),
(try_begin),
(eq,"$g_current_weapon","itm_british_brown_bess"),
(assign,":player_new_item","itm_british_brown_bess_bare"),
(else_try),
(eq,"$g_current_weapon","itm_british_brown_bess_bare"),
(assign,":player_new_item","itm_british_brown_bess"),
(else_try),
# Repeat the same for other factions
# .......
(try_end),
(multiplayer_send_2_int_to_server, multiplayer_event_equip_bayonet, "$g_current_weapon",":player_new_item"),
(assign,"$g_bayonet_is_being_fixed",0),
])