]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix invasion
authorMario <mario@smbclan.net>
Wed, 16 Nov 2016 10:51:10 +0000 (20:51 +1000)
committerMario <mario@smbclan.net>
Wed, 16 Nov 2016 10:51:10 +0000 (20:51 +1000)
qcsrc/common/monsters/monster.qh
qcsrc/common/monsters/monster/zombie.qh
qcsrc/common/monsters/sv_spawn.qc
qcsrc/server/mutators/mutator/gamemode_invasion.qc

index 2685e2fbced75be78c0402980f5a5acea84f9294..ab644988aa4d1192e60fde95bb97f28da642c0d3 100644 (file)
@@ -12,6 +12,7 @@ const int MON_FLAG_CRUSH = BIT(11); // monster can be stomped in special modes
 const int MON_FLAG_RIDE = BIT(12); // monster can be ridden in special modes
 const int MONSTER_SIZE_QUAKE = BIT(13);
 const int MONSTER_TYPE_PASSIVE = BIT(14); // doesn't target or chase enemies
 const int MON_FLAG_RIDE = BIT(12); // monster can be ridden in special modes
 const int MONSTER_SIZE_QUAKE = BIT(13);
 const int MONSTER_TYPE_PASSIVE = BIT(14); // doesn't target or chase enemies
+const int MONSTER_TYPE_UNDEAD = BIT(15); // monster is by most definitions a zombie (doesn't fully die unless gibbed)
 
 // entity properties of monsterinfo:
 .bool(int, entity actor, entity targ) monster_attackfunc;
 
 // entity properties of monsterinfo:
 .bool(int, entity actor, entity targ) monster_attackfunc;
index b52056e71d9d0b58fd394f4bac976dd5f45c4fec..d3c94cd4546724e1597daa8e4ec8af8caa715be6 100644 (file)
@@ -7,7 +7,7 @@ MODEL(MON_ZOMBIE, M_Model("zombie.dpm"));
 #endif
 
 CLASS(Zombie, Monster)
 #endif
 
 CLASS(Zombie, Monster)
-    ATTRIB(Zombie, spawnflags, int, MON_FLAG_MELEE | MON_FLAG_RIDE);
+    ATTRIB(Zombie, spawnflags, int, MONSTER_TYPE_UNDEAD | MON_FLAG_MELEE | MON_FLAG_RIDE);
     ATTRIB(Zombie, mins, vector, '-18 -18 -25');
     ATTRIB(Zombie, maxs, vector, '18 18 47');
 #ifdef GAMEQC
     ATTRIB(Zombie, mins, vector, '-18 -18 -25');
     ATTRIB(Zombie, maxs, vector, '18 18 47');
 #ifdef GAMEQC
index 6d9daa2964cbb4c6c5c1d4c25561e22fcf2c2731..497dee86664b54d644f405e4be5ea47fc01969e9 100644 (file)
@@ -69,7 +69,11 @@ entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby,
        }
 
        // Monster_Spawn checks if monster is valid
        }
 
        // Monster_Spawn checks if monster is valid
-       Monster_Spawn(e, false, monster_id);
+       if(!Monster_Spawn(e, false, monster_id))
+       {
+               delete(e);
+               return NULL; // remove even if told not to, as we didn't spawn any kind of monster
+       }
 
        return e;
 }
 
        return e;
 }
index efed23a5df41f48dd0897ffb72c8434412f1cb47..1496feec595cdd2ec0fb83b0026ba267ae7380a7 100644 (file)
@@ -23,28 +23,18 @@ spawnfunc(invasion_spawnpoint)
 
        this.classname = "invasion_spawnpoint";
        IL_PUSH(g_invasion_spawns, this);
 
        this.classname = "invasion_spawnpoint";
        IL_PUSH(g_invasion_spawns, this);
-
-       if(autocvar_g_invasion_zombies_only) // precache only if it hasn't been already
-       if(this.spawnmob)
-       {
-               FOREACH(Monsters, it.netname == this.spawnmob,
-               {
-                       it.mr_precache(it);
-               });
-       }
 }
 
 Monster invasion_PickMonster(int supermonster_count)
 {
 }
 
 Monster invasion_PickMonster(int supermonster_count)
 {
-       if(autocvar_g_invasion_zombies_only)
-               return MON_ZOMBIE;
-
        RandomSelection_Init();
 
        FOREACH(Monsters, it != MON_Null,
        {
                if((it.spawnflags & MONSTER_TYPE_PASSIVE) || (it.spawnflags & MONSTER_TYPE_FLY) || (it.spawnflags & MONSTER_TYPE_SWIM) || (it.spawnflags & MONSTER_SIZE_QUAKE) || ((it.spawnflags & MON_FLAG_SUPERMONSTER) && supermonster_count >= 1))
                        continue;
        RandomSelection_Init();
 
        FOREACH(Monsters, it != MON_Null,
        {
                if((it.spawnflags & MONSTER_TYPE_PASSIVE) || (it.spawnflags & MONSTER_TYPE_FLY) || (it.spawnflags & MONSTER_TYPE_SWIM) || (it.spawnflags & MONSTER_SIZE_QUAKE) || ((it.spawnflags & MON_FLAG_SUPERMONSTER) && supermonster_count >= 1))
                        continue;
+               if(autocvar_g_invasion_zombies_only && !(it.spawnflags & MONSTER_TYPE_UNDEAD))
+                       continue;
         RandomSelection_AddEnt(it, 1, 1);
        });
 
         RandomSelection_AddEnt(it, 1, 1);
        });
 
@@ -77,11 +67,18 @@ void invasion_SpawnChosenMonster(Monster mon)
                setsize(e, mon.mins, mon.maxs);
 
                if(MoveToRandomMapLocation(e, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
                setsize(e, mon.mins, mon.maxs);
 
                if(MoveToRandomMapLocation(e, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
-                       monster = spawnmonster(e, "", mon.m_id, NULL, NULL, e.origin, false, false, 2);
-               else return;
+                       monster = spawnmonster(e, "", mon.monsterid, NULL, NULL, e.origin, false, false, 2);
+               else
+               {
+                       delete(e);
+                       return;
+               }
        }
        else // if spawnmob field falls through (unset), fallback to mon (relying on spawnmonster for that behaviour)
        }
        else // if spawnmob field falls through (unset), fallback to mon (relying on spawnmonster for that behaviour)
-               monster = spawnmonster(spawn(), spawn_point.spawnmob, mon.m_id, spawn_point, spawn_point, spawn_point.origin, false, false, 2);
+               monster = spawnmonster(spawn(), spawn_point.spawnmob, mon.monsterid, spawn_point, spawn_point, spawn_point.origin, false, false, 2);
+
+       if(!monster)
+               return;
 
        if(spawn_point) monster.target2 = spawn_point.target2;
        monster.spawnshieldtime = time;
 
        if(spawn_point) monster.target2 = spawn_point.target2;
        monster.spawnshieldtime = time;
@@ -465,22 +462,5 @@ void invasion_DelayedInit(entity this) // Do this check with a delay so we can w
 
 void invasion_Initialize()
 {
 
 void invasion_Initialize()
 {
-       if(autocvar_g_invasion_zombies_only) {
-               Monster mon = MON_ZOMBIE;
-               mon.mr_precache(mon);
-       } else
-       {
-               float i;
-               entity mon;
-               for(i = MON_FIRST; i <= MON_LAST; ++i)
-               {
-                       mon = get_monsterinfo(i);
-                       if((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM))
-                               continue; // flying/swimming monsters not yet supported
-
-                       mon.mr_precache(mon);
-               }
-       }
-
        InitializeEntity(NULL, invasion_DelayedInit, INITPRIO_GAMETYPE);
 }
        InitializeEntity(NULL, invasion_DelayedInit, INITPRIO_GAMETYPE);
 }