From a77c14223df1103793956a4f7522bd4b6f60dd40 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 3 Oct 2015 09:03:20 +1000 Subject: [PATCH] Monsters: remove MON_ACTION --- qcsrc/common/animdecide.qc | 2 +- qcsrc/common/monsters/monster.qh | 46 +++++++--------------- qcsrc/common/monsters/monster/mage.qc | 2 +- qcsrc/common/monsters/monster/shambler.qc | 2 +- qcsrc/common/monsters/monster/spider.qc | 2 +- qcsrc/common/monsters/monster/wyvern.qc | 2 +- qcsrc/common/monsters/monster/zombie.qc | 2 +- qcsrc/common/monsters/sv_monsters.qc | 15 ++++--- qcsrc/server/mutators/gamemode_invasion.qc | 15 ++++--- 9 files changed, 39 insertions(+), 49 deletions(-) diff --git a/qcsrc/common/animdecide.qc b/qcsrc/common/animdecide.qc index 7e670ee73..0db1a6afd 100644 --- a/qcsrc/common/animdecide.qc +++ b/qcsrc/common/animdecide.qc @@ -27,7 +27,7 @@ bool monsters_animoverride(entity e) if(!monster_id) { return false; } - MON_ACTION(monster_id, MR_ANIM); + monster_id.mr_anim(monster_id); vector none = '0 0 0'; e.anim_duckwalk = e.anim_walk; diff --git a/qcsrc/common/monsters/monster.qh b/qcsrc/common/monsters/monster.qh index 0fd247694..0a78b7772 100644 --- a/qcsrc/common/monsters/monster.qh +++ b/qcsrc/common/monsters/monster.qh @@ -27,13 +27,9 @@ const int MON_FLAG_RIDE = 4096; // monster can be ridden in special modes .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 */ @@ -46,34 +42,20 @@ CLASS(Monster, Object) 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 diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index 63ebffc9c..7194b7e84 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -18,7 +18,7 @@ ENDCLASS(Mage) REGISTER_MONSTER(MAGE, NEW(Mage)) { #ifndef MENUQC - MON_ACTION(this, MR_PRECACHE); + this.mr_precache(this); #endif } diff --git a/qcsrc/common/monsters/monster/shambler.qc b/qcsrc/common/monsters/monster/shambler.qc index 2c6c74b0e..40d0ef6a3 100644 --- a/qcsrc/common/monsters/monster/shambler.qc +++ b/qcsrc/common/monsters/monster/shambler.qc @@ -18,7 +18,7 @@ ENDCLASS(Shambler) REGISTER_MONSTER(SHAMBLER, NEW(Shambler)) { #ifndef MENUQC - MON_ACTION(this, MR_PRECACHE); + this.mr_precache(this); #endif } diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index 539e66ad2..8f3bc1178 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -18,7 +18,7 @@ ENDCLASS(Spider) REGISTER_MONSTER(SPIDER, NEW(Spider)) { #ifndef MENUQC - MON_ACTION(this, MR_PRECACHE); + this.mr_precache(this); #endif } diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index 17b0a96d7..2b1c035ed 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -18,7 +18,7 @@ ENDCLASS(Wyvern) REGISTER_MONSTER(WYVERN, NEW(Wyvern)) { #ifndef MENUQC - MON_ACTION(this, MR_PRECACHE); + this.mr_precache(this); #endif } diff --git a/qcsrc/common/monsters/monster/zombie.qc b/qcsrc/common/monsters/monster/zombie.qc index 0e06e4ae8..b9619be19 100644 --- a/qcsrc/common/monsters/monster/zombie.qc +++ b/qcsrc/common/monsters/monster/zombie.qc @@ -18,7 +18,7 @@ ENDCLASS(Zombie) REGISTER_MONSTER(ZOMBIE, NEW(Zombie)) { #ifndef MENUQC - MON_ACTION(this, MR_PRECACHE); + this.mr_precache(this); #endif } diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index e3e1de4b4..34bd6e5aa 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -471,7 +471,8 @@ void Monster_UpdateModel() 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() @@ -1037,7 +1038,8 @@ void Monster_Dead(entity attacker, float gibbed) 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'); @@ -1070,7 +1072,8 @@ void Monster_Damage(entity inflictor, entity attacker, float damage, int deathty 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) @@ -1231,7 +1234,8 @@ void Monster_Think() 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(); @@ -1241,7 +1245,8 @@ void Monster_Think() 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; } diff --git a/qcsrc/server/mutators/gamemode_invasion.qc b/qcsrc/server/mutators/gamemode_invasion.qc index bb36e2654..6bf1b7790 100644 --- a/qcsrc/server/mutators/gamemode_invasion.qc +++ b/qcsrc/server/mutators/gamemode_invasion.qc @@ -13,8 +13,10 @@ void spawnfunc_invasion_spawnpoint() 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) @@ -430,9 +432,10 @@ void invasion_DelayedInit() // Do this check with a delay so we can wait for tea 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; @@ -442,7 +445,7 @@ void invasion_Initialize() 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); } } -- 2.39.2