Forum

T_BeamDamage, Front sided radius damage

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

T_BeamDamage, Front sided radius damage

Postby jim » Sat Jun 07, 2008 1:38 am

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: Select all
//==============================================================================
//  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!
User avatar
jim
 
Posts: 599
Joined: Fri Aug 05, 2005 2:35 pm
Location: In The Sun

Postby r00k » Mon Jun 09, 2008 3:28 pm

cant you just set "ignore" as attacker?

or if you can't then if (head.takedamage && head != attacker) ...
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: Bing [Bot] and 1 guest