.vector anim_walk;
.vector anim_spawn;
-bool m_null(entity thismon, int) { return false; }
-bool m_new(entity thismon, int);
-
/** If you register a new monster, make sure to add it to all.inc */
CLASS(Monster, Object)
ATTRIB(Monster, monsterid, int, 0)
- ATTRIB(Monster, monster_func, bool(Monster, int), m_new)
/** attributes */
ATTRIB(Monster, spawnflags, int, 0)
/** human readable name */
ATTRIB(Monster, mins, vector, '-0 -0 -0')
/** hitbox size */
ATTRIB(Monster, maxs, vector, '0 0 0')
-ENDCLASS(Monster)
-
-// monster requests
-const int MR_SETUP = 1; // (SERVER) setup monster data
-.bool(Monster this) mr_setup;
-const int MR_THINK = 2; // (SERVER) logic to run every frame
-.bool(Monster this) mr_think;
-const int MR_DEATH = 3; // (SERVER) called when monster dies
-.bool(Monster this) mr_death;
-const int MR_PRECACHE = 4; // (BOTH) precaches models/sounds used by this monster
-.bool(Monster this) mr_precache;
-const int MR_PAIN = 5; // (SERVER) called when monster is damaged
-.bool(Monster this) mr_pain;
-const int MR_ANIM = 6; // (BOTH?) sets animations for monster
-.bool(Monster this) mr_anim;
+
+ /** (SERVER) setup monster data */
+ METHOD(Monster, mr_setup, bool(Monster this)) { return false; }
+ /** (SERVER) logic to run every frame */
+ METHOD(Monster, mr_think, bool(Monster this)) { return false; }
+ /** (SERVER) called when monster dies */
+ METHOD(Monster, mr_death, bool(Monster this)) { return false; }
+ /** (BOTH) precaches models/sounds used by this monster */
+ METHOD(Monster, mr_precache, bool(Monster this)) { return false; }
+ /** (SERVER) called when monster is damaged */
+ METHOD(Monster, mr_pain, bool(Monster this)) { return false; }
+ /** (BOTH?) sets animations for monster */
+ METHOD(Monster, mr_anim, bool(Monster this)) { return false; }
-// other useful macros
-#define MON_ACTION(mon,mrequest) mon.monster_func(mon, mrequest)
-#define _MON_ACTION(mon,mrequest) MON_ACTION(get_monsterinfo(mon), mrequest)
-
-bool m_new(entity this, int req) {
- if (req == MR_SETUP) return this.mr_setup ? this.mr_setup(this) : false;
- if (req == MR_THINK) return this.mr_think ? this.mr_think(this) : false;
- if (req == MR_DEATH) return this.mr_death ? this.mr_death(this) : false;
- if (req == MR_PRECACHE) return this.mr_precache ? this.mr_precache(this) : false;
- if (req == MR_PAIN) return this.mr_pain ? this.mr_pain(this) : false;
- if (req == MR_ANIM) return this.mr_anim ? this.mr_anim(this) : false;
- return false;
-}
+ENDCLASS(Monster)
#endif
self.anim_die2 = animfixfps(self, '9 1 0.01', '0 0 0');*/
// then get the real values
- _MON_ACTION(self.monsterid, MR_ANIM);
+ Monster mon = get_monsterinfo(self.monsterid);
+ mon.mr_anim(mon);
}
void Monster_Touch()
CSQCModel_UnlinkEntity();
- _MON_ACTION(self.monsterid, MR_DEATH);
+ 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');
damage_take = take;
frag_attacker = attacker;
frag_deathtype = deathtype;
- _MON_ACTION(self.monsterid, MR_PAIN);
+ Monster mon = get_monsterinfo(self.monsterid);
+ mon.mr_pain(mon);
take = damage_take;
if(take)
return;
}
- if(_MON_ACTION(self.monsterid, MR_THINK))
+ Monster mon = get_monsterinfo(self.monsterid);
+ if(mon.mr_think(mon))
Monster_Move(self.speed2, self.speed, self.stopspeed);
Monster_Anim();
float Monster_Spawn_Setup()
{SELFPARAM();
- _MON_ACTION(self.monsterid, MR_SETUP);
+ Monster mon = get_monsterinfo(self.monsterid);
+ mon.mr_setup(mon);
// ensure some basic needs are met
if(!self.health) { self.health = 100; }
self.classname = "invasion_spawnpoint";
if(autocvar_g_invasion_zombies_only) // precache only if it hasn't been already
- if(self.monsterid)
- _MON_ACTION(self.monsterid, MR_PRECACHE);
+ if(self.monsterid) {
+ Monster mon = get_monsterinfo(self.monsterid);
+ mon.mr_precache(mon);
+ }
}
float invasion_PickMonster(float supermonster_count)
void invasion_Initialize()
{
- if(autocvar_g_invasion_zombies_only)
- MON_ACTION(MON_ZOMBIE, MR_PRECACHE);
- else
+ if(autocvar_g_invasion_zombies_only) {
+ Monster mon = MON_ZOMBIE;
+ mon.mr_precache(mon);
+ } else
{
float i;
entity mon;
if((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM))
continue; // flying/swimming monsters not yet supported
- MON_ACTION(mon, MR_PRECACHE);
+ mon.mr_precache(mon);
}
}