Forum

Reflecting Shield

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Reflecting Shield

Postby Madfox » Wed Mar 10, 2010 10:33 pm

Well, I have a model with 12 frames, in which there are four to block the player's attack.
I really have no idea where to start. So I took the part of a single spike to reflect, in the spike_touch function.
Later I can see for other weapons, if I understand how it works.

I divide the shielding in two parts, because I think blocking is another thing than reflecting.
As I said earlier, I'm a carrot when it comes to coding.
So to start I searched in Weapons.qc line 694 :

Code: Select all
.float hit_z;
void() spike_touch =
{
local float rand;
   if (other == self.owner)
      return;

   if (other.solid == SOLID_TRIGGER)
      return;   // trigger field, do nothing

   if (pointcontents(self.origin) == CONTENT_SKY)
   {
      remove(self);
      return;
        }   

// hit something that bleeds
   if (other.takedamage)
   {
      spawn_touchblood (9);
      T_Damage (other, self, self.owner, 9);
        }
        if(other.classname == "monster_ogre_melee")
        {
//      all of our new reflection code goes here
        local vector I,N;
        I = self.velocity;
        N = normalize(self.origin - other.origin);
        self.velocity = 2*(N*I)*N - I;

        self.owner = other;
        self.touch = spike_touch_reflected;

        return;
//      all of our new reflection code end here

   }
   else
   {
      WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
      
      if (self.classname == "wizspike")
         WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
      else if (self.classname == "knightspike")
         WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
      else
         WriteByte (MSG_BROADCAST, TE_SPIKE);
      WriteCoord (MSG_BROADCAST, self.origin_x);
      WriteCoord (MSG_BROADCAST, self.origin_y);
      WriteCoord (MSG_BROADCAST, self.origin_z);
   }

   remove(self);

};




After I made a new statement for "spike_touch_reflected" the code will compile, but I'm halfway.
User avatar
Madfox
 
Posts: 106
Joined: Sat Jan 15, 2005 3:13 pm
Location: Holland

Postby Madfox » Tue Mar 30, 2010 3:48 am

Can some one at least give me a simple blocking code advice?
User avatar
Madfox
 
Posts: 106
Joined: Sat Jan 15, 2005 3:13 pm
Location: Holland

Postby r00k » Tue Mar 30, 2010 7:26 am

You could have a global variable such as .float blocking so on certain frames it's set 1, then in combat.qc just make entities (target) not take damage if self.blocking == 1.

Code: Select all
void () player_block1 = [ 8, player_block2 ]
{
   self.blocking = 1;
     if (!(self.health))
          self.blocking = 0;
};

void () player_block2 = [ 9, player_block1 ]
{
     if (!(self.health))
          self.blocking = 0;
};



Code: Select all

void (entity targ, entity inflictor, entity attacker, float damage) T_Damage =
{
   local   vector   dir;

   if (!targ.takedamage)
   {
      return;
   }

   if (targ.blocking)
   {
      return;
   }

r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest