#include <server/round_handler.qh>
#endif
-void monsters_setstatus()
-{SELFPARAM();
- self.stat_monsters_total = monsters_total;
- self.stat_monsters_killed = monsters_killed;
+void monsters_setstatus(entity this)
+{
+ this.stat_monsters_total = monsters_total;
+ this.stat_monsters_killed = monsters_killed;
}
-void monster_dropitem()
-{SELFPARAM();
- if(!self.candrop || !self.monster_loot)
+void monster_dropitem(entity this)
+{
+ if(!this.candrop || !this.monster_loot)
return;
- vector org = self.origin + ((self.mins + self.maxs) * 0.5);
+ vector org = this.origin + ((this.mins + this.maxs) * 0.5);
entity e = new(droppedweapon); // use weapon handling to remove it on touch
e.spawnfunc_checked = true;
- e.monster_loot = self.monster_loot;
+ e.monster_loot = this.monster_loot;
MUTATOR_CALLHOOK(MonsterDropItem, e);
e = other;
if(e && e.monster_loot)
{
- setself(e);
e.noalign = true;
- e.monster_loot(e);
+ WITHSELF(e, e.monster_loot(e));
e.gravity = 1;
e.movetype = MOVETYPE_TOSS;
e.reset = SUB_Remove;
e.velocity = randomvec() * 175 + '0 0 325';
e.item_spawnshieldtime = time + 0.7;
SUB_SetFade(e, time + autocvar_g_monsters_drop_time, 1);
- setself(this);
}
}
-void monster_makevectors(entity e)
-{SELFPARAM();
- if(IS_MONSTER(self))
+void monster_makevectors(entity this, entity targ)
+{
+ if(IS_MONSTER(this))
{
- vector v;
-
- v = e.origin + (e.mins + e.maxs) * 0.5;
- self.v_angle = vectoangles(v - (self.origin + self.view_ofs));
- self.v_angle_x = -self.v_angle_x;
+ vector v = targ.origin + (targ.mins + targ.maxs) * 0.5;
+ this.v_angle = vectoangles(v - (this.origin + this.view_ofs));
+ this.v_angle_x = -this.v_angle_x;
}
- makevectors(self.v_angle);
+ makevectors(this.v_angle);
}
// ===============
// Target handling
// ===============
-bool Monster_ValidTarget(entity mon, entity player)
-{SELFPARAM();
+bool Monster_ValidTarget(entity this, entity targ)
+{
// ensure we're not checking nonexistent monster/target
- if(!mon || !player) { return false; }
+ if(!this || !targ) { return false; }
- if((player == mon)
- || (autocvar_g_monsters_lineofsight && !checkpvs(mon.origin + mon.view_ofs, player)) // enemy cannot be seen
- || (IS_VEHICLE(player) && !((get_monsterinfo(mon.monsterid)).spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless
+ if((targ == this)
+ || (autocvar_g_monsters_lineofsight && !checkpvs(this.origin + this.view_ofs, targ)) // enemy cannot be seen
+ || (IS_VEHICLE(targ) && !((get_monsterinfo(this.monsterid)).spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless
|| (time < game_starttime) // monsters do nothing before match has started
- || (player.takedamage == DAMAGE_NO)
- || (player.items & IT_INVISIBILITY)
- || (IS_SPEC(player) || IS_OBSERVER(player)) // don't attack spectators
- || (!IS_VEHICLE(player) && (IS_DEAD(player) || IS_DEAD(mon) || player.health <= 0 || mon.health <= 0))
- || (mon.monster_follow == player || player.monster_follow == mon)
- || (!IS_VEHICLE(player) && (player.flags & FL_NOTARGET))
- || (!autocvar_g_monsters_typefrag && player.BUTTON_CHAT)
- || (SAME_TEAM(player, mon))
- || (STAT(FROZEN, player))
- || (player.alpha != 0 && player.alpha < 0.5)
+ || (targ.takedamage == DAMAGE_NO)
+ || (targ.items & IT_INVISIBILITY)
+ || (IS_SPEC(targ) || IS_OBSERVER(targ)) // don't attack spectators
+ || (!IS_VEHICLE(targ) && (IS_DEAD(targ) || IS_DEAD(this) || targ.health <= 0 || this.health <= 0))
+ || (this.monster_follow == targ || targ.monster_follow == this)
+ || (!IS_VEHICLE(targ) && (targ.flags & FL_NOTARGET))
+ || (!autocvar_g_monsters_typefrag && PHYS_INPUT_BUTTON_CHAT(targ))
+ || (SAME_TEAM(targ, this))
+ || (STAT(FROZEN, targ))
+ || (targ.alpha != 0 && targ.alpha < 0.5)
)
{
// if any of the above checks fail, target is not valid
return false;
}
- traceline(mon.origin + self.view_ofs, player.origin, 0, mon);
+ traceline(this.origin + this.view_ofs, targ.origin, 0, this);
- if((trace_fraction < 1) && (trace_ent != player))
+ if((trace_fraction < 1) && (trace_ent != targ))
return false;
- if(autocvar_g_monsters_target_infront || (mon.spawnflags & MONSTERFLAG_INFRONT))
- if(mon.enemy != player)
+ if(autocvar_g_monsters_target_infront || (this.spawnflags & MONSTERFLAG_INFRONT))
+ if(this.enemy != targ)
{
float dot;
- makevectors (mon.angles);
- dot = normalize (player.origin - mon.origin) * v_forward;
+ makevectors (this.angles);
+ dot = normalize (targ.origin - this.origin) * v_forward;
if(dot <= autocvar_g_monsters_target_infront_range) { return false; }
}
if(closest_target)
{
vector closest_target_center = CENTER_OR_VIEWOFS(closest_target);
- if(vlen(ent_center - head_center) < vlen(ent_center - closest_target_center))
+ if(vlen2(ent_center - head_center) < vlen2(ent_center - closest_target_center))
{ closest_target = head; }
}
else { closest_target = head; }
}
}
-void Monster_Delay_Action()
-{SELFPARAM();
- entity oldself = self;
- setself(self.owner);
- if(Monster_ValidTarget(self, self.enemy)) { oldself.use(); }
+.void(entity) monster_delayedfunc;
+void Monster_Delay_Action_self();
+void Monster_Delay_Action(entity this)
+{
+ if(Monster_ValidTarget(this.owner, this.owner.enemy)) { this.monster_delayedfunc(this.owner); }
- if(oldself.cnt > 0)
+ if(this.cnt > 1)
{
- oldself.cnt -= 1;
- oldself.think = Monster_Delay_Action;
- oldself.nextthink = time + oldself.respawn_time;
+ this.cnt -= 1;
+ this.think = Monster_Delay_Action_self;
+ this.nextthink = time + this.count;
}
else
{
- oldself.think = SUB_Remove_self;
- oldself.nextthink = time;
+ this.think = SUB_Remove_self;
+ this.nextthink = time;
}
}
-void Monster_Delay(float repeat_count, float repeat_defer, float defer_amnt, void() func)
-{SELFPARAM();
+void Monster_Delay_Action_self()
+{
+ SELFPARAM();
+ Monster_Delay_Action(self);
+}
+
+void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func)
+{
// deferred attacking, checks if monster is still alive and target is still valid before attacking
entity e = spawn();
- e.think = Monster_Delay_Action;
+ e.think = Monster_Delay_Action_self;
e.nextthink = time + defer_amnt;
e.count = defer_amnt;
- e.owner = self;
- e.use = func;
+ e.owner = this;
+ e.monster_delayedfunc = func;
e.cnt = repeat_count;
- e.respawn_time = repeat_defer;
}
fclose(fh);
}
-void Monster_Sounds_Precache()
-{SELFPARAM();
- string m = (get_monsterinfo(self.monsterid)).m_model.model_str();
+void Monster_Sounds_Precache(entity this)
+{
+ string m = (Monsters_from(this.monsterid)).m_model.model_str();
float globhandle, n, i;
string f;
search_end(globhandle);
}
-void Monster_Sounds_Clear()
-{SELFPARAM();
-#define _MSOUND(m) if(self.monstersound_##m) { strunzone(self.monstersound_##m); self.monstersound_##m = string_null; }
+void Monster_Sounds_Clear(entity this)
+{
+#define _MSOUND(m) if(this.monstersound_##m) { strunzone(this.monstersound_##m); this.monstersound_##m = string_null; }
ALLMONSTERSOUNDS
#undef _MSOUND
}
return string_null;
}
-bool Monster_Sounds_Load(string f, int first)
-{SELFPARAM();
+bool Monster_Sounds_Load(entity this, string f, int first)
+{
float fh;
string s;
var .string field;
field = Monster_Sound_SampleField(argv(0));
if(GetMonsterSoundSampleField_notFound)
continue;
- if (self.(field))
- strunzone(self.(field));
- self.(field) = strzone(strcat(argv(1), " ", argv(2)));
+ if (this.(field))
+ strunzone(this.(field));
+ this.(field) = strzone(strcat(argv(1), " ", argv(2)));
}
fclose(fh);
return true;
}
.int skin_for_monstersound;
-void Monster_Sounds_Update()
-{SELFPARAM();
- if(self.skin == self.skin_for_monstersound) { return; }
+void Monster_Sounds_Update(entity this)
+{
+ if(this.skin == this.skin_for_monstersound) { return; }
- self.skin_for_monstersound = self.skin;
- Monster_Sounds_Clear();
- if(!Monster_Sounds_Load(get_monster_model_datafilename(self.model, self.skin, "sounds"), 0))
- Monster_Sounds_Load(get_monster_model_datafilename(self.model, 0, "sounds"), 0);
+ this.skin_for_monstersound = this.skin;
+ Monster_Sounds_Clear(this);
+ if(!Monster_Sounds_Load(this, get_monster_model_datafilename(this.model, this.skin, "sounds"), 0))
+ Monster_Sounds_Load(this, get_monster_model_datafilename(this.model, 0, "sounds"), 0);
}
-void Monster_Sound(.string samplefield, float sound_delay, float delaytoo, float chan)
-{SELFPARAM();
+void Monster_Sound(entity this, .string samplefield, float sound_delay, float delaytoo, float chan)
+{
if(!autocvar_g_monsters_sounds) { return; }
if(delaytoo)
- if(time < self.msound_delay)
+ if(time < this.msound_delay)
return; // too early
- GlobalSound_string(self, self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
+ GlobalSound_string(this, this.(samplefield), chan, VOICETYPE_PLAYERSOUND);
- self.msound_delay = time + sound_delay;
+ this.msound_delay = time + sound_delay;
}
// Monster attack handlers
// =======================
-float Monster_Attack_Melee(entity targ, float damg, vector anim, float er, float animtime, int deathtype, float dostop)
-{SELFPARAM();
- if(dostop && (self.flags & FL_MONSTER)) { self.state = MONSTER_ATTACK_MELEE; }
+bool Monster_Attack_Melee(entity this, entity targ, float damg, vector anim, float er, float animtime, int deathtype, bool dostop)
+{
+ if(dostop && IS_MONSTER(this)) { this.state = MONSTER_ATTACK_MELEE; }
- setanim(self, anim, false, true, false);
+ setanim(this, anim, false, true, false);
- if(self.animstate_endtime > time && (self.flags & FL_MONSTER))
- self.attack_finished_single[0] = self.anim_finished = self.animstate_endtime;
+ if(this.animstate_endtime > time && IS_MONSTER(this))
+ this.attack_finished_single[0] = this.anim_finished = this.animstate_endtime;
else
- self.attack_finished_single[0] = self.anim_finished = time + animtime;
+ this.attack_finished_single[0] = this.anim_finished = time + animtime;
- monster_makevectors(targ);
+ monster_makevectors(this, targ);
- traceline(self.origin + self.view_ofs, self.origin + v_forward * er, 0, self);
+ traceline(this.origin + this.view_ofs, this.origin + v_forward * er, 0, this);
if(trace_ent.takedamage)
- Damage(trace_ent, self, self, damg * MONSTER_SKILLMOD(self), deathtype, trace_ent.origin, normalize(trace_ent.origin - self.origin));
+ Damage(trace_ent, this, this, damg * MONSTER_SKILLMOD(this), deathtype, trace_ent.origin, normalize(trace_ent.origin - this.origin));
return true;
}
-float Monster_Attack_Leap_Check(vector vel)
-{SELFPARAM();
- if(self.state && (self.flags & FL_MONSTER))
+bool Monster_Attack_Leap_Check(entity this, vector vel)
+{
+ if(this.state && IS_MONSTER(this))
return false; // already attacking
- if(!(IS_ONGROUND(self)))
+ if(!IS_ONGROUND(this))
return false; // not on the ground
- if(self.health <= 0)
+ if(this.health <= 0 || IS_DEAD(this))
return false; // called when dead?
- if(time < self.attack_finished_single[0])
+ if(time < this.attack_finished_single[0])
return false; // still attacking
- vector old = self.velocity;
+ vector old = this.velocity;
- self.velocity = vel;
- tracetoss(self, self);
- self.velocity = old;
- if (trace_ent != self.enemy)
+ this.velocity = vel;
+ tracetoss(this, this);
+ this.velocity = old;
+ if (trace_ent != this.enemy)
return false;
return true;
}
-bool Monster_Attack_Leap(vector anm, void() touchfunc, vector vel, float animtime)
-{SELFPARAM();
- if(!Monster_Attack_Leap_Check(vel))
+bool Monster_Attack_Leap(entity this, vector anm, void() touchfunc, vector vel, float animtime)
+{
+ if(!Monster_Attack_Leap_Check(this, vel))
return false;
- setanim(self, anm, false, true, false);
+ setanim(this, anm, false, true, false);
- if(self.animstate_endtime > time && (self.flags & FL_MONSTER))
- self.attack_finished_single[0] = self.anim_finished = self.animstate_endtime;
+ if(this.animstate_endtime > time && (this.flags & FL_MONSTER))
+ this.attack_finished_single[0] = this.anim_finished = this.animstate_endtime;
else
- self.attack_finished_single[0] = self.anim_finished = time + animtime;
+ this.attack_finished_single[0] = this.anim_finished = time + animtime;
- if(self.flags & FL_MONSTER)
- self.state = MONSTER_ATTACK_RANGED;
- self.touch = touchfunc;
- self.origin_z += 1;
- self.velocity = vel;
- UNSET_ONGROUND(self);
+ if(this.flags & FL_MONSTER)
+ this.state = MONSTER_ATTACK_RANGED;
+ this.touch = touchfunc;
+ this.origin_z += 1;
+ this.velocity = vel;
+ UNSET_ONGROUND(this);
return true;
}
-void Monster_Attack_Check(entity e, entity targ)
+void Monster_Attack_Check(entity this, entity targ)
{
- if((e == world || targ == world)
- || (!e.monster_attackfunc)
- || (time < e.attack_finished_single[0])
+ if((this == world || targ == world)
+ || (!this.monster_attackfunc)
+ || (time < this.attack_finished_single[0])
) { return; }
- float targ_vlen = vlen(targ.origin - e.origin);
-
- if(targ_vlen <= e.attack_range)
+ if(vdist(targ.origin - this.origin, <=, this.attack_range))
{
- float attack_success = e.monster_attackfunc(MONSTER_ATTACK_MELEE, targ);
+ bool attack_success = this.monster_attackfunc(MONSTER_ATTACK_MELEE, this, targ);
if(attack_success == 1)
- Monster_Sound(monstersound_melee, 0, false, CH_VOICE);
+ Monster_Sound(this, monstersound_melee, 0, false, CH_VOICE);
else if(attack_success > 0)
return;
}
- if(targ_vlen > e.attack_range)
+ if(vdist(targ.origin - this.origin, >, this.attack_range))
{
- float attack_success = e.monster_attackfunc(MONSTER_ATTACK_RANGED, targ);
+ float attack_success = this.monster_attackfunc(MONSTER_ATTACK_RANGED, this, targ);
if(attack_success == 1)
- Monster_Sound(monstersound_melee, 0, false, CH_VOICE);
+ Monster_Sound(this, monstersound_melee, 0, false, CH_VOICE);
else if(attack_success > 0)
return;
}
// Main monster functions
// ======================
-void Monster_UpdateModel()
-{SELFPARAM();
+void Monster_UpdateModel(entity this)
+{
// assume some defaults
- /*self.anim_idle = animfixfps(self, '0 1 0.01', '0 0 0');
- self.anim_walk = animfixfps(self, '1 1 0.01', '0 0 0');
- self.anim_run = animfixfps(self, '2 1 0.01', '0 0 0');
- self.anim_fire1 = animfixfps(self, '3 1 0.01', '0 0 0');
- self.anim_fire2 = animfixfps(self, '4 1 0.01', '0 0 0');
- self.anim_melee = animfixfps(self, '5 1 0.01', '0 0 0');
- self.anim_pain1 = animfixfps(self, '6 1 0.01', '0 0 0');
- self.anim_pain2 = animfixfps(self, '7 1 0.01', '0 0 0');
- self.anim_die1 = animfixfps(self, '8 1 0.01', '0 0 0');
- self.anim_die2 = animfixfps(self, '9 1 0.01', '0 0 0');*/
+ /*this.anim_idle = animfixfps(this, '0 1 0.01', '0 0 0');
+ this.anim_walk = animfixfps(this, '1 1 0.01', '0 0 0');
+ this.anim_run = animfixfps(this, '2 1 0.01', '0 0 0');
+ this.anim_fire1 = animfixfps(this, '3 1 0.01', '0 0 0');
+ this.anim_fire2 = animfixfps(this, '4 1 0.01', '0 0 0');
+ this.anim_melee = animfixfps(this, '5 1 0.01', '0 0 0');
+ this.anim_pain1 = animfixfps(this, '6 1 0.01', '0 0 0');
+ this.anim_pain2 = animfixfps(this, '7 1 0.01', '0 0 0');
+ this.anim_die1 = animfixfps(this, '8 1 0.01', '0 0 0');
+ this.anim_die2 = animfixfps(this, '9 1 0.01', '0 0 0');*/
// then get the real values
- Monster mon = get_monsterinfo(self.monsterid);
- mon.mr_anim(mon);
+ Monster mon = get_monsterinfo(this.monsterid);
+ mon.mr_anim(mon, this);
}
void Monster_Touch()
if(other == world) { return; }
if(other.monster_attack)
- if(self.enemy != other)
+ if(this.enemy != other)
if(!IS_MONSTER(other))
- if(Monster_ValidTarget(self, other))
- self.enemy = other;
+ if(Monster_ValidTarget(this, other))
+ this.enemy = other;
}
-void Monster_Miniboss_Check()
-{SELFPARAM();
- if(MUTATOR_CALLHOOK(MonsterCheckBossFlag))
+void Monster_Miniboss_Check(entity this)
+{
+ if(MUTATOR_CALLHOOK(MonsterCheckBossFlag, this))
return;
float chance = random() * 100;
// g_monsters_miniboss_chance cvar or spawnflags 64 causes a monster to be a miniboss
- if ((self.spawnflags & MONSTERFLAG_MINIBOSS) || (chance < autocvar_g_monsters_miniboss_chance))
+ if ((this.spawnflags & MONSTERFLAG_MINIBOSS) || (chance < autocvar_g_monsters_miniboss_chance))
{
- self.health += autocvar_g_monsters_miniboss_healthboost;
- self.effects |= EF_RED;
- if(!self.weapon)
- self.weapon = WEP_VORTEX.m_id;
+ this.health += autocvar_g_monsters_miniboss_healthboost;
+ this.effects |= EF_RED;
+ if(!this.weapon)
+ this.weapon = WEP_VORTEX.m_id;
}
}
-bool Monster_Respawn_Check()
-{SELFPARAM();
- if(self.deadflag == DEAD_DEAD) // don't call when monster isn't dead
- if(MUTATOR_CALLHOOK(MonsterRespawn, self))
+bool Monster_Respawn_Check(entity this)
+{
+ if(this.deadflag == DEAD_DEAD) // don't call when monster isn't dead
+ if(MUTATOR_CALLHOOK(MonsterRespawn, this))
return true; // enabled by a mutator
- if(self.spawnflags & MONSTERFLAG_NORESPAWN)
+ if(this.spawnflags & MONSTERFLAG_NORESPAWN)
return false;
if(!autocvar_g_monsters_respawn)
return true;
}
-void Monster_Respawn() { SELFPARAM(); Monster_Spawn(self.monsterid); }
+void Monster_Respawn() { SELFPARAM(); Monster_Spawn(this, this.monsterid); }
-void Monster_Dead_Fade()
-{SELFPARAM();
- if(Monster_Respawn_Check())
+void Monster_Dead_Fade(entity this)
+{
+ if(Monster_Respawn_Check(this))
{
- self.spawnflags |= MONSTERFLAG_RESPAWNED;
- self.think = Monster_Respawn;
- self.nextthink = time + self.respawntime;
- self.monster_lifetime = 0;
- self.deadflag = DEAD_RESPAWNING;
- if(self.spawnflags & MONSTER_RESPAWN_DEATHPOINT)
+ this.spawnflags |= MONSTERFLAG_RESPAWNED;
+ this.think = Monster_Respawn;
+ this.nextthink = time + this.respawntime;
+ this.monster_lifetime = 0;
+ this.deadflag = DEAD_RESPAWNING;
+ if(this.spawnflags & MONSTER_RESPAWN_DEATHPOINT)
{
- self.pos1 = self.origin;
- self.pos2 = self.angles;
+ this.pos1 = this.origin;
+ this.pos2 = this.angles;
}
- self.event_damage = func_null;
- self.takedamage = DAMAGE_NO;
- setorigin(self, self.pos1);
- self.angles = self.pos2;
- self.health = self.max_health;
- setmodel(self, MDL_Null);
+ this.event_damage = func_null;
+ this.takedamage = DAMAGE_NO;
+ setorigin(this, this.pos1);
+ this.angles = this.pos2;
+ this.health = this.max_health;
+ setmodel(this, MDL_Null);
}
else
{
// number of monsters spawned with mobspawn command
totalspawned -= 1;
- SUB_SetFade(self, time + 3, 1);
+ SUB_SetFade(this, time + 3, 1);
}
}
-void Monster_Use()
-{SELFPARAM();
- if(Monster_ValidTarget(self, activator)) { self.enemy = activator; }
+void Monster_Use(entity this, entity actor, entity trigger)
+{
+ if(Monster_ValidTarget(this, actor)) { this.enemy = actor; }
}
-vector Monster_Move_Target(entity targ)
-{SELFPARAM();
+vector Monster_Move_Target(entity this, entity targ)
+{
// enemy is always preferred target
- if(self.enemy)
+ if(this.enemy)
{
- vector targ_origin = ((self.enemy.absmin + self.enemy.absmax) * 0.5);
- targ_origin = WarpZone_RefSys_TransformOrigin(self.enemy, self, targ_origin); // origin of target as seen by the monster (us)
- WarpZone_TraceLine(self.origin, targ_origin, MOVE_NOMONSTERS, self);
-
- if((self.enemy == world)
- || (IS_DEAD(self.enemy) || self.enemy.health < 1)
- || (STAT(FROZEN, self.enemy))
- || (self.enemy.flags & FL_NOTARGET)
- || (self.enemy.alpha < 0.5 && self.enemy.alpha != 0)
- || (self.enemy.takedamage == DAMAGE_NO)
- || (vlen(self.origin - targ_origin) > self.target_range)
- || ((trace_fraction < 1) && (trace_ent != self.enemy)))
+ vector targ_origin = ((this.enemy.absmin + this.enemy.absmax) * 0.5);
+ targ_origin = WarpZone_RefSys_TransformOrigin(this.enemy, this, targ_origin); // origin of target as seen by the monster (us)
+ WarpZone_TraceLine(this.origin, targ_origin, MOVE_NOMONSTERS, this);
+
+ if((this.enemy == world)
+ || (IS_DEAD(this.enemy) || this.enemy.health < 1)
+ || (STAT(FROZEN, this.enemy))
+ || (this.enemy.flags & FL_NOTARGET)
+ || (this.enemy.alpha < 0.5 && this.enemy.alpha != 0)
+ || (this.enemy.takedamage == DAMAGE_NO)
+ || (vdist(this.origin - targ_origin, >, this.target_range))
+ || ((trace_fraction < 1) && (trace_ent != this.enemy)))
{
- self.enemy = world;
- self.pass_distance = 0;
+ this.enemy = world;
+ this.pass_distance = 0;
}
- if(self.enemy)
+ if(this.enemy)
{
- /*WarpZone_TrailParticles(world, particleeffectnum(EFFECT_RED_PASS), self.origin, targ_origin);
+ /*WarpZone_TrailParticles(world, particleeffectnum(EFFECT_RED_PASS), this.origin, targ_origin);
print("Trace origin: ", vtos(targ_origin), "\n");
- print("Target origin: ", vtos(self.enemy.origin), "\n");
- print("My origin: ", vtos(self.origin), "\n"); */
+ print("Target origin: ", vtos(this.enemy.origin), "\n");
+ print("My origin: ", vtos(this.origin), "\n"); */
- self.monster_movestate = MONSTER_MOVE_ENEMY;
- self.last_trace = time + 1.2;
- if(self.monster_moveto)
- return self.monster_moveto; // assumes code is properly setting this when monster has an enemy
+ this.monster_movestate = MONSTER_MOVE_ENEMY;
+ this.last_trace = time + 1.2;
+ if(this.monster_moveto)
+ return this.monster_moveto; // assumes code is properly setting this when monster has an enemy
else
return targ_origin;
}
- /*makevectors(self.angles);
- self.monster_movestate = MONSTER_MOVE_ENEMY;
- self.last_trace = time + 1.2;
- return self.enemy.origin; */
+ /*makevectors(this.angles);
+ this.monster_movestate = MONSTER_MOVE_ENEMY;
+ this.last_trace = time + 1.2;
+ return this.enemy.origin; */
}
- switch(self.monster_moveflags)
+ switch(this.monster_moveflags)
{
case MONSTER_MOVE_FOLLOW:
{
- self.monster_movestate = MONSTER_MOVE_FOLLOW;
- self.last_trace = time + 0.3;
- return (self.monster_follow) ? self.monster_follow.origin : self.origin;
+ this.monster_movestate = MONSTER_MOVE_FOLLOW;
+ this.last_trace = time + 0.3;
+ return (this.monster_follow) ? this.monster_follow.origin : this.origin;
}
case MONSTER_MOVE_SPAWNLOC:
{
- self.monster_movestate = MONSTER_MOVE_SPAWNLOC;
- self.last_trace = time + 2;
- return self.pos1;
+ this.monster_movestate = MONSTER_MOVE_SPAWNLOC;
+ this.last_trace = time + 2;
+ return this.pos1;
}
case MONSTER_MOVE_NOMOVE:
{
- if(self.monster_moveto)
+ if(this.monster_moveto)
{
- self.last_trace = time + 0.5;
- return self.monster_moveto;
+ this.last_trace = time + 0.5;
+ return this.monster_moveto;
}
else
{
- self.monster_movestate = MONSTER_MOVE_NOMOVE;
- self.last_trace = time + 2;
+ this.monster_movestate = MONSTER_MOVE_NOMOVE;
+ this.last_trace = time + 2;
}
- return self.origin;
+ return this.origin;
}
default:
case MONSTER_MOVE_WANDER:
{
vector pos;
- self.monster_movestate = MONSTER_MOVE_WANDER;
+ this.monster_movestate = MONSTER_MOVE_WANDER;
- if(self.monster_moveto)
+ if(this.monster_moveto)
{
- self.last_trace = time + 0.5;
- pos = self.monster_moveto;
+ this.last_trace = time + 0.5;
+ pos = this.monster_moveto;
}
else if(targ)
{
- self.last_trace = time + 0.5;
+ this.last_trace = time + 0.5;
pos = targ.origin;
}
else
{
- self.last_trace = time + self.wander_delay;
+ this.last_trace = time + this.wander_delay;
- self.angles_y = rint(random() * 500);
- makevectors(self.angles);
- pos = self.origin + v_forward * self.wander_distance;
+ this.angles_y = rint(random() * 500);
+ makevectors(this.angles);
+ pos = this.origin + v_forward * this.wander_distance;
- if(((self.flags & FL_FLY) && (self.spawnflags & MONSTERFLAG_FLY_VERTICAL)) || (self.flags & FL_SWIM))
+ if(((this.flags & FL_FLY) && (this.spawnflags & MONSTERFLAG_FLY_VERTICAL)) || (this.flags & FL_SWIM))
{
pos.z = random() * 200;
if(random() >= 0.5)
}
}
-void Monster_CalculateVelocity(entity mon, vector to, vector from, float turnrate, float movespeed)
-{SELFPARAM();
+void Monster_CalculateVelocity(entity this, vector to, vector from, float turnrate, float movespeed)
+{
float current_distance = vlen((('1 0 0' * to.x) + ('0 1 0' * to.y)) - (('1 0 0' * from.x) + ('0 1 0' * from.y))); // for the sake of this check, exclude Z axis
float initial_height = 0; //min(50, (targ_distance * tanh(20)));
- float current_height = (initial_height * min(1, (self.pass_distance) ? (current_distance / self.pass_distance) : current_distance));
+ float current_height = (initial_height * min(1, (this.pass_distance) ? (current_distance / this.pass_distance) : current_distance));
//print("current_height = ", ftos(current_height), ", initial_height = ", ftos(initial_height), ".\n");
vector targpos;
if(current_height) // make sure we can actually do this arcing path
{
targpos = (to + ('0 0 1' * current_height));
- WarpZone_TraceLine(mon.origin, targpos, MOVE_NOMONSTERS, mon);
+ WarpZone_TraceLine(this.origin, targpos, MOVE_NOMONSTERS, this);
if(trace_fraction < 1)
{
//print("normal arc line failed, trying to find new pos...");
- WarpZone_TraceLine(to, targpos, MOVE_NOMONSTERS, mon);
+ WarpZone_TraceLine(to, targpos, MOVE_NOMONSTERS, this);
targpos = (trace_endpos + '0 0 -10');
- WarpZone_TraceLine(mon.origin, targpos, MOVE_NOMONSTERS, mon);
+ WarpZone_TraceLine(this.origin, targpos, MOVE_NOMONSTERS, this);
if(trace_fraction < 1) { targpos = to; /* print(" ^1FAILURE^7, reverting to original direction.\n"); */ }
/*else { print(" ^3SUCCESS^7, using new arc line.\n"); } */
}
}
else { targpos = to; }
- //mon.angles = normalize(('0 1 0' * to_y) - ('0 1 0' * from_y));
+ //this.angles = normalize(('0 1 0' * to_y) - ('0 1 0' * from_y));
vector desired_direction = normalize(targpos - from);
- if(turnrate) { mon.velocity = (normalize(normalize(mon.velocity) + (desired_direction * 50)) * movespeed); }
- else { mon.velocity = (desired_direction * movespeed); }
+ if(turnrate) { this.velocity = (normalize(normalize(this.velocity) + (desired_direction * 50)) * movespeed); }
+ else { this.velocity = (desired_direction * movespeed); }
- //mon.steerto = steerlib_attract2(targpos, 0.5, 500, 0.95);
- //mon.angles = vectoangles(mon.velocity);
+ //this.steerto = steerlib_attract2(targpos, 0.5, 500, 0.95);
+ //this.angles = vectoangles(this.velocity);
}
-void Monster_Move(float runspeed, float walkspeed, float stpspeed)
-{SELFPARAM();
- if(self.target2) { self.goalentity = find(world, targetname, self.target2); }
+void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
+{
+ if(this.target2) { this.goalentity = find(world, targetname, this.target2); }
entity targ;
- if(STAT(FROZEN, self) == 2)
+ if(STAT(FROZEN, this) == 2)
{
- self.revive_progress = bound(0, self.revive_progress + self.ticrate * self.revive_speed, 1);
- self.health = max(1, self.revive_progress * self.max_health);
- self.iceblock.alpha = bound(0.2, 1 - self.revive_progress, 1);
+ this.revive_progress = bound(0, this.revive_progress + this.ticrate * this.revive_speed, 1);
+ this.health = max(1, this.revive_progress * this.max_health);
+ this.iceblock.alpha = bound(0.2, 1 - this.revive_progress, 1);
- if(!(self.spawnflags & MONSTERFLAG_INVINCIBLE) && self.sprite)
- WaypointSprite_UpdateHealth(self.sprite, self.health);
+ if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE) && this.sprite)
+ WaypointSprite_UpdateHealth(this.sprite, this.health);
- movelib_brake_simple(stpspeed);
- setanim(self, self.anim_idle, true, false, false);
+ movelib_brake_simple(this, stpspeed);
+ setanim(this, this.anim_idle, true, false, false);
- self.enemy = world;
- self.nextthink = time + self.ticrate;
+ this.enemy = world;
+ this.nextthink = time + this.ticrate;
- if(self.revive_progress >= 1)
- Unfreeze(self);
+ if(this.revive_progress >= 1)
+ Unfreeze(this);
return;
}
- else if(STAT(FROZEN, self) == 3)
+ else if(STAT(FROZEN, this) == 3)
{
- self.revive_progress = bound(0, self.revive_progress - self.ticrate * self.revive_speed, 1);
- self.health = max(0, autocvar_g_nades_ice_health + (self.max_health-autocvar_g_nades_ice_health) * self.revive_progress );
+ this.revive_progress = bound(0, this.revive_progress - this.ticrate * this.revive_speed, 1);
+ this.health = max(0, autocvar_g_nades_ice_health + (this.max_health-autocvar_g_nades_ice_health) * this.revive_progress );
- if(!(self.spawnflags & MONSTERFLAG_INVINCIBLE) && self.sprite)
- WaypointSprite_UpdateHealth(self.sprite, self.health);
+ if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE) && this.sprite)
+ WaypointSprite_UpdateHealth(this.sprite, this.health);
- movelib_brake_simple(stpspeed);
- setanim(self, self.anim_idle, true, false, false);
+ movelib_brake_simple(this, stpspeed);
+ setanim(this, this.anim_idle, true, false, false);
- self.enemy = world;
- self.nextthink = time + self.ticrate;
+ this.enemy = world;
+ this.nextthink = time + this.ticrate;
- if(self.health < 1)
+ if(this.health < 1)
{
- Unfreeze(self);
- self.health = 0;
- if(self.event_damage)
- self.event_damage(self, self.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, self.origin, '0 0 0');
+ Unfreeze(this);
+ this.health = 0;
+ if(this.event_damage)
+ this.event_damage(this, this, this.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, this.origin, '0 0 0');
}
- else if ( self.revive_progress <= 0 )
- Unfreeze(self);
+ else if ( this.revive_progress <= 0 )
+ Unfreeze(this);
return;
}
- if(self.flags & FL_SWIM)
+ if(this.flags & FL_SWIM)
{
- if(self.waterlevel < WATERLEVEL_WETFEET)
+ if(this.waterlevel < WATERLEVEL_WETFEET)
{
- if(time >= self.last_trace)
+ if(time >= this.last_trace)
{
- self.last_trace = time + 0.4;
+ this.last_trace = time + 0.4;
- Damage (self, world, world, 2, DEATH_DROWN.m_id, self.origin, '0 0 0');
- self.angles = '90 90 0';
+ Damage (this, world, world, 2, DEATH_DROWN.m_id, this.origin, '0 0 0');
+ this.angles = '90 90 0';
if(random() < 0.5)
{
- self.velocity_y += random() * 50;
- self.velocity_x -= random() * 50;
+ this.velocity_y += random() * 50;
+ this.velocity_x -= random() * 50;
}
else
{
- self.velocity_y -= random() * 50;
- self.velocity_x += random() * 50;
+ this.velocity_y -= random() * 50;
+ this.velocity_x += random() * 50;
}
- self.velocity_z += random() * 150;
+ this.velocity_z += random() * 150;
}
- self.movetype = MOVETYPE_BOUNCE;
- //self.velocity_z = -200;
+ this.movetype = MOVETYPE_BOUNCE;
+ //this.velocity_z = -200;
return;
}
- else if(self.movetype == MOVETYPE_BOUNCE)
+ else if(this.movetype == MOVETYPE_BOUNCE)
{
- self.angles_x = 0;
- self.movetype = MOVETYPE_WALK;
+ this.angles_x = 0;
+ this.movetype = MOVETYPE_WALK;
}
}
- targ = self.goalentity;
+ targ = this.goalentity;
- if (MUTATOR_CALLHOOK(MonsterMove, runspeed, walkspeed, targ)
+ if (MUTATOR_CALLHOOK(MonsterMove, this, runspeed, walkspeed, targ)
|| gameover
- || self.draggedby != world
+ || this.draggedby != world
|| (round_handler_IsActive() && !round_handler_IsRoundStarted())
|| time < game_starttime
|| (autocvar_g_campaign && !campaign_bots_may_start)
- || time < self.spawn_time)
+ || time < this.spawn_time)
{
runspeed = walkspeed = 0;
- if(time >= self.spawn_time)
- setanim(self, self.anim_idle, true, false, false);
- movelib_brake_simple(stpspeed);
+ if(time >= this.spawn_time)
+ setanim(this, this.anim_idle, true, false, false);
+ movelib_brake_simple(this, stpspeed);
return;
}
targ = monster_target;
- runspeed = bound(0, monster_speed_run * MONSTER_SKILLMOD(self), runspeed * 2.5); // limit maxspeed to prevent craziness
- walkspeed = bound(0, monster_speed_walk * MONSTER_SKILLMOD(self), walkspeed * 2.5); // limit maxspeed to prevent craziness
+ runspeed = bound(0, monster_speed_run * MONSTER_SKILLMOD(this), runspeed * 2.5); // limit maxspeed to prevent craziness
+ walkspeed = bound(0, monster_speed_walk * MONSTER_SKILLMOD(this), walkspeed * 2.5); // limit maxspeed to prevent craziness
if(teamplay)
if(autocvar_g_monsters_teams)
- if(DIFF_TEAM(self.monster_follow, self))
- self.monster_follow = world;
+ if(DIFF_TEAM(this.monster_follow, this))
+ this.monster_follow = world;
- if(time >= self.last_enemycheck)
+ if(time >= this.last_enemycheck)
{
- if(!self.enemy)
+ if(!this.enemy)
{
- self.enemy = Monster_FindTarget(self);
- if(self.enemy)
+ this.enemy = Monster_FindTarget(this);
+ if(this.enemy)
{
- WarpZone_RefSys_Copy(self.enemy, self);
- WarpZone_RefSys_AddInverse(self.enemy, self); // wz1^-1 ... wzn^-1 receiver
- self.moveto = WarpZone_RefSys_TransformOrigin(self.enemy, self, (0.5 * (self.enemy.absmin + self.enemy.absmax)));
- self.monster_moveto = '0 0 0';
- self.monster_face = '0 0 0';
-
- self.pass_distance = vlen((('1 0 0' * self.enemy.origin_x) + ('0 1 0' * self.enemy.origin_y)) - (('1 0 0' * self.origin_x) + ('0 1 0' * self.origin_y)));
- Monster_Sound(monstersound_sight, 0, false, CH_VOICE);
+ WarpZone_RefSys_Copy(this.enemy, this);
+ WarpZone_RefSys_AddInverse(this.enemy, this); // wz1^-1 ... wzn^-1 receiver
+ this.moveto = WarpZone_RefSys_TransformOrigin(this.enemy, this, (0.5 * (this.enemy.absmin + this.enemy.absmax)));
+ this.monster_moveto = '0 0 0';
+ this.monster_face = '0 0 0';
+
+ this.pass_distance = vlen((('1 0 0' * this.enemy.origin_x) + ('0 1 0' * this.enemy.origin_y)) - (('1 0 0' * this.origin_x) + ('0 1 0' * this.origin_y)));
+ Monster_Sound(this, monstersound_sight, 0, false, CH_VOICE);
}
}
- self.last_enemycheck = time + 1; // check for enemies every second
+ this.last_enemycheck = time + 1; // check for enemies every second
}
- if(self.state == MONSTER_ATTACK_RANGED && (IS_ONGROUND(self)))
+ if(this.state == MONSTER_ATTACK_RANGED && IS_ONGROUND(this))
{
- self.state = 0;
- self.touch = Monster_Touch;
+ this.state = 0;
+ this.touch = Monster_Touch;
}
- if(self.state && time >= self.attack_finished_single[0])
- self.state = 0; // attack is over
+ if(this.state && time >= this.attack_finished_single[0])
+ this.state = 0; // attack is over
- if(self.state != MONSTER_ATTACK_MELEE) // don't move if set
- if(time >= self.last_trace || self.enemy) // update enemy or rider instantly
- self.moveto = Monster_Move_Target(targ);
+ if(this.state != MONSTER_ATTACK_MELEE) // don't move if set
+ if(time >= this.last_trace || this.enemy) // update enemy or rider instantly
+ this.moveto = Monster_Move_Target(this, targ);
- if(!self.enemy)
- Monster_Sound(monstersound_idle, 7, true, CH_VOICE);
+ if(!this.enemy)
+ Monster_Sound(this, monstersound_idle, 7, true, CH_VOICE);
- if(self.state == MONSTER_ATTACK_MELEE)
- self.moveto = self.origin;
+ if(this.state == MONSTER_ATTACK_MELEE)
+ this.moveto = this.origin;
- if(self.enemy && self.enemy.vehicle)
+ if(this.enemy && this.enemy.vehicle)
runspeed = 0;
- if(!(self.spawnflags & MONSTERFLAG_FLY_VERTICAL) && !(self.flags & FL_SWIM))
- self.moveto_z = self.origin_z;
+ if(!(this.spawnflags & MONSTERFLAG_FLY_VERTICAL) && !(this.flags & FL_SWIM))
+ this.moveto_z = this.origin_z;
- if(vlen(self.origin - self.moveto) > 100)
+ if(vdist(this.origin - this.moveto, >, 100))
{
- float do_run = (self.enemy || self.monster_moveto);
- if((IS_ONGROUND(self)) || ((self.flags & FL_FLY) || (self.flags & FL_SWIM)))
- Monster_CalculateVelocity(self, self.moveto, self.origin, true, ((do_run) ? runspeed : walkspeed));
-
- if(time > self.pain_finished) // TODO: use anim_finished instead!
- if(!self.state)
- if(time > self.anim_finished)
- if(vlen(self.velocity) > 10)
- setanim(self, ((do_run) ? self.anim_run : self.anim_walk), true, false, false);
+ float do_run = (this.enemy || this.monster_moveto);
+ if(IS_ONGROUND(this) || ((this.flags & FL_FLY) || (this.flags & FL_SWIM)))
+ Monster_CalculateVelocity(this, this.moveto, this.origin, true, ((do_run) ? runspeed : walkspeed));
+
+ if(time > this.pain_finished) // TODO: use anim_finished instead!
+ if(!this.state)
+ if(time > this.anim_finished)
+ if(vdist(this.velocity, >, 10))
+ setanim(this, ((do_run) ? this.anim_run : this.anim_walk), true, false, false);
else
- setanim(self, self.anim_idle, true, false, false);
+ setanim(this, this.anim_idle, true, false, false);
}
else
{
- entity e = find(world, targetname, self.target2);
+ entity e = find(world, targetname, this.target2);
if(e.target2)
- self.target2 = e.target2;
+ this.target2 = e.target2;
else if(e.target)
- self.target2 = e.target;
-
- movelib_brake_simple(stpspeed);
- if(time > self.anim_finished)
- if(time > self.pain_finished)
- if(!self.state)
- if(vlen(self.velocity) <= 30)
- setanim(self, self.anim_idle, true, false, false);
+ this.target2 = e.target;
+
+ movelib_brake_simple(this, stpspeed);
+ if(time > this.anim_finished)
+ if(time > this.pain_finished)
+ if(!this.state)
+ if(vdist(this.velocity, <=, 30))
+ setanim(this, this.anim_idle, true, false, false);
}
- self.steerto = steerlib_attract2(((self.monster_face) ? self.monster_face : self.moveto), 0.5, 500, 0.95);
+ this.steerto = steerlib_attract2(this, ((this.monster_face) ? this.monster_face : this.moveto), 0.5, 500, 0.95);
- vector real_angle = vectoangles(self.steerto) - self.angles;
+ vector real_angle = vectoangles(this.steerto) - this.angles;
float turny = 25;
- if(self.state == MONSTER_ATTACK_MELEE)
+ if(this.state == MONSTER_ATTACK_MELEE)
turny = 0;
if(turny)
{
- turny = bound(turny * -1, shortangle_f(real_angle.y, self.angles.y), turny);
- self.angles_y += turny;
+ turny = bound(turny * -1, shortangle_f(real_angle.y, this.angles.y), turny);
+ this.angles_y += turny;
}
- Monster_Attack_Check(self, self.enemy);
+ Monster_Attack_Check(this, this.enemy);
}
-void Monster_Remove(entity mon)
+void Monster_Remove(entity this)
{
+ if(IS_CLIENT(this))
+ return; // don't remove it?
+
.entity weaponentity = weaponentities[0];
- if(!mon) { return; }
+ if(!this) { return; }
- if(!MUTATOR_CALLHOOK(MonsterRemove, mon))
- Send_Effect(EFFECT_ITEM_PICKUP, mon.origin, '0 0 0', 1);
+ if(!MUTATOR_CALLHOOK(MonsterRemove, this))
+ Send_Effect(EFFECT_ITEM_PICKUP, this.origin, '0 0 0', 1);
- if(mon.(weaponentity)) { remove(mon.(weaponentity)); }
- if(mon.iceblock) { remove(mon.iceblock); }
- WaypointSprite_Kill(mon.sprite);
- remove(mon);
+ if(this.(weaponentity)) { remove(this.(weaponentity)); }
+ if(this.iceblock) { remove(this.iceblock); }
+ WaypointSprite_Kill(this.sprite);
+ remove(this);
}
void Monster_Dead_Think()
{SELFPARAM();
- self.nextthink = time + self.ticrate;
+ this.nextthink = time + this.ticrate;
- if(self.monster_lifetime != 0)
- if(time >= self.monster_lifetime)
+ if(this.monster_lifetime != 0)
+ if(time >= this.monster_lifetime)
{
- Monster_Dead_Fade();
+ Monster_Dead_Fade(this);
return;
}
}
-void Monster_Appear()
-{SELFPARAM();
- self.enemy = activator;
- self.spawnflags &= ~MONSTERFLAG_APPEAR; // otherwise, we get an endless loop
- Monster_Spawn(self.monsterid);
+void Monster_Appear(entity this, entity actor, entity trigger)
+{
+ this.enemy = actor;
+ this.spawnflags &= ~MONSTERFLAG_APPEAR; // otherwise, we get an endless loop
+ Monster_Spawn(this, this.monsterid);
}
-float Monster_Appear_Check(entity ent, float monster_id)
+bool Monster_Appear_Check(entity this, int monster_id)
{
- if(!(ent.spawnflags & MONSTERFLAG_APPEAR))
+ if(!(this.spawnflags & MONSTERFLAG_APPEAR))
return false;
- ent.think = func_null;
- ent.monsterid = monster_id; // set so this monster is properly registered (otherwise, normal initialization is used)
- ent.nextthink = 0;
- ent.use = Monster_Appear;
- ent.flags = FL_MONSTER; // set so this monster can get butchered
+ this.think = func_null;
+ this.monsterid = monster_id; // set so this monster is properly registered (otherwise, normal initialization is used)
+ this.nextthink = 0;
+ this.use = Monster_Appear;
+ this.flags = FL_MONSTER; // set so this monster can get butchered
return true;
}
this.moveto = this.origin;
}
-void Monster_Dead_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
- self.health -= damage;
+void Monster_Dead_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+{
+ this.health -= damage;
- Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, self, attacker);
+ Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, this, attacker);
- if(self.health <= -100) // 100 health until gone?
+ if(this.health <= -50) // 100 health until gone?
{
- Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, self, attacker);
+ Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, this, attacker);
// number of monsters spawned with mobspawn command
totalspawned -= 1;
- self.think = SUB_Remove_self;
- self.nextthink = time + 0.1;
- self.event_damage = func_null;
+ this.think = SUB_Remove_self;
+ this.nextthink = time + 0.1;
+ this.event_damage = func_null;
}
}
-void Monster_Dead(entity attacker, float gibbed)
-{SELFPARAM();
- self.think = Monster_Dead_Think;
- self.nextthink = time;
- self.monster_lifetime = time + 5;
+void Monster_Dead(entity this, entity attacker, float gibbed)
+{
+ this.think = Monster_Dead_Think;
+ this.nextthink = time;
+ this.monster_lifetime = time + 5;
- if(STAT(FROZEN, self))
+ if(STAT(FROZEN, this))
{
- Unfreeze(self); // remove any icy remains
- self.health = 0; // reset by Unfreeze
+ Unfreeze(this); // remove any icy remains
+ this.health = 0; // reset by Unfreeze
}
- monster_dropitem();
+ monster_dropitem(this);
- Monster_Sound(monstersound_death, 0, false, CH_VOICE);
+ Monster_Sound(this, monstersound_death, 0, false, CH_VOICE);
- if(!(self.spawnflags & MONSTERFLAG_SPAWNED) && !(self.spawnflags & MONSTERFLAG_RESPAWNED))
+ if(!(this.spawnflags & MONSTERFLAG_SPAWNED) && !(this.spawnflags & MONSTERFLAG_RESPAWNED))
monsters_killed += 1;
if(IS_PLAYER(attacker))
- if(autocvar_g_monsters_score_spawned || !((self.spawnflags & MONSTERFLAG_SPAWNED) || (self.spawnflags & MONSTERFLAG_RESPAWNED)))
+ if(autocvar_g_monsters_score_spawned || !((this.spawnflags & MONSTERFLAG_SPAWNED) || (this.spawnflags & MONSTERFLAG_RESPAWNED)))
PlayerScore_Add(attacker, SP_SCORE, +autocvar_g_monsters_score_kill);
if(gibbed)
totalspawned -= 1;
}
- self.event_damage = ((gibbed) ? func_null : Monster_Dead_Damage);
- self.solid = SOLID_CORPSE;
- self.takedamage = DAMAGE_AIM;
- self.deadflag = DEAD_DEAD;
- self.enemy = world;
- self.movetype = MOVETYPE_TOSS;
- self.moveto = self.origin;
- self.touch = Monster_Touch; // reset incase monster was pouncing
- self.reset = func_null;
- self.state = 0;
- self.attack_finished_single[0] = 0;
- self.effects = 0;
-
- if(!((self.flags & FL_FLY) || (self.flags & FL_SWIM)))
- self.velocity = '0 0 0';
-
- CSQCModel_UnlinkEntity(self);
-
- Monster mon = get_monsterinfo(self.monsterid);
- mon.mr_death(mon);
-
- if(self.candrop && self.weapon)
- W_ThrowNewWeapon(self, self.weapon, 0, self.origin, randomvec() * 150 + '0 0 325');
+ this.event_damage = ((gibbed) ? func_null : Monster_Dead_Damage);
+ this.solid = SOLID_CORPSE;
+ this.takedamage = DAMAGE_AIM;
+ this.deadflag = DEAD_DEAD;
+ this.enemy = world;
+ this.movetype = MOVETYPE_TOSS;
+ this.moveto = this.origin;
+ this.touch = Monster_Touch; // reset incase monster was pouncing
+ this.reset = func_null;
+ this.state = 0;
+ this.attack_finished_single[0] = 0;
+ this.effects = 0;
+
+ if(!((this.flags & FL_FLY) || (this.flags & FL_SWIM)))
+ this.velocity = '0 0 0';
+
+ CSQCModel_UnlinkEntity(this);
+
+ Monster mon = get_monsterinfo(this.monsterid);
+ mon.mr_death(mon, this);
+
+ if(this.candrop && this.weapon)
+ W_ThrowNewWeapon(this, this.weapon, 0, this.origin, randomvec() * 150 + '0 0 325');
}
-void Monster_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
- if((self.spawnflags & MONSTERFLAG_INVINCIBLE) && deathtype != DEATH_KILL.m_id && !ITEM_DAMAGE_NEEDKILL(deathtype))
+void Monster_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+{
+ if((this.spawnflags & MONSTERFLAG_INVINCIBLE) && deathtype != DEATH_KILL.m_id && !ITEM_DAMAGE_NEEDKILL(deathtype))
return;
- if(STAT(FROZEN, self) && deathtype != DEATH_KILL.m_id && deathtype != DEATH_NADE_ICE_FREEZE.m_id)
+ if(STAT(FROZEN, this) && deathtype != DEATH_KILL.m_id && deathtype != DEATH_NADE_ICE_FREEZE.m_id)
return;
- //if(time < self.pain_finished && deathtype != DEATH_KILL.m_id)
+ //if(time < this.pain_finished && deathtype != DEATH_KILL.m_id)
//return;
- if(time < self.spawnshieldtime && deathtype != DEATH_KILL.m_id)
+ if(time < this.spawnshieldtime && deathtype != DEATH_KILL.m_id)
return;
- if(deathtype == DEATH_FALL.m_id && self.draggedby != world)
+ if(deathtype == DEATH_FALL.m_id && this.draggedby != world)
return;
vector v;
float take, save;
- v = healtharmor_applydamage(100, self.armorvalue / 100, deathtype, damage);
+ v = healtharmor_applydamage(100, this.armorvalue / 100, deathtype, damage);
take = v_x;
save = v_y;
damage_take = take;
frag_attacker = attacker;
frag_deathtype = deathtype;
- Monster mon = get_monsterinfo(self.monsterid);
- mon.mr_pain(mon);
+ Monster mon = get_monsterinfo(this.monsterid);
+ mon.mr_pain(mon, this);
take = damage_take;
if(take)
{
- self.health -= take;
- Monster_Sound(monstersound_pain, 1.2, true, CH_PAIN);
+ this.health -= take;
+ Monster_Sound(this, monstersound_pain, 1.2, true, CH_PAIN);
}
- if(self.sprite)
- WaypointSprite_UpdateHealth(self.sprite, self.health);
+ if(this.sprite)
+ WaypointSprite_UpdateHealth(this.sprite, this.health);
- self.dmg_time = time;
+ this.dmg_time = time;
if(sound_allowed(MSG_BROADCAST, attacker) && deathtype != DEATH_DROWN.m_id)
- spamsound (self, CH_PAIN, SND(BODYIMPACT1), VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER
+ spamsound (this, CH_PAIN, SND(BODYIMPACT1), VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER
- self.velocity += force * self.damageforcescale;
+ this.velocity += force * this.damageforcescale;
if(deathtype != DEATH_DROWN.m_id && take)
{
- Violence_GibSplash_At(hitloc, force, 2, bound(0, take, 200) / 16, self, attacker);
+ Violence_GibSplash_At(hitloc, force, 2, bound(0, take, 200) / 16, this, attacker);
if (take > 50)
- Violence_GibSplash_At(hitloc, force * -0.1, 3, 1, self, attacker);
+ Violence_GibSplash_At(hitloc, force * -0.1, 3, 1, this, attacker);
if (take > 100)
- Violence_GibSplash_At(hitloc, force * -0.2, 3, 1, self, attacker);
+ Violence_GibSplash_At(hitloc, force * -0.2, 3, 1, this, attacker);
}
- if(self.health <= 0)
+ if(this.health <= 0)
{
if(deathtype == DEATH_KILL.m_id)
- self.candrop = false; // killed by mobkill command
+ this.candrop = false; // killed by mobkill command
// TODO: fix this?
- activator = attacker;
- other = self.enemy;
- SUB_UseTargets();
- self.target2 = self.oldtarget2; // reset to original target on death, incase we respawn
+ SUB_UseTargets(this, attacker, this.enemy);
+ this.target2 = this.oldtarget2; // reset to original target on death, incase we respawn
- Monster_Dead(attacker, (self.health <= -100 || deathtype == DEATH_KILL.m_id));
+ Monster_Dead(this, attacker, (this.health <= -100 || deathtype == DEATH_KILL.m_id));
- WaypointSprite_Kill(self.sprite);
+ WaypointSprite_Kill(this.sprite);
- frag_target = self;
- MUTATOR_CALLHOOK(MonsterDies, attacker);
+ MUTATOR_CALLHOOK(MonsterDies, this, attacker);
- if(self.health <= -100 || deathtype == DEATH_KILL.m_id) // check if we're already gibbed
+ if(this.health <= -100 || deathtype == DEATH_KILL.m_id) // check if we're already gibbed
{
- Violence_GibSplash(self, 1, 0.5, attacker);
+ Violence_GibSplash(this, 1, 0.5, attacker);
- self.think = SUB_Remove_self;
- self.nextthink = time + 0.1;
+ this.think = SUB_Remove_self;
+ this.nextthink = time + 0.1;
}
}
}
// don't check for enemies, just keep walking in a straight line
-void Monster_Move_2D(float mspeed, float allow_jumpoff)
-{SELFPARAM();
- if(gameover || (round_handler_IsActive() && !round_handler_IsRoundStarted()) || self.draggedby != world || time < game_starttime || (autocvar_g_campaign && !campaign_bots_may_start) || time < self.spawn_time)
+void Monster_Move_2D(entity this, float mspeed, bool allow_jumpoff)
+{
+ if(gameover || (round_handler_IsActive() && !round_handler_IsRoundStarted()) || this.draggedby != world || time < game_starttime || (autocvar_g_campaign && !campaign_bots_may_start) || time < this.spawn_time)
{
mspeed = 0;
- if(time >= self.spawn_time)
- setanim(self, self.anim_idle, true, false, false);
- movelib_brake_simple(0.6);
+ if(time >= this.spawn_time)
+ setanim(this, this.anim_idle, true, false, false);
+ movelib_brake_simple(this, 0.6);
return;
}
float reverse = false;
vector a, b;
- makevectors(self.angles);
- a = self.origin + '0 0 16';
- b = self.origin + '0 0 16' + v_forward * 32;
+ makevectors(this.angles);
+ a = this.origin + '0 0 16';
+ b = this.origin + '0 0 16' + v_forward * 32;
- traceline(a, b, MOVE_NORMAL, self);
+ traceline(a, b, MOVE_NORMAL, this);
if(trace_fraction != 1.0)
{
if(!allow_jumpoff)
{
a = b - '0 0 32';
- traceline(b, a, MOVE_WORLDONLY, self);
+ traceline(b, a, MOVE_WORLDONLY, this);
if(trace_fraction == 1.0)
reverse = true;
} */
if(reverse)
{
- self.angles_y = anglemods(self.angles_y - 180);
- makevectors(self.angles);
+ this.angles_y = anglemods(this.angles_y - 180);
+ makevectors(this.angles);
}
- movelib_move_simple_gravity(v_forward, mspeed, 1);
+ movelib_move_simple_gravity(this, v_forward, mspeed, 1);
- if(time > self.pain_finished)
- if(time > self.attack_finished_single[0])
- if(vlen(self.velocity) > 10)
- setanim(self, self.anim_walk, true, false, false);
+ if(time > this.pain_finished)
+ if(time > this.attack_finished_single[0])
+ if(vdist(this.velocity, >, 10))
+ setanim(this, this.anim_walk, true, false, false);
else
- setanim(self, self.anim_idle, true, false, false);
+ setanim(this, this.anim_idle, true, false, false);
}
-void Monster_Anim()
-{SELFPARAM();
- int deadbits = (self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
- if(IS_DEAD(self))
+void Monster_Anim(entity this)
+{
+ int deadbits = (this.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
+ if(IS_DEAD(this))
{
if (!deadbits)
{
deadbits = 0;
}
int animbits = deadbits;
- if(STAT(FROZEN, self))
+ if(STAT(FROZEN, this))
animbits |= ANIMSTATE_FROZEN;
- if(self.crouch)
+ if(this.crouch)
animbits |= ANIMSTATE_DUCK; // not that monsters can crouch currently...
- animdecide_setstate(self, animbits, false);
- animdecide_setimplicitstate(self, (IS_ONGROUND(self)));
+ animdecide_setstate(this, animbits, false);
+ animdecide_setimplicitstate(this, (IS_ONGROUND(this)));
/* // weapon entities for monsters?
- if (self.weaponentity)
+ if (this.weaponentity)
{
- updateanim(self.weaponentity);
- if (!self.weaponentity.animstate_override)
- setanim(self.weaponentity, self.weaponentity.anim_idle, true, false, false);
+ updateanim(this.weaponentity);
+ if (!this.weaponentity.animstate_override)
+ setanim(this.weaponentity, this.weaponentity.anim_idle, true, false, false);
}
*/
}
void Monster_Think()
{SELFPARAM();
- self.think = Monster_Think;
- self.nextthink = self.ticrate;
+ this.think = Monster_Think;
+ this.nextthink = this.ticrate;
- if(self.monster_lifetime)
- if(time >= self.monster_lifetime)
+ if(this.monster_lifetime)
+ if(time >= this.monster_lifetime)
{
- Damage(self, self, self, self.health + self.max_health, DEATH_KILL.m_id, self.origin, self.origin);
+ Damage(this, this, this, this.health + this.max_health, DEATH_KILL.m_id, this.origin, this.origin);
return;
}
- Monster mon = get_monsterinfo(self.monsterid);
- if(mon.mr_think(mon))
- Monster_Move(self.speed2, self.speed, self.stopspeed);
+ Monster mon = get_monsterinfo(this.monsterid);
+ if(mon.mr_think(mon, this))
+ Monster_Move(this, this.speed2, this.speed, this.stopspeed);
- Monster_Anim();
+ Monster_Anim(this);
- CSQCMODEL_AUTOUPDATE(self);
+ CSQCMODEL_AUTOUPDATE(this);
}
-float Monster_Spawn_Setup()
-{SELFPARAM();
- Monster mon = get_monsterinfo(self.monsterid);
- mon.mr_setup(mon);
+bool Monster_Spawn_Setup(entity this)
+{
+ Monster mon = Monsters_from(this.monsterid);
+ mon.mr_setup(mon, this);
// ensure some basic needs are met
- if(!self.health) { self.health = 100; }
- if(!self.armorvalue) { self.armorvalue = bound(0.2, 0.5 * MONSTER_SKILLMOD(self), 0.9); }
- if(!self.target_range) { self.target_range = autocvar_g_monsters_target_range; }
- if(!self.respawntime) { self.respawntime = autocvar_g_monsters_respawn_delay; }
- if(!self.monster_moveflags) { self.monster_moveflags = MONSTER_MOVE_WANDER; }
- if(!self.attack_range) { self.attack_range = autocvar_g_monsters_attack_range; }
- if(!self.damageforcescale) { self.damageforcescale = autocvar_g_monsters_damageforcescale; }
-
- if(!(self.spawnflags & MONSTERFLAG_RESPAWNED))
+ if(!this.health) { this.health = 100; }
+ if(!this.armorvalue) { this.armorvalue = bound(0.2, 0.5 * MONSTER_SKILLMOD(this), 0.9); }
+ if(!this.target_range) { this.target_range = autocvar_g_monsters_target_range; }
+ if(!this.respawntime) { this.respawntime = autocvar_g_monsters_respawn_delay; }
+ if(!this.monster_moveflags) { this.monster_moveflags = MONSTER_MOVE_WANDER; }
+ if(!this.attack_range) { this.attack_range = autocvar_g_monsters_attack_range; }
+ if(!this.damageforcescale) { this.damageforcescale = autocvar_g_monsters_damageforcescale; }
+
+ if(!(this.spawnflags & MONSTERFLAG_RESPAWNED))
{
- Monster_Miniboss_Check();
- self.health *= MONSTER_SKILLMOD(self);
+ Monster_Miniboss_Check(this);
+ this.health *= MONSTER_SKILLMOD(this);
- if(!self.skin)
- self.skin = rint(random() * 4);
+ if(!this.skin)
+ this.skin = rint(random() * 4);
}
- self.max_health = self.health;
- self.pain_finished = self.nextthink;
+ this.max_health = this.health;
+ this.pain_finished = this.nextthink;
- if(IS_PLAYER(self.monster_follow))
- self.effects |= EF_DIMLIGHT;
+ if(IS_PLAYER(this.monster_follow))
+ this.effects |= EF_DIMLIGHT;
- if(!self.wander_delay) { self.wander_delay = 2; }
- if(!self.wander_distance) { self.wander_distance = 600; }
+ if(!this.wander_delay) { this.wander_delay = 2; }
+ if(!this.wander_distance) { this.wander_distance = 600; }
- Monster_Sounds_Precache();
- Monster_Sounds_Update();
+ Monster_Sounds_Precache(this);
+ Monster_Sounds_Update(this);
if(teamplay)
- self.monster_attack = true; // we can have monster enemies in team games
+ this.monster_attack = true; // we can have monster enemies in team games
- Monster_Sound(monstersound_spawn, 0, false, CH_VOICE);
+ Monster_Sound(this, monstersound_spawn, 0, false, CH_VOICE);
if(autocvar_g_monsters_healthbars)
{
- entity wp = WaypointSprite_Spawn(WP_Monster, 0, 1024, self, '0 0 1' * (self.maxs.z + 15), world, self.team, self, sprite, true, RADARICON_DANGER);
- wp.wp_extra = self.monsterid;
- wp.colormod = ((self.team) ? Team_ColorRGB(self.team) : '1 0 0');
- if(!(self.spawnflags & MONSTERFLAG_INVINCIBLE))
+ entity wp = WaypointSprite_Spawn(WP_Monster, 0, 1024, this, '0 0 1' * (this.maxs.z + 15), world, this.team, this, sprite, true, RADARICON_DANGER);
+ wp.wp_extra = this.monsterid;
+ wp.colormod = ((this.team) ? Team_ColorRGB(this.team) : '1 0 0');
+ if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE))
{
- WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
- WaypointSprite_UpdateHealth(self.sprite, self.health);
+ WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health);
+ WaypointSprite_UpdateHealth(this.sprite, this.health);
}
}
- self.think = Monster_Think;
- self.nextthink = time + self.ticrate;
+ this.think = Monster_Think;
+ this.nextthink = time + this.ticrate;
- if(MUTATOR_CALLHOOK(MonsterSpawn))
+ if(MUTATOR_CALLHOOK(MonsterSpawn, this))
return false;
return true;
}
-bool Monster_Spawn(int mon_id)
-{SELFPARAM();
+bool Monster_Spawn(entity this, int mon_id)
+{
// setup the basic required properties for a monster
- entity mon = get_monsterinfo(mon_id);
+ entity mon = Monsters_from(mon_id);
if(!mon.monsterid) { return false; } // invalid monster
- if(!autocvar_g_monsters) { Monster_Remove(self); return false; }
+ if(!autocvar_g_monsters) { Monster_Remove(this); return false; }
- if(Monster_Appear_Check(self, mon_id)) { return true; } // return true so the monster isn't removed
+ if(Monster_Appear_Check(this, mon_id)) { return true; } // return true so the monster isn't removed
- if(!self.monster_skill)
- self.monster_skill = cvar("g_monsters_skill");
+ if(!this.monster_skill)
+ this.monster_skill = cvar("g_monsters_skill");
// support for quake style removing monsters based on skill
- if(self.monster_skill == MONSTER_SKILL_EASY) if(self.spawnflags & MONSTERSKILL_NOTEASY) { Monster_Remove(self); return false; }
- if(self.monster_skill == MONSTER_SKILL_MEDIUM) if(self.spawnflags & MONSTERSKILL_NOTMEDIUM) { Monster_Remove(self); return false; }
- if(self.monster_skill == MONSTER_SKILL_HARD) if(self.spawnflags & MONSTERSKILL_NOTHARD) { Monster_Remove(self); return false; }
+ if(this.monster_skill == MONSTER_SKILL_EASY) if(this.spawnflags & MONSTERSKILL_NOTEASY) { Monster_Remove(this); return false; }
+ if(this.monster_skill == MONSTER_SKILL_MEDIUM) if(this.spawnflags & MONSTERSKILL_NOTMEDIUM) { Monster_Remove(this); return false; }
+ if(this.monster_skill == MONSTER_SKILL_HARD) if(this.spawnflags & MONSTERSKILL_NOTHARD) { Monster_Remove(this); return false; }
- if(self.team && !teamplay)
- self.team = 0;
+ if(this.team && !teamplay)
+ this.team = 0;
- if(!(self.spawnflags & MONSTERFLAG_SPAWNED)) // naturally spawned monster
- if(!(self.spawnflags & MONSTERFLAG_RESPAWNED)) // don't count re-spawning monsters either
+ if(!(this.spawnflags & MONSTERFLAG_SPAWNED)) // naturally spawned monster
+ if(!(this.spawnflags & MONSTERFLAG_RESPAWNED)) // don't count re-spawning monsters either
monsters_total += 1;
- setmodel(self, mon.m_model);
- self.flags = FL_MONSTER;
- self.classname = "monster";
- self.takedamage = DAMAGE_AIM;
- self.bot_attack = true;
- self.iscreature = true;
- self.teleportable = true;
- self.damagedbycontents = true;
- self.monsterid = mon_id;
- self.event_damage = Monster_Damage;
- self.touch = Monster_Touch;
- self.use = Monster_Use;
- self.solid = SOLID_BBOX;
- self.movetype = MOVETYPE_WALK;
- self.spawnshieldtime = time + autocvar_g_monsters_spawnshieldtime;
- self.enemy = world;
- self.velocity = '0 0 0';
- self.moveto = self.origin;
- self.pos1 = self.origin;
- self.pos2 = self.angles;
- self.reset = Monster_Reset;
- self.netname = mon.netname;
- self.monster_attackfunc = mon.monster_attackfunc;
- self.monster_name = mon.monster_name;
- self.candrop = true;
- self.view_ofs = '0 0 0.7' * (self.maxs_z * 0.5);
- self.oldtarget2 = self.target2;
- self.pass_distance = 0;
- self.deadflag = DEAD_NO;
- self.noalign = ((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM));
- self.spawn_time = time;
- self.gravity = 1;
- self.monster_moveto = '0 0 0';
- self.monster_face = '0 0 0';
- self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP;
-
- if(!self.scale) { self.scale = 1; }
- if(autocvar_g_monsters_edit) { self.grab = 1; }
- if(autocvar_g_fullbrightplayers) { self.effects |= EF_FULLBRIGHT; }
- if(autocvar_g_nodepthtestplayers) { self.effects |= EF_NODEPTHTEST; }
- if(mon.spawnflags & MONSTER_TYPE_SWIM) { self.flags |= FL_SWIM; }
+ setmodel(this, mon.m_model);
+ this.flags = FL_MONSTER;
+ this.classname = "monster";
+ this.takedamage = DAMAGE_AIM;
+ this.bot_attack = true;
+ this.iscreature = true;
+ this.teleportable = true;
+ this.damagedbycontents = true;
+ this.monsterid = mon_id;
+ this.event_damage = Monster_Damage;
+ this.touch = Monster_Touch;
+ this.use = Monster_Use;
+ this.solid = SOLID_BBOX;
+ this.movetype = MOVETYPE_WALK;
+ this.spawnshieldtime = time + autocvar_g_monsters_spawnshieldtime;
+ this.enemy = world;
+ this.velocity = '0 0 0';
+ this.moveto = this.origin;
+ this.pos1 = this.origin;
+ this.pos2 = this.angles;
+ this.reset = Monster_Reset;
+ this.netname = mon.netname;
+ this.monster_attackfunc = mon.monster_attackfunc;
+ this.monster_name = mon.monster_name;
+ this.candrop = true;
+ this.view_ofs = '0 0 0.7' * (this.maxs_z * 0.5);
+ this.oldtarget2 = this.target2;
+ this.pass_distance = 0;
+ this.deadflag = DEAD_NO;
+ this.noalign = ((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM));
+ this.spawn_time = time;
+ this.gravity = 1;
+ this.monster_moveto = '0 0 0';
+ this.monster_face = '0 0 0';
+ this.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP;
+
+ if(!this.scale) { this.scale = 1; }
+ if(autocvar_g_monsters_edit) { this.grab = 1; }
+ if(autocvar_g_fullbrightplayers) { this.effects |= EF_FULLBRIGHT; }
+ if(autocvar_g_nodepthtestplayers) { this.effects |= EF_NODEPTHTEST; }
+ if(mon.spawnflags & MONSTER_TYPE_SWIM) { this.flags |= FL_SWIM; }
+
+ if(autocvar_g_playerclip_collisions)
+ this.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
if(mon.spawnflags & MONSTER_TYPE_FLY)
{
- self.flags |= FL_FLY;
- self.movetype = MOVETYPE_FLY;
+ this.flags |= FL_FLY;
+ this.movetype = MOVETYPE_FLY;
}
- if(!(self.spawnflags & MONSTERFLAG_RESPAWNED))
+ if(!(this.spawnflags & MONSTERFLAG_RESPAWNED))
{
if(mon.spawnflags & MONSTER_SIZE_BROKEN)
- self.scale *= 1.3;
+ this.scale *= 1.3;
if(mon.spawnflags & MONSTER_SIZE_QUAKE)
if(autocvar_g_monsters_quake_resize)
- self.scale *= 1.3;
+ this.scale *= 1.3;
}
- setsize(self, mon.mins * self.scale, mon.maxs * self.scale);
+ setsize(this, mon.mins * this.scale, mon.maxs * this.scale);
- self.ticrate = bound(sys_frametime, ((!self.ticrate) ? autocvar_g_monsters_think_delay : self.ticrate), 60);
+ this.ticrate = bound(sys_frametime, ((!this.ticrate) ? autocvar_g_monsters_think_delay : this.ticrate), 60);
- Monster_UpdateModel();
+ Monster_UpdateModel(this);
- if(!Monster_Spawn_Setup())
+ if(!Monster_Spawn_Setup(this))
{
- Monster_Remove(self);
+ Monster_Remove(this);
return false;
}
- if(!self.noalign)
+ if(!this.noalign)
{
- setorigin(self, self.origin + '0 0 20');
- tracebox(self.origin + '0 0 64', self.mins, self.maxs, self.origin - '0 0 10000', MOVE_WORLDONLY, self);
- setorigin(self, trace_endpos);
+ setorigin(this, this.origin + '0 0 20');
+ tracebox(this.origin + '0 0 64', this.mins, this.maxs, this.origin - '0 0 10000', MOVE_WORLDONLY, this);
+ setorigin(this, trace_endpos);
}
- if(!(self.spawnflags & MONSTERFLAG_RESPAWNED))
- monster_setupcolors(self);
+ if(!(this.spawnflags & MONSTERFLAG_RESPAWNED))
+ monster_setupcolors(this);
- CSQCMODEL_AUTOINIT(self);
+ CSQCMODEL_AUTOINIT(this);
return true;
}