It started long ago from discussion on Q&A. I've gave up atm, but yesterday, playing arround with animation flags for papa's pike bracing animation gave some fresh idea. Thanks to Harry for making the low side animation, I can finish this code, here :
global variable must be initialized at game_start script:
"$key_crouch" is key used as crouch/stand toggle for player agent
"$key_crouch_command" is key to command our troops to crouch
"$key_stand_command" is key to command our troops to stand
"$g_crouch_speed_limiter". 1 means that AI agents in crouching stance will be automatically speed limited to prevent them from running.
Usage :
- put these mission template's triggers above mission_templates = [ at module_mission_templates.py
- add + crouching_triggers to trigger list of any mission templates you want to enable crouching
- put these scripts to module_scripts.py
- Edit 3 animations and add 4 new animations at module_animations.py. You should need custom_anim.brf of the vision LE to get Harry's low side animation.
- If you have Cartread's deployed pavise models you can uncomment the #pavise_related_things
and the result :
Player crouching behind a deployed pavise shield
Crouching Formation
Credits :
harry_ for low side animation
Code:
slot_agent_crouching = 27
global variable must be initialized at game_start script:
"$key_crouch" is key used as crouch/stand toggle for player agent
"$key_crouch_command" is key to command our troops to crouch
"$key_stand_command" is key to command our troops to stand
"$g_crouch_speed_limiter". 1 means that AI agents in crouching stance will be automatically speed limited to prevent them from running.
Usage :
- put these mission template's triggers above mission_templates = [ at module_mission_templates.py
- add + crouching_triggers to trigger list of any mission templates you want to enable crouching
- put these scripts to module_scripts.py
- Edit 3 animations and add 4 new animations at module_animations.py. You should need custom_anim.brf of the vision LE to get Harry's low side animation.
- If you have Cartread's deployed pavise models you can uncomment the #pavise_related_things
Code:
player_crouch = (0, 0, 2,
[(neg|main_hero_fallen),(key_clicked,"$key_crouch"),
(get_player_agent_no, ":player_agent"), (agent_get_horse, ":horse", ":player_agent"), (le, ":horse", 0),
(try_begin),
#pavise_related_things BEGIN
# (key_is_down, key_left_control),
# (call_script, "script_deploy_pavise", ":player_agent"),
#(else_try),
#pavise_related_things END
(agent_get_slot, ":crouching", ":player_agent", slot_agent_crouching),
(eq, ":crouching", 0),
(agent_set_animation, ":player_agent", "anim_stand_to_crouch"),
(agent_set_slot, ":player_agent", slot_agent_crouching, 1),
(else_try),
(agent_set_animation, ":player_agent", "anim_crouch_to_stand"),
(agent_set_slot, ":player_agent", slot_agent_crouching, 0),
(try_end)], [])
crouching_command = (0, 0, 0,
[(neg|main_hero_fallen),
(assign, ":command", -1),
(try_begin),
(key_clicked, "$key_crouch_command"),
#Pavise related things BEGIN
#(try_begin),
# (key_is_down, key_left_control),
# (assign, ":command", 2),
#(else_try),
#Pavise related things END
(assign, ":command", 1),
#Pavise related things BEGIN
#(try_end),
#Pavise related things END
(else_try),
(key_clicked, "$key_stand_command"),
(assign, ":command", 0),
(try_end),
(ge, ":command", 0),
(call_script, "script_crouch_command", ":command"),], [])
crouching_scan = (0, 0, 0, [(call_script, "script_crouching_scan"),], [])
crouching_triggers = [player_crouch,crouching_command,crouching_scan]
Code:
("crouch_command",
[(get_player_agent_no, ":player_agent"),
(agent_get_team, ":player_team", ":player_agent"),
(store_script_param_1, ":command"),
(try_for_agents, ":agent"),
(neq, ":agent", ":player_agent"),
(agent_is_alive, ":agent"),
(agent_is_human, ":agent"),
(agent_get_team, ":team", ":agent"),
(eq, ":team", ":player_team"),
(agent_get_division, ":class", ":agent"),
(class_is_listening_order, ":player_team", ":class"),
(agent_get_horse, ":horse", ":agent"),
(le, ":horse", 0),
(call_script, "script_agent_do_crouch", ":agent", ":command"),
(try_end), ]),
("cf_agent_pushed_to_crouch",
[(store_script_param_1, ":agent"),
(get_player_agent_no, ":player_agent"),
(agent_get_slot, ":crouching", ":agent", slot_agent_crouching),
(eq, ":crouching", 0),
(agent_set_animation, ":agent", "anim_stand_to_crouch"),
(agent_set_slot, ":agent", slot_agent_crouching, 1),
(try_begin),
(neq, ":agent", ":player_agent"),
(eq, "$g_crouch_speed_limiter", 1),
(agent_set_speed_limit, ":agent", 0),
(try_end), ]),
("team_order_class_to_crouch",
[(store_script_param, ":team", 1),
(store_script_param, ":class", 2),
(store_script_param, ":command", 3),
(get_player_agent_no, ":player_agent"),
(try_for_agents, ":agent"),
(neq, ":agent", ":player_agent"),
(agent_is_alive, ":agent"),
(agent_is_human, ":agent"),
(agent_get_team, ":team_no", ":agent"),
(eq, ":team_no", ":team"),
(agent_get_division, ":class_no", ":agent"),
(this_or_next|eq, ":class_no", ":class"),
(eq, ":class", grc_everyone),
(agent_get_horse, ":horse", ":agent"),
(le, ":horse", 0),
(call_script, "script_agent_do_crouch", ":agent", ":command"),
(try_end), ]),
("agent_do_crouch",
[(store_script_param_1, ":agent"),
(store_script_param_2, ":action"),
(agent_get_slot, ":crouching", ":agent", slot_agent_crouching),
(try_begin),
#pavise_related_things BEGIN
# (eq, ":action", 2),
# (call_script, "script_deploy_pavise", ":agent"),
#(else_try),
#pavise_related_things END
(eq, ":action", 0),
(agent_set_animation, ":agent", "anim_crouch_to_stand"),
(agent_set_slot, ":agent", slot_agent_crouching, 0),
(else_try),
(eq, ":crouching", 0),
(agent_set_animation, ":agent", "anim_stand_to_crouch"),
(agent_set_slot, ":agent", slot_agent_crouching, 1),
(else_try),
(eq, ":crouching", 1),
(agent_get_animation, ":anim", ":agent",0),
(neq, ":anim", "anim_stand_to_crouch"),
(agent_set_animation, ":agent", "anim_stand_to_crouch"),
(try_end),
(try_begin),
(eq, "$g_crouch_speed_limiter", 1),
(try_begin),
(eq, ":action", 0),
(agent_set_speed_limit, ":agent", 999999),
(else_try),
(eq, ":action", 1),
(agent_set_speed_limit, ":agent", 0),
(try_end),
(try_end), ]),
("crouching_scan",
[(try_for_agents, ":agent"),
(agent_is_alive, ":agent"),
(agent_is_human, ":agent"),
(agent_get_slot, ":crouching", ":agent", slot_agent_crouching),
(gt, ":crouching", 0),
(agent_get_horse, ":horse", ":agent"),
(le, ":horse", 0),
(assign, ":forced_to_stand", 0),
(agent_get_wielded_item, ":weapon", ":agent", 0),
(try_begin),
#pavise_related_things BEGIN
# (assign, ":behind", 0),
# (try_begin),
# (call_script, "script_cf_is_behind_pavise", ":agent", "spr_pavise_shield1"),
# (assign, ":behind", 1),
# (else_try),
# (call_script, "script_cf_is_behind_pavise", ":agent", "spr_pavise_shield3"),
# (assign, ":behind", 1),
# (try_end),
# (eq, ":behind", 1),
# (agent_get_attack_action, ":action", ":agent"),
# (gt, ":action", 0),
# (assign, ":forced_to_stand", 1),
#(else_try),
#pavise_related_things END
(lt, ":weapon", 0),
(else_try),
(item_get_type, ":weapon_type", ":weapon"),
(eq, ":weapon_type", itp_type_crossbow),
(try_begin),
(agent_get_attack_action, ":action", ":agent"), # Loading Crossbow always standing
(eq, ":action", 5),
(assign, ":forced_to_stand", 1),
(try_end),
(else_try),
(eq, ":weapon", itm_long_bow), # Attacking with Longbow always standing
(agent_get_attack_action, ":action", ":agent"),
(this_or_next|eq, ":action", 1), (eq, ":action", 2),
(assign, ":forced_to_stand", 1),
(try_end),
(agent_get_speed, pos6, ":agent"),
(set_fixed_point_multiplier, 100),
(position_get_y,":speed",pos6), (store_mul, ":speed2", ":speed",2), (val_abs, ":speed2"),
(position_get_x,":drift",pos6), (assign, ":abs_drift", ":drift"), (val_abs, ":abs_drift"),
(try_begin),
(eq,":forced_to_stand", 1),
(try_begin),
(agent_get_animation, ":anim", ":agent",0),
(eq, ":anim", "anim_stand_to_crouch"),
(agent_set_animation, ":agent", "anim_crouch_to_low"),
(agent_set_slot, ":agent", slot_agent_crouching, 3),
(try_end),
(else_try),
(this_or_next|eq, ":abs_drift", 0),
(lt, ":abs_drift", ":speed2"),
(try_begin),
(eq, ":speed", 0),
(try_begin),
(eq, ":crouching", 3),
(agent_set_animation, ":agent", "anim_stand_to_crouch"),
(agent_set_slot, ":agent", slot_agent_crouching, 1),
(try_end),
(else_try),
(eq, ":crouching", 1),
(agent_set_animation, ":agent", "anim_crouch_to_low"),
(agent_set_slot, ":agent", slot_agent_crouching, 2),
(else_try),
(agent_set_slot, ":agent", slot_agent_crouching, 3),
(is_between, ":speed", 1, 200),
(agent_set_animation, ":agent", "anim_walk_forward_crouch"),
(else_try),
(is_between, ":speed", -200, 0),
(agent_set_animation, ":agent", "anim_walk_backward_crouch"),
(try_end),
(else_try),
(lt, ":abs_drift", 200),
(agent_set_slot, ":agent", slot_agent_crouching, 3),
(try_begin),
(gt, ":drift", 0),
(agent_set_animation, ":agent", "anim_walk_right_crouch"),
(else_try),
(agent_set_animation, ":agent", "anim_walk_left_crouch"),
(try_end),
(try_end),
(try_end), ]),
#pavise_related_things BEGIN
#("cf_is_behind_pavise",
# [(store_script_param, ":agent_no", 1),
# (store_script_param, ":pavise", 2),
# (set_fixed_point_multiplier, 100),
# (assign, ":behind", 0),
# (agent_get_position, pos5, ":agent_no"),
# (scene_prop_get_num_instances, ":num_pavises", ":pavise"),
# (try_for_range, ":pavise_no", 0, ":num_pavises"),
# (eq, ":behind", 0),
# (scene_prop_get_instance, ":pavise_prop_id", ":pavise", ":pavise_no"),
# (prop_instance_is_valid, ":pavise_prop_id"),
# (scene_prop_get_hit_points, ":hp", ":pavise_prop_id"),
# (gt, ":hp", 0),
# (prop_instance_get_position, pos2, ":pavise_prop_id"),
# (position_transform_position_to_local, pos3, pos5, pos2),
# (position_get_y, ":posy", pos3),
# (is_between, ":posy", 0, 100),
# (position_get_x, ":posx", pos3),
# (is_between, ":posx", -70, 70),
# (assign, ":behind", 1),
# (try_end),
# (eq, ":behind", 1), ]),
#
#
#("deploy_pavise",
# [(store_script_param, ":agent_no", 1),
# (agent_get_wielded_item, ":shield_item", ":agent_no", 1),
# (try_begin),
# (is_between, ":shield_item", "itm_tab_shield_pavise_a", "itm_tab_shield_pavise_c"),
# (assign, ":pavise_shield","spr_pavise_shield3"),
# (else_try),
# (is_between, ":shield_item", "itm_tab_shield_pavise_c", "itm_tab_shield_small_round_a"),
# (assign, ":pavise_shield","spr_pavise_shield1"),
# (else_try),
# (assign, ":pavise_shield", 0),
# (try_end),
# (try_begin),
# (gt, ":pavise_shield", 0),
# (call_script, "script_cf_agent_pushed_to_crouch",":agent_no"),
# (set_fixed_point_multiplier, 100),
# (agent_get_position, pos2, ":agent_no"),
# (position_move_y, pos2, 75, 0),
# (position_set_z_to_ground_level, pos2),
# (set_spawn_position, pos2),
# (spawn_scene_prop, ":pavise_shield"),
# (agent_unequip_item, ":agent_no", ":shield_item"),
# (try_end), ]),
#pavise_related_things END
Code:
["walk_forward_crouch", acf_enforce_lowerbody, amf_priority_continue|amf_use_cycle_period|amf_client_prediction,
# DUNDE :
#[1.7, "low_walk", 0, 48, arf_use_walk_progress,pack2f(0.4,0.9)],
[1.7, "low_walk", 0, 48, arf_use_walk_progress|arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0]],
["stand_to_crouch", acf_enforce_lowerbody, amf_priority_continue|amf_client_prediction|amf_keep,
[1.0, "crouch_down", 0, 81, arf_blend_in_1, 0, (0.0,0,0.0)]],
["crouch_to_stand", acf_enforce_lowerbody, amf_priority_continue|amf_client_prediction|amf_play,
[1.0, "crouch_down", 154, 185, arf_blend_in_1, 0, (0.0,0,0.0)]],
Code:
["walk_backward_crouch", acf_enforce_lowerbody, amf_priority_continue|amf_use_cycle_period|amf_client_prediction,
[1.7, "low_walk", 48, 0, arf_use_inv_walk_progress|arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0]],
["walk_left_crouch", acf_enforce_lowerbody, amf_priority_continue|amf_use_cycle_period|amf_client_prediction,
[1.7, "crouch_side", 58, 0, arf_use_inv_walk_progress|arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0]],
["walk_right_crouch", acf_enforce_lowerbody, amf_priority_continue|amf_use_cycle_period|amf_client_prediction,
[1.7, "crouch_side", 0, 58, arf_use_inv_walk_progress|arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0]],
["crouch_to_low", acf_enforce_lowerbody, amf_priority_kick|amf_client_prediction|amf_play,
[0.7, "crouch_down", 154, 180, arf_blend_in_1, 0, (0.0,0,0.0)]],
and the result :
Player crouching behind a deployed pavise shield
Crouching Formation
Credits :
harry_ for low side animation