.void() monster_spawnfunc;
.void() monster_die;
-.void() monster_delayedattack;
.float monster_movestate; // used to tell what the monster is currently doing
const float MONSTER_MOVE_OWNER = 1; // monster will move to owner if in range, or stand still
if(e == world)
return;
if(targ == world)
- {
- e.monster_delayedattack = func_null;
- e.delay = -1;
return;
- }
if not(e.monster_attackfunc)
return;
-
- if(e.monster_delayedattack && e.delay != -1)
- {
- if(time < e.delay)
- return;
-
- e.monster_delayedattack();
-
- return;
- }
if(time < e.attack_finished_single)
return;
self.solid = SOLID_BBOX;
self.scale = 1;
self.movetype = MOVETYPE_WALK;
- self.delay = -1; // used in attack delay code
self.spawnshieldtime = time + autocvar_g_monsters_spawnshieldtime;
monsters_spawned += 1;
self.enemy = world;
{
self.brute_cycles += 1;
self.angles_y = self.angles_y + random()* 25;
- self.delay = time + 0.2;
- self.monster_delayedattack = brute_blade;
monster_melee(self.enemy, autocvar_g_monster_brute_chainsaw_damage, 0.3, DEATH_MONSTER_BRUTE_BLADE, TRUE);
- if(self.brute_cycles >= 4)
- {
- self.monster_delayedattack = func_null;
- self.delay = -1;
- }
+ if(self.brute_cycles <= 4)
+ defer(0.2, brute_blade);
}
void brute_uzi()
{
self.brute_cycles += 1;
- if(self.brute_cycles > autocvar_g_monster_brute_attack_uzi_bullets)
- {
- self.monster_delayedattack = func_null;
- self.delay = -1;
- return;
- }
-
monster_makevectors(self.enemy);
W_SetupShot (self, autocvar_g_antilag_bullets && 18000 >= autocvar_g_antilag_bullets, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, autocvar_g_monster_brute_attack_uzi_damage);
fireBallisticBullet(w_shotorg, w_shotdir, 0.02, 18000, 5, autocvar_g_monster_brute_attack_uzi_damage, autocvar_g_monster_brute_attack_uzi_force, DEATH_MONSTER_BRUTE_UZI, 0, 1, 115);
endFireBallisticBullet();
- self.delay = time + 0.1;
- self.monster_delayedattack = brute_uzi;
+ if(self.brute_cycles <= autocvar_g_monster_brute_attack_uzi_bullets)
+ defer(0.1, brute_uzi);
}
void brute_grenade_explode()
{
monsters_setframe(brute_anim_pain);
self.attack_finished_single = time + 0.8;
- self.delay = time + 0.1;
- self.monster_delayedattack = brute_uzi;
+ defer(0.1, brute_uzi);
}
else
{
void knight_inferno()
{
- self.monster_delayedattack = func_null;
- self.delay = -1;
if not(self.enemy)
return;
monster_makevectors(self.enemy);
- self.monster_delayedattack = func_null;
- self.delay = -1;
-
self.effects |= EF_MUZZLEFLASH;
sound(self, CHAN_WEAPON, "weapons/fireball2.wav", 1, ATTN_NORM);
void knight_spikes()
{
- self.monster_delayedattack = knight_spikes;
- self.delay = time + 0.1;
self.knight_cycles += 1;
knight_spike();
- if(self.knight_cycles >= 7)
- {
- self.monster_delayedattack = func_null;
- self.delay = -1;
- }
+
+ if(self.knight_cycles <= 7)
+ defer(0.1, knight_spikes);
}
float knight_attack_ranged()
case 1:
{
monsters_setframe(knight_anim_magic2);
- self.delay = time + 0.4;
- self.monster_delayedattack = knight_fireball;
self.attack_finished_single = time + 2;
+ defer(0.4, knight_fireball);
return TRUE;
}
case 2:
{
- self.monster_delayedattack = knight_inferno;
- self.delay = time + 0.5;
self.attack_finished_single = time + 3;
+ defer(0.5, knight_inferno);
return TRUE;
}
case 3:
{
monsters_setframe(knight_anim_magic3);
- self.monster_delayedattack = knight_spikes;
- self.delay = time + 0.4;
self.attack_finished_single = time + 3;
+ defer(0.4, knight_spikes);
return TRUE;
}
void mageattack_melee()
{
monster_melee(self.enemy, autocvar_g_monster_mage_attack_melee_damage, 0.3, DEATH_MONSTER_MAGE, TRUE);
-
- self.delay = -1;
- self.monster_delayedattack = func_null;
}
void mage_grenade_explode()
{
entity missile;
vector dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
-
- self.delay = -1;
- self.monster_delayedattack = func_null;
makevectors(self.angles);
{
case MONSTER_ATTACK_MELEE:
{
- self.monster_delayedattack = mageattack_melee;
- self.delay = time + 0.2;
monsters_setframe(mage_anim_attack);
self.attack_finished_single = time + autocvar_g_monster_mage_attack_melee_delay;
+ defer(0.2, mageattack_melee);
return TRUE;
}
}
monsters_setframe(mage_anim_attack);
- self.delay = time + 0.2;
self.attack_finished_single = time + autocvar_g_monster_mage_attack_spike_delay;
- self.monster_delayedattack = mage_spike;
+ defer(0.2, mage_spike);
return TRUE;
}
void shambler_smash()
{
- self.monster_delayedattack = func_null;
- self.delay = -1;
-
monster_melee(self.enemy, autocvar_g_monster_shambler_damage, 0.3, DEATH_MONSTER_SHAMBLER_SMASH, TRUE);
}
void shambler_delayedsmash()
{
monsters_setframe(shambler_anim_smash);
- self.monster_delayedattack = shambler_smash;
- self.delay = time + 0.7;
+ defer(0.7, shambler_smash);
self.attack_finished_single = time + 1.1;
}
void shambler_swing()
{
- float r = ((random() < 0.5) ? TRUE : FALSE);
+ float r = (random() < 0.5);
monsters_setframe((r) ? shambler_anim_swingr : shambler_anim_swingl);
monster_melee(self.enemy, autocvar_g_monster_shambler_attack_claw_damage, 0.3, DEATH_MONSTER_SHAMBLER_CLAW, TRUE);
self.attack_finished_single = time + 0.8;
- self.monster_delayedattack = func_null;
- self.delay = -1;
if(r)
- {
- self.monster_delayedattack = shambler_swing;
- self.delay = time + 0.5;
- }
+ defer(0.5, shambler_swing);
}
void CastLightning()
{
- self.monster_delayedattack = func_null;
- self.delay = -1;
-
local vector org, dir;
//vector v = '0 0 0';
{
monsters_setframe(shambler_anim_magic);
self.attack_finished_single = time + 1.1;
- self.monster_delayedattack = CastLightning;
- self.delay = time + 0.6;
+ defer(0.6, CastLightning);
return TRUE;
}