From: Mario Date: Wed, 19 Oct 2016 19:41:12 +0000 (+1000) Subject: Add a passive flag for monsters that don't chase players X-Git-Tag: xonotic-v0.8.2~502 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8612ccf267eae3835ec429a021ab3363634e4025;p=xonotic%2Fxonotic-data.pk3dir.git Add a passive flag for monsters that don't chase players --- diff --git a/qcsrc/common/monsters/monster.qh b/qcsrc/common/monsters/monster.qh index babf6e4fa..e579d7d87 100644 --- a/qcsrc/common/monsters/monster.qh +++ b/qcsrc/common/monsters/monster.qh @@ -1,16 +1,17 @@ #pragma once // special spawn flags -const int MONSTER_RESPAWN_DEATHPOINT = 16; // re-spawn where we died -const int MONSTER_TYPE_FLY = 32; -const int MONSTER_TYPE_SWIM = 64; -const int MONSTER_SIZE_BROKEN = 128; // TODO: remove when bad models are replaced -const int MON_FLAG_SUPERMONSTER = 256; // incredibly powerful monster -const int MON_FLAG_RANGED = 512; // monster shoots projectiles -const int MON_FLAG_MELEE = 1024; -const int MON_FLAG_CRUSH = 2048; // monster can be stomped in special modes -const int MON_FLAG_RIDE = 4096; // monster can be ridden in special modes -const int MONSTER_SIZE_QUAKE = 8192; +const int MONSTER_RESPAWN_DEATHPOINT = BIT(4); // re-spawn where we died +const int MONSTER_TYPE_FLY = BIT(5); +const int MONSTER_TYPE_SWIM = BIT(6); +const int MONSTER_SIZE_BROKEN = BIT(7); // TODO: remove when bad models are replaced +const int MON_FLAG_SUPERMONSTER = BIT(8); // incredibly powerful monster +const int MON_FLAG_RANGED = BIT(9); // monster shoots projectiles +const int MON_FLAG_MELEE = BIT(10); +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 // entity properties of monsterinfo: .bool(int, entity actor, entity targ) monster_attackfunc; diff --git a/qcsrc/server/mutators/mutator/gamemode_invasion.qc b/qcsrc/server/mutators/mutator/gamemode_invasion.qc index a057408b9..aa1a2643e 100644 --- a/qcsrc/server/mutators/mutator/gamemode_invasion.qc +++ b/qcsrc/server/mutators/mutator/gamemode_invasion.qc @@ -34,21 +34,21 @@ spawnfunc(invasion_spawnpoint) } } -int invasion_PickMonster(int supermonster_count) +Monster invasion_PickMonster(int supermonster_count) { if(autocvar_g_invasion_zombies_only) - return MON_ZOMBIE.monsterid; + return MON_ZOMBIE; RandomSelection_Init(); FOREACH(Monsters, it != MON_Null, { - if((it.spawnflags & MONSTER_TYPE_FLY) || (it.spawnflags & MONSTER_TYPE_SWIM) || (it.spawnflags & MONSTER_SIZE_QUAKE) || ((it.spawnflags & MON_FLAG_SUPERMONSTER) && supermonster_count >= 1)) + 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_AddFloat(it.monsterid, 1, 1); + RandomSelection_AddEnt(it, 1, 1); }); - return RandomSelection_chosen_float; + return RandomSelection_chosen_ent; } entity invasion_PickSpawn() @@ -64,7 +64,7 @@ entity invasion_PickSpawn() return RandomSelection_chosen_ent; } -void invasion_SpawnChosenMonster(int mon) +void invasion_SpawnChosenMonster(Monster mon) { entity spawn_point, monster; @@ -74,17 +74,17 @@ void invasion_SpawnChosenMonster(int mon) { LOG_TRACE("Warning: couldn't find any invasion_spawnpoint spawnpoints, attempting to spawn monsters in random locations"); entity e = spawn(); - setsize(e, (get_monsterinfo(mon)).mins, (get_monsterinfo(mon)).maxs); + 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("", mon, NULL, NULL, e.origin, false, false, 2); + monster = spawnmonster("", mon.m_id, NULL, NULL, e.origin, false, false, 2); else return; setthink(e, SUB_Remove); e.nextthink = time + 0.1; } else // if spawnmob field falls through (unset), fallback to mon (relying on spawnmonster for that behaviour) - monster = spawnmonster(spawn_point.spawnmob, mon, spawn_point, spawn_point, spawn_point.origin, false, false, 2); + monster = spawnmonster(spawn_point.spawnmob, mon.m_id, spawn_point, spawn_point, spawn_point.origin, false, false, 2); if(spawn_point) monster.target2 = spawn_point.target2; monster.spawnshieldtime = time; @@ -125,7 +125,7 @@ void invasion_SpawnChosenMonster(int mon) void invasion_SpawnMonsters(int supermonster_count) { - int chosen_monster = invasion_PickMonster(supermonster_count); + Monster chosen_monster = invasion_PickMonster(supermonster_count); invasion_SpawnChosenMonster(chosen_monster); }