From: Mario Date: Wed, 16 Nov 2016 10:51:10 +0000 (+1000) Subject: Fix invasion X-Git-Tag: xonotic-v0.8.2~437 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=110554a235aafe14d1ae6dd6310a982a9af9e7fe;p=xonotic%2Fxonotic-data.pk3dir.git Fix invasion --- diff --git a/qcsrc/common/monsters/monster.qh b/qcsrc/common/monsters/monster.qh index 2685e2fbc..ab644988a 100644 --- a/qcsrc/common/monsters/monster.qh +++ b/qcsrc/common/monsters/monster.qh @@ -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 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; diff --git a/qcsrc/common/monsters/monster/zombie.qh b/qcsrc/common/monsters/monster/zombie.qh index b52056e71..d3c94cd45 100644 --- a/qcsrc/common/monsters/monster/zombie.qh +++ b/qcsrc/common/monsters/monster/zombie.qh @@ -7,7 +7,7 @@ MODEL(MON_ZOMBIE, M_Model("zombie.dpm")); #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 diff --git a/qcsrc/common/monsters/sv_spawn.qc b/qcsrc/common/monsters/sv_spawn.qc index 6d9daa296..497dee866 100644 --- a/qcsrc/common/monsters/sv_spawn.qc +++ b/qcsrc/common/monsters/sv_spawn.qc @@ -69,7 +69,11 @@ entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby, } // 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; } diff --git a/qcsrc/server/mutators/mutator/gamemode_invasion.qc b/qcsrc/server/mutators/mutator/gamemode_invasion.qc index efed23a5d..1496feec5 100644 --- a/qcsrc/server/mutators/mutator/gamemode_invasion.qc +++ b/qcsrc/server/mutators/mutator/gamemode_invasion.qc @@ -23,28 +23,18 @@ spawnfunc(invasion_spawnpoint) 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) { - 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; + if(autocvar_g_invasion_zombies_only && !(it.spawnflags & MONSTER_TYPE_UNDEAD)) + continue; 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)) - 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) - 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; @@ -465,22 +462,5 @@ void invasion_DelayedInit(entity this) // Do this check with a delay so we can w 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); }