OSP Code Combat Shield Bash kit. Bug fixed and expanded!

Users who are viewing this thread

Nice job :smile:, I have tested it and all works fine, except that the player can 'spam' it to rapidly kill someone, and it also works when dead, and it can also be used to kill allies.
 
I think this should also be posted over in  PYTHON SCRIPT/SCHEME EXCHANGE sticked topic so it doesn't get lost in the flood of new threads to follow M&B release....

Mirathei said:
Pretty simple really, press the attack controll while holding the defend controll. Ai will do it automatically when applicable with some degree of randomization.
To install, just paste the following in to module scripts:




  ("cf_agent_shield_bash",
    [(store_script_param, ":agent",1),
    (agent_get_position,pos1,":agent"),
    (agent_set_animation, ":agent", "anim_release_bash"),
    (agent_play_sound,":agent","snd_man_grunt"),
    (assign,":victim",-1),
    (try_for_agents,":possible_victim"),
        (agent_is_alive,":possible_victim"),
        (agent_is_human,":possible_victim"),
        (neq,":possible_victim",":agent"),
        (agent_get_class ,":class", ":possible_victim"),
        (neq,":class",grc_cavalry),
        (agent_get_position,pos2,":possible_victim"),
        (get_distance_between_positions,":dist",pos1,pos2),
        (lt,":dist",150),
        (neg|position_is_behind_position,pos2,pos1),
        (assign,":victim",":possible_victim"),
    (end_try),
    (gt,":victim",-1),
    (store_random_in_range,":rand",1,20),
    (store_agent_hit_points,":hp",":victim",1),
    (val_sub,":hp",":rand"),
    (try_begin),
        (gt,":hp",0),
        (agent_set_hit_points,":victim",":hp",1),
        (agent_play_sound,":agent","snd_shield_hit_wood_wood"),
        (agent_play_sound,":victim","snd_blunt_hit"),
        (agent_set_animation, ":victim", "anim_strike_fall_back_rise_after_bashed"),
    (else_try),
        (agent_play_sound,":agent","snd_shield_hit_wood_wood"),
        (agent_play_sound,":victim","snd_blunt_hit"),
        (agent_deliver_damage_to_agent,":agent",":victim"),
    (end_try),
  ]),

The following into any applicable mission template:

      (0, 0, 0, [(game_key_is_down, gk_defend),(game_key_clicked, gk_attack),],
      [(assign,":continue",0),
        (get_player_agent_no,":player"),
        (try_for_range,":shield","itm_wooden_shield","itm_heraldic_mail_with_surcoat"),
            (agent_has_item_equipped,":player",":shield"),
            (assign,":continue",1),
        (end_try),
        (eq,":continue",1),
        (agent_get_horse,":horse",":player"),
        (neg|gt,":horse",0),
        (call_script,"script_cf_agent_shield_bash",":player"),
        ]),

      (1.0, 0, 0, [],
      [(get_player_agent_no,":player"),
        (try_for_agents,":agent"),
          (agent_is_alive,":agent"),
          (agent_is_human,":agent"),
          (neq,":agent",":player"),
          (agent_get_class ,":class", ":agent"),
          (neq,":class",grc_cavalry),
          (assign,":continue",0),
          (try_for_range,":shield","itm_wooden_shield","itm_heraldic_mail_with_surcoat"),
              (agent_has_item_equipped,":agent",":shield"),
              (assign,":continue",1),
          (end_try),
          (eq,":continue",1),
          (assign,":chances",0),
          (agent_get_team,":team",":agent"),
          (agent_get_position,pos1,":agent"),
          (try_for_agents,":eek:ther"),
                (agent_is_alive,":eek:ther"),
                (agent_is_human,":eek:ther"),
                (agent_get_class ,":class", ":eek:ther"),
                (neq,":class",grc_cavalry),
                (agent_get_team,":eek:therteam",":eek:ther"),
                (neq,":team",":eek:therteam"),
                (agent_get_position,pos2,":eek:ther"),
                (get_distance_between_positions,":dist",pos1,pos2),
                (neg|position_is_behind_position,pos2,pos1),
                (lt,":dist",200),
                (val_add,":chances",1),
          (end_try),
          (store_agent_hit_points,":health",":agent",0),
          (val_mul,":health",-1),
          (val_add,":health",100),
          (val_div,":health",10),
          (val_mul,":chances",":health"),
          (store_random_in_range,":rand",1,25),
          (lt,":rand",":chances"),
          (call_script,"script_cf_agent_shield_bash",":agent"),
        (end_try),]),

