OSP Code Combat [WB] Horse Trample fun

Users who are viewing this thread

A quick and easy script, press Ctrl+J to rear. It can be modified to work in multiplayer, although I'm sure people will spam it more than necessary. It is not recommended for implementation for the AI, since additional logic loops are required for them and they get stuck and rear in the worst places. For converting this script to multiplayer, I recommend adding an additional agent slot to track the cooldown, and possibly some other animations as well so it can be distinguished from normal rears.

It does require some stats-tracking, namely the charge and base health of the horses (a script is included for Native items, but you can generate the slot value automatically).
Code:
slot_item_horse_health = 21
slot_item_horse_charge = 22
Code:
  ("init_horse_slot",
    [
    (item_set_slot, "itm_sumpter_horse", slot_item_horse_health, 100),
    (item_set_slot, "itm_saddle_horse", slot_item_horse_health, 100),
    (item_set_slot, "itm_steppe_horse", slot_item_horse_health, 120),
    (item_set_slot, "itm_arabian_horse_a", slot_item_horse_health, 110),
    (item_set_slot, "itm_arabian_horse_b", slot_item_horse_health, 120),
    (item_set_slot, "itm_courser", slot_item_horse_health, 110),
    (item_set_slot, "itm_hunter", slot_item_horse_health, 160),
    (item_set_slot, "itm_warhorse", slot_item_horse_health, 165),
    (item_set_slot, "itm_charger", slot_item_horse_health, 165),
    (item_set_slot, "itm_warhorse_sarranid", slot_item_horse_health, 165),
    (item_set_slot, "itm_warhorse_steppe", slot_item_horse_health, 150),

    (item_set_slot, "itm_sumpter_horse", slot_item_horse_charge, 9),
    (item_set_slot, "itm_saddle_horse", slot_item_horse_charge, 10),
    (item_set_slot, "itm_steppe_horse", slot_item_horse_charge, 8),
    (item_set_slot, "itm_arabian_horse_a", slot_item_horse_charge, 12),
    (item_set_slot, "itm_arabian_horse_b", slot_item_horse_charge, 16),
    (item_set_slot, "itm_courser", slot_item_horse_charge, 12),
    (item_set_slot, "itm_hunter", slot_item_horse_charge, 24),
    (item_set_slot, "itm_warhorse", slot_item_horse_charge, 28),
    (item_set_slot, "itm_charger", slot_item_horse_charge, 32),
    (item_set_slot, "itm_warhorse_sarranid", slot_item_horse_charge, 32),
    (item_set_slot, "itm_warhorse_steppe", slot_item_horse_charge, 28),
    ]
  ),

Other than the condition that the player is alive and mounted, there are no other checks. Animation checks might be appropriate to make sure the horse isn't jumping, but the cooldown period between rears is good enough for now. The code is heavily commented for debugging purposes, but basically health increases the damage done and the speed at which the horse is travelling at affects the radius of the knockdown effect. Feel free to adjust the size of the semi-circle and the reciprocal damage done.
Code:
      #rearing knock-down action (hoove slashing = cut damage)
      (0, 0, 8, [
        (this_or_next|key_is_down, key_left_control),
        (key_is_down, key_right_control),
        (key_clicked, key_j), #there is no gk for rearing - how unfortunate
        ## Keep the conditions here simple - we can check in the consequence since it's run every frame
        ],

        [
        (get_player_agent_no, ":player_agent"),
        (agent_is_alive, ":player_agent"),
        (agent_get_horse, ":horse_agent", ":player_agent"),
        (ge, ":horse_agent", 0),
        
        (set_fixed_point_multiplier, 100),
        (store_agent_hit_points, ":hit_point", ":horse_agent", 1),
        (agent_get_item_id, ":horse_item", ":horse_agent"),
        (item_get_slot, ":horse_charge", ":horse_item", slot_item_horse_charge),
        (item_get_slot, ":horse_max", ":horse_item", slot_item_horse_health),
        (val_mul, ":horse_charge", ":hit_point"),
        (val_div, ":horse_max", 2),  #usually around 100 to 160 base
        (val_div, ":horse_charge", ":horse_max"),
        
        (agent_get_team, ":player_team", ":player_agent"),
        
        (agent_get_speed, pos1, ":horse_agent"),
        (position_get_y, ":speed", pos1),
        # (assign, reg1, ":speed"),
        # (assign, reg2, ":horse_charge"),
        # (str_store_item_name, s1, ":horse_item"),
        # (display_message, "@{s1} going at {reg1} m/s charging for {reg2} dmg"),
        (val_div, ":speed", 3), #cut top speed by a 3rd, 2 m radius max
        (val_add, ":speed", ":horse_charge"), #50 cm minimum - warhorses can have a larger base radius
        (agent_get_position, pos1, ":horse_agent"),
        #move along the position to get final semicircle in front of horse
        
        (assign, ":num_wounded", 0),
        (try_for_agents, ":agent_no"),
          # (neq, ":agent_no", ":player_agent"), #many of the below would already disqualify the player
          (agent_is_alive, ":agent_no"),
          (agent_is_human, ":agent_no"),
          (agent_get_horse, ":agent_horse", ":agent_no"),
          (eq, ":agent_horse", -1),
          
          (agent_get_team, ":agent_team", ":agent_no"),
          (teams_are_enemies, ":agent_team", ":player_team"),
          (agent_get_position, pos2, ":agent_no"),
          (neg|position_is_behind_position, pos2, pos1), #cannot be trampled while behind the horse
          (get_distance_between_positions, ":cur_distance", pos1, pos2),
          (le, ":cur_distance", ":speed"), #the faster it's going the more it will affect those in front
          #knockdown animation?
          (val_add, ":num_wounded", 1),

          # (str_store_agent_name, s2, ":agent_no"),
          (agent_deliver_damage_to_agent_advanced, reg2, ":horse_agent", ":agent_no", ":horse_charge"),
          (gt, reg2, 5),
          # (display_message, "@{reg2} trample damage dealt to {s2}"), #the above operation already notifies you
          (agent_set_animation, ":agent_no", "anim_shield_strike"),
        (try_end),
        
        #deliver reciprocal damage to horse
        (try_begin),
          (gt, ":num_wounded", 0),
          (agent_get_troop_id, ":player_troop", ":player_agent"),
          (store_skill_level, ":riding", "skl_riding", ":player_troop"),
          
          (options_get_damage_to_player, ":adder"), #0:quarter;1:half;2:full
          (store_sub, ":adder", 4, ":adder"), #original was division by 3 per riding
          (val_add, ":riding", ":adder"), #so we don't divide by 0
          
          (val_mul, ":num_wounded", 28),
          (val_div, ":num_wounded", ":riding"),
          #note that this ignores armor
          (val_sub, ":hit_point", ":num_wounded"),
          (agent_set_hit_points, ":horse_agent", ":hit_point", 1),
          (assign, reg1, ":num_wounded"),
          (display_message, "@Horse received {reg1} trample damage", 0xffaa99),
        (try_end),
        # (agent_deliver_damage_to_agent, ":player_agent", ":horse_agent", ":num_wounded"),
        
        ]
      ),

You also need an additional animation slot - this is because agent_deliver_damage_to_agent will deal cutting damage and won't actually knock them down properly as horses normally would. If you have added shield bash already this won't be necessary, but if you don't this animation should overwrite one of the unused human slots.
Code:
 ["shield_strike", acf_enforce_all|acf_align_with_ground, amf_priority_striked|amf_play|amf_accurate_body|amf_restart,
    [2, "anim_human", blow+5000, blow+5010, arf_blend_in_3|arf_make_custom_sound],
    [2.5, "anim_human", blow+5400, blow+5453, arf_blend_in_2|arf_make_custom_sound],
    [2.5, "anim_human", blow+5400, blow+5445, arf_blend_in_2|arf_make_custom_sound],
   ],

Finally, if anybody doesn't likes horses, I'll add a menu option to slaughter them for food using some of those slot values. That concludes this OSP of the week, the download given in the previous kit will contain this integrated in quick battle mode - the additional health given by the combat modifiers will scatter people around hilariously.
 
You are in rampage, friend. Another good work, though less amusing than your previous work, I must admit. :smile:
 
Thank you  :smile:

If you want some script ideas, i have it Somebody, and i need help  :mrgreen:

Just in case :

-realistic tournaments like a simulation
-gestion town (like in stronghold the game, the settlers...) i have the mechanic and plans.
-hunting camps with animals 

And more...

Or i wait for the next script  :mrgreen:

Thanks!
 
Very nice. I've thought about making horses kick (with something like an instakill for someone very close behind the horse), but this is a great idea to make use of the already-existing CTRL+J horse rear combo. Good work, Somebody.

cwr said:
Yes! Someone (Somebody?) please make a hunting OSP. :smile:
But it exists: http://forums.taleworlds.com/index.php?topic=39335.0 :grin:
 
Sabaku no Gaara said:
thanks for it, but we can trample when horse is running, right ?
Ctrl+J is the native functionality for rearing, trampling while running is the native behaviour of just bumping into them
DerHerbst said:
This sounds amazing!  Is there a preview (video or photo) of the trampling in action?  Thanks!
No video as it uses Native animations, but here's a screenshot I guess
8WaDL.jpg
 
Back
Top Bottom