AoE/Splash damage

正在查看此主题的用户

ragnarokk1966

Sergeant
Hello,

Let me start with, I am totally new to modding. I have been reading the wonderful guides out there and kinda plugging along and learning.  My question is,  Is there any way to add a weapon that does splash/aoe damage?  Kinda like a grenade. I figured out how to add items and get them into the game, but I don't know if its possible to add a ranged weapon that does aoe damage.  Any ideas or even some sample code to work with would be greatly appreciated.

Thanks
 
Yeah, it is. Quite simple, too, actually. The easiest way that I can think off my head, is something like this.

插入代码块:
#Using ti_on_weapon_attack you can implement this script.
   (try_for_agents, ":agent"),
      (get_player_agent_no, ":player_agent"),
      (agent_get_look_position, pos1, ":player_agent"),
      (agent_get_position, pos2, ":agent"),
      (get_distance_between_positions, ":distance", pos1, pos2),
      (lt, ":distance", 200), #200 cm.
      (agent_deliver_damage_to_agent, ":player_agent", ":agent"), #Insta-kill.
   (try_end),

Hope this gave you a sample enough. I based this off my head so there probably are errors. But keep rockin'.
 
Thats a conversation of mostly veteran modder I saved to my libary. The title says it all:

http://forums.taleworlds.com/index.php/topic,62649.msg1625236.html#msg1625236


you may download miratheis :"curtain of fire" mod with source code also to try arround with that stuff!

The script from "Berserker Pride" does it for weapons who can be used in melee to!!
 
Thank you guys for the quick response.  I followed the link that Meneldur posted.  Lots of great stuff there.  I'm dinking around with this snipet of code and have a few questions for you.  This was provided by killkhergit in the above mentioned thread.

[(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),
])]],

is the (lt,":dist",1500),
the area affected? And the (val_sub,":cur_hit_points",25),  what exactly is the 25?
 
(val_sub, destination, value), val stands for value, sub stands for subtract, destination stands for the variable you want to subtract it from, value stands for the amount. So, in simple terms, it would look like this.

(value subtract from this destination this amount/value).
 
Ok great, thanks again guys.  Only one more question for now    :eek:.  The line

(lt,":dist",1500),

what is the 1500?  Is that the area affected?



 
That's the "distance" between position 1 and position 2 in centimetres.
 
Should the ti_on_attack script be attached to the weapon (ie. crossbow) or to the missile?  Neither seems to be working for me, for some reason, and I would love to see this in action.  What I really need it to work with is throwing weapons, but I realise that hasn't been perfected yet.

Sadly, I can't contribute anything useful - this, and the other threads, are all a bit above my head.
 
Hello,

It seems to me that it does not matter what I put in for (val_sub,":cur_hit_points",30), 

Its always an insta kill for anyone in the aoe area.  Here is my 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",500),
      (particle_system_burst,"psys_blood_hit_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",30),   
      (agent_set_hit_points,":agent",":cur_hit_points",1),
      (agent_deliver_damage_to_agent,":player_agent",":agent"),
    (try_end),


If I am understanding how the code works, it should subtract 30 from anyone within the 500 dist.  It does not do that,  it kills everyone in the 500 dist area.  What am I missing?  And thanks in advance for your help.
 
For some reason the agent_deliver_damage_to_agent seems to instakill for me as well.
So I add a line that ensures that the enemy at is at 0 hp before calling it.  Put this in below the agent_set_hitpoints line.
      (try_begin),
        (lt,":cur_hit_points",1),
        (agent_deliver_damage_to_agent,":player_agent",":agent"),
      (try_end),

EDIT: Oops put this line below the val_sub one or the game will crash after a battle
(val_max,":cur_hit_points",0),
Health is not allowed to dip below 0.
 
It might have something to do with this;

  (agent_set_hit_points,":agent",":cur_hit_points",1),

that may be setting the agent's hit points to 1, as opposed to setting the HP to the value stored in '1'. I suggest changing the;

(store_agent_hit_points, ":cur_hit_points",":agent",1),
      (val_sub,":cur_hit_points",30),   
      (agent_set_hit_points,":agent",":cur_hit_points",1),

to

(store_agent_hit_points, ":cur_hit_points",":agent",":agent_hp"),
      (val_sub,":cur_hit_points",30),   
      (agent_set_hit_points,":agent",":cur_hit_points",":agent_hp"),


and see if that works.
 
The 1 just tells the game to use absolute health points instead of percentages.  The fix I posted works I use it in my mod a lot.
 
I want to say thank you to everyone who has provided information to me about adding the aoe/splash damage to this game.  After much reading, and rereading and writing and re writing, this is what I have come up with.  It seems to work and it does not insta kill the target.  It damages all bad guys within the (lt,":dist",1500), range.  Once the bad guy is hit, it plays this effect on all the bad guys who were damaged  (particle_system_burst,"psys_game_hoof_dust",pos2,15), ( i don't know what the ,15 is, but it works ) and it doesn't hurt me or my allies.

Once again thank you.  Now all I have to do is figure out how to make an electrical discharge effect and a whirlwind effect.  Got any ideas?    :smile:



[(ti_on_weapon_attack,
  [(get_player_agent_no, ":player_no"),
    (try_for_agents,":agent"),
      (agent_get_position,pos1,":player_no"),
      (neq,":agent",":player_no"),
      (neg|agent_is_ally,":agent"),
  (agent_is_alive,":agent"),
  (agent_is_human,":agent"),
      (agent_get_position,pos2,":agent"),
      (get_distance_between_positions,":dist",pos1,pos2),
      (lt,":dist",1500),
      (particle_system_burst,"psys_game_hoof_dust",pos2,15),
      (agent_deliver_damage_to_agent,":player_no",":agent"),
    (try_end),
  ],)],],
 
后退
顶部 底部