OSP Code Combat Area damage script improvement.

Users who are viewing this thread

killkhergit

Squire
This code gives weapons area damage:

Code:
[(ti_on_weapon_attack, 
   [(get_player_agent_no, ":player_agent"),
    (agent_get_team,":player_team", ":player_agent"),
    (agent_get_position,pos1,":player_agent"),
    (try_for_agents,":agent"),
      (agent_is_alive,":agent"),
      #(agent_is_human,":agent"), 
      (neq,":agent",":player_agent"),
      (agent_get_team,":team",":agent"),
      (neq,":team",":player_team"),
      (agent_get_position,pos2,":agent"),
      (get_distance_between_positions,":dist",pos1,pos2),
      (lt,":dist",1500),
      (particle_system_burst,"psys_game_blood_1",pos2,100),
      (particle_system_burst,"psys_boemfik",pos2,100),
      (agent_play_sound,":agent","snd_man_die"),
      (agent_play_sound,":agent","snd_boem"),
      (store_agent_hit_points, ":cur_hit_points",":agent",1),
      (val_sub,":cur_hit_points",25),
      (agent_set_hit_points,":agent",":cur_hit_points",1),
      (agent_deliver_damage_to_agent,":player_agent",":agent"),
    (try_end),
   ])]],

But, there's two problems:
- It won't damage your team, but it will damage other friendlies, how can I fix that?
- If used on throwable weapons, it will only measure the distance from the player to the enemy. So: how can I get the position where the weapon hits the ground / follow the flying object?



No, this script isn't copyrighted, copylefted, or copymiddled. If you want to use it in mods (non-private), ask me via PM.
 
killkhergit said:
- It won't damage your team, but it will damage other friendlies, how can I fix that?

instead of checking if teams are same as player or not, check (neg|agent_is_ally,...)
 
Chel said:
killkhergit said:
- It won't damage your team, but it will damage other friendlies, how can I fix that?
instead of checking if teams are same as player or not, check (neg|agent_is_ally,...)

So, I don't have to define my own team anymore and only have to use that bit of code to filter allies out? Thanks.

fedeita said:
maybe it could be used for 2h swords?

I don't know why it shouldn't work, so yes.
 
Cool I'm just wondering does this code check if the agent is in front of you so that say you don't kill everyone in a circle around and behind you you when you only swing forward? Thanks for posting this.
 
Berserker Pride said:
Cool I'm just wondering does this code check if the agent is in front of you so that say you don't kill everyone in a circle around and behind you you when you only swing forward? Thanks for posting this.

It damages the agents around you. But I'd like to know how I can check if agents are in front of the player.  :!:
 
I may have found something useful in header_operations. position_is_behind_position    = 713 # (position_is_behind_position,<position_no_1>,<position_no_2>), maybe it could check if the ai is behind the player.  Seems like it "should" work anyway.
So for example. (neg|position_is_behind_position,pos2,pos1),
:EDIT how much distance is 1500 anyway is that the same as reach 150?
 
If this works with swords & takes in consideration the side of attack then it would be the best add for the gameplay because it's really annoying when you slice two guys in front of you & if one of them is hit then the blade just go through the second without doing any damage.
so good luck.
 
Sibylla said:
If this works with swords & takes in consideration the side of attack then it would be the best add for the gameplay because it's really annoying when you slice two guys in front of you & if one of them is hit then the blade just go through the second without doing any damage.
so good luck.

It does suck, but how often, when trying to cut through a guy wearing armor, that you cut clean through him and hit the guy next to him?  I guess it's just a game, but I guess it might be cool.  One thing you have to look at is can you check the length of the weapon?  also you would need to do some math on only hitting the 90 degrees infront of the player.  And should only be with side swings.
 
HokieBT said:
Fyi - i dont think that trigger works with melee weapons...

The it_on_weapon_attack?  I guess you would have tried it with some light sabre stuff.  I had a few neat ideas if it did work (like having the blade off until you strike/block, then having it stay on for a bit, then going off.)
 
yeah, I tried to use it add the lightsaber noise to some weapons and it wouldn't trigger at all.    Jinnai had to help me with this issue by writing a trigger that checks if the attack key was clicked and you have a certain weapon equipped then it plays a certain noise and there is another trigger that loops through all agents on the battlefield and checks their weapons and if their are currently attacking.....  definitely not ideal but the best we could manage.
 
Just tested if it works on melee weapons: nope, confirmed. Bummer.

Here's a better version that includes Chel's suggestion:
Code:
[(ti_on_weapon_attack, 
   [(get_player_agent_no, ":player_agent"),
    (agent_get_position,pos1,":player_agent"),
    (try_for_agents,":agent"),
      (agent_is_alive,":agent"),
      #(agent_is_human,":agent"), 
      (neq,":agent",":player_agent"),
      (neg|agent_is_ally,":agent"),     
      (agent_get_position,pos2,":agent"),
      (get_distance_between_positions,":dist",pos1,pos2),
      (lt,":dist",1500),
      (particle_system_burst,"psys_game_blood_1",pos2,100),
      (particle_system_burst,"psys_boemfik",pos2,100),
      (agent_play_sound,":agent","snd_man_die"),
      (agent_play_sound,":agent","snd_boom"),
      (store_agent_hit_points, ":cur_hit_points",":agent",1),
      (val_sub,":cur_hit_points",25),
      (agent_set_hit_points,":agent",":cur_hit_points",1),
      (agent_deliver_damage_to_agent,":player_agent",":agent"),
    (try_end),
])]],

Berserker Pride said:
Hey HokieBT when you write key_clicked how do you write attack key clicked is it R_mouse or something?

It's "key_left_mouse_button".

Some questions remain:
- How can the code be used on melee weapons?
- If used on throwable weapons, it will only measure the distance from the player to the enemy. So: how can I get the position where the weapon hits the ground / follow the flying object?
 
I've got an answer to let the code work for melee weapons and it will only hit guys in front of you check it.
Code:
dragonslayer_trigger = (0, 0, 15, [
    (key_clicked, key_j),
    (neg|main_hero_fallen,0),
    (get_player_agent_no, ":player_agent"),
    (agent_get_wielded_item,":wielded_item",":player_agent",0),
    (eq,":wielded_item","itm_dragonslayer"),

                                  ],
    #(get_player_agent_no, ":player_agent"),
    [#(agent_get_team,":player_team", ":player_agent"),
    (get_player_agent_no, ":player_agent"),    
    (agent_get_position,pos1,":player_agent"),
    (try_for_agents,":agent"),
      (agent_is_alive,":agent"),
      #(agent_is_human,":agent"), 
      (neq,":agent",":player_agent"),
      (neg|agent_is_ally,":agent"),
      (agent_get_position,pos2,":agent"),
      (neg|position_is_behind_position,pos2,pos1),
      (get_distance_between_positions,":dist",pos1,pos2),
      (lt,":dist",300),
      (particle_system_burst,"psys_game_blood",pos2,100),
      #(particle_system_burst,"psys_boemfik",pos2,100),
      (agent_play_sound,":agent","snd_man_die"),
      (agent_play_sound,":agent","snd_metal_hit_high_armor_high_damage"),
      (store_agent_hit_points, ":cur_hit_points",":agent",1),
      (val_sub,":cur_hit_points",25),
      (agent_set_hit_points,":agent",":cur_hit_points",1),
      (agent_deliver_damage_to_agent,":player_agent",":agent"),
      (agent_set_animation,":player_agent","anim_release_slashright_twohanded"),
    (try_end),
    ])
The guts of this is basically still your code the only difference is I gave it an animation and I made it a mission template trigger. This part here makes sure that the weapon is in your hand
(agent_get_wielded_item,":wielded_item",":player_agent",0),
    (eq,":wielded_item","itm_dragonslayer"),
Now all you have to do is add the trigger name ex dragonslayer_trigger, to all the mission templates that involve combat.  Right now its looks pretty plain but the code works.  I want to add a cool particle effect so you really know when you knock guys down.  Its no worse than the area effect damage on games like bladestorm.  All you do is change the range of the effect to the range of your weapon. I've got it set up so that you can only use it every 15 seconds.  Otherwise you would just spam it.
EDIT I had the below wrong.
I tried using agent_get_look_position,":player_agent", but that only make the look position under my feet. And hence any bomb would explode out from my character not where I was looking.  Maybe Mouse_get_position will work better.  I wonder how they made the hand cannons in TEATRC work.  Something has to check where the hand_cannoneers are looking when they fire and it can't be mouse_get_position.
 
very nice, Berserker!
So
(neg|position_is_behind_position,pos2,pos1),
checks the facing of the player as well? It will then only affect those in 180 degree arc infront of the player?
you could also add an animation to the agents being hit with the attack.



 
Yea I tested it and if a guy gets behind you the attack won't hit him.  To really look good I need an awesome sword arc particle effect or something.  Right now I have one that makes big glowy sparks fly away from the player but it looks kinda iffy.
 
Back
Top Bottom