Inside3D!
     

T_BeamDamage, Front sided radius damage

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
jim



Joined: 05 Aug 2005
Posts: 400
Location: In The Sun

PostPosted: Sat Jun 07, 2008 1:38 am    Post subject: T_BeamDamage, Front sided radius damage Reply with quote

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!
Back to top
View user's profile Send private message Visit poster's website
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Mon Jun 09, 2008 3:28 pm    Post subject: Reply with quote

cant you just set "ignore" as attacker?

or if you can't then if (head.takedamage && head != attacker) ...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group