(
"lead_charge",mtf_battle_mode|mtf_synch_inventory,charge,
"You lead your men to battle.",
[
(1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
(0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
(4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
(4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
],
[
sp_shield_bash_1,
sp_shield_bash_2,
#sp_shield_bash_3,
common_weapon_break,
theoris_decapitation,
common_blokowanie_pociskow,
#SW - added regen for certain agents
common_regeneration_store_info,
common_regeneration,
custom_commander_special_strike,
custom_commander_give_hero_extra_wp,
## MadVader deathcam begin
common_init_deathcam,
common_start_deathcam,
common_move_deathcam,
common_rotate_deathcam,
common_secondary_fire,
## MadVader deathcam end
common_secondary_fire = [
#test for ammo when spawned
(ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param_1, ":agent_no"),
(agent_is_human, ":agent_no"),
(call_script, "script_agent_init_secondary_ammo", ":agent_no"),
]
),
(ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param_1, ":agent_no"),
(call_script, "script_agent_reassign_team", ":agent_no"),
(assign, ":initial_courage_score", 5000),
(agent_get_troop_id, ":troop_id", ":agent_no"),
(store_character_level, ":troop_level", ":troop_id"),
(val_mul, ":troop_level", 35),
(val_add, ":initial_courage_score", ":troop_level"), #average : 20 * 35 = 700
(store_random_in_range, ":randomized_addition_courage", 0, 3000), #average : 1500
(val_add, ":initial_courage_score", ":randomized_addition_courage"),
(agent_get_party_id, ":agent_party", ":agent_no"),
(party_get_morale, ":cur_morale", ":agent_party"),
(store_sub, ":morale_effect_on_courage", ":cur_morale", 70),
(val_mul, ":morale_effect_on_courage", 30), #this can effect morale with -2100..900
(val_add, ":initial_courage_score", ":morale_effect_on_courage"),
#average = 5000 + 700 + 1500 = 7200; min : 5700, max : 8700
#morale effect = min : -2100(party morale is 0), average : 0(party morale is 70), max : 900(party morale is 100)
#min starting : 3600, max starting : 9600, average starting : 7200
(agent_set_slot, ":agent_no", slot_agent_courage_score, ":initial_courage_score"),
]),
#ai loop
(2, 0, 0, [],
[
(try_for_agents, ":agent_no"),
(agent_is_active, ":agent_no"),
(agent_is_human, ":agent_no"),
(agent_is_alive, ":agent_no"),
(agent_is_non_player, ":agent_no"),
#(agent_slot_ge, ":agent_no", slot_agent_bonus_ammo, 1),
(agent_get_wielded_item, ":pistol", ":agent_no", 1),
(eq, ":pistol", "itm_flintlock_shield"),
(agent_get_slot, ":interval", ":agent_no", slot_agent_bonus_cooldown),
(agent_get_slot, ":ammo", ":agent_no", slot_agent_bonus_ammo),
(try_begin), #reloading
(lt, ":ammo", 0),
(gt, ":interval", 100),
(val_sub, ":interval", 10),
(val_add, ":ammo", 1),
(val_mul, ":ammo", -1),
(agent_set_slot, ":agent_no", slot_agent_bonus_ammo, ":ammo"),
(str_store_string, s2, "@reloading"),
(agent_set_animation, ":agent_no", "anim_reload_pistol_alt"),
(agent_set_animation_progress, ":agent_no", 0),
(else_try), #decreasing
(gt, ":interval", 0),
(agent_get_troop_id, ":troop_no", ":agent_no"),
(store_skill_level, ":skill", "skl_weapon_master", ":troop_no"),
(val_add, ":skill", 3),
(val_sub, ":interval", ":skill"),
(str_clear, s2),
(else_try), #targeting
(le, ":interval", 0),
(gt, ":ammo", 0),
(try_begin),
(call_script, "script_cf_agent_secondary_target", ":agent_no"),
(store_random_in_range, ":interval", 150, 300),
(str_store_string, s2, "@shooting"),
(else_try), #failed target
(store_random_in_range, ":random_no", 30, 75),
(val_add, ":interval", ":random_no"),
(str_store_string, s2, "@waiting"),
(try_end),
(try_end),
(val_max, ":interval", 0),
(try_begin),
(neg|str_is_empty, s2),
(str_store_agent_name, s1, ":agent_no"),
(assign, reg0, ":agent_no"),
(assign, reg1, ":ammo"),
(assign, reg2, ":interval"),
(display_message, "@{reg0}:{s1} has {reg1} extra ammo left with {reg2} interval while {s2}"),
(try_end),
(agent_set_slot, ":agent_no", slot_agent_bonus_cooldown, ":interval"),
(try_end),
]),
#separate handler for actual firing
(1, 3, 5, [
# (get_player_agent_no, "$g_player_agent"),
(agent_is_alive, "$g_player_agent"),
(agent_get_animation, ":animation", "$g_player_agent", 1),
(eq, ":animation", "anim_ready_pistol_alt"), #ready state, not interrupted
(neg|game_key_is_down, gk_defend),
(agent_get_slot, ":ammo", "$g_player_agent", slot_agent_bonus_ammo),
(gt, ":ammo", 0), #has shots left, not reloading
(agent_get_wielded_item, ":pistol", "$g_player_agent", 1),
(eq, ":pistol", "itm_flintlock_shield"),
(call_script, "script_agent_secondary_fire", "$g_player_agent"), #ammo is flipped here
],
#finish reload action after 3 seconds - animation can become interrupted but who cares
[
(get_player_agent_no, "$g_player_agent"),
#do slot usage
(agent_get_slot, ":ammo", "$g_player_agent", slot_agent_bonus_ammo),
(val_mul, ":ammo", -1), #renormalize count
(val_sub, ":ammo", 1),
(try_begin), #depleted bonus ammo, going into regular pool
(le, ":ammo", 0),
(assign, ":ammo", -1),
(try_for_range, ":item_slots", ek_item_0, ek_head),
(agent_get_item_slot, ":cur_item", "$g_player_agent", ":item_slots"),
(gt, ":cur_item", 0),
(item_get_type, ":cur_type", ":cur_item"),
(eq, ":cur_type", itp_type_bullets),
(agent_get_ammo_for_slot, ":cur_ammo", "$g_player_agent", ":item_slots"),
(val_add, ":ammo", ":cur_ammo"),
(try_end),
(try_begin),
(neq, ":ammo", -1),
(agent_set_ammo, "$g_player_agent", "itm_cartridges", ":ammo"), #this line might change to accomodate other types
(assign, ":ammo", 1), #take bullet from main ammo stack
(else_try),
(assign, ":ammo", 0),
(try_end),
(try_end),
# (val_max, ":ammo", 0),
(agent_set_slot, "$g_player_agent", slot_agent_bonus_ammo, ":ammo"),
# (agent_set_ammo, ":player_agent", "itm_cartridges", ":ammo"),
# (presentation_set_duration, 0), #remove the crosshair
# (try_begin),
# (eq, ":ammo", 0),
# (display_message, "@No more secondary ammo...", 0xff99aa),
# (try_end),
# (call_script, "script_agent_secondary_fire", ":player_agent"),
]
),
#try not to check every frame to prevent sticky triggers
(0.5, 0, 5, [
(game_key_is_down, gk_defend),
# (get_player_agent_no, "$g_player_agent"),
(agent_is_alive, "$g_player_agent"),
(agent_get_wielded_item, ":pistol", "$g_player_agent", 1),
(eq, ":pistol", "itm_flintlock_shield"), #test for first behaviour
(agent_get_animation, ":animation", "$g_player_agent", 1),
#not already reloading (either hands)
(neg|is_between, ":animation", "anim_ready_pistol_alt", "anim_unused_human_anim_47"),
(neg|is_between, ":animation", "anim_ready_pistol", "anim_ready_swingright_fist"),
],
[
# (get_player_agent_no, "$g_player_agent"),
(agent_get_slot, ":ammo", "$g_player_agent", slot_agent_bonus_ammo),
(try_begin),
(gt, ":ammo", 0), #has shots left
# (agent_get_animation, ":animation", "$g_player_agent", 1),
# (try_begin), #make sure the priority is higher?
# (eq, ":animation", "anim_ready_pistol_alt"), #now handled in separate release trigger
# (call_script, "script_agent_secondary_fire", "$g_player_agent"),
# (else_try), #the ready animation already has a high piority to override the defend from shields
(agent_set_animation, "$g_player_agent", "anim_ready_pistol_alt", 1), #keep position
# (try_end),
(try_begin), #do crosshair jittering somehow
(neg|is_presentation_active, "prsnt_cross_hair"),
(start_presentation, "prsnt_cross_hair"),
(try_end),
(else_try), #check for leftover ammunition from cartridges instead
(is_presentation_active, "prsnt_cross_hair"),
(display_message, "@Out of secondary ammo", 0xFF99AA),
# (overlay_animate_to_alpha, "$g_quick_battle_map", 1500, 0),
(presentation_set_duration, 0),
(try_end),
]
),
#doing the rising/falling edge here is probably preferrable to perpetual checking in presentations
(ti_on_item_unwielded, 0, 0, [
(store_trigger_param_1, ":agent_no"),
# (get_player_agent_no, ":player_agent"),
(eq, ":agent_no", "$g_player_agent"),
],
[
(store_trigger_param_2, ":item_no"),
(eq, ":item_no", "itm_flintlock_shield"),
# # (try_begin),
# (is_presentation_active, "prsnt_cross_hair"),
# (gt, "$g_quick_battle_map", 0),
# (store_add, ":display", "$g_quick_battle_map", 1),
# (overlay_animate_to_alpha, "$g_quick_battle_map", 500, 0),
# # (overlay_set_alpha, "$g_quick_battle_map", 0),
# (overlay_set_display, ":display", 0),
# (store_add, ":tableau", ":display", 1),
# (overlay_set_display, ":tableau", 0),
# # (try_end),
(presentation_set_duration, 0),
]),
(ti_on_item_wielded, 0, 0, [
(store_trigger_param_1, ":agent_no"),
# (get_player_agent_no, ":player_agent"),
(eq, ":agent_no", "$g_player_agent"),
],
[
(store_trigger_param_2, ":item_no"),
(eq, ":item_no", "itm_flintlock_shield"),
(start_presentation, "prsnt_cross_hair"),
# (try_begin),
# (neg|is_presentation_active, "prsnt_cross_hair"),
# (start_presentation, "prsnt_cross_hair"),
# (else_try),
# (gt, "$g_quick_battle_map", 0),
# (store_add, ":display", "$g_quick_battle_map", 1),
# (overlay_animate_to_alpha, "$g_quick_battle_map", 750, 0xFF),
# # (overlay_set_alpha, "$g_quick_battle_map", 0xFF),
# (overlay_set_display, ":display", 1),
# (store_add, ":tableau", ":display", 1),
# (overlay_set_display, ":tableau", 1),
# (try_end),
]),
(ti_on_item_dropped, 0, 0, [
(store_trigger_param_1, ":agent_no"),
# (get_player_agent_no, ":player_agent"),
(eq, ":agent_no", "$g_player_agent"),
],
[ (store_trigger_param_1, ":player_agent"),
(store_trigger_param_2, ":item_no"),
(eq, ":item_no", "itm_flintlock_shield"),
(store_trigger_param_3, ":prop_no"),
(try_begin), #no additional cartridges
(agent_get_slot, ":ammo", ":player_agent", slot_agent_bonus_ammo),
(is_between, ":ammo", 0, 5),
(scene_prop_set_slot, ":prop_no", scene_prop_slots_end, ":ammo"),
(agent_set_slot, ":player_agent", slot_agent_bonus_ammo, 0),
(else_try), #average of 5 bullets left
(gt, ":ammo", 5),
(val_sub, ":ammo", 5),
(scene_prop_set_slot, ":prop_no", scene_prop_slots_end, 5),
(agent_set_slot, ":player_agent", slot_agent_bonus_ammo, ":ammo"),
(try_end),
]),
(ti_on_item_picked_up, 0, 0, [
(store_trigger_param_1, ":agent_no"),
# (get_player_agent_no, ":player_agent"),
(eq, ":agent_no", "$g_player_agent"),
],
[ (store_trigger_param_1, ":player_agent"),
(store_trigger_param_2, ":item_no"),
(eq, ":item_no", "itm_flintlock_shield"),
(store_trigger_param_3, ":prop_no"),
(scene_prop_get_slot, ":ammo", ":prop_no", scene_prop_slots_end),
(agent_get_slot, ":cur_ammo", ":player_agent", slot_agent_bonus_ammo),
(val_add, ":cur_ammo", ":ammo"),
(agent_set_slot, ":player_agent", slot_agent_bonus_ammo, ":cur_ammo"),
]),
]