OSP Code Combat Spear Bracing Kit (Updated)

正在查看此主题的用户

In real life, 'bracing' your spear wouldn't prevent you rotating to face the horse charging at you. The spear kit kind of compensates for not being able to do this by giving a much wider target area than the actual angle of your spear, but it's a bit clunky and not much fun. Like I already said, it also does nothing to make the horse rear up as far as I saw, and it doesn't seem to ever hurt the rider, so it doesn't stop someone charging at you unless you're lucky enough to kill the horse in one hit before it and its rider crashes into you. Every time I used it against a horseman charging at me, I did about 30-60 damage to the horse which didn't seem to bother, and continued to bash into me while its rider simultaneously attacked and injured me. As it is, it's less effective than thrusting at the horse normally - then you can damage the rider as well as the horse and at least interrupt their attack, or stop the horse physically by poking it in the chest. Spear bracing might be a bit more effective when the AI use it together, I haven't tested it in a large battle yet.

In real battles, you'd set your spear wall up to present a wall of points aimed towards attacking enemies. As you hinted at, it generally worked very effectively against cavalry because horses aren't suicidal and won't charge into sharp pointy things. If they somehow were convinced to attack it, they couldn't possibly penetrate it at speed without being skewered and they couldn't go at it slowly because they'd get poked to death before they got in range for the rider to do anything about it. In M&B horses are as crazy and suicidal as the people, so they don't think twice about charging at your spear - that removes the possibility of the most realistic outcome of the horse refusing to charge onto spears. As of yet the second outcome isn't possible either since horses can just ride through a braced spear so long as it doesn't kill them.

I don't like to be critical of something I couldn't possibly have created myself, it's amazing that anything at all has been managed.
 
The original kit in NE would instakill any horse that hit it. Maybe after a certain speed it should instakill again?
 
it would be possible to code AI for the horses not wanting to run into the spear wall, just iterate over the agents, see if they are close to the wall and then script their behavior to move away from it. You could do this based on horse type, as trained warhorses would be more willing to charge to their deaths than a normal saddle horse, and throw some randomness in there for good measure.

Equally, giving a limited range of rotation might also be possible but more difficult.
 
Hello.

I have a problem with this kit.
I put triggers at the top of module_mission_templates betwen common_siege_assign_men_to_belfry and tournament_triggers, put trigger names under lead_charge, agents and animations where it was said. I change all "itm_somethinghere" to the correct value. All compiled well and I start a new game.
But I can't brace spears! I pressed "B" many times, I tried all polearms - nothing, as if there were no changes in module files...
I don't know what to do, how to make it work. Help me please.

P.S. Sorry for my English.
 
If it compiled properly, then the files should work. It's probably something simple.

Are you testing it in battles? It only works in actual battles, assuming you only put it in the lead_charge mission template. It won't do anything if you press B in a town or village.

Where did you build the module? Into the native folder? Make sure that you put the custom files into the module folder you're actually playing - it sounds obvious, but I managed to fail at doing that when I tested it first (I think I pressed ctrl+c instead of ctrl+v when pasting the files to my test module...)
 
FrisianDude 说:
Oh, ta. Odd, I never had that "(assign,"$setting_use_spearwall",1)" sentence. :razz:
Now just to get rid of the
"WARNING: Local variable never used: speardist
WARNING: Local variable never used: speardist"  Odd, because it is being used.

Adding the
插入代码块:
      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,
in other battle-templates increased the amount of warnings, but it's always the same warning. Obviously I'm not getting anywhere. :???:
 
Aethelred, FrisianDude thank you for your help.
My mistake was in (eq,"$setting_use_spearwall",1) in 2,4,6,9 spearwall triggers. I newer defined this variable in code, that is why, I think, check (eq,"$setting_use_spearwall",1) was not working. I delited this check from triggers and now I'm able to brace spears.
Thank you again.
 
MartinF 说:
it would be possible to code AI for the horses not wanting to run into the spear wall, just iterate over the agents, see if they are close to the wall and then script their behavior to move away from it. You could do this based on horse type, as trained warhorses would be more willing to charge to their deaths than a normal saddle horse, and throw some randomness in there for good measure.