And the following into module animations (note that these must be pasted over two unused animations, not at the end of the file):

["strike_fall_back_rise_after_bashed", acf_enforce_all|acf_align_with_ground,
  [2.0, "anim_human", blow+5400, blow+5453, arf_blend_in_2],
],
["release_bash", acf_enforce_all|acf_right_cut|acf_parallels_for_look_slope,
  [0.62, "anim_human", combat+5710, combat+5740, blend_in_release],
],



Things to take note of: bashing is only for and only against footmen., thus cavalry will not bash or be bashed. Also, only shields in the range referenced in red above will be bash usable. If you want to bash with a shield, put it in that range.


Enjoy.  :smile:
 
You didn't really need to quote the entire code there Red River.

I have tested it and all works fine, except that the player can 'spam' it to rapidly kill someone, and it also works when dead, and it can also be used to kill allies.

The AI can do it too, so all is fair. The AI constantly did it when I was too close.
 
there's more.. the code doesn't check if the shield is equiped. that means one can "shield bash" with any weapon even a crossbow so lon' as the shield is attached to the back. and if a weapon is not equiped the shield by itself won't do any damage.
the bash spam is way to easy against somebody who's got no shield or even with a shield. there's no delay so one can tap attack buttom very rapidly. don't think AI can do that though.
 
I've found the bash spam interesting, and the AI definitely does do it. I assume you're talking about bashing them as soon as they get up? It definitely happens with the AI, and the victim can actually bash the attacker in return as a 'counter', and this often goes back and forth a couple of times until someone goes down. It's a little like grappling actually. You can also bash someone as you fall down dead :lol:.
 
No. He's talking about how the player can potentially bash 20 times a second. It's a legitimate bug and I'll definitely need to fix it.
 
Well although its useful even w/o damage, very much so, decreased damage would be better, im sure if someone slammed a shield into you it'd bloody hurt, and it'd hurt still if you got knocked down by a hit like that while wearing heavy armor.
Although it would reduce the amount of coding he has to do, since spamming it 20 times a second wont mean insta-killing them.

and Mirathei you continue to impress me, time and time again, without end. You sir, are god.
 
Zaro said:
That's not the module system, as it isn't a mod folder containing text files, it's a separate download that contains python files than compile into text files. You can download it in a sticky near the top of this section.

thank you, damn i cant believe i never figured this out


EDIT: can anybody paste a link to where i can download the Module System because all I can find is the one for .903 and i gotta run so i dont have time to look around at the moment, thanks.
 
Personally, I think it ought to do no damage, and should be used only to knock the enemy off balance.

There should be a chance of a little damage (I have it set to 0-5) but a potential 25 is too high, especially considering that the move is oftened countered and often both troops counter each other a few times within 4-5 seconds (an effect I like). The loser ends up on the ground, and often stays there.
 
As in a spear actually breaking the block? I think it works well as is, since if they close the gap or protect well, you knock them down and then skewer them :lol:.
 
I believe he means to make up for the weakness spears have compared to others weapons, and i believe a tweaked Shield Bash would work quite well :smile: This could be what spear users have been waiting for.
 
Sorry, troops are all equipped with shields in my mod, so the single attack direction of the spear has never bothered me.

He's talking about how the player can potentially bash 20 times a second. It's a legitimate bug and I'll definitely need to fix it.

Some sort of time restriction? Any plans on making the chance of success dependent on shield skill? From what I remember it is random, but using a stat would allow better troops to pull it more often, and also to negate a lesser troop trying to pull the move on them.

I can't go back to combat without shield bash.
 
Bah. Shield bash is more important than flaming arrows :razz:.

o, all I have to do is paste this anywhere into the scripts?

The instructions are in the first post, you need to use the module system (in case you aren't already), paste a part in scripts, paste a part in mission_templates in several places, and a part in animations.
 
Only the missions_templates part needs to be specific. You'll need to place it in each combat template.
 
Back
Top Bottom