]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/monster/zombie.qc
Add a check just incase the mutator deletes the item entity
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / zombie.qc
index 53b392ca2cd0fe40ec164069962455f31a7156ea..805fb7bf779b9ffee09e7fd6b353a7aef9133bfc 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;
+
+       monsters_setframe(zombie_anim_blockend);
+       self.armorvalue = 0;
+       self.m_armor_blockpercent = autocvar_g_monsters_armor_blockpercent;
+}
+
+float zombie_block()
+{
+       monsters_setframe(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)
@@ -91,20 +114,16 @@ float zombie_attack(float attack_type)
                                chosen_anim = zombie_anim_attackstanding2;
                        else
                                chosen_anim = zombie_anim_attackstanding3;
-                               
-                       monsters_setframe(chosen_anim);
-
-                       self.attack_finished_single = time + MON_CVAR(zombie, attack_melee_delay);
                        
-                       monster_melee(self.enemy, MON_CVAR(zombie, attack_melee_damage), self.attack_range, DEATH_MONSTER_ZOMBIE_MELEE, TRUE);
+                       if(random() < 0.3 && self.health < 75 && self.enemy.health > 10)
+                               return zombie_block();
                        
-                       return TRUE;
+                       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 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));
                }
        }
        
@@ -136,6 +155,8 @@ float m_zombie(float req)
                }
                case MR_DEATH:
                {
+                       self.armorvalue = 0;
+                       self.m_armor_blockpercent = autocvar_g_monsters_armor_blockpercent;
                        monsters_setframe((random() > 0.5) ? zombie_anim_deathback1 : zombie_anim_deathfront1);
                        return TRUE;
                }
@@ -144,7 +165,7 @@ float m_zombie(float req)
                        if not(self.health) self.health = MON_CVAR(zombie, health);
                        
                        if(self.spawnflags & MONSTERFLAG_NORESPAWN)
-                               self.spawnflags &~= MONSTERFLAG_NORESPAWN; // zombies always respawn
+                               self.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn
                        
                        self.monster_loot = spawnfunc_item_health_medium;
                        self.monster_attackfunc = zombie_attack;