]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/monster/zombie.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / zombie.qc
index 7b04cfcd2936754e040afdc6f17a39caf7ecc543..307737ff81d0a9e05155465af2eb3ba855f7bbd7 100644 (file)
@@ -2,7 +2,7 @@
 REGISTER_MONSTER(
 /* MON_##id   */ ZOMBIE,
 /* function   */ m_zombie,
-/* spawnflags */ 0,
+/* spawnflags */ MON_FLAG_MELEE,
 /* mins,maxs  */ '-18 -18 -25', '18 18 47',
 /* model      */ "zombie.dpm",
 /* netname    */ "zombie",
@@ -77,6 +77,29 @@ void zombie_attack_leap_touch()
                self.touch = MonsterTouch;
 }
 
+void zombie_blockend()
+{
+       if(self.health <= 0)
+               return;
+
+       self.frame = zombie_anim_blockend;
+       self.armorvalue = 0;
+       self.m_armor_blockpercent = autocvar_g_monsters_armor_blockpercent;
+}
+
+float zombie_block()
+{
+       self.frame = zombie_anim_blockstart;
+       self.armorvalue = 100;
+       self.m_armor_blockpercent = 0.9;
+       self.state = MONSTER_STATE_ATTACK_MELEE; // freeze monster
+       self.attack_finished_single = time + 2.1;
+       
+       defer(2, zombie_blockend);
+       
+       return TRUE;
+}
+
 float zombie_attack(float attack_type)
 {
        switch(attack_type)
@@ -92,18 +115,15 @@ float zombie_attack(float attack_type)
                        else
                                chosen_anim = zombie_anim_attackstanding3;
                        
-                       if(monster_melee(self.enemy, MON_CVAR(zombie, attack_melee_damage), chosen_anim, self.attack_range, MON_CVAR(zombie, attack_melee_delay), DEATH_MONSTER_ZOMBIE_MELEE, TRUE))
-                               return TRUE;
-                               
-                       return FALSE;
+                       if(random() < 0.3 && self.health < 75 && self.enemy.health > 10)
+                               return zombie_block();
+                       
+                       return monster_melee(self.enemy, MON_CVAR(zombie, attack_melee_damage), chosen_anim, self.attack_range, MON_CVAR(zombie, attack_melee_delay), DEATH_MONSTER_ZOMBIE_MELEE, TRUE);
                }
                case MONSTER_ATTACK_RANGED:
                {
                        makevectors(self.angles);
-                       if(monster_leap(zombie_anim_attackleap, zombie_attack_leap_touch, v_forward * MON_CVAR(zombie, attack_leap_speed) + '0 0 200', MON_CVAR(zombie, attack_leap_delay)))
-                               return TRUE;
-                               
-                       return FALSE;
+                       return monster_leap(zombie_anim_attackleap, zombie_attack_leap_touch, v_forward * MON_CVAR(zombie, attack_leap_speed) + '0 0 200', MON_CVAR(zombie, attack_leap_delay));
                }
        }
        
@@ -135,7 +155,9 @@ float m_zombie(float req)
                }
                case MR_DEATH:
                {
-                       monsters_setframe((random() > 0.5) ? zombie_anim_deathback1 : zombie_anim_deathfront1);
+                       self.armorvalue = 0;
+                       self.m_armor_blockpercent = autocvar_g_monsters_armor_blockpercent;
+                       self.frame = ((random() > 0.5) ? zombie_anim_deathback1 : zombie_anim_deathfront1);
                        return TRUE;
                }
                case MR_SETUP:
@@ -147,16 +169,16 @@ float m_zombie(float req)
                        
                        self.monster_loot = spawnfunc_item_health_medium;
                        self.monster_attackfunc = zombie_attack;
-                       monsters_setframe(zombie_anim_spawn);
+                       self.frame = zombie_anim_spawn;
                        self.spawn_time = time + 2.1;
                        self.spawnshieldtime = self.spawn_time;
                        self.respawntime = 0.2;
                        
                        return TRUE;
                }
-               case MR_INIT:
+               case MR_PRECACHE:
                {
-                       // nothing
+                       precache_model ("models/monsters/zombie.dpm");
                        return TRUE;
                }
                case MR_CONFIG:
@@ -175,12 +197,7 @@ float m_zombie(float req)
 {
        switch(req)
        {
-               case MR_DEATH:
-               {
-                       // nothing
-                       return TRUE;
-               }
-               case MR_INIT:
+               case MR_PRECACHE:
                {
                        precache_model ("models/monsters/zombie.dpm");
                        return TRUE;