if(e && e.monster_loot)
{
e.noalign = true;
- e.monster_loot(e);
+ StartItem(e, e.monster_loot);
e.gravity = 1;
set_movetype(e, MOVETYPE_TOSS);
e.reset = SUB_Remove;
return false;
}
- traceline(this.origin + this.view_ofs, targ.origin, MOVE_NOMONSTERS, this);
+ vector targ_origin = ((targ.absmin + targ.absmax) * 0.5);
+ traceline(this.origin + this.view_ofs, targ_origin, MOVE_NOMONSTERS, this);
- if(trace_fraction < 1)
+ if(trace_fraction < 1 && trace_ent != targ)
return false; // solid
if(autocvar_g_monsters_target_infront || (this.spawnflags & MONSTERFLAG_INFRONT))
void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
{
// update goal entity if lost
- if(this.target2 && this.goalentity.targetname != this.target2) { this.goalentity = find(NULL, targetname, this.target2); }
+ if(this.target2 && this.target2 != "" && this.goalentity.targetname != this.target2)
+ this.goalentity = find(NULL, targetname, this.target2);
if(STAT(FROZEN, this) == 2)
{
else
{
entity e = this.goalentity; //find(NULL, targetname, this.target2);
- if(e.target2)
+ if(e.target2 && e.target2 != "")
this.target2 = e.target2;
- else if(e.target) // compatibility
+ else if(e.target && e.target != "") // compatibility
this.target2 = e.target;
movelib_brake_simple(this, stpspeed);
totalspawned -= 1;
}
+ if(!gibbed && this.mdl_dead && this.mdl_dead != "")
+ _setmodel(this, this.mdl_dead);
+
this.event_damage = ((gibbed) ? func_null : Monster_Dead_Damage);
this.solid = SOLID_CORPSE;
this.takedamage = DAMAGE_AIM;
this.dmg_time = time;
- if(sound_allowed(MSG_BROADCAST, attacker) && deathtype != DEATH_DROWN.m_id)
- spamsound (this, CH_PAIN, SND(BODYIMPACT1), VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER
+ if(deathtype != DEATH_DROWN.m_id && deathtype != DEATH_FIRE.m_id && sound_allowed(MSG_BROADCAST, attacker))
+ spamsound (this, CH_PAIN, SND_BODYIMPACT1, VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER
this.velocity += force * this.damageforcescale;
if(!autocvar_g_monsters) { Monster_Remove(this); return false; }
if(!(this.spawnflags & MONSTERFLAG_RESPAWNED))
+ {
IL_PUSH(g_monsters, this);
+ if(this.mdl && this.mdl != "")
+ precache_model(this.mdl);
+ if(this.mdl_dead && this.mdl_dead != "")
+ precache_model(this.mdl_dead);
+ }
if(check_appear && Monster_Appear_Check(this, mon_id)) { return true; } // return true so the monster isn't removed
if(!(this.spawnflags & MONSTERFLAG_RESPAWNED)) // don't count re-spawning monsters either
monsters_total += 1;
- setmodel(this, mon.m_model);
+ if(this.mdl && this.mdl != "")
+ _setmodel(this, this.mdl);
+ else
+ setmodel(this, mon.m_model);
+
this.flags = FL_MONSTER;
this.classname = "monster";
this.takedamage = DAMAGE_AIM;