]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a passive flag for monsters that don't chase players
authorMario <mario@smbclan.net>
Wed, 19 Oct 2016 19:41:12 +0000 (05:41 +1000)
committerMario <mario@smbclan.net>
Wed, 19 Oct 2016 19:41:12 +0000 (05:41 +1000)
qcsrc/common/monsters/monster.qh
qcsrc/server/mutators/mutator/gamemode_invasion.qc

index babf6e4faf19a2f1e1879afd774693a05514c762..e579d7d87dbfd0360f1ae842404c69e51a98d6ca 100644 (file)
@@ -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;
index a057408b965846b31c1c2bd7e2486b9d03b1fcee..aa1a2643e6d2ecea736c91235cd070a88faf0b13 100644 (file)
@@ -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);
 }