if((targ == this)
|| (autocvar_g_monsters_lineofsight && !checkpvs(this.origin + this.view_ofs, targ)) // enemy cannot be seen
- || (IS_VEHICLE(targ) && !((REGISTRY_GET(Monsters, this.monsterid)).spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless
+ || (IS_VEHICLE(targ) && !(this.monsterdef.spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless
|| (time < game_starttime) // monsters do nothing before match has started
|| (targ.takedamage == DAMAGE_NO)
|| (game_stopped)
void Monster_Sounds_Precache(entity this)
{
- string m = (REGISTRY_GET(Monsters, this.monsterid)).m_model.model_str();
+ string m = this.monsterdef.m_model.model_str();
float globhandle, n, i;
string f;
this.anim_die2 = animfixfps(this, '9 1 0.01', '0 0 0');*/
// then get the real values
- Monster mon = REGISTRY_GET(Monsters, this.monsterid);
+ Monster mon = this.monsterdef;
mon.mr_anim(mon, this);
}
return true;
}
-void Monster_Respawn(entity this) { Monster_Spawn(this, true, this.monsterid); }
+void Monster_Respawn(entity this) { Monster_Spawn(this, true, this); }
.vector pos1, pos2;
void Monster_Appear(entity this, entity actor, entity trigger)
{
this.enemy = actor;
- Monster_Spawn(this, false, this.monsterid);
+ Monster_Spawn(this, false, this.monsterdef);
}
-bool Monster_Appear_Check(entity this, int monster_id)
+bool Monster_Appear_Check(entity this, Monster monster_id)
{
if(!(this.spawnflags & MONSTERFLAG_APPEAR))
return false;
setthink(this, func_null);
- this.monsterid = monster_id; // set so this monster is properly registered (otherwise, normal initialization is used)
+ this.monsterdef = 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
CSQCModel_UnlinkEntity(this);
- Monster mon = REGISTRY_GET(Monsters, this.monsterid);
+ Monster mon = this.monsterdef;
mon.mr_death(mon, this);
if(this.candrop && this.weapon)
float take = v.x;
//float save = v.y;
- Monster mon = REGISTRY_GET(Monsters, this.monsterid);
+ Monster mon = this.monsterdef;
take = mon.mr_pain(mon, this, take, attacker, deathtype);
if(take)
this.last_enemycheck = time + 1; // check for enemies every second
}
- Monster mon = REGISTRY_GET(Monsters, this.monsterid);
+ Monster mon = this.monsterdef;
if(mon.mr_think(mon, this))
{
Monster_Move(this, this.speed2, this.speed, this.stopspeed);
bool Monster_Spawn_Setup(entity this)
{
- Monster mon = REGISTRY_GET(Monsters, this.monsterid);
+ Monster mon = this.monsterdef;
mon.mr_setup(mon, this);
// ensure some basic needs are met
if(autocvar_g_monsters_healthbars)
{
entity wp = WaypointSprite_Spawn(WP_Monster, 0, 1024, this, '0 0 1' * (this.maxs.z + 15), NULL, this.team, this, sprite, true, RADARICON_DANGER);
- wp.wp_extra = this.monsterid;
+ wp.wp_extra = this.monsterdef.monsterid;
wp.colormod = ((this.team) ? Team_ColorRGB(this.team) : '1 0 0');
if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE))
{
return true;
}
-bool Monster_Spawn(entity this, bool check_appear, int mon_id)
+bool Monster_Spawn(entity this, bool check_appear, Monster mon)
{
// setup the basic required properties for a monster
- entity mon = REGISTRY_GET(Monsters, mon_id);
- if(!mon.monsterid) { return false; } // invalid monster
+ if(!mon || mon == MON_Null) { return false; } // invalid monster
if(!autocvar_g_monsters) { Monster_Remove(this); return false; }
if(!(this.spawnflags & MONSTERFLAG_RESPAWNED) && !(this.flags & FL_MONSTER))
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(check_appear && Monster_Appear_Check(this, mon)) { return true; } // return true so the monster isn't removed
if(!this.monster_skill)
this.monster_skill = cvar("g_monsters_skill");
if(!this.damagedbycontents)
IL_PUSH(g_damagedbycontents, this);
this.damagedbycontents = true;
- this.monsterid = mon_id;
+ this.monsterdef = mon;
this.event_damage = Monster_Damage;
this.event_heal = Monster_Heal;
settouch(this, Monster_Touch);