OSP Code Combat [WB] Taunting

Users who are viewing this thread

Pumpkin Lord

The following script introduces a good ol' combat mechanic, allowing to lure soldiers to yourself in a certain distance depending on your ironflesh skill.

In most of the RPG and action games, it is a common fact that there is needed a "tank" to take the aggro while others playing their own roles in the party. Well, it is one of those perks a tank needs most.

Basically, it works like...you cast the spell (Has a cooldown of 3 minutes.), runs a poor "skl_ironflesh" comparison to enhance the taunting range before actually firing and depends on the ironflesh skill you have, so will the range be wider and more mobs to lure at yourself.

mission_template code

Code:
#Taunting system
common_taunting_system = (
  0, 0, 180, [(key_clicked, key_o),],
  [
       (get_player_agent_no, ":cool_man"),
       (agent_get_troop_id, ":cool_trp", ":cool_man"),
       (store_skill_level, ":i_skl_level", "skl_ironflesh", ":cool_trp"),         
       (agent_get_position, pos1, ":cool_man"),
        (assign, ":t_value", 100),
         (try_begin),
          (eq, ":i_skl_level", 1),
          (assign, ":t_value", 150),
           (else_try),
          (eq, ":i_skl_level", 2),
          (assign, ":t_value", 200),
           (else_try),
          (eq, ":i_skl_level", 3),
          (assign, ":t_value", 250),
           (else_try),
          (eq, ":i_skl_level", 4),
          (assign, ":t_value", 300),
           (else_try),
          (eq, ":i_skl_level", 5),
          (assign, ":t_value", 350),
           (else_try),
          (eq, ":i_skl_level", 6),
          (assign, ":t_value", 400),
           (else_try),
          (eq, ":i_skl_level", 7),
          (assign, ":t_value", 450),
           (else_try),
          (eq, ":i_skl_level", 8),
          (assign, ":t_value", 500),
           (else_try),
          (eq, ":i_skl_level", 9),
          (assign, ":t_value", 550),
           (else_try),
          (eq, ":i_skl_level", 10),
          (assign, ":t_value", 600),
         (try_end),
        #(val_add, ":t_value", 3000), #DEBUG
        (assign, reg0, ":t_value"),
        (try_for_agents, ":taunted"),
         (agent_get_position, pos2, ":taunted"),
         (get_distance_between_positions, ":t_distance", pos1, pos2),
         (le,":t_distance", ":t_value"),
         (agent_is_alive, ":taunted"),
         (neg|agent_is_ally, ":taunted"),
          (agent_force_rethink, ":taunted"),
          (agent_clear_relations_with_agents, ":taunted"),
          (agent_set_is_alarmed, ":taunted", 0),
          (agent_set_look_target_agent, ":taunted", ":cool_man"),
         (try_begin),
           (agent_is_alive, ":cool_man"),
           (agent_add_relation_with_agent, ":taunted", ":cool_man", -1),
           (agent_set_is_alarmed, ":taunted", 1),
           (agent_set_scripted_destination, ":taunted", pos1),
        (try_end),
      (try_end),
      #(agent_get_number_of_enemies_following, ":t_taunted", ":cool_man"),
      #(assign, reg1, ":t_taunted"),
      (display_message, "@ Taunt launched. {reg0} is the taunt range."),

    ])

There is one known issue with placement of lured troops really. I will fix that when I have the time. While at it, I will soon put up a gameplay video.

Enjoy. :smile:
 
Do a (val_mul, ":i_skl_level", 50), (store_add, ":t_value", 100, ":i_skl_level"), instead of the loop. You'll also want to take into account agents with ranged weapons that should try shooting instead of walking.
 
Somebody said:
Do a (val_mul, ":i_skl_level", 50), (store_add, ":t_value", 100, ":i_skl_level"), instead of the loop. You'll also want to take into account agents with ranged weapons that should try shooting instead of walking.

I prefer to keep my code as plain and lame as it can be in fact. (Since the loop is less confusing and ugly at same time.) On the matter of ranged weapons, turning them around in first place does the trick if their weapon is loaded at that time, then they react to trigger properly. Which is how I want. (Sometimes they just come off without shooting but...well this unpredictability spices up the realism of combat.)
 
Adjust the end of the code like this:
        (try_begin),
          (agent_is_alive, ":cool_man"),
          (agent_add_relation_with_agent, ":taunted", ":cool_man", -1),
          (agent_set_is_alarmed, ":taunted", 1),
          (agent_set_scripted_destination, ":taunted", pos1),
        (try_end),
      (try_end),
      #(agent_get_number_of_enemies_following, ":t_taunted", ":cool_man"),
      #(assign, reg1, ":t_taunted"),
    (play_sound, "snd_cow_moo"),

    ])

The mooing will surely taunt any enemy of yours :grin:
 
Pretty good, definitely use it. Thanks Efe for your effort and sharing!
 
Code:
      (2, 0, 0, [(call_script, "script_center_ambiance_sounds")], []),
        
      
    ],
  ),
#-## Outposts end

[b]#Taunting system
common_taunting_system = (
  0, 0, 180, [(key_clicked, key_o),],
  [
       (get_player_agent_no, ":cool_man"),
       (agent_get_troop_id, ":cool_trp", ":cool_man"),
       (store_skill_level, ":i_skl_level", "skl_ironflesh", ":cool_trp"),         
       (agent_get_position, pos1, ":cool_man"),
        (assign, ":t_value", 100),
         (try_begin),
          (eq, ":i_skl_level", 1),
          (assign, ":t_value", 150),
           (else_try),
          (eq, ":i_skl_level", 2),
          (assign, ":t_value", 200),
           (else_try),
          (eq, ":i_skl_level", 3),
          (assign, ":t_value", 250),
           (else_try),
          (eq, ":i_skl_level", 4),
          (assign, ":t_value", 300),
           (else_try),
          (eq, ":i_skl_level", 5),
          (assign, ":t_value", 350),
           (else_try),
          (eq, ":i_skl_level", 6),
          (assign, ":t_value", 400),
           (else_try),
          (eq, ":i_skl_level", 7),
          (assign, ":t_value", 450),
           (else_try),
          (eq, ":i_skl_level", 8),
          (assign, ":t_value", 500),
           (else_try),
          (eq, ":i_skl_level", 9),
          (assign, ":t_value", 550),
           (else_try),
          (eq, ":i_skl_level", 10),
          (assign, ":t_value", 600),
         (try_end),
        #(val_add, ":t_value", 3000), #DEBUG
        (assign, reg0, ":t_value"),
        (try_for_agents, ":taunted"),
         (agent_get_position, pos2, ":taunted"),
         (get_distance_between_positions, ":t_distance", pos1, pos2),
         (le,":t_distance", ":t_value"),
         (agent_is_alive, ":taunted"),
         (neg|agent_is_ally, ":taunted"),
          (agent_force_rethink, ":taunted"),
          (agent_clear_relations_with_agents, ":taunted"),
          (agent_set_is_alarmed, ":taunted", 0),
          (agent_set_look_target_agent, ":taunted", ":cool_man"),
    (try_begin),
           (agent_is_alive, ":cool_man"),
           (agent_add_relation_with_agent, ":taunted", ":cool_man", -1),
           (agent_set_is_alarmed, ":taunted", 1),
           (agent_set_scripted_destination, ":taunted", pos1),
        (try_end),
      (try_end),
      #(agent_get_number_of_enemies_following, ":t_taunted", ":cool_man"),
      #(assign, reg1, ":t_taunted"),
      (play_sound, "snd_cow_moo"),

    ])

]
[/b]
## thanks for your help dude

builder of the gods said:
That = is the problem of the syntax error (batch) i think it is something else
ps i put it at the back
THE problem is common taunting system = (syntax directs to =)
 
You have an extra bracket ] at the end of what you posted. Do not put it at the back or inside a mission template, this is a trigger which we define for the compiler as common_taunting_system. You then add this trigger to mission templates by listing common_taunting_system, in the list of triggers.
 
Back
Top Bottom