]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Slightly better handling of monster loot for mutators
authorMario <mario.mario@y7mail.com>
Sat, 1 Jun 2013 22:14:58 +0000 (08:14 +1000)
committerMario <mario.mario@y7mail.com>
Sat, 1 Jun 2013 22:14:58 +0000 (08:14 +1000)
qcsrc/server/monsters/lib/monsters.qc
qcsrc/server/mutators/base.qh
qcsrc/server/mutators/mutator_minstagib.qc

index 06f9d41879e48b7113f7ef590c886abf07d4a56c..122b0de274bb25aa866c0ac866a2ca5ce0636710 100644 (file)
@@ -14,7 +14,7 @@ void M_Item_Touch ()
 
 void monster_item_spawn()
 {
-       self.monster_delayedattack();
+       self.monster_loot();
        
        self.gravity = 1;
        self.velocity = randomvec() * 175 + '0 0 325';
@@ -36,40 +36,41 @@ void Monster_DropItem (string itype, string itemsize)
                {
                        switch(itemsize)
                        {
-                               case "mega": e.monster_delayedattack = spawnfunc_item_armor_large; break;
-                               case "large": e.monster_delayedattack = spawnfunc_item_armor_big; break;
-                               case "medium": e.monster_delayedattack = spawnfunc_item_armor_medium; break;
-                               case "small": e.monster_delayedattack = spawnfunc_item_armor_small; break;
+                               case "mega": e.monster_loot = spawnfunc_item_armor_large; break;
+                               case "large": e.monster_loot = spawnfunc_item_armor_big; break;
+                               case "medium": e.monster_loot = spawnfunc_item_armor_medium; break;
+                               case "small": e.monster_loot = spawnfunc_item_armor_small; break;
                        }
-                       break; // break here?
+                       break;
                }
                case "health":
                {
                        switch(itemsize)
                        {
-                               case "mega": e.monster_delayedattack = spawnfunc_item_health_mega; break;
-                               case "large": e.monster_delayedattack = spawnfunc_item_health_large; break;
-                               case "medium": e.monster_delayedattack = spawnfunc_item_health_medium; break;
-                               case "small": e.monster_delayedattack = spawnfunc_item_health_small; break;
+                               case "mega": e.monster_loot = spawnfunc_item_health_mega; break;
+                               case "large": e.monster_loot = spawnfunc_item_health_large; break;
+                               case "medium": e.monster_loot = spawnfunc_item_health_medium; break;
+                               case "small": e.monster_loot = spawnfunc_item_health_small; break;
                        }
-                       break; // break here?
+                       break;
                }
                case "ammo":
                {
                        switch(itemsize)
                        {
-                               case "shells": e.monster_delayedattack = spawnfunc_item_shells; break;
-                               case "cells": e.monster_delayedattack = spawnfunc_item_cells; break;
-                               case "rockets": e.monster_delayedattack = spawnfunc_item_rockets; break;
+                               case "shells": e.monster_loot = spawnfunc_item_shells; break;
+                               case "cells": e.monster_loot = spawnfunc_item_cells; break;
+                               case "rockets": e.monster_loot = spawnfunc_item_rockets; break;
                                case "bullets":
-                               case "nails": e.monster_delayedattack = spawnfunc_item_bullets; break;
+                               case "nails": e.monster_loot = spawnfunc_item_bullets; break;
                        }
                        break;
                }
        }
        
-       if(g_minstagib)
-               e.monster_delayedattack = spawnfunc_item_minst_cells;
+       other = e;
+       MUTATOR_CALLHOOK(MonsterDropItem);
+       e = other;
                
        e.think = monster_item_spawn;
        e.nextthink = time + 0.1;
@@ -238,12 +239,6 @@ void Monster_CheckDropCvars (string mon)
        dropitem = cvar_string(strcat("g_monster_", mon, "_drop"));
        dropsize = cvar_string(strcat("g_monster_", mon, "_drop_size"));
        
-       monster_dropitem = dropitem;
-       monster_dropsize = dropsize;
-       MUTATOR_CALLHOOK(MonsterDropItem);
-       dropitem = monster_dropitem;
-       dropsize = monster_dropsize;
-       
        if(autocvar_g_monsters_forcedrop)
                Monster_DropItem(autocvar_g_monsters_drop_type, autocvar_g_monsters_drop_size);
        else if(dropitem != "")
index 75b71219f80dffc34a38b85f3f236d0107721fc9..e0e14979fe46ff40c174d542574991d881d6fb09 100644 (file)
@@ -174,8 +174,7 @@ MUTATOR_HOOKABLE(MonsterRespawn);
 MUTATOR_HOOKABLE(MonsterDropItem);
        // called when a monster is dropping loot
        // INPUT, OUTPUT:
-               string monster_dropitem;
-               string monster_dropsize;
+               .void() monster_loot;
        
 MUTATOR_HOOKABLE(MonsterMove);
        // called when a monster moves
index 28e8623d69ddf191f72b47daef6ec8810c55a7e9..04de1ce4dbcd1a202042351fa394d631342e8c35 100644 (file)
@@ -109,6 +109,13 @@ MUTATOR_HOOKFUNCTION(minstagib_MatchEnd)
        return FALSE;
 }
 
+MUTATOR_HOOKFUNCTION(minstagib_MonsterLoot)
+{
+       other.monster_loot = spawnfunc_item_minst_cells;
+
+       return FALSE;
+}
+
 MUTATOR_HOOKFUNCTION(minstagib_BotShouldAttack)
 {
        if(checkentity.items & IT_STRENGTH)
@@ -402,6 +409,7 @@ MUTATOR_HOOKFUNCTION(minstagib_BuildMutatorsPrettyString)
 MUTATOR_DEFINITION(mutator_minstagib)
 {
        MUTATOR_HOOK(MatchEnd, minstagib_MatchEnd, CBC_ORDER_ANY);
+       MUTATOR_HOOK(MonsterDropItem, minstagib_MonsterLoot, CBC_ORDER_ANY);
        MUTATOR_HOOK(BotShouldAttack, minstagib_BotShouldAttack, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPhysics, minstagib_PlayerPhysics, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerSpawn, minstagib_PlayerSpawn, CBC_ORDER_ANY);