]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_invasion.qc
Merge branch 'master' into TimePath/spawnfunc
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_invasion.qc
index a5e19f67aab28efb62403fb90a2679cd954355d3..5dbe12d22d9c7701f042591b7d04e677509ec34f 100644 (file)
@@ -1,4 +1,12 @@
-void spawnfunc_invasion_spawnpoint()
+#include "gamemode_invasion.qh"
+#include "../_all.qh"
+
+#include "gamemode.qh"
+
+#include "../../common/monsters/spawn.qh"
+#include "../../common/monsters/sv_monsters.qh"
+
+spawnfunc(invasion_spawnpoint)
 {
        if(!g_invasion) { remove(self); return; }
 
@@ -12,7 +20,7 @@ void spawnfunc_invasion_spawnpoint()
 float invasion_PickMonster(float supermonster_count)
 {
        if(autocvar_g_invasion_zombies_only)
-               return MON_ZOMBIE;
+               return MON_ZOMBIE.monsterid;
 
        float i;
        entity mon;
@@ -54,7 +62,7 @@ void invasion_SpawnChosenMonster(float mon)
 
        if(spawn_point == world)
        {
-               dprint("Warning: couldn't find any invasion_spawnpoint spawnpoints, attempting to spawn monsters in random locations\n");
+               LOG_TRACE("Warning: couldn't find any invasion_spawnpoint spawnpoints, attempting to spawn monsters in random locations\n");
                entity e = spawn();
                setsize(e, (get_monsterinfo(mon)).mins, (get_monsterinfo(mon)).maxs);
 
@@ -67,11 +75,11 @@ void invasion_SpawnChosenMonster(float mon)
        }
        else
                monster = spawnmonster("", ((spawn_point.monsterid) ? spawn_point.monsterid : mon), spawn_point, spawn_point, spawn_point.origin, false, false, 2);
-       
+
        if(spawn_point) monster.target2 = spawn_point.target2;
        monster.spawnshieldtime = time;
        if(spawn_point && spawn_point.target_range) monster.target_range = spawn_point.target_range;
-       
+
        if(teamplay)
        if(spawn_point && spawn_point.team && inv_monsters_perteam[spawn_point.team] > 0)
                monster.team = spawn_point.team;
@@ -82,14 +90,14 @@ void invasion_SpawnChosenMonster(float mon)
                if(inv_monsters_perteam[NUM_TEAM_2] > 0) RandomSelection_Add(world, NUM_TEAM_2, string_null, 1, 1);
                if(invasion_teams >= 3) if(inv_monsters_perteam[NUM_TEAM_3] > 0) { RandomSelection_Add(world, NUM_TEAM_3, string_null, 1, 1); }
                if(invasion_teams >= 4) if(inv_monsters_perteam[NUM_TEAM_4] > 0) { RandomSelection_Add(world, NUM_TEAM_4, string_null, 1, 1); }
-               
+
                monster.team = RandomSelection_chosen_float;
        }
-       
+
        if(teamplay)
        {
                monster_setupcolors(monster);
-       
+
                if(monster.sprite)
                {
                        WaypointSprite_UpdateTeamRadar(monster.sprite, RADARICON_DANGER, ((monster.team) ? Team_ColorRGB(monster.team) : '1 0 0'));
@@ -98,7 +106,7 @@ void invasion_SpawnChosenMonster(float mon)
                        monster.sprite.SendFlags |= 1;
                }
        }
-       
+
        monster.monster_attack = false; // it's the player's job to kill all the monsters
 
        if(inv_roundcnt >= inv_maxrounds)
@@ -118,7 +126,7 @@ float Invasion_CheckWinner()
        if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
        {
                FOR_EACH_MONSTER(head)
-                       monster_remove(head);
+                       Monster_Remove(head);
 
                Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_OVER);
                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_OVER);
@@ -157,7 +165,7 @@ float Invasion_CheckWinner()
 
        if(inv_numspawned < 1)
                return 0; // nothing has spawned yet
