OSP Code Combat Spear Bracing Kit (Updated)

The Mercenary

Grandmaster Knight
Best answers
0
Woke up with a terrible headache and decided to release it.

Code:
spearwall_trigger_1 = (0.2, 0, ti_once, [], [
        (assign,"$spear_in_position",0),
        (try_for_agents,":agent"),
          (agent_set_slot,":agent",slot_agent_spearwall,0),
          (agent_set_slot,":agent",slot_agent_x,0),
          (agent_set_slot,":agent",slot_agent_y,0),
          (agent_set_slot,":agent",slot_agent_z,0),
          (agent_set_slot,":agent",slot_agent_speed,0),
        (try_end),
        ])

spearwall_trigger_2 = (0.2, 0, 0, [(eq,"$setting_use_spearwall",1)], [
        (set_fixed_point_multiplier, 100),
        (try_for_agents,":agent"),
          (agent_is_alive,":agent"),
          (agent_get_slot,":oldagentx",":agent",slot_agent_x),
          (agent_get_slot,":oldagenty",":agent",slot_agent_y),
          (agent_get_slot,":oldagentz",":agent",slot_agent_z),
          (agent_get_position, pos1, ":agent"),
          (position_get_x,":agentx",pos1),
          (position_get_y,":agenty",pos1),
          (position_get_z,":agentz",pos1),
          (position_set_x,pos2,":oldagentx"),
          (position_set_y,pos2,":oldagenty"),
          (position_set_z,pos2,":oldagentz"),
          (position_set_x,pos1,":agentx"),
          (position_set_y,pos1,":agenty"),
          (position_set_z,pos1,":agentz"),
          (get_distance_between_positions,":speed",pos1,pos2),
          (agent_set_slot,":agent",slot_agent_x,":agentx"),
          (agent_set_slot,":agent",slot_agent_y,":agenty"),
          (agent_set_slot,":agent",slot_agent_z,":agentz"),
          (agent_set_slot,":agent",slot_agent_speed,":speed"),
        (try_end),
        ])

spearwall_trigger_3 = (0, 0, 0, [(eq,"$spear_in_position",1),(this_or_next|game_key_clicked, gk_attack),
        (this_or_next|game_key_clicked, gk_defend),(this_or_next|game_key_clicked, gk_defend),
        (this_or_next|game_key_clicked, gk_move_forward),(this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),(this_or_next|game_key_clicked, gk_move_right),
        (this_or_next|game_key_clicked, gk_equip_primary_weapon),(this_or_next|game_key_clicked, gk_equip_secondary_weapon),
        (this_or_next|game_key_clicked, gk_action),(game_key_clicked, gk_sheath_weapon)
        ], 
       [(get_player_agent_no,":player"),
        (agent_is_alive,":player"),
        (display_message,"@Releasing spear.",0x6495ed),
        (agent_set_animation, ":player", "anim_release_thrust_staff"),
        (assign,"$spear_in_position",0),
        ])

spearwall_trigger_4 = (0.2, 0, 0, [(eq,"$setting_use_spearwall",1)], [
        (try_for_agents,":agent"),
          (agent_get_horse,":horse",":agent"),
          (neg|gt,":horse",0),
          (agent_get_slot,":speartimer",":agent",slot_agent_spearwall),
          (lt,":speartimer",10),
          (val_add,":speartimer",2),
          (agent_set_slot,":agent",slot_agent_spearwall,":speartimer"),
        (try_end),
        ])

spearwall_trigger_5 = (3, 0, 0, [(eq,"$spear_in_position",1)],[
        (get_player_agent_no,":player"),
        (agent_is_alive,":player"),
        (agent_set_animation, ":player", "anim_spearwall_hold"),
        ])

spearwall_trigger_6 = (0.1, 0, 0, [(eq,"$setting_use_spearwall",1)], [
        (get_player_agent_no,":player"),
        (agent_get_team,":playerteam",":player"),
        (try_for_agents,":agent"),
           (agent_is_alive,":agent"),
           (neq,":agent",":player"),
           (agent_is_human,":agent"),
           (agent_get_horse,":horse",":agent"),
           (neg|gt,":horse",0),
           (agent_get_slot,":speartimer",":agent",slot_agent_spearwall),
           (ge,":speartimer",10),
           (agent_get_simple_behavior,":state",":agent"),
           (agent_get_team,":team1",":agent"),
           (agent_get_class,":class",":agent"),
           (team_get_movement_order,":order",":team1",":class"),
           (assign,":continue",0),
           (try_begin),
              (neq,":team1",":playerteam"),
              (this_or_next|eq,":state",aisb_hold),
              (this_or_next|eq,":state",aisb_flock),
              (eq,":state",aisb_go_to_pos),
              (assign,":continue",1),
           (else_try),
              (this_or_next|eq,":order",mordr_hold),
              (eq,":order",mordr_stand_ground),
              (this_or_next|eq,":state",aisb_hold),
              (this_or_next|eq,":state",aisb_flock),
              (this_or_next|eq,":state",aisb_melee),
              (eq,":state",aisb_go_to_pos),
              (assign,":continue",1),
           (try_end),
           (eq,":continue",1),
           (assign,":continue",0),
           (try_begin),
              (eq,":team1",":playerteam"),
              (eq,"$rout",0),
              (assign,":continue",1),
           (else_try),
              (eq,"$airout",0),
              (assign,":continue",1),
           (try_end),
           (eq,":continue",1),
           (assign,":continue",0),
           (agent_get_wielded_item, ":handone", ":agent", 0),
           (agent_get_wielded_item, ":handtwo", ":agent", 1),
           (assign,":speardist",145),
           (try_for_range,":spear","itm_pitch_fork","itm_wooden_shield"),
              (this_or_next|eq,":handone",":spear"),
              (eq,":handtwo",":spear"),
              (assign,":continue",1),
              (try_begin),
                 (eq,":spear","itm_war_spear"),
                 (assign,":speardist",160),
              (else_try),
                 (eq,":spear","itm_spear_e_2-5m"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_light_lance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_lance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_heavy_lance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_pike"),
                 (assign,":speardist",255),
              (else_try),
                 (eq,":spear","itm_ashwood_pike"),
                 (assign,":speardist",255),
              (else_try),
                 (eq,":spear","itm_awlpike"),
                 (assign,":speardist",170),
              (else_try),
                 (eq,":spear","itm_pitch_fork"),
                 (assign,":speardist",164),
              (else_try),
                 (eq,":spear","itm_military_fork"),
                 (assign,":speardist",145),
              (else_try),
                 (eq,":spear","itm_battle_fork"),
                 (assign,":speardist",152),
              (else_try),
                 (eq,":spear","itm_boar_spear"),
                 (assign,":speardist",167),
              (else_try),
                 (eq,":spear","itm_glaive"),
                 (assign,":speardist",167),
              (else_try),
                 (eq,":spear","itm_poleaxe"),
                 (assign,":speardist",190),
              (else_try),
                 (eq,":spear","itm_polehammer"),
                 (assign,":speardist",140),
              (else_try),
                 (eq,":spear","itm_shortened_spear"),
                 (assign,":speardist",130),
              (else_try),
                 (eq,":spear","itm_halberd"),
                 (assign,":speardist",185),
              (else_try),
                 (eq,":spear","itm_ancient_halbard"),
                 (assign,":speardist",185),
              (else_try),
                 (eq,":spear","itm_klance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_jousting_lance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_double_sided_lance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_staff"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_quarter_staff"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_iron_staff"),
                 (assign,":continue",0),
              (try_end),
           (try_end),
           (eq,":continue",1),
           (assign,":victim",-1),
           (agent_get_position,pos1,":agent"),
           (try_for_agents,":possible_victim"),
              (agent_is_alive,":possible_victim"),
              (neg|agent_is_human,":possible_victim"),
              (agent_get_rider,":rider",":possible_victim"),
              (ge,":rider",0),
              (agent_get_team,":team2",":rider"),
              (teams_are_enemies,":team1",":team2"),
              (agent_get_position,pos2,":possible_victim"),
              (get_distance_between_positions,":dist",pos1,pos2),
              (lt,":dist",":speardist"),
              (neg|position_is_behind_position,pos2,pos1),
              (agent_get_slot,":speed",":possible_victim",slot_agent_speed),
              (ge,":speed",120), # Remember to change this if the timing on speed checks changes
              (assign,":victim",":possible_victim"),
           (try_end),
           (gt,":victim",-1),
           (agent_set_animation, ":agent", "anim_spearwall_hold"),
           (agent_play_sound,":victim","snd_metal_hit_high_armor_high_damage"),
           (store_agent_hit_points,":hp",":victim",0),
           (store_agent_hit_points,":oldhp",":victim",1),
           (val_div,":speed",2), # Remember to change this if the timing on speed checks changes
           (val_sub,":speed",15),
           (val_sub,":hp",":speed"),
           (val_max,":hp",0),
           (agent_set_slot,":agent",slot_agent_spearwall,0),
           (agent_get_horse,":playerhorse",":player"),           
           (agent_set_hit_points,":victim",":hp",0),
           (agent_deliver_damage_to_agent,":victim",":victim"),
           (try_begin),
              (eq,":victim",":playerhorse"),
              (store_agent_hit_points,":hp",":victim",1),
              (val_sub,":oldhp",":hp"),
              (assign,reg1,":oldhp"),
              (display_message,"@Your horse received {reg1} damage from a braced spear!",0xff4040),
           (try_end),
        (try_end),
        ])
spearwall_trigger_7 = (0.1, 0, 0, [(eq,"$spear_in_position",1)], [
        (get_player_agent_no,":player"),
        (agent_is_alive,":player"),
        (store_agent_hit_points,":hp",":player",1),
        (lt,":hp","$spear_hp"),
        (display_message,"@The injury causes your grip on the spear to slip!",0xff4040),
        (agent_set_animation, ":player", "anim_release_thrust_staff"),
        (assign,"$spear_in_position",0),
        ])

spearwall_trigger_8 = (0.1, 0, 0, [(eq,"$spear_in_position",1)], [
        (get_player_agent_no,":player"),
        (agent_is_alive,":player"),
        (agent_get_slot,":speartimer",":player",slot_agent_spearwall),
        (ge,":speartimer",10),
        (assign,":victim",-1),
        (agent_get_position,pos1,":player"),
        (try_for_agents,":possible_victim"),
           (agent_is_alive,":possible_victim"),
           (neg|agent_is_human,":possible_victim"),
           (agent_get_rider,":rider",":possible_victim"),
           (ge,":rider",0),
           (neg|agent_is_ally,":rider"),
           (agent_get_position,pos2,":possible_victim"),
           (get_distance_between_positions,":dist",pos1,pos2),
           (lt,":dist","$spear_dist"),
           (neg|position_is_behind_position,pos2,pos1),
           (agent_get_slot,":speed",":possible_victim",slot_agent_speed),
           (ge,":speed",120), # Remember to change this if the timing on speed checks changes
           (assign,":victim",":possible_victim"),
        (try_end),
        (gt,":victim",-1),
        (agent_play_sound,":victim","snd_metal_hit_high_armor_high_damage"),
        (store_agent_hit_points,":hp",":victim",0),
        (store_agent_hit_points,":oldhp",":victim",1),
        (val_div,":speed",2), # Remember to change this if the timing on speed checks changes
        (val_sub,":speed",15),
        (val_sub,":hp",":speed"),
        (val_max,":hp",0),
        (agent_set_hit_points,":victim",":hp",0),
        (agent_deliver_damage_to_agent,":victim",":victim"),
        (agent_set_slot,":player",slot_agent_spearwall,0),
        (store_agent_hit_points,":hp",":victim",1),
        (val_sub,":oldhp",":hp"),
        (assign,reg1,":oldhp"),
        (display_message,"@Spear-wall dealt {reg1} damage!"),
        ])
spearwall_trigger_9 = (0, 0, 2, [(key_clicked, key_b),(eq,"$setting_use_spearwall",1)],
       [(assign,":continue",0),
        (get_player_agent_no,":player"),
        (agent_is_alive,":player"),
        (agent_get_wielded_item, ":handone", ":player", 0),
        (agent_get_wielded_item, ":handtwo", ":player", 1),
        (assign,"$spear_dist",145),
        (try_for_range,":spear","itm_pitch_fork","itm_wooden_shield"),
            (this_or_next|eq,":handone",":spear"),
            (eq,":handtwo",":spear"),
            (assign,":continue",1),
              (try_begin),
                 (eq,":spear","itm_war_spear"),
                 (assign,"$spear_dist",160),
              (else_try),
                 (eq,":spear","itm_spear_e_2-5m"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_light_lance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_lance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_heavy_lance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_pike"),
                 (assign,"$spear_dist",255),
              (else_try),
                 (eq,":spear","itm_ashwood_pike"),
                 (assign,"$spear_dist",255),
              (else_try),
                 (eq,":spear","itm_awlpike"),
                 (assign,"$spear_dist",170),
              (else_try),
                 (eq,":spear","itm_pitch_fork"),
                 (assign,"$spear_dist",164),
              (else_try),
                 (eq,":spear","itm_military_fork"),
                 (assign,"$spear_dist",145),
              (else_try),
                 (eq,":spear","itm_battle_fork"),
                 (assign,"$spear_dist",152),
              (else_try),
                 (eq,":spear","itm_boar_spear"),
                 (assign,"$spear_dist",167),
              (else_try),
                 (eq,":spear","itm_glaive"),
                 (assign,"$spear_dist",167),
              (else_try),
                 (eq,":spear","itm_poleaxe"),
                 (assign,"$spear_dist",190),
              (else_try),
                 (eq,":spear","itm_polehammer"),
                 (assign,"$spear_dist",140),
              (else_try),
                 (eq,":spear","itm_shortened_spear"),
                 (assign,"$spear_dist",130),
              (else_try),
                 (eq,":spear","itm_halberd"),
                 (assign,"$spear_dist",185),
              (else_try),
                 (eq,":spear","itm_ancient_halbard"),
                 (assign,"$spear_dist",185),
              (else_try),
                 (eq,":spear","itm_klance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_jousting_lance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_double_sided_lance"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_staff"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_quarter_staff"),
                 (assign,":continue",0),
              (else_try),
                 (eq,":spear","itm_iron_staff"),
                 (assign,":continue",0),
              (try_end),
        (try_end),
        (eq,":continue",1),
       	(agent_get_horse,":horse",":player"),
        (neg|gt,":horse",0),
        (neq, "$spear_in_position", 1),
        (display_message,"@Bracing spear for charge.",0x6495ed),
        (agent_set_animation, ":player", "anim_spearwall_hold"),
        (assign, "$spear_in_position", 1),
        (store_agent_hit_points,"$spear_hp",":player",1),
        ])
Stick that in at the top of mission templates, with the rest of the triggers.

Code:
      spearwall_trigger_1,
      spearwall_trigger_2,
      spearwall_trigger_3,
      spearwall_trigger_4,
      spearwall_trigger_5,
      spearwall_trigger_6,
      spearwall_trigger_7,
      spearwall_trigger_8,
      spearwall_trigger_9,
Put that in in the end of the mission that you want to use bracing in (such as lead_charge) right before the final

    ],
  ),


