]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Remove .checkattack
authorMario <mario.mario@y7mail.com>
Sat, 27 Apr 2013 20:50:37 +0000 (06:50 +1000)
committerMario <mario.mario@y7mail.com>
Sat, 27 Apr 2013 20:50:37 +0000 (06:50 +1000)
qcsrc/server/monsters/lib/defs.qh
qcsrc/server/monsters/lib/monsters.qc
qcsrc/server/monsters/monster/shalrath.qc

index 4169c0d911824bcda2b0ecf2a6938d91122a9a80..fd448f1f8d2156e3bf582eec38806e2ade8fc1ea 100644 (file)
@@ -1,11 +1,11 @@
-.float()       checkattack;
-
 .float(float attack_type) monster_attackfunc;
 const float MONSTER_ATTACK_MELEE       = 1;
 const float MONSTER_ATTACK_RANGED      = 2;
 
 .float candrop;
 
+.float attack_range;
+
 .float spawn_time; // stop monster from moving around right after spawning
 
 .string oldtarget2;
index ad292447805fcc61d7e28eb8c09d6d52744f383a..8dd36f0aaf8138c122663c3308cbde7f33d7bc01 100644 (file)
@@ -348,51 +348,45 @@ float monster_leap (float anm, void() touchfunc, vector vel, float anim_finished
        return TRUE;
 }
 
-float GenericCheckAttack ()
+void monster_checkattack(entity e, entity targ)
 {
-       // checking attack while dead?
-       if (self.health <= 0)
-               return FALSE;
-               
-       // reset delays when we have no enemy
-       if not(self.enemy)
+       if(e == world)
+               return;
+       if(targ == world)
        {
-               self.monster_delayedattack = func_null;
-               self.delay = -1;
+               e.monster_delayedattack = func_null;
+               e.delay = -1;
+               return;
        }
                
-       if(self.monster_delayedattack && self.delay != -1)
+       if not(e.monster_attackfunc)
+               return;
+               
+       if(e.monster_delayedattack && e.delay != -1)
        {
-               if(time < self.delay)
-                       return FALSE;
+               if(time < e.delay)
+                       return;
                        
-               self.monster_delayedattack();
+               e.monster_delayedattack();
+               
+               return;
        }
        
-       if (time < self.attack_finished_single)
-               return FALSE;
-               
-       if not(self.monster_attackfunc)
-               return FALSE; // doesn't have an attack function?!
+       if(time < e.attack_finished_single)
+               return;
                
-       if(vlen(self.enemy.origin - self.origin) <= 100)
+       if(vlen(targ.origin - e.origin) <= e.attack_range)
+       if(e.monster_attackfunc(MONSTER_ATTACK_MELEE))
        {
-               monster_sound(self.msound_attack_melee, 0, FALSE); // no delay for attack sounds
-               if(self.monster_attackfunc(MONSTER_ATTACK_MELEE))
-                       return TRUE;
+               monster_sound(e.msound_attack_melee, 0, FALSE);
+               return;
        }
-
-       // see if any entities are in the way of the shot
-       if not(findtrajectorywithleading(self.origin, '0 0 0', '0 0 0', self.enemy, 800, 0, 2.5, 0, self))
-               return FALSE;
-
-       if(self.monster_attackfunc(MONSTER_ATTACK_RANGED))
+       
+       if(e.monster_attackfunc(MONSTER_ATTACK_RANGED))
        {
-               monster_sound(self.msound_attack_ranged, 0, FALSE); // no delay for attack sounds
-               return TRUE;
+               monster_sound(e.msound_attack_ranged, 0, FALSE);
+               return;
        }
-
-       return FALSE;
 }
 
 void monster_makevectors(entity e)
@@ -660,9 +654,9 @@ void monster_move(float runspeed, float walkspeed, float stopspeed, float manim_
                        }
                }
        }
-               
-       if(self.enemy && self.checkattack)
-               self.checkattack();
+       
+       if(self.enemy)
+               monster_checkattack(self, self.enemy);
                
        self.SendFlags |= MSF_ANG;
        self.SendFlags |= MSF_MOVE;
@@ -1001,7 +995,6 @@ float monster_initialize(string  net_name, float mon_id,
        self.touch                              = MonsterTouch;
        self.use                                = monster_use;
        self.solid                              = SOLID_BBOX;
-       self.checkattack                = GenericCheckAttack;
        self.scale                              = 1;
        self.movetype                   = MOVETYPE_WALK;
        self.delay                              = -1; // used in attack delay code
@@ -1019,6 +1012,9 @@ float monster_initialize(string  net_name, float mon_id,
        self.spawn_time                 = time;
        self.dphitcontentsmask  = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP;
        
+       if not(self.attack_range)
+               self.attack_range = 120;
+       
        if not(self.ticrate)
                self.ticrate = autocvar_g_monsters_think_delay;
                
index fbbccc9d156051244e47cbb26c22e59265a5520c..1ec6cec90042c5fc2c438b3156c0d608134c090f 100644 (file)
@@ -220,63 +220,6 @@ void ShalMissile()
        CSQCProjectile(missile, TRUE, PROJECTILE_VORE_SPIKE, TRUE);
 }
 
-float ShalrathCheckAttack()
-{
-       vector spot1 = '0 0 0', spot2 = '0 0 0';
-
-       if (self.health <= 0)
-               return FALSE;
-               
-       // reset delays when we have no enemy
-       if not(self.enemy)
-       {
-               self.monster_delayedattack = func_null;
-               self.delay = -1;
-       }
-       
-       if(self.monster_delayedattack && self.delay != -1)
-       {
-               if(time < self.delay)
-                       return FALSE;
-                       
-               self.monster_delayedattack();
-               self.delay = -1;
-               self.monster_delayedattack = func_null;
-       }
-       
-       if(time < self.attack_finished_single)
-               return FALSE;
-               
-       if not(self.monster_attackfunc)
-               return FALSE; // no attack function?!
-       
-       if (vlen(self.enemy.origin - self.origin) <= 120)
-       {
-               if(self.monster_attackfunc(MONSTER_ATTACK_MELEE))
-               {
-                       monster_sound(self.msound_attack_melee, 0, FALSE); // no delay for attack sounds
-                       return TRUE;
-               }
-       }
-
-// see if any entities are in the way of the shot
-       spot1 = self.origin + self.view_ofs;
-       spot2 = self.enemy.origin + self.enemy.view_ofs;
-
-       traceline (spot1, spot2, FALSE, self);
-
-       if (trace_ent != self.enemy && trace_fraction < 1)
-               return FALSE; // don't have a clear shot
-
-       //if (trace_inopen && trace_inwater)
-       //      return FALSE; // sight line crossed contents
-
-       if (self.monster_attackfunc(MONSTER_ATTACK_RANGED))
-               return TRUE;
-
-       return FALSE;
-}
-
 void shalrath_heal()
 {
        entity head;
@@ -410,7 +353,6 @@ void shalrath_spawn()
 
        self.damageforcescale   = 0.003;
        self.classname                  = "monster_shalrath";
-       self.checkattack                = ShalrathCheckAttack;
        self.monster_attackfunc = mage_attack;
        self.nextthink                  = time + random() * 0.5 + 0.1;
        self.think                              = shalrath_think;