]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/monster/zombie.qc
Monsters: make mage more player friendly
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / zombie.qc
index c1bf45389ab795233aa8d036188c1bd0963b7092..0e06e4ae8ee1ca6ceb3fae5d1f1276a0704a22d1 100644 (file)
@@ -1,15 +1,31 @@
-#ifdef REGISTER_MONSTER
-REGISTER_MONSTER(
-/* MON_##id   */ ZOMBIE,
-/* functions  */ M_Zombie, M_Zombie_Attack,
-/* spawnflags */ MON_FLAG_MELEE,
-/* mins,maxs  */ '-18 -18 -25', '18 18 47',
-/* model      */ "zombie.dpm",
-/* netname    */ "zombie",
-/* fullname   */ _("Zombie")
-);
-
-#else
+#ifndef ZOMBIE_H
+#define ZOMBIE_H
+
+#ifndef MENUQC
+MODEL(MON_ZOMBIE, "models/monsters/zombie.dpm");
+#endif
+
+CLASS(Zombie, Monster)
+    ATTRIB(Zombie, spawnflags, int, MON_FLAG_MELEE | MON_FLAG_RIDE);
+    ATTRIB(Zombie, mins, vector, '-18 -18 -25');
+    ATTRIB(Zombie, maxs, vector, '18 18 47');
+#ifndef MENUQC
+    ATTRIB(Zombie, m_model, Model, MDL_MON_ZOMBIE);
+#endif
+    ATTRIB(Zombie, netname, string, "zombie");
+    ATTRIB(Zombie, monster_name, string, _("Zombie"));
+ENDCLASS(Zombie)
+
+REGISTER_MONSTER(ZOMBIE, NEW(Zombie)) {
+#ifndef MENUQC
+    MON_ACTION(this, MR_PRECACHE);
+#endif
+}
+
+#endif
+
+#ifdef IMPLEMENTATION
+
 #ifdef SVQC
 float autocvar_g_monster_zombie_health;
 float autocvar_g_monster_zombie_damageforcescale = 0.55;
@@ -58,7 +74,7 @@ const float zombie_anim_spawn                         = 30;
 */
 
 void M_Zombie_Attack_Leap_Touch()
-{
+{SELFPARAM();
        if (self.health <= 0)
                return;
 
@@ -81,7 +97,7 @@ void M_Zombie_Attack_Leap_Touch()
 }
 
 void M_Zombie_Defend_Block_End()
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
 
@@ -90,7 +106,7 @@ void M_Zombie_Defend_Block_End()
 }
 
 float M_Zombie_Defend_Block()
-{
+{SELFPARAM();
        self.armorvalue = 0.9;
        self.state = MONSTER_ATTACK_MELEE; // freeze monster
        self.attack_finished_single = time + 2.1;
@@ -102,8 +118,8 @@ float M_Zombie_Defend_Block()
        return true;
 }
 
-float M_Zombie_Attack(float attack_type)
-{
+float M_Zombie_Attack(float attack_type, entity targ)
+{SELFPARAM();
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
@@ -133,28 +149,27 @@ float M_Zombie_Attack(float attack_type)
        return false;
 }
 
-void spawnfunc_monster_zombie() { Monster_Spawn(MON_ZOMBIE); }
+void spawnfunc_monster_zombie() { Monster_Spawn(MON_ZOMBIE.monsterid); }
 #endif // SVQC
 
-bool M_Zombie(int req)
-{
-       switch(req)
-       {
                #ifdef SVQC
-               case MR_THINK:
+               METHOD(Zombie, mr_think, bool(Zombie thismon))
                {
+                       SELFPARAM();
                        if(time >= self.spawn_time)
                                self.damageforcescale = autocvar_g_monster_zombie_damageforcescale;
                        return true;
                }
-               case MR_PAIN:
+               METHOD(Zombie, mr_pain, bool(Zombie thismon))
                {
+                       SELFPARAM();
                        self.pain_finished = time + 0.34;
                        setanim(self, ((random() > 0.5) ? self.anim_pain1 : self.anim_pain2), true, true, false);
                        return true;
                }
-               case MR_DEATH:
+               METHOD(Zombie, mr_death, bool(Zombie thismon))
                {
+                       SELFPARAM();
                        self.armorvalue = autocvar_g_monsters_armor_blockpercent;
 
                        setanim(self, ((random() > 0.5) ? self.anim_die1 : self.anim_die2), false, true, true);
@@ -162,8 +177,9 @@ bool M_Zombie(int req)
                }
                #endif
                #ifndef MENUQC
-               case MR_ANIM:
+               METHOD(Zombie, mr_anim, bool(Zombie thismon))
                {
+                       SELFPARAM();
                        vector none = '0 0 0';
                        self.anim_die1 = animfixfps(self, '9 1 0.5', none); // 2 seconds
                        self.anim_die2 = animfixfps(self, '12 1 0.5', none); // 2 seconds
@@ -184,7 +200,7 @@ bool M_Zombie(int req)
                }
                #endif
                #ifdef SVQC
-               case MR_SETUP:
+               METHOD(Zombie, mr_setup, bool(Zombie thismon))
                {
                        if(!self.health) self.health = (autocvar_g_monster_zombie_health);
                        if(!self.speed) { self.speed = (autocvar_g_monster_zombie_speed_walk); }
@@ -197,6 +213,7 @@ bool M_Zombie(int req)
                        self.spawnflags |= MONSTER_RESPAWN_DEATHPOINT;
 
                        self.monster_loot = spawnfunc_item_health_medium;
+                       self.monster_attackfunc = M_Zombie_Attack;
                        self.spawnshieldtime = self.spawn_time;
                        self.respawntime = 0.2;
                        self.damageforcescale = 0.0001; // no push while spawning
@@ -206,15 +223,10 @@ bool M_Zombie(int req)
 
                        return true;
                }
-               case MR_PRECACHE:
+               METHOD(Zombie, mr_precache, bool(Zombie thismon))
                {
-                       precache_model("models/monsters/zombie.dpm");
                        return true;
                }
                #endif
-       }
-
-       return true;
-}
 
-#endif // REGISTER_MONSTER
+#endif