Agents you need:

Code:
slot_agent_spearwall = 142
slot_agent_x = 143
slot_agent_y = 144
slot_agent_z = 145
slot_agent_speed = 146
Toss in module_constants.

Animations:
Code:
 ["spearwall_hold", acf_thrust|acf_enforce_all|acf_align_with_ground,
   [4.0, "anim_human", combat+7310, combat+7310, blend_in_ready],
 ],
In module_animations, overwriting one of the unused. (That was just for you, jik)

I believe that's all of it. Now, for your own mod, you have to change parts.

Find this:            (try_for_range,":spear","itm_pitch_fork","itm_wooden_shield"),

and change the first item to the beginning of where the spears are in your mod and the "item_wooden_shield" to the end.

Next, scroll down a small bit to see the area where it starts with:
                (try_begin),
                (eq,":spear","itm_war_spear"),
                (assign,":speardist",160),

and ends with:

              (else_try),
                (eq,":spear","itm_iron_staff"),
                (assign,":continue",0),
              (try_end),

You need to change it. Each "itm_somethinghere" needs to become an spear in your mod. For items that you don't want braced (iron staff is an example here), set it to ":continue",0. The other values are the length of the spear when braced. So, the war spear can kill horses from 160 M&B distance units away. This part of the code enables the AI to brace their spears.



