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)
}
}
}
-
- if(self.enemy && self.checkattack)
- self.checkattack();
+
+ if(self.enemy)
+ monster_checkattack(self, self.enemy);
self.SendFlags |= MSF_ANG;
self.SendFlags |= MSF_MOVE;
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
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;
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;
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;