Equally, giving a limited range of rotation might also be possible but more difficult.

You could also make a chance for the spear wall to strop the horse (even if not killed).  I'm sure that horses charging a spear wall (yes they did if trained well enough) might actually get through with minor damage (not an exact hit).  You are forgetting the fear of the guy holding the spear.  Are you telling me that he is not afraid of the horse and rider charging at him?  If I remember correctly spear walls were usually comprised of expendable low level troops.
 
If a spear wall holds, I can't see how a horse is ever going to get through unless it's very heavily armoured. Why do you think relatively poorly equipped pike based armies were able to crush larger, richer cavalry armies? Of course the spear wall men are afraid of horses charging at them, but that's the only reason they'd ever fail to ward off a cavalry charge on its own - when they break and run, they're easy victims. If it remains disciplined, a horse might only get a glancing hit from one spearman, but in a real battle there'd be plenty of others nearby and behind to make it realistically impossible for a horse to penetrate a solid spear wall and survive. Even the best trained horse isn't going to react positively to getting spears stuck into its chest, nor would it survive long.
 
Frisian dude I'm going to post all my code for the spearwall triggers hopefully it helps you out.
########################Begin#################################
spearwall_trigger_1 = (0.2, 0, ti_once, [], [
        (assign,"$spear_in_position",0),
        (assign,"$setting_use_spearwall",1),
        (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",160),
              (else_try),
                (eq,":spear","itm_awlpike"),
                (assign,":speardist",170),
              (else_try),
                (eq,":spear","itm_pitch_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_military_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_battle_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_boar_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_glaive"),
                (assign,":speardist",167),
              (else_try),
                (eq,":spear","itm_poleaxe"),
                (assign,":speardist",180),
              (else_try),
                (eq,":spear","itm_polehammer"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_shortened_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_fauchard"),
                (assign,":speardist",140),
              (else_try),
                (eq,":spear","itm_halberd_e"),
                (assign,":speardist",150),
              (else_try),
                (eq,":spear","itm_halberd_f"),
                (assign,":speardist",150),
              (else_try),
                (eq,":spear","itm_knight_polehammer_a"),
                (assign,":speardist",155),
              (else_try),
                (eq,":spear","itm_knight_polehammer_b"),
                (assign,":speardist",150),
              (else_try),
                (eq,":spear","itm_bill"),
                (assign,":speardist",160),
              (else_try),
                (eq,":spear","itm_midland_lance"),
                (assign,":speardist",290),
              (else_try),
                (eq,":spear","itm_kushan_lance"),
                (assign,":speardist",270),
              (else_try),
                (eq,":spear","itm_cataphract_lance"),
                (assign,":speardist",260),
              (else_try),
                (eq,":spear","itm_mercenary_lance"),
                (assign,":speardist",290),
              (else_try),
                (eq,":spear","itm_tudor_spear"),
                (assign,":speardist",190),
              (else_try),
                (eq,":spear","itm_dark_jousting_pike"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_jousting_pike"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_sheep_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_daka_spear"),
                (assign,":speardist",130),
              (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",160),
              (else_try),
                (eq,":spear","itm_awlpike"),
                (assign,"$spear_dist",170),
              (else_try),
                (eq,":spear","itm_pitch_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_military_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_battle_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_boar_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_glaive"),
                (assign,"$spear_dist",167),
              (else_try),
                (eq,":spear","itm_poleaxe"),
                (assign,"$spear_dist",180),
              (else_try),
                (eq,":spear","itm_polehammer"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_shortened_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_fauchard"),
                (assign,"$spear_dist",140),
              (else_try),
                (eq,":spear","itm_halberd_e"),
                (assign,"$spear_dist",150),
              (else_try),
                (eq,":spear","itm_halberd_f"),
                (assign,"$spear_dist",150),
              (else_try),
                (eq,":spear","itm_knight_polehammer_a"),
                (assign,"$spear_dist",155),
              (else_try),
                (eq,":spear","itm_knight_polehammer_b"),
                (assign,"$spear_dist",150),
              (else_try),
                (eq,":spear","itm_bill"),
                (assign,"$spear_dist",160),
              (else_try),
                (eq,":spear","itm_midland_lance"),
                (assign,"$spear_dist",290),
              (else_try),
                (eq,":spear","itm_kushan_lance"),
                (assign,"$spear_dist",270),
              (else_try),
                (eq,":spear","itm_cataphract_lance"),
                (assign,"$spear_dist",260),
              (else_try),
                (eq,":spear","itm_mercenary_lance"),
                (assign,"$spear_dist",290),
              (else_try),
                (eq,":spear","itm_tudor_spear"),
                (assign,"$spear_dist",190),
              (else_try),
                (eq,":spear","itm_dark_jousting_pike"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_jousting_pike"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_sheep_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_daka_spear"),
                (assign,"$spear_dist",130),
              (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),
        ])
      ########################End#####################
Just notice that the first block of weapon reaches uses the local variable :speardist and the second set uses the global $spear_dist hopefully the code helps.
 
Berserker Pride 说:
Frisian dude I'm going to post all my code for the spearwall triggers hopefully it helps you out.
########################Begin#################################
spearwall_trigger_1 = (0.2, 0, ti_once, [], [
        (assign,"$spear_in_position",0),
        (assign,"$setting_use_spearwall",1),
        (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",160),
              (else_try),
                (eq,":spear","itm_awlpike"),
                (assign,":speardist",170),
              (else_try),
                (eq,":spear","itm_pitch_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_military_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_battle_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_boar_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_glaive"),
                (assign,":speardist",167),
              (else_try),
                (eq,":spear","itm_poleaxe"),
                (assign,":speardist",180),
              (else_try),
                (eq,":spear","itm_polehammer"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_shortened_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_fauchard"),
                (assign,":speardist",140),
              (else_try),
                (eq,":spear","itm_halberd_e"),
                (assign,":speardist",150),
              (else_try),
                (eq,":spear","itm_halberd_f"),
                (assign,":speardist",150),
              (else_try),
                (eq,":spear","itm_knight_polehammer_a"),
                (assign,":speardist",155),
              (else_try),
                (eq,":spear","itm_knight_polehammer_b"),
                (assign,":speardist",150),
              (else_try),
                (eq,":spear","itm_bill"),
                (assign,":speardist",160),
              (else_try),
                (eq,":spear","itm_midland_lance"),
                (assign,":speardist",290),
              (else_try),
                (eq,":spear","itm_kushan_lance"),
                (assign,":speardist",270),
              (else_try),
                (eq,":spear","itm_cataphract_lance"),
                (assign,":speardist",260),
              (else_try),
                (eq,":spear","itm_mercenary_lance"),
                (assign,":speardist",290),
              (else_try),
                (eq,":spear","itm_tudor_spear"),
                (assign,":speardist",190),
              (else_try),
                (eq,":spear","itm_dark_jousting_pike"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_jousting_pike"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_sheep_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_daka_spear"),
                (assign,":speardist",130),
              (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",160),
              (else_try),
                (eq,":spear","itm_awlpike"),
                (assign,"$spear_dist",170),
              (else_try),
                (eq,":spear","itm_pitch_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_military_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_battle_fork"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_boar_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_glaive"),
                (assign,"$spear_dist",167),
              (else_try),
                (eq,":spear","itm_poleaxe"),
                (assign,"$spear_dist",180),
              (else_try),
                (eq,":spear","itm_polehammer"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_shortened_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_fauchard"),
                (assign,"$spear_dist",140),
              (else_try),
                (eq,":spear","itm_halberd_e"),
                (assign,"$spear_dist",150),
              (else_try),
                (eq,":spear","itm_halberd_f"),
                (assign,"$spear_dist",150),
              (else_try),
                (eq,":spear","itm_knight_polehammer_a"),
                (assign,"$spear_dist",155),
              (else_try),
                (eq,":spear","itm_knight_polehammer_b"),
                (assign,"$spear_dist",150),
              (else_try),
                (eq,":spear","itm_bill"),
                (assign,"$spear_dist",160),
              (else_try),
                (eq,":spear","itm_midland_lance"),
                (assign,"$spear_dist",290),
              (else_try),
                (eq,":spear","itm_kushan_lance"),
                (assign,"$spear_dist",270),
              (else_try),
                (eq,":spear","itm_cataphract_lance"),
                (assign,"$spear_dist",260),
              (else_try),
                (eq,":spear","itm_mercenary_lance"),
                (assign,"$spear_dist",290),
              (else_try),
                (eq,":spear","itm_tudor_spear"),
                (assign,"$spear_dist",190),
              (else_try),
                (eq,":spear","itm_dark_jousting_pike"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_jousting_pike"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_sheep_spear"),
                (assign,":continue",0),
              (else_try),
                (eq,":spear","itm_daka_spear"),
                (assign,"$spear_dist",130),
              (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),
        ])
      ########################End#####################
Just notice that the first block of weapon reaches uses the local variable :speardist and the second set uses the global $spear_dist hopefully the code helps.
It solved some problems but one still stands...
When i enter M&B i start a new game, no errors, but when i enter a battle i press "b" but nothing happens (and yes, i'v tried other keys)

Aethelred 说:
If it compiled properly, then the files should work. It's probably something simple.

Are you testing it in battles? It only works in actual battles, assuming you only put it in the lead_charge mission template. It won't do anything if you press B in a town or village.

Where did you build the module? Into the native folder? Make sure that you put the custom files into the module folder you're actually playing - it sounds obvious, but I managed to fail at doing that when I tested it first (I think I pressed ctrl+c instead of ctrl+v when pasting the files to my test module...)

And i didn't did any of those errors...

Help???
 
Are you sure you are using a weapon that has a range listed in the 6th trigger?  And make sure all your polearms are together and in between this (try_for_range,":spear","itm_pitch_fork","itm_wooden_shield"), The first polearm can be whatever you want but the last should be just before the itm_wooden_shield in module_items. EDIT: For anyone who thinks the damage isn't enough just change these two sections
#(val_div,":speed",2), # Remember to change this if the timing on speed checks changes
        (val_sub,":speed",15),
     
The current code divides the local var ":speed" in half before subtracing the speed from the horses health by tabbing out that line damage to the horse is doubled.  It also seems to take 15 away from the damage in that line as well so you could tab that out too.  Those two lines show up in trigger 5 and trigger 8 change both and it will almost guarantee a kill if the horse is at high speed.
 
Berserker Pride 说:
Are you sure you are using a weapon that has a range listed in the 6th trigger?  And make sure all your polearms are together and in between this (try_for_range,":spear","itm_pitch_fork","itm_wooden_shield"), The first polearm can be whatever you want but the last should be just before the itm_wooden_shield in module_items. EDIT: For anyone who thinks the damage isn't enough just change these two sections
#(val_div,":speed",2), # Remember to change this if the timing on speed checks changes
        (val_sub,":speed",15),
     
The current code divides the local var ":speed" in half before subtracing the speed from the horses health by tabbing out that line damage to the horse is doubled.  It also seems to take 15 away from the damage in that line as well so you could tab that out too.  Those two lines show up in trigger 5 and trigger 8 change both and it will almost guarantee a kill if the horse is at high speed.
I'v copy pasted everything you'v posted (the python code) right below

common_battle_mission_start = (
  ti_before_mission_start, 0, 0, [],
  [
    (team_set_relation, 0, 2, 1),
    (team_set_relation, 1, 3, 1),
    (call_script, "script_change_banners_and_chest"),
    ])

maybe it isn't suposed to be there i'm gettin on my nervs with this not to say f*#& up but i think it is worth it
 
look at this post:
http://forums.taleworlds.com/index.php/topic,63070.0.html

may make life a bit easier for you.
 
The AI doesn't use bracing, or not?
I have modded some Landsknecht into Native + formations, morale, shieldbash and bracing.
My character can brace his spear, but the AI won't.
 
jik 说:
look at this post:
http://forums.taleworlds.com/index.php/topic,63070.0.html

may make life a bit easier for you.

Thanks for helping the distribution of the Compilation.
 
The ai do brace but it seems they only do it if set for hold position.  Or maybe they brace when I do.  I wish they would brace a little more though.  In Native Expanded you couldn't go through a mob without getting spearbraced.
EDIT: They seem to brace enough after all.  As long as there is a few spearmen it seems one of them will spearbrace you.
 
后退
顶部 底部