Now scroll down to the second:                                      (try_for_range,":spear","itm_pitch_fork","itm_wooden_shield"),


Change it again.


Then scroll down a tiny bit and change it (the spear lengths) again.

This part enables the player to brace spears.


I think that's all. I'm going to go get some coffee.

Remember to credit the development team of NE if you use this.

EDIT: Oh yeah, I forgot. You need to copy the code part into mission templates, any mission where you feel that you need to be able to skewer horses.

Here's an added bonus thingie:

Code:
call_horse_trigger_1 = (0, 0, 3, [(key_clicked, key_m)], [
      (get_player_agent_no,":agent"),
      (agent_get_horse,":horse",":agent"),
      (neg|gt,":horse",0),
      (troop_get_slot,":horse",":agent",slot_troop_horse),
      (agent_play_sound,":agent","snd_whistle"),
      (display_message,"@You whistle for your horse."),
      (gt,":horse",0),
      (agent_is_alive,":horse"),
      (agent_get_position, pos1, ":agent"),
      (agent_set_scripted_destination, ":horse", pos1, 0),
    ])

call_horse_trigger_2 = (0.2, 0, ti_once, [], [
      (get_player_agent_no,":agent"),
      (agent_get_horse,":horse",":agent"),
      (troop_set_slot,":agent",slot_troop_horse,":horse"),
    ])
Yes, it lets you whistle for your horse to come to you. Assuming it's alive, that is. It also goes into module_mission_templates.



Forgot a second thing. You hit B to brace in this version. Or maybe it's G.

Hit your keyboard randomly. You'll find it eventually.
 

Llew2

Cheap ass bum
Count
M&BWB
Best answers
0
Sounds quite awesome. Do characters actually hold the spear properly, or...?
 

The Mercenary

Grandmaster Knight
Best answers
0
Llew2 said:
Sounds quite awesome. Do characters actually hold the spear properly, or...?
Currently, the code there uses the animation that you have when you prepare to thrust with a spear. You could create a new one and place it in in place of the animation we have in place. So, no, they don't really hold it properly. :razz:

