
#Shield Bash Script
("shield_bash",[
(this_or_next|multiplayer_is_server),
(neg|game_in_multiplayer_mode),
(get_player_agent_no,":player_agent"),
(try_begin),
(gt, ":player_agent", 0),
(agent_get_animation, ":anim", ":player_agent",0),
(agent_get_horse, ":my_horse", ":player_agent"),
(agent_get_wielded_item, ":shield_item", ":player_agent", 1),
(try_begin),
(neq, ":anim", "anim_shield_bash"),
(eq, ":my_horse", -1),
(is_between, ":shield_item", "itm_wooden_shield", "itm_steel_shield_herald03"),
(agent_set_animation, ":player_agent","anim_shield_bash"),
(agent_get_position, pos63,":player_agent"),
(position_move_y,pos63,75),#75 cm directly ahead, so it's not a cuboid space around player center
(agent_get_troop_id, ":id", ":player_agent"),
(troop_get_type, ":type", ":id"),
(try_begin),
(eq, ":type", tf_male),
(agent_play_sound, ":player_agent", "snd_man_yell"),
(else_try),
(agent_play_sound, ":player_agent", "snd_woman_yell"),
(try_end),
(try_for_agents,":agent"),
(gt, ":agent", 0),
(neg|agent_is_ally,":agent"),#don't bash allies
(agent_is_human, ":agent"),#stop if not human
(agent_is_active,":agent"),
(agent_is_alive,":agent"),
(try_begin),
(agent_get_position,pos62,":agent"),
(get_distance_between_positions,":dist",pos63,pos62),
(lt,":dist",100),#Set this to whatever you like- 1 meter radius clears a big section of crowd
(agent_get_horse, ":horse", ":agent"),
(eq, ":horse", -1),
(neq,":agent",":player_agent"),
(agent_play_sound, ":player_agent", "snd_wooden_hit_low_armor_high_damage"),
(position_move_y,pos62,-25),
(agent_set_position, ":agent", pos62),
(agent_set_animation, ":agent","anim_shield_strike"),
(try_end),
(try_end),
(try_end),
(try_end),
]),
#End Shield Bash Script
ommon_shield_bash = (0,0,0,[
(key_clicked, key_left_control),
(neg|main_hero_fallen),
],
[
(call_script, "script_shield_bash"),
])
["shield_bash", 0, amf_play|amf_priority_defend|amf_use_defend_speed|amf_client_owner_prediction,
[0.75, "defend_shield_parry_all", 1, 50, blend_in_defense], #Adjust duration for balance. Currently at 0.75 seconds, fixed.
[0.75, "defend_shield_right", 1, 50, blend_in_defense],
[0.75, "defend_shield_left", 1, 50, blend_in_defense],
[0.75, "defend_shield_right", 1, 50, blend_in_defense],
],
["shield_strike", acf_enforce_all|acf_align_with_ground, amf_priority_striked|amf_play|amf_accurate_body|amf_restart,
[1.0, "anim_human", blow+5000, blow+5010, arf_blend_in_3|arf_make_custom_sound],
[1.7, "anim_human", blow+5400, blow+5453, arf_blend_in_2|arf_make_custom_sound],
[1.44, "anim_human", blow+5400, blow+5445, arf_blend_in_2|arf_make_custom_sound],
],

Ok you added this to module scriptsJC LEON 说:module_scripts
插入代码块:#Shield Bash Script ("shield_bash",[ (this_or_next|multiplayer_is_server), (neg|game_in_multiplayer_mode), (get_player_agent_no,":player_agent"), (try_begin), (gt, ":player_agent", 0), (agent_get_animation, ":anim", ":player_agent",0), (agent_get_horse, ":my_horse", ":player_agent"), (agent_get_wielded_item, ":shield_item", ":player_agent", 1), (try_begin), (neq, ":anim", "anim_shield_bash"), (eq, ":my_horse", -1), (is_between, ":shield_item", "itm_wooden_shield", "itm_steel_shield_herald03"), (agent_set_animation, ":player_agent","anim_shield_bash"), (agent_get_position, pos63,":player_agent"), (position_move_y,pos63,75),#75 cm directly ahead, so it's not a cuboid space around player center (agent_get_troop_id, ":id", ":player_agent"), (troop_get_type, ":type", ":id"), (try_begin), (eq, ":type", tf_male), (agent_play_sound, ":player_agent", "snd_man_yell"), (else_try), (agent_play_sound, ":player_agent", "snd_woman_yell"), (try_end), (try_for_agents,":agent"), (gt, ":agent", 0), (neg|agent_is_ally,":agent"),#don't bash allies (agent_is_human, ":agent"),#stop if not human (agent_is_active,":agent"), (agent_is_alive,":agent"), (try_begin), (agent_get_position,pos62,":agent"), (get_distance_between_positions,":dist",pos63,pos62), (lt,":dist",100),#Set this to whatever you like- 1 meter radius clears a big section of crowd (agent_get_horse, ":horse", ":agent"), (eq, ":horse", -1), (neq,":agent",":player_agent"), (agent_play_sound, ":player_agent", "snd_wooden_hit_low_armor_high_damage"), (position_move_y,pos62,-25), (agent_set_position, ":agent", pos62), (agent_set_animation, ":agent","anim_shield_strike"), (try_end), (try_end), (try_end), (try_end), ]), #End Shield Bash Script
JC LEON 说:module_mission_templates (you obviously need to put it into specific mt's like other common_ scripts): -------where must i put these lines????
插入代码块:common_shield_bash = (0,0,0,[ (key_clicked, key_left_control), (neg|main_hero_fallen), ], [ (call_script, "script_shield_bash"), ])
JC LEON 说:module_animations (needs to replace a free unused_human_anim ofc): ------ I put these lines into the first unusued human animations.
插入代码块:["shield_bash", 0, amf_play|amf_priority_defend|amf_use_defend_speed|amf_client_owner_prediction, [0.75, "defend_shield_parry_all", 1, 50, blend_in_defense], #Adjust duration for balance. Currently at 0.75 seconds, fixed. [0.75, "defend_shield_right", 1, 50, blend_in_defense], [0.75, "defend_shield_left", 1, 50, blend_in_defense], [0.75, "defend_shield_right", 1, 50, blend_in_defense], ], ["shield_strike", acf_enforce_all|acf_align_with_ground, amf_priority_striked|amf_play|amf_accurate_body|amf_restart, [1.0, "anim_human", blow+5000, blow+5010, arf_blend_in_3|arf_make_custom_sound], [1.7, "anim_human", blow+5400, blow+5453, arf_blend_in_2|arf_make_custom_sound], [1.44, "anim_human", blow+5400, blow+5445, arf_blend_in_2|arf_make_custom_sound], ],
JC LEON 说:to shield bash work correclty must i put other files like .bfr , .dds or somehing other??
many tanks in adance...
leon



################################################
## Shield Bash ##
## Developed by 'xenoargh' for singleplayer. ##
## Revamped by 'Sinisterius'. ##
## Animations Copyright (C) 2010 'xenoargh'. ##
################################################
#####
#Add these following triggers to module_mission_templates.py,
#above all other code. Then simply add:
#sp_shield_bash_1,
#sp_shield_bash_2,
#sp_shield_bash_3,
#To your mission templates to activate the triggers.
sp_shield_bash_1 = (
0, 0, 0,
[
(eq, "$sp_shield_bash", 1),
(game_key_is_down, gk_defend),
(game_key_clicked, gk_attack),
],
[
(get_player_agent_no, ":agent"),
(agent_is_active, ":agent"),
(agent_is_alive, ":agent"),
(neg|agent_slot_ge, ":agent", sp_agent_shield_bash_timer, 1), #Less than.
(agent_get_wielded_item, ":item", ":agent", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield), #Shield equipped.
(agent_get_defend_action, ":action", ":agent"),
(eq, ":action", 2), #Blocking.
(agent_get_horse, ":horse", ":agent"),
(eq, ":horse", -1), #No horse.
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, 5),
(agent_set_animation, ":agent", "anim_shield_bash"),
(agent_get_troop_id, ":troop", ":agent"),
(troop_get_type, ":type", ":troop"),
(try_begin),
(eq, ":type", tf_male),
(agent_play_sound, ":agent", "snd_man_yell"),
(else_try),
(eq, ":type", tf_female),
(agent_play_sound, ":agent", "snd_woman_yell"),
(try_end),
(agent_get_position, pos1, ":agent"),
(assign, ":victim", -1),
(assign, ":minimum_distance", 150),
(try_for_agents, ":suspect"),
(agent_is_alive, ":suspect"),
(agent_is_human, ":suspect"),
(neg|agent_is_ally, ":suspect"),
(agent_get_position, pos2, ":suspect"),
(neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind basher.
(get_distance_between_positions, ":distance", pos1, pos2),
(le, ":distance", ":minimum_distance"),
(assign, ":minimum_distance", ":distance"),
(assign, ":victim", ":suspect"),
(try_end),
(ge, ":victim", 0),
(agent_play_sound, ":victim", "snd_wooden_hit_low_armor_high_damage"),
(agent_get_defend_action, ":action", ":victim"),
(try_begin),
(eq, ":action", 2), #Blocking.
(neg|position_is_behind_position, pos1, pos2), #If basher isn't behind victim.
(agent_get_wielded_item, ":item", ":victim", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield),
(agent_set_animation, ":victim", "anim_shield_bash"),
(else_try),
(agent_set_animation, ":victim", "anim_shield_strike"),
(try_end),
])
sp_shield_bash_2 = (
1, 0, 0, [(eq, "$sp_shield_bash", 1)],
[
(get_player_agent_no, ":agent"),
(agent_is_active, ":agent"),
(agent_is_alive, ":agent"),
(agent_get_slot, ":timer", ":agent", sp_agent_shield_bash_timer),
(val_sub, ":timer", 1),
(val_max, ":timer", 0),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":timer"),
])
sp_shield_bash_3 = (
0.25, 0, 0, [(eq, "$sp_shield_bash_ai", 1)],
[
(get_player_agent_no, ":player_agent"),
(try_for_agents, ":agent"),
(neq, ":agent", ":player_agent"),
(agent_is_alive, ":agent"),
(agent_is_human, ":agent"),
(try_begin),
(neg|agent_slot_ge, ":agent", sp_agent_shield_bash_timer, 1), #Less than.
(agent_slot_eq, ":agent", slot_agent_is_running_away, 0), #Isn't routing.
(agent_get_wielded_item, ":item", ":agent", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield), #Shield equipped.
(agent_get_attack_action, ":action", ":agent"),
(eq, ":action", 0), #Free.
(agent_get_horse, ":horse", ":agent"),
(eq, ":horse", -1), #No horse.
(agent_get_team, ":team", ":agent"),
(agent_get_position, pos1, ":agent"),
(assign, ":victim", -1),
(assign, ":minimum_distance", 125),
(try_for_agents, ":suspect"),
(agent_is_alive, ":suspect"),
(agent_is_human, ":suspect"),
(agent_get_position, pos2, ":suspect"),
(neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind basher.
(agent_get_team, ":suspect_team", ":suspect"),
(neq, ":suspect_team", ":team"),
(get_distance_between_positions, ":distance", pos1, pos2),
(le, ":distance", ":minimum_distance"),
(assign, ":minimum_distance", ":distance"),
(assign, ":victim", ":suspect"),
(try_end),
(ge, ":victim", 0),
(agent_get_horse, ":horse", ":victim"),
(eq, ":horse", -1),
(store_random_in_range, ":rand", 15, 26),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":rand"), #20 is 20*0.25=5seconds.
(agent_set_animation, ":agent", "anim_shield_bash"),
(agent_get_troop_id, ":troop", ":agent"),
(troop_get_type, ":type", ":troop"),
(try_begin),
(eq, ":type", tf_male),
(agent_play_sound, ":agent", "snd_man_yell"),
(else_try),
(eq, ":type", tf_female),
(agent_play_sound, ":agent", "snd_woman_yell"),
(try_end),
(agent_play_sound, ":victim", "snd_wooden_hit_low_armor_high_damage"),
(agent_get_defend_action, ":action", ":victim"),
(try_begin),
(eq, ":action", 2), #Blocking.
(neg|position_is_behind_position, pos1, pos2), #If basher isn't behind victim.
(agent_get_wielded_item, ":item", ":victim", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield),
(agent_set_animation, ":victim", "anim_shield_bash"),
(else_try),
(agent_set_animation, ":victim", "anim_shield_strike"),
(try_end),
(try_end),
(agent_get_slot, ":timer", ":agent", sp_agent_shield_bash_timer),
(val_sub, ":timer", 1),
(val_max, ":timer", 0),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":timer"),
(try_end),
])
#####
#The following animations go into module_animations.py.
#Simply replace two unused human animations with these animations.
#You can adjust the duration of the bash, simply modify the '0.50' to
#your liking. So '1.0' is 1second and '0.50' is half a second.
["shield_bash", acf_enforce_all|acf_align_with_ground, amf_priority_striked|amf_play|amf_accurate_body|amf_restart,
[0.50, "defend_shield_parry_all", 1, 50, blend_in_defense], #Adjust duration for balance. Currently at 0.50 seconds, fixed.
[0.50, "defend_shield_right", 1, 50, blend_in_defense],
[0.50, "defend_shield_left", 1, 50, blend_in_defense],
[0.50, "defend_shield_right", 1, 50, blend_in_defense],
],
["shield_strike", acf_enforce_all|acf_align_with_ground, amf_priority_striked|amf_play|amf_accurate_body|amf_restart,
[1.0, "anim_human", blow+5000, blow+5010, arf_blend_in_3|arf_make_custom_sound],
[1.7, "anim_human", blow+5400, blow+5453, arf_blend_in_2|arf_make_custom_sound],
[1.44, "anim_human", blow+5400, blow+5445, arf_blend_in_2|arf_make_custom_sound],
],
#####
#This goes into module_constants.py, agent slots.
sp_agent_shield_bash_timer = 50

JC LEON 说:my problems are in this piece of code since i really dont understand where I must put the code and how to use it
I tried to put in on the start of the code and other positions ,comple worked fine but shield bash doesnt work ingame
You never called the triggers. To do so you must add#Add these following triggers to module_mission_templates.py,
#above all other code. Then simply add:
#sp_shield_bash_1,
#sp_shield_bash_2,
#sp_shield_bash_3,
#To your mission templates to activate the triggers.

sp_shield_bash_1 = (
0, 0, 0,
[
(eq, "$sp_shield_bash", 1),
(game_key_is_down, gk_defend),
(game_key_clicked, gk_attack),
],
[
(get_player_agent_no, ":agent"),
(agent_is_active, ":agent"),
(agent_is_alive, ":agent"),
(neg|agent_slot_ge, ":agent", sp_agent_shield_bash_timer, 1), #Less than.
(agent_get_wielded_item, ":item", ":agent", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield), #Shield equipped.
(agent_get_defend_action, ":action", ":agent"),
(eq, ":action", 2), #Blocking.
(agent_get_horse, ":horse", ":agent"),
(eq, ":horse", -1), #No horse.
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, 5),
(agent_set_animation, ":agent", "anim_shield_bash"),
(agent_get_troop_id, ":troop", ":agent"),
(troop_get_type, ":type", ":troop"),
(try_begin),
(eq, ":type", tf_male),
(agent_play_sound, ":agent", "snd_man_yell"),
(else_try),
(eq, ":type", tf_female),
(agent_play_sound, ":agent", "snd_woman_yell"),
(try_end),
(agent_get_position, pos1, ":agent"),
(assign, ":victim", -1),
(assign, ":minimum_distance", 150),
(try_for_agents, ":suspect"),
(agent_is_alive, ":suspect"),
(agent_is_human, ":suspect"),
(neg|agent_is_ally, ":suspect"),
(agent_get_position, pos2, ":suspect"),
(neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind basher.
(get_distance_between_positions, ":distance", pos1, pos2),
(le, ":distance", ":minimum_distance"),
(assign, ":minimum_distance", ":distance"),
(assign, ":victim", ":suspect"),
(try_end),
(ge, ":victim", 0),
(agent_play_sound, ":victim", "snd_wooden_hit_low_armor_high_damage"),
(agent_get_defend_action, ":action", ":victim"),
(try_begin),
(eq, ":action", 2), #Blocking.
(neg|position_is_behind_position, pos1, pos2), #If basher isn't behind victim.
(agent_get_wielded_item, ":item", ":victim", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield),
(agent_set_animation, ":victim", "anim_shield_bash"),
(else_try),
(agent_set_animation, ":victim", "anim_shield_strike"),
(try_end),
])
sp_shield_bash_2 = (
1, 0, 0, [(eq, "$sp_shield_bash", 1)],
[
(get_player_agent_no, ":agent"),
(agent_is_active, ":agent"),
(agent_is_alive, ":agent"),
(agent_get_slot, ":timer", ":agent", sp_agent_shield_bash_timer),
(val_sub, ":timer", 1),
(val_max, ":timer", 0),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":timer"),
])
sp_shield_bash_3 = (
0.25, 0, 0, [(eq, "$sp_shield_bash_ai", 1)],
[
(get_player_agent_no, ":player_agent"),
(try_for_agents, ":agent"),
(neq, ":agent", ":player_agent"),
(agent_is_alive, ":agent"),
(agent_is_human, ":agent"),
(try_begin),
(neg|agent_slot_ge, ":agent", sp_agent_shield_bash_timer, 1), #Less than.
(agent_slot_eq, ":agent", slot_agent_is_running_away, 0), #Isn't routing.
(agent_get_wielded_item, ":item", ":agent", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield), #Shield equipped.
(agent_get_attack_action, ":action", ":agent"),
(eq, ":action", 0), #Free.
(agent_get_horse, ":horse", ":agent"),
(eq, ":horse", -1), #No horse.
(agent_get_team, ":team", ":agent"),
(agent_get_position, pos1, ":agent"),
(assign, ":victim", -1),
(assign, ":minimum_distance", 125),
(try_for_agents, ":suspect"),
(agent_is_alive, ":suspect"),
(agent_is_human, ":suspect"),
(agent_get_position, pos2, ":suspect"),
(neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind basher.
(agent_get_team, ":suspect_team", ":suspect"),
(neq, ":suspect_team", ":team"),
(get_distance_between_positions, ":distance", pos1, pos2),
(le, ":distance", ":minimum_distance"),
(assign, ":minimum_distance", ":distance"),
(assign, ":victim", ":suspect"),
(try_end),
(ge, ":victim", 0),
(agent_get_horse, ":horse", ":victim"),
(eq, ":horse", -1),
(store_random_in_range, ":rand", 15, 26),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":rand"), #20 is 20*0.25=5seconds.
(agent_set_animation, ":agent", "anim_shield_bash"),
(agent_get_troop_id, ":troop", ":agent"),
(troop_get_type, ":type", ":troop"),
(try_begin),
(eq, ":type", tf_male),
(agent_play_sound, ":agent", "snd_man_yell"),
(else_try),
(eq, ":type", tf_female),
(agent_play_sound, ":agent", "snd_woman_yell"),
(try_end),
(agent_play_sound, ":victim", "snd_wooden_hit_low_armor_high_damage"),
(agent_get_defend_action, ":action", ":victim"),
(try_begin),
(eq, ":action", 2), #Blocking.
(neg|position_is_behind_position, pos1, pos2), #If basher isn't behind victim.
(agent_get_wielded_item, ":item", ":victim", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield),
(agent_set_animation, ":victim", "anim_shield_bash"),
(else_try),
(agent_set_animation, ":victim", "anim_shield_strike"),
(try_end),
(try_end),
(agent_get_slot, ":timer", ":agent", sp_agent_shield_bash_timer),
(val_sub, ":timer", 1),
(val_max, ":timer", 0),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":timer"),
(try_end),
])

JC LEON 说:sorry for my noobsih but i think i'm an idiot...
I contune to dont undertand
I have no clear some infos..
1- where must i put the fisrt piece of code i module_missions_template?
2 - when you taolk about the triggers...
are you referring to this ??
#sp_shield_bash_1,
#sp_shield_bash_2,
#sp_shield_bash_3,
or i must put these?
插入代码块:sp_shield_bash_1 = ( 0, 0, 0, [ (eq, "$sp_shield_bash", 1), (game_key_is_down, gk_defend), (game_key_clicked, gk_attack), ], [ (get_player_agent_no, ":agent"), (agent_is_active, ":agent"), (agent_is_alive, ":agent"), (neg|agent_slot_ge, ":agent", sp_agent_shield_bash_timer, 1), #Less than. (agent_get_wielded_item, ":item", ":agent", 1), #Offhand. (gt, ":item", 0), (item_get_type, ":type", ":item"), (eq, ":type", itp_type_shield), #Shield equipped. (agent_get_defend_action, ":action", ":agent"), (eq, ":action", 2), #Blocking. (agent_get_horse, ":horse", ":agent"), (eq, ":horse", -1), #No horse. (agent_set_slot, ":agent", sp_agent_shield_bash_timer, 5), (agent_set_animation, ":agent", "anim_shield_bash"), (agent_get_troop_id, ":troop", ":agent"), (troop_get_type, ":type", ":troop"), (try_begin), (eq, ":type", tf_male), (agent_play_sound, ":agent", "snd_man_yell"), (else_try), (eq, ":type", tf_female), (agent_play_sound, ":agent", "snd_woman_yell"), (try_end), (agent_get_position, pos1, ":agent"), (assign, ":victim", -1), (assign, ":minimum_distance", 150), (try_for_agents, ":suspect"), (agent_is_alive, ":suspect"), (agent_is_human, ":suspect"), (neg|agent_is_ally, ":suspect"), (agent_get_position, pos2, ":suspect"), (neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind basher. (get_distance_between_positions, ":distance", pos1, pos2), (le, ":distance", ":minimum_distance"), (assign, ":minimum_distance", ":distance"), (assign, ":victim", ":suspect"), (try_end), (ge, ":victim", 0), (agent_play_sound, ":victim", "snd_wooden_hit_low_armor_high_damage"), (agent_get_defend_action, ":action", ":victim"), (try_begin), (eq, ":action", 2), #Blocking. (neg|position_is_behind_position, pos1, pos2), #If basher isn't behind victim. (agent_get_wielded_item, ":item", ":victim", 1), #Offhand. (gt, ":item", 0), (item_get_type, ":type", ":item"), (eq, ":type", itp_type_shield), (agent_set_animation, ":victim", "anim_shield_bash"), (else_try), (agent_set_animation, ":victim", "anim_shield_strike"), (try_end), ]) sp_shield_bash_2 = ( 1, 0, 0, [(eq, "$sp_shield_bash", 1)], [ (get_player_agent_no, ":agent"), (agent_is_active, ":agent"), (agent_is_alive, ":agent"), (agent_get_slot, ":timer", ":agent", sp_agent_shield_bash_timer), (val_sub, ":timer", 1), (val_max, ":timer", 0), (agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":timer"), ]) sp_shield_bash_3 = ( 0.25, 0, 0, [(eq, "$sp_shield_bash_ai", 1)], [ (get_player_agent_no, ":player_agent"), (try_for_agents, ":agent"), (neq, ":agent", ":player_agent"), (agent_is_alive, ":agent"), (agent_is_human, ":agent"), (try_begin), (neg|agent_slot_ge, ":agent", sp_agent_shield_bash_timer, 1), #Less than. (agent_slot_eq, ":agent", slot_agent_is_running_away, 0), #Isn't routing. (agent_get_wielded_item, ":item", ":agent", 1), #Offhand. (gt, ":item", 0), (item_get_type, ":type", ":item"), (eq, ":type", itp_type_shield), #Shield equipped. (agent_get_attack_action, ":action", ":agent"), (eq, ":action", 0), #Free. (agent_get_horse, ":horse", ":agent"), (eq, ":horse", -1), #No horse. (agent_get_team, ":team", ":agent"), (agent_get_position, pos1, ":agent"), (assign, ":victim", -1), (assign, ":minimum_distance", 125), (try_for_agents, ":suspect"), (agent_is_alive, ":suspect"), (agent_is_human, ":suspect"), (agent_get_position, pos2, ":suspect"), (neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind basher. (agent_get_team, ":suspect_team", ":suspect"), (neq, ":suspect_team", ":team"), (get_distance_between_positions, ":distance", pos1, pos2), (le, ":distance", ":minimum_distance"), (assign, ":minimum_distance", ":distance"), (assign, ":victim", ":suspect"), (try_end), (ge, ":victim", 0), (agent_get_horse, ":horse", ":victim"), (eq, ":horse", -1), (store_random_in_range, ":rand", 15, 26), (agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":rand"), #20 is 20*0.25=5seconds. (agent_set_animation, ":agent", "anim_shield_bash"), (agent_get_troop_id, ":troop", ":agent"), (troop_get_type, ":type", ":troop"), (try_begin), (eq, ":type", tf_male), (agent_play_sound, ":agent", "snd_man_yell"), (else_try), (eq, ":type", tf_female), (agent_play_sound, ":agent", "snd_woman_yell"), (try_end), (agent_play_sound, ":victim", "snd_wooden_hit_low_armor_high_damage"), (agent_get_defend_action, ":action", ":victim"), (try_begin), (eq, ":action", 2), #Blocking. (neg|position_is_behind_position, pos1, pos2), #If basher isn't behind victim. (agent_get_wielded_item, ":item", ":victim", 1), #Offhand. (gt, ":item", 0), (item_get_type, ":type", ":item"), (eq, ":type", itp_type_shield), (agent_set_animation, ":victim", "anim_shield_bash"), (else_try), (agent_set_animation, ":victim", "anim_shield_strike"), (try_end), (try_end), (agent_get_slot, ":timer", ":agent", sp_agent_shield_bash_timer), (val_sub, ":timer", 1), (val_max, ":timer", 0), (agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":timer"), (try_end), ])

JC LEON 说:1- where must i put the fisrt piece of code i module_missions_template?
JC LEON 说:2 - when you taolk about the triggers...
sp_shield_bash_1 = (
0, 0, 0,
[
(eq, "$sp_shield_bash", 1),
(game_key_is_down, gk_defend),
(game_key_clicked, gk_attack),
],
[
(get_player_agent_no, ":agent"),
(agent_is_active, ":agent"),
(agent_is_alive, ":agent"),
(neg|agent_slot_ge, ":agent", sp_agent_shield_bash_timer, 1), #Less than.
(agent_get_wielded_item, ":item", ":agent", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield), #Shield equipped.
(agent_get_defend_action, ":action", ":agent"),
(eq, ":action", 2), #Blocking.
(agent_get_horse, ":horse", ":agent"),
(eq, ":horse", -1), #No horse.
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, 5),
(agent_set_animation, ":agent", "anim_shield_bash"),
(agent_get_troop_id, ":troop", ":agent"),
(troop_get_type, ":type", ":troop"),
(try_begin),
(eq, ":type", tf_male),
(agent_play_sound, ":agent", "snd_man_yell"),
(else_try),
(eq, ":type", tf_female),
(agent_play_sound, ":agent", "snd_woman_yell"),
(try_end),
(agent_get_position, pos1, ":agent"),
(assign, ":victim", -1),
(assign, ":minimum_distance", 150),
(try_for_agents, ":suspect"),
(agent_is_alive, ":suspect"),
(agent_is_human, ":suspect"),
(neg|agent_is_ally, ":suspect"),
(agent_get_position, pos2, ":suspect"),
(neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind basher.
(get_distance_between_positions, ":distance", pos1, pos2),
(le, ":distance", ":minimum_distance"),
(assign, ":minimum_distance", ":distance"),
(assign, ":victim", ":suspect"),
(try_end),
(ge, ":victim", 0),
(agent_play_sound, ":victim", "snd_wooden_hit_low_armor_high_damage"),
(agent_get_defend_action, ":action", ":victim"),
(try_begin),
(eq, ":action", 2), #Blocking.
(neg|position_is_behind_position, pos1, pos2), #If basher isn't behind victim.
(agent_get_wielded_item, ":item", ":victim", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield),
(agent_set_animation, ":victim", "anim_shield_bash"),
(else_try),
(agent_set_animation, ":victim", "anim_shield_strike"),
(try_end),
])
sp_shield_bash_2 = (
1, 0, 0, [(eq, "$sp_shield_bash", 1)],
[
(get_player_agent_no, ":agent"),
(agent_is_active, ":agent"),
(agent_is_alive, ":agent"),
(agent_get_slot, ":timer", ":agent", sp_agent_shield_bash_timer),
(val_sub, ":timer", 1),
(val_max, ":timer", 0),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":timer"),
])
sp_shield_bash_3 = (
0.25, 0, 0, [(eq, "$sp_shield_bash_ai", 1)],
[
(get_player_agent_no, ":player_agent"),
(try_for_agents, ":agent"),
(neq, ":agent", ":player_agent"),
(agent_is_alive, ":agent"),
(agent_is_human, ":agent"),
(try_begin),
(neg|agent_slot_ge, ":agent", sp_agent_shield_bash_timer, 1), #Less than.
(agent_slot_eq, ":agent", slot_agent_is_running_away, 0), #Isn't routing.
(agent_get_wielded_item, ":item", ":agent", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield), #Shield equipped.
(agent_get_attack_action, ":action", ":agent"),
(eq, ":action", 0), #Free.
(agent_get_horse, ":horse", ":agent"),
(eq, ":horse", -1), #No horse.
(agent_get_team, ":team", ":agent"),
(agent_get_position, pos1, ":agent"),
(assign, ":victim", -1),
(assign, ":minimum_distance", 125),
(try_for_agents, ":suspect"),
(agent_is_alive, ":suspect"),
(agent_is_human, ":suspect"),
(agent_get_position, pos2, ":suspect"),
(neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind basher.
(agent_get_team, ":suspect_team", ":suspect"),
(neq, ":suspect_team", ":team"),
(get_distance_between_positions, ":distance", pos1, pos2),
(le, ":distance", ":minimum_distance"),
(assign, ":minimum_distance", ":distance"),
(assign, ":victim", ":suspect"),
(try_end),
(ge, ":victim", 0),
(agent_get_horse, ":horse", ":victim"),
(eq, ":horse", -1),
(store_random_in_range, ":rand", 15, 26),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":rand"), #20 is 20*0.25=5seconds.
(agent_set_animation, ":agent", "anim_shield_bash"),
(agent_get_troop_id, ":troop", ":agent"),
(troop_get_type, ":type", ":troop"),
(try_begin),
(eq, ":type", tf_male),
(agent_play_sound, ":agent", "snd_man_yell"),
(else_try),
(eq, ":type", tf_female),
(agent_play_sound, ":agent", "snd_woman_yell"),
(try_end),
(agent_play_sound, ":victim", "snd_wooden_hit_low_armor_high_damage"),
(agent_get_defend_action, ":action", ":victim"),
(try_begin),
(eq, ":action", 2), #Blocking.
(neg|position_is_behind_position, pos1, pos2), #If basher isn't behind victim.
(agent_get_wielded_item, ":item", ":victim", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield),
(agent_set_animation, ":victim", "anim_shield_bash"),
(else_try),
(agent_set_animation, ":victim", "anim_shield_strike"),
(try_end),
(try_end),
(agent_get_slot, ":timer", ":agent", sp_agent_shield_bash_timer),
(val_sub, ":timer", 1),
(val_max, ":timer", 0),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":timer"),
(try_end),
])

