if(e && e.monster_loot)
{
e.noalign = true;
- WITH(entity, self, e, e.monster_loot(e));
+ WITHSELF(e, e.monster_loot(e));
e.gravity = 1;
e.movetype = MOVETYPE_TOSS;
e.reset = SUB_Remove;
|| (!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 && targ.BUTTON_CHAT)
+ || (!autocvar_g_monsters_typefrag && PHYS_INPUT_BUTTON_CHAT(targ))
|| (SAME_TEAM(targ, this))
|| (STAT(FROZEN, targ))
|| (targ.alpha != 0 && targ.alpha < 0.5)
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_self()
{
+ SELFPARAM();
Monster_Delay_Action(self);
}
|| (time < this.attack_finished_single[0])
) { return; }
- float targ_vlen = vlen(targ.origin - this.origin);
-
- if(targ_vlen <= this.attack_range)
+ if(vdist(targ.origin - this.origin, <=, this.attack_range))
{
bool attack_success = this.monster_attackfunc(MONSTER_ATTACK_MELEE, this, targ);
if(attack_success == 1)
return;
}
- if(targ_vlen > this.attack_range)
+ if(vdist(targ.origin - this.origin, >, this.attack_range))
{
float attack_success = this.monster_attackfunc(MONSTER_ATTACK_RANGED, this, targ);
if(attack_success == 1)
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(entity this)
return true;
}
-void Monster_Respawn() { SELFPARAM(); Monster_Spawn(self, self.monsterid); }
+void Monster_Respawn() { SELFPARAM(); Monster_Spawn(this, this.monsterid); }
void Monster_Dead_Fade(entity this)
{
}
}
-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 this, entity targ)
|| (this.enemy.flags & FL_NOTARGET)
|| (this.enemy.alpha < 0.5 && this.enemy.alpha != 0)
|| (this.enemy.takedamage == DAMAGE_NO)
- || (vlen(this.origin - targ_origin) > this.target_range)
+ || (vdist(this.origin - targ_origin, >, this.target_range))
|| ((trace_fraction < 1) && (trace_ent != this.enemy)))
{
this.enemy = world;
Unfreeze(this);
this.health = 0;
if(this.event_damage)
- this.event_damage(this, this.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, this.origin, '0 0 0');
+ this.event_damage(this, this, this.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, this.origin, '0 0 0');
}
else if ( this.revive_progress <= 0 )
if(!(this.spawnflags & MONSTERFLAG_FLY_VERTICAL) && !(this.flags & FL_SWIM))
this.moveto_z = this.origin_z;
- if(vlen(this.origin - this.moveto) > 100)
+ if(vdist(this.origin - this.moveto, >, 100))
{
float do_run = (this.enemy || this.monster_moveto);
if(IS_ONGROUND(this) || ((this.flags & FL_FLY) || (this.flags & FL_SWIM)))
if(time > this.pain_finished) // TODO: use anim_finished instead!
if(!this.state)
if(time > this.anim_finished)
- if(vlen(this.velocity) > 10)
+ if(vdist(this.velocity, >, 10))
setanim(this, ((do_run) ? this.anim_run : this.anim_walk), true, false, false);
else
setanim(this, this.anim_idle, true, false, false);
if(time > this.anim_finished)
if(time > this.pain_finished)
if(!this.state)
- if(vlen(this.velocity) <= 30)
+ if(vdist(this.velocity, <=, 30))
setanim(this, this.anim_idle, true, false, false);
}
void Monster_Remove(entity this)
{
+ if(IS_CLIENT(this))
+ return; // don't remove it?
+
.entity weaponentity = weaponentities[0];
if(!this) { return; }
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(self);
+ 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, 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);
}
bool Monster_Appear_Check(entity this, int monster_id)
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 <= -50) // 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;
}
}
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, self);
+ Monster mon = get_monsterinfo(this.monsterid);
+ mon.mr_pain(mon, this);
take = damage_take;
if(take)
{
- self.health -= take;
- Monster_Sound(self, 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(self, 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;
}
}
}
if(time > this.pain_finished)
if(time > this.attack_finished_single[0])
- if(vlen(this.velocity) > 10)
+ if(vdist(this.velocity, >, 10))
setanim(this, this.anim_walk, true, false, false);
else
setanim(this, this.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, self))
- Monster_Move(self, 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(self);
+ Monster_Anim(this);
- CSQCMODEL_AUTOUPDATE(self);
+ CSQCMODEL_AUTOUPDATE(this);
}
bool Monster_Spawn_Setup(entity this)
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)
{
this.flags |= FL_FLY;