FrisianDude said:
Sounds very nice. Once I evened out some bugs with a new town, I'll try this. Thanks alot. :smile:
There's still a couple bugs, such as being able to brace mid-swing or kill horsemen behind you. Aside from that, it should work fine.
 

jik

Knight
Best answers
0
Quick request,

Can you add "KIT" to the end of your subject for this?  Easier to search for.
 

Mordachai

Squire
Best answers
0
Very cool!  Thanks for taking the time to package this in a form that others can use.  Much Appreciated! :smile:
 

Blankin

Squire
WB
Best answers
0
It lets spearman brace the spear, killing or giving quite a hit in a horse. And the second code let you call your horse.
 

Berserker Pride

Grandmaster Knight
WB
Best answers
0
Thank you very much for releasing this kit mercenary. I played your mod and it did wonders to curb the "I have a horse I can't die syndrome". I am having trouble implementing it though it keeps throwing out a syntax error here: with an arrow pointing at that first = sign
spearwall_trigger_1 = (0.2, 0, ti_once, [], [
        (assign,"$spear_in_position",0),
        (try_for_agents,":agent"),
          (agent_set_slot,":agent",slot_agent_spearwall,0),
          (agent_set_slot,":agent",slot_agent_x,0),
          (agent_set_slot,":agent",slot_agent_y,0),
          (agent_set_slot,":agent",slot_agent_z,0),
          (agent_set_slot,":agent",slot_agent_speed,0),
        (try_end),
        ])

spearwall_trigger_2 = (0.2, 0, 0, [(eq,"$setting_use_spearwall",1)], [
        (set_fixed_point_multiplier, 100),
        (try_for_agents,":agent"),
          (agent_is_alive,":agent"),
          (agent_get_slot,":eek:ldagentx",":agent",slot_agent_x),
          (agent_get_slot,":eek:ldagenty",":agent",slot_agent_y),
          (agent_get_slot,":eek:ldagentz",":agent",slot_agent_z),
          (agent_get_position, pos1, ":agent"),
          (position_get_x,":agentx",pos1),
          (position_get_y,":agenty",pos1),
          (position_get_z,":agentz",pos1),
          (position_set_x,pos2,":eek:ldagentx"),
          (position_set_y,pos2,":eek:ldagenty"),
          (position_set_z,pos2,":eek:ldagentz"),
          (position_set_x,pos1,":agentx"),
          (position_set_y,pos1,":agenty"),
          (position_set_z,pos1,":agentz"),
          (get_distance_between_positions,":speed",pos1,pos2),
          (agent_set_slot,":agent",slot_agent_x,":agentx"),
          (agent_set_slot,":agent",slot_agent_y,":agenty"),
          (agent_set_slot,":agent",slot_agent_z,":agentz"),
          (agent_set_slot,":agent",slot_agent_speed,":speed"),
        (try_end),
        ])

spearwall_trigger_3 = (0, 0, 0, [(eq,"$spear_in_position",1),(this_or_next|game_key_clicked, gk_attack),
        (this_or_next|game_key_clicked, gk_defend),(this_or_next|game_key_clicked, gk_defend),
        (this_or_next|game_key_clicked, gk_move_forward),(this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),(this_or_next|game_key_clicked, gk_move_right),
        (this_or_next|game_key_clicked, gk_equip_primary_weapon),(this_or_next|game_key_clicked, gk_equip_secondary_weapon),
        (this_or_next|game_key_clicked, gk_action),(game_key_clicked, gk_sheath_weapon)
        ],
      [(get_player_agent_no,":player"),
        (agent_is_alive,":player"),
        (display_message,"@Releasing spear.",0x6495ed),
        (agent_set_animation, ":player", "anim_release_thrust_staff"),
        (assign,"$spear_in_position",0),
        ])

spearwall_trigger_4 = (0.2, 0, 0, [(eq,"$setting_use_spearwall",1)], [
        (try_for_agents,":agent"),
          (agent_get_horse,":horse",":agent"),
          (neg|gt,":horse",0),
          (agent_get_slot,":speartimer",":agent",slot_agent_spearwall),
          (lt,":speartimer",10),
          (val_add,":speartimer",2),
          (agent_set_slot,":agent",slot_agent_spearwall,":speartimer"),
        (try_end),
        ])

spearwall_trigger_5 = (3, 0, 0, [(eq,"$spear_in_position",1)],[
        (get_player_agent_no,":player"),
        (agent_is_alive,":player"),
        (agent_set_animation, ":player", "anim_spearwall_hold"),
        ])

spearwall_trigger_6 = (0.1, 0, 0, [(eq,"$setting_use_spearwall",1)], [
        (get_player_agent_no,":player"),
        (agent_get_team,":playerteam",":player"),
        (try_for_agents,":agent"),
          (agent_is_alive,":agent"),
          (neq,":agent",":player"),
          (agent_is_human,":agent"),
          (agent_get_horse,":horse",":agent"),
          (neg|gt,":horse",0),
          (agent_get_slot,":speartimer",":agent",slot_agent_spearwall),
          (ge,":speartimer",10),
          (agent_get_simple_behavior,":state",":agent"),
          (agent_get_team,":team1",":agent"),
          (agent_get_class,":class",":agent"),
          (team_get_movement_order,":eek:rder",":team1",":class"),
          (assign,":continue",0),
          (try_begin),
              (neq,":team1",":playerteam"),
              (this_or_next|eq,":state",aisb_hold),
              (this_or_next|eq,":state",aisb_flock),
              (eq,":state",aisb_go_to_pos),
              (assign,":continue",1),
          (else_try),
              (this_or_next|eq,":eek:rder",mordr_hold),
              (eq,":eek:rder",mordr_stand_ground),
              (this_or_next|eq,":state",aisb_hold),
              (this_or_next|eq,":state",aisb_flock),
              (this_or_next|eq,":state",aisb_melee),
              (eq,":state",aisb_go_to_pos),
              (assign,":continue",1),
          (try_end),
          (eq,":continue",1),
          (assign,":continue",0),
          (try_begin),
              (eq,":team1",":playerteam"),
              (eq,"$rout",0),
              (assign,":continue",1),
          (else_try),
              (eq,"$airout",0),
              (assign,":continue",1),
          (try_end),
          (eq,":continue",1),
          (assign,":continue",0),
          (agent_get_wielded_item, ":handone", ":agent", 0),
          (agent_get_wielded_item, ":handtwo", ":agent", 1),
          (assign,":speardist",145),
          (try_for_range,":spear","itm_pitch_fork","itm_wooden_shield"),
              (this_or_next|eq,":handone",":spear"),
              (eq,":handtwo",":spear"),
              (assign,":continue",1),
              (try_begin),
                (eq,":spear","itm_war_spear"),
                (assign,":speardist",160),
              (else_try),
                (eq,":spear","itm_spear_e_2-5m"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_light_lance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_lance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_heavy_lance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_pike"),
                (assign,":speardist",255),
              (else_try),
                (eq,":spear","itm_ashwood_pike"),
                (assign,":speardist",255),
              (else_try),
                (eq,":spear","itm_awlpike"),
                (assign,":speardist",170),
              (else_try),
                (eq,":spear","itm_pitch_fork"),
                (assign,":speardist",164),
              (else_try),
                (eq,":spear","itm_military_fork"),
                (assign,":speardist",145),
              (else_try),
                (eq,":spear","itm_battle_fork"),
                (assign,":speardist",152),
              (else_try),
                (eq,":spear","itm_boar_spear"),
                (assign,":speardist",167),
              (else_try),
                (eq,":spear","itm_glaive"),
                (assign,":speardist",167),
              (else_try),
                (eq,":spear","itm_poleaxe"),
                (assign,":speardist",190),
              (else_try),
                (eq,":spear","itm_polehammer"),
                (assign,":speardist",140),
              (else_try),
                (eq,":spear","itm_shortened_spear"),
                (assign,":speardist",130),
              (else_try),
                (eq,":spear","itm_halberd"),
                (assign,":speardist",185),
              (else_try),
                (eq,":spear","itm_ancient_halbard"),
                (assign,":speardist",185),
              (else_try),
                (eq,":spear","itm_klance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_jousting_lance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_double_sided_lance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_staff"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_quarter_staff"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_iron_staff"),
                (assign,":continue",0),
              (try_end),
          (try_end),
          (eq,":continue",1),
          (assign,":victim",-1),
          (agent_get_position,pos1,":agent"),
          (try_for_agents,":possible_victim"),
              (agent_is_alive,":possible_victim"),
              (neg|agent_is_human,":possible_victim"),
              (agent_get_rider,":rider",":possible_victim"),
              (ge,":rider",0),
              (agent_get_team,":team2",":rider"),
              (teams_are_enemies,":team1",":team2"),
              (agent_get_position,pos2,":possible_victim"),
              (get_distance_between_positions,":dist",pos1,pos2),
              (lt,":dist",":speardist"),
              (neg|position_is_behind_position,pos2,pos1),
              (agent_get_slot,":speed",":possible_victim",slot_agent_speed),
              (ge,":speed",120), # Remember to change this if the timing on speed checks changes
              (assign,":victim",":possible_victim"),
          (try_end),
          (gt,":victim",-1),
          (agent_set_animation, ":agent", "anim_spearwall_hold"),
          (agent_play_sound,":victim","snd_metal_hit_high_armor_high_damage"),
          (store_agent_hit_points,":hp",":victim",0),
          (store_agent_hit_points,":eek:ldhp",":victim",1),
          (val_div,":speed",2), # Remember to change this if the timing on speed checks changes
          (val_sub,":speed",15),
          (val_sub,":hp",":speed"),
          (val_max,":hp",0),
          (agent_set_slot,":agent",slot_agent_spearwall,0),
          (agent_get_horse,":playerhorse",":player"),         
          (agent_set_hit_points,":victim",":hp",0),
          (agent_deliver_damage_to_agent,":victim",":victim"),
          (try_begin),
              (eq,":victim",":playerhorse"),
              (store_agent_hit_points,":hp",":victim",1),
              (val_sub,":eek:ldhp",":hp"),
              (assign,reg1,":eek:ldhp"),
              (display_message,"@Your horse received {reg1} damage from a braced spear!",0xff4040),
          (try_end),
        (try_end),
        ])
spearwall_trigger_7 = (0.1, 0, 0, [(eq,"$spear_in_position",1)], [
        (get_player_agent_no,":player"),
        (agent_is_alive,":player"),
        (store_agent_hit_points,":hp",":player",1),
        (lt,":hp","$spear_hp"),
        (display_message,"@The injury causes your grip on the spear to slip!",0xff4040),
        (agent_set_animation, ":player", "anim_release_thrust_staff"),
        (assign,"$spear_in_position",0),
        ])

spearwall_trigger_8 = (0.1, 0, 0, [(eq,"$spear_in_position",1)], [
        (get_player_agent_no,":player"),
        (agent_is_alive,":player"),
        (agent_get_slot,":speartimer",":player",slot_agent_spearwall),
        (ge,":speartimer",10),
        (assign,":victim",-1),
        (agent_get_position,pos1,":player"),
        (try_for_agents,":possible_victim"),
          (agent_is_alive,":possible_victim"),
          (neg|agent_is_human,":possible_victim"),
          (agent_get_rider,":rider",":possible_victim"),
          (ge,":rider",0),
          (neg|agent_is_ally,":rider"),
          (agent_get_position,pos2,":possible_victim"),
          (get_distance_between_positions,":dist",pos1,pos2),
          (lt,":dist","$spear_dist"),
          (neg|position_is_behind_position,pos2,pos1),
          (agent_get_slot,":speed",":possible_victim",slot_agent_speed),
          (ge,":speed",120), # Remember to change this if the timing on speed checks changes
          (assign,":victim",":possible_victim"),
        (try_end),
        (gt,":victim",-1),
        (agent_play_sound,":victim","snd_metal_hit_high_armor_high_damage"),
        (store_agent_hit_points,":hp",":victim",0),
        (store_agent_hit_points,":eek:ldhp",":victim",1),
        (val_div,":speed",2), # Remember to change this if the timing on speed checks changes
        (val_sub,":speed",15),
        (val_sub,":hp",":speed"),
        (val_max,":hp",0),
        (agent_set_hit_points,":victim",":hp",0),
        (agent_deliver_damage_to_agent,":victim",":victim"),
        (agent_set_slot,":player",slot_agent_spearwall,0),
        (store_agent_hit_points,":hp",":victim",1),
        (val_sub,":eek:ldhp",":hp"),
        (assign,reg1,":eek:ldhp"),
        (display_message,"@Spear-wall dealt {reg1} damage!"),
        ])
spearwall_trigger_9 = (0, 0, 2, [(key_clicked, key_b),(eq,"$setting_use_spearwall",1)],
      [(assign,":continue",0),
        (get_player_agent_no,":player"),
        (agent_is_alive,":player"),
        (agent_get_wielded_item, ":handone", ":player", 0),
        (agent_get_wielded_item, ":handtwo", ":player", 1),
        (assign,"$spear_dist",145),
        (try_for_range,":spear","itm_pitch_fork","itm_wooden_shield"),
            (this_or_next|eq,":handone",":spear"),
            (eq,":handtwo",":spear"),
            (assign,":continue",1),
              (try_begin),
                (eq,":spear","itm_war_spear"),
                (assign,"$spear_dist",160),
              (else_try),
                (eq,":spear","itm_spear_e_2-5m"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_light_lance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_lance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_heavy_lance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_pike"),
                (assign,"$spear_dist",255),
              (else_try),
                (eq,":spear","itm_ashwood_pike"),
                (assign,"$spear_dist",255),
              (else_try),
                (eq,":spear","itm_awlpike"),
                (assign,"$spear_dist",170),
              (else_try),
                (eq,":spear","itm_pitch_fork"),
                (assign,"$spear_dist",164),
              (else_try),
                (eq,":spear","itm_military_fork"),
                (assign,"$spear_dist",145),
              (else_try),
                (eq,":spear","itm_battle_fork"),
                (assign,"$spear_dist",152),
              (else_try),
                (eq,":spear","itm_boar_spear"),
                (assign,"$spear_dist",167),
              (else_try),
                (eq,":spear","itm_glaive"),
                (assign,"$spear_dist",167),
              (else_try),
                (eq,":spear","itm_poleaxe"),
                (assign,"$spear_dist",190),
              (else_try),
                (eq,":spear","itm_polehammer"),
                (assign,"$spear_dist",140),
              (else_try),
                (eq,":spear","itm_shortened_spear"),
                (assign,"$spear_dist",130),
              (else_try),
                (eq,":spear","itm_halberd"),
                (assign,"$spear_dist",185),
              (else_try),
                (eq,":spear","itm_ancient_halbard"),
                (assign,"$spear_dist",185),
              (else_try),
                (eq,":spear","itm_klance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_jousting_lance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_double_sided_lance"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_staff"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_quarter_staff"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_iron_staff"),
                (assign,":continue",0),
              (try_end),
        (try_end),
        (eq,":continue",1),
      (agent_get_horse,":horse",":player"),
        (neg|gt,":horse",0),
        (neq, "$spear_in_position", 1),
        (display_message,"@Bracing spear for charge.",0x6495ed),
        (agent_set_animation, ":player", "anim_spearwall_hold"),
        (assign, "$spear_in_position", 1),
        (store_agent_hit_points,"$spear_hp",":player",1),
        ])
I don't know why the compiler doesn't like the first "=" symbol.  The code is copied in right where the triggers in the lead_charge mission template begins.
 

Lord Leoric of Wercheg

Grandmaster Knight
Best answers
0
Sorry but I'm not very good at coding yet, I know that you have to place the code in module_mission templates and place it in the lead the charge part, but where do I put it exactly? When I try to put it in the Ai triggers for the mission template it just gives me syntax errors. Can someone post the code with some references like what's on top of it and what's below? :neutral:Please....? :sad:
 

jik

Knight
Best answers
0
hmmm...  Looking over the code, it may be that TheMercenary might have added some new agent slots. looking at the agent slots, I see this:

########################################################
##  AGENT SLOTS            #############################
########################################################

slot_agent_target_entry_point    = 0
slot_agent_target_x_pos          = 1
slot_agent_target_y_pos          = 2
slot_agent_is_alive_before_retreat= 3
slot_agent_is_in_scripted_mode    = 4
slot_agent_is_not_reinforcement  = 5
slot_agent_tournament_point      = 6
slot_agent_arena_team_set        = 7
slot_agent_map_overlay_id        = 10
slot_agent_target_entry_point    = 11
   
########################################################
##  FACTION SLOTS          #############################
########################################################

In the first trigger alone there are 4 slot calls that don't exist in native:

          (agent_set_slot,":agent",slot_agent_x,0),
          (agent_set_slot,":agent",slot_agent_y,0),
          (agent_set_slot,":agent",slot_agent_z,0),
          (agent_set_slot,":agent",slot_agent_speed,0),

I guess you could go through the code and find all the agent slot calls, but it would be easier if TheMercenary would include the slot defs too.

(Maybe some brief code documenation too?)
 

WarlordG

Banned
Best answers
0
Lord Leoric of Wercheg said:
Sorry but I'm not very good at coding yet, I know that you have to place the code in module_mission templates and place it in the lead the charge part, but where do I put it exactly? When I try to put it in the Ai triggers for the mission template it just gives me syntax errors. Can someone post the code with some references like what's on top of it and what's below? :neutral:Please....? :sad:
I want to know too >_>
 

The Mercenary

Grandmaster Knight
Best answers
0
Yeah, I'll do that as soon as I find which file the agent defs are in and which folder has the current module stuff.
 

FrisianDude

Archduke
M&BWB
Best answers
0
Now it might be that it's because it's 4:17 in the morning, but I can't think of where to put all this script. Ofcourse, if it's obvious I'll be angry at myself when I wake up, but I honestly can't think of it now.  :???:
 

jik

Knight
Best answers
0
There are pieces missing (like slot definitions).  Wait a bit, I think TheMercenary will be fixing it up soon.
 

jik

Knight
Best answers
0
jik said:
There are pieces missing (like slot definitions).  Wait a bit, I think TheMercenary will be fixing it up soon.
It wouldn't be hard to add the agent slots yourself.  All the code goes near the top of the mission_templates.py file (where the other pre-defined triggers are), then you use the one line calls in your mission_templates tuples.