Damage depending on distance

Posted By: 3run

Damage depending on distance - 04/04/11 13:58

I tried to use "vec_dist" to make different damage from explosion.
Problem is that it works visa versa, I need to invert distance from "vec_dist"?
How to do that? Or may be there is another way which I don't see?
Posted By: alibaba

Re: Damage depending on distance - 04/04/11 14:13

Just make something like this:
if(vec_dist(my.x,you.x)>100&&vec_dist(my.x,you.x)<200)
{
blabla
}
Posted By: wdlmaster

Re: Damage depending on distance - 04/04/11 15:05

Code:
d = vec_dist (my.x,you.x);
my.health -= (1000 - d) * some_factor_to_control_the_strength * (d < 1000);


1000 is the maximum damage radius
Posted By: 3run

Re: Damage depending on distance - 04/04/11 16:58

Alibaba, thank you, but you didn't get me right laugh
I don't need to detect distance, I need to use it to decrease health.
wdlmaster, thank you, I'll give it a try, only one question:
* what number must be used for "some_factor_to_control_the_strength"?
Maximum damage radius for me is 500.
Posted By: xxxxxxx

Re: Damage depending on distance - 04/04/11 17:26

Code:
d = vec_dist (my.x,you.x);
my.health -= (500 - clamp(d,0,500))/500 * some_factor_to_control_the_strength;


"some_factor_to_control_the_strength" is the damage, which you get in the center of the explosion with my code!
xxxxxxx
Posted By: 3run

Re: Damage depending on distance - 04/04/11 19:08

OK, now it's clear for me, thank you.
© 2024 lite-C Forums