]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a proper death message for zombies
authorMario <mario.mario@y7mail.com>
Sun, 10 Feb 2013 07:12:25 +0000 (18:12 +1100)
committerMario <mario.mario@y7mail.com>
Sun, 10 Feb 2013 07:12:25 +0000 (18:12 +1100)
qcsrc/server/monsters/monster/zombie.qc
qcsrc/server/mutators/mutator_zombie_apocalypse.qc

index a6692a72537ab3f1ed042b69bae20a8bd1a494aa..939bf325c6b26fb479ce04be7c96b4563732a9c6 100644 (file)
@@ -98,7 +98,7 @@ void zombie_attack_standing()
        dot = normalize (self.enemy.origin - self.origin) * v_forward;
        if(dot > 0.3)
        {
-               Damage(self.enemy, self, self, bigdmg * monster_skill, DEATH_MONSTER_MELEE, self.origin, '0 0 0');
+               Damage(self.enemy, self, self, bigdmg * monster_skill, DEATH_MONSTER_ZOMBIE, self.origin, '0 0 0');
        }
        
        if(self.enemy.health < 1)
@@ -134,7 +134,7 @@ void zombie_attack_leap_touch()
 
        angles_face = vectoangles(self.moveto - self.origin);
        angles_face = normalize(angles_face) * autocvar_g_monster_zombie_attack_leap_force;
-       Damage(other, self, self, bigdmg * monster_skill, DEATH_MONSTER_MELEE, trace_endpos, angles_face);      
+       Damage(other, self, self, bigdmg * monster_skill, DEATH_MONSTER_ZOMBIE, trace_endpos, angles_face);     
                
        self.touch = MonsterTouch;
 }
index 85b21dce80cff6a53a4c3f29d5d85b94ed984d63..2c3030eb2894df5df91c988e7b855f64f54c38cb 100644 (file)
@@ -1,7 +1,7 @@
 // Zombie Apocalypse mutator - small side project
 // Spawns a defined number of zombies at the start of a match
 
-float za_numspawns;
+float za_numspawns, totalzombies, roundcnt, numzoms;
 entity PickZombieSpawn()
 {
        entity sp;
@@ -36,6 +36,7 @@ void zombie_spawn_somewhere ()
        {
                mon = spawnmonster("zombie", self, self, self.origin, TRUE, 2);
                tracebox(mon.origin, mon.mins, mon.maxs, mon.origin, MOVE_NOMONSTERS, mon);
+               mon.spawnflags |= MONSTERFLAG_NORESPAWN;
 
                if(trace_startsolid)
                {
@@ -50,15 +51,44 @@ void zombie_spawn_somewhere ()
                zombie_spawn_somewhere();
 }
 
+void() spawn_zombies;
+void za_roundwon()
+{
+       entity head;
+       FOR_EACH_PLAYER(head)
+       {
+               Send_CSQC_Centerprint_Generic(head, CPID_MINSTA_FINDAMMO, "All the zombies have been exterminated! Prepare for round 2!", 0, 0);
+       }
+       
+       roundcnt += 1;
+       
+       numzoms = autocvar_g_za_monster_count * roundcnt;
+       
+       monsters_total = numzoms;
+       totalzombies = numzoms;
+       
+       self.think = spawn_zombies;
+       self.nextthink = time + 10;
+}
+
 void spawn_zombies ()
-{      
-    float numzoms;
+{
+       self.nextthink = time + 1;
+       
+       if(totalzombies < 1)
+       {
+               self.think = za_roundwon;
+               self.nextthink = time;
+               return;
+       }
+       
+       if(gameover || numzoms <= 0)
+               return;
+               
     entity e;
     
     print("Them zombies be spawnin'!\n");
 
-       numzoms = autocvar_g_za_monster_count;
-
        while(numzoms > 0)
        {
         e = spawn();
@@ -67,27 +97,41 @@ void spawn_zombies ()
 
                numzoms -= 1;
        }
-       
-       if(self)
-        remove(self);
 }
 
 void za_init ()
 {
     entity e;
-    
+       
+       roundcnt = 1;
+       
+    numzoms = autocvar_g_za_monster_count * roundcnt;
+       
+       monsters_total = numzoms;
+       totalzombies = numzoms;
+       
     e = spawn();
        e.think = spawn_zombies;
        e.nextthink = time + 3;
 }
 
-MUTATOR_HOOKFUNCTION(Zombies_BuildMutatorsString)
+MUTATOR_HOOKFUNCTION(za_ZombieDies)
+{
+       if(frag_attacker.classname == "player")
+               PlayerScore_Add(frag_attacker, SP_SCORE, 1);
+       
+       totalzombies -= 1;
+       monsters_killed += 1;
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(za_BuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":Zombies");
        return 0;
 }
 
-MUTATOR_HOOKFUNCTION(Zombies_BuildMutatorsPrettyString)
+MUTATOR_HOOKFUNCTION(za_BuildMutatorsPrettyString)
 {
        ret_string = strcat(ret_string, ", Zombies");
        return 0;
@@ -95,8 +139,9 @@ MUTATOR_HOOKFUNCTION(Zombies_BuildMutatorsPrettyString)
 
 MUTATOR_DEFINITION(mutator_zombie_apocalypse)
 {
-       MUTATOR_HOOK(BuildMutatorsString, Zombies_BuildMutatorsString, CBC_ORDER_ANY);
-       MUTATOR_HOOK(BuildMutatorsPrettyString, Zombies_BuildMutatorsPrettyString, CBC_ORDER_ANY);
+       MUTATOR_HOOK(MonsterDies, za_ZombieDies, CBC_ORDER_ANY);
+       MUTATOR_HOOK(BuildMutatorsString, za_BuildMutatorsString, CBC_ORDER_ANY);
+       MUTATOR_HOOK(BuildMutatorsPrettyString, za_BuildMutatorsPrettyString, CBC_ORDER_ANY);
     
     MUTATOR_ONADD
     {