-               
+
        if(teamplay)
        {
                if(((red_alive > 0) + (blue_alive > 0) + (yellow_alive > 0) + (pink_alive > 0)) > 1)
@@ -182,7 +190,7 @@ float Invasion_CheckWinner()
                if(pink_alive > 0)
                if(winner_team) { winner_team = 0; }
                else { winner_team = NUM_TEAM_4; }
-       }       
+       }
        else
        FOR_EACH_PLAYER(head)
        {
@@ -195,7 +203,7 @@ float Invasion_CheckWinner()
        }
 
        FOR_EACH_MONSTER(head)
-               monster_remove(head);
+               Monster_Remove(head);
 
        if(teamplay)
        {
@@ -253,7 +261,7 @@ void Invasion_RoundStart()
 }
 
 MUTATOR_HOOKFUNCTION(invasion_MonsterDies)
-{
+{SELFPARAM();
        if(!(self.spawnflags & MONSTERFLAG_RESPAWNED))
        {
                inv_numkilled += 1;
@@ -275,7 +283,7 @@ MUTATOR_HOOKFUNCTION(invasion_MonsterDies)
 }
 
 MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn)
-{
+{SELFPARAM();
        if(!(self.spawnflags & MONSTERFLAG_SPAWNED))
                return true;
 
@@ -288,7 +296,7 @@ MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn)
        self.monster_skill = inv_monsterskill;
 
        if((get_monsterinfo(self.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
-               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_INVASION_SUPERMONSTER, M_NAME(self.monsterid));
+               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_INVASION_SUPERMONSTER, self.monster_name);
 
        self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP;
 
@@ -296,11 +304,11 @@ MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(invasion_OnEntityPreSpawn)
-{
+{SELFPARAM();
        if(startsWith(self.classname, "monster_"))
        if(!(self.spawnflags & MONSTERFLAG_SPAWNED))
                return true;
-       
+
        return false;
 }
 
@@ -319,7 +327,7 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerRegen)
 }
 
 MUTATOR_HOOKFUNCTION(invasion_PlayerSpawn)
-{
+{SELFPARAM();
        self.bot_attack = false;
        return false;
 }
@@ -336,7 +344,7 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerDamage)
 }
 
 MUTATOR_HOOKFUNCTION(invasion_PlayerCommand)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE) // command was already handled?
                return false;
 
@@ -358,9 +366,9 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerCommand)
 
 MUTATOR_HOOKFUNCTION(invasion_BotShouldAttack)
 {
-       if(!(checkentity.flags & FL_MONSTER))
+       if(!IS_MONSTER(checkentity))
                return true;
-       
+
        return false;
 }
 
@@ -374,7 +382,7 @@ MUTATOR_HOOKFUNCTION(invasion_SetStartItems)
 
 MUTATOR_HOOKFUNCTION(invasion_AccuracyTargetValid)
 {
-       if(frag_target.flags & FL_MONSTER)
+       if(IS_MONSTER(frag_target))
                return MUT_ACCADD_INVALID;
        return MUT_ACCADD_INDIFFERENT;
 }
@@ -406,7 +414,7 @@ void invasion_DelayedInit() // Do this check with a delay so we can wait for tea
                invasion_teams = bound(2, autocvar_g_invasion_teams, 4);
        else
                invasion_teams = 0;
-       
+
        independent_players = 1; // to disable extra useless scores
 
        invasion_ScoreRules(invasion_teams);
@@ -423,7 +431,7 @@ void invasion_DelayedInit() // Do this check with a delay so we can wait for tea
 void invasion_Initialize()
 {
        if(autocvar_g_invasion_zombies_only)
-               MON_ACTION(MON_ZOMBIE, MR_PRECACHE);
+               MON_ACTION(MON_ZOMBIE.monsterid, MR_PRECACHE);
        else
        {
                float i;
@@ -437,7 +445,7 @@ void invasion_Initialize()
                        MON_ACTION(i, MR_PRECACHE);
                }
        }
-       
+
        InitializeEntity(world, invasion_DelayedInit, INITPRIO_GAMETYPE);
 }
 
@@ -475,7 +483,7 @@ MUTATOR_DEFINITION(gamemode_invasion)
 
        MUTATOR_ONREMOVE
        {
-               print("This is a game type and it cannot be removed at runtime.");
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
                return -1;
        }