jim

Joined: 05 Aug 2005 Posts: 400 Location: In The Sun
|
Posted: Sat Jun 07, 2008 1:38 am Post subject: T_BeamDamage, Front sided radius damage |
|
|
There was this T_BeamDamage that was quite unused. I thought I'll make it some "front sided radius damage". It appeared to work allright, until I decided to shoot the beam up, then it damaged myself too.
I took the check if head is in front of the beam, from infront function... isn't good enough check for this then...
Code: | //==============================================================================
// T_BeamDamage
// beam based damage, target needs to be infront of the beam
// currently used by energy gun wave projectile
//==============================================================================
void(entity inflictor, entity attacker, float damage, float radius, float type, entity ignore) T_BeamDamage =
{
local float points, dot;
local vector vec;
local entity head;
head = findradius(inflictor.origin, radius);
while(head)
{
if(head != ignore)
{
if(head.takedamage)
{
vec = normalize(head.origin - inflictor.origin);
makevectors(inflictor.angles);
dot = vec * v_forward;
// infront of the inflictor
if(dot > 0.3)
{
points = 0.5 * vlen(inflictor.origin - head.origin);
if(points < 0)
points = 0;
points = damage - points;
if(points > 0)
{
if(CanDamage(head, inflictor))
{
// takes less damage
if(head.flags & FL_NOBIGDAMAGE)
T_Damage(head, inflictor, attacker, points * 0.5, type);
else
T_Damage(head, inflictor, attacker, points, type);
}
}
}
}
}
head = head.chain;
}
}; |
Any ideas how to improve it? Quick solution would be to set player ignore the beam, but that's not good for future solutions...
I've found some little improvement (maybe) from dpextensions.qc..
If I replace makevectors(inflictor.angles); with vectorvectors(inflictor.angles); I can aim up without getting killed, but when I aim between my legs (I've increased the aim up and down limits a bit), I get damaged. It may be good for something, but it's not wanted behaviour. _________________ zbang! |
|