]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_quake3.qc
Fix stat references on non-player entities
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_quake3.qc
index d20c90055dfcdd91024d68d9a2ee5f6cc3270588..85ec325bdf6ea5c7196acaa8073d3aaf4cc832d5 100644 (file)
@@ -1,29 +1,28 @@
-#include "_all.qh"
+#include "t_quake3.qh"
 
-#include "../common/weapons/all.qh"
-#include "../common/buffs.qh"
+#include <common/weapons/_all.qh>
 
-void spawnfunc_weapon_crylink();
-void spawnfunc_weapon_electro();
-void spawnfunc_weapon_hagar();
-void spawnfunc_weapon_machinegun();
-void spawnfunc_weapon_vortex();
+spawnfunc(weapon_crylink);
+spawnfunc(weapon_electro);
+spawnfunc(weapon_hagar);
+spawnfunc(weapon_machinegun);
+spawnfunc(weapon_vortex);
 
-void spawnfunc_target_items();
+spawnfunc(target_items);
 
-void spawnfunc_item_bullets();
-void spawnfunc_item_cells();
-void spawnfunc_item_rockets();
-void spawnfunc_item_shells();
+spawnfunc(item_bullets);
+spawnfunc(item_cells);
+spawnfunc(item_rockets);
+spawnfunc(item_shells);
 
-void spawnfunc_item_jetpack();
+spawnfunc(item_jetpack);
 
-void spawnfunc_item_armor_big();
-void spawnfunc_item_armor_large();
-void spawnfunc_item_armor_small();
+spawnfunc(item_armor_big);
+spawnfunc(item_armor_mega);
+spawnfunc(item_armor_small);
 
-void spawnfunc_item_health_medium();
-void spawnfunc_item_health_mega();
+spawnfunc(item_health_medium);
+spawnfunc(item_health_mega);
 
 //***********************
 //QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
@@ -32,45 +31,48 @@ void spawnfunc_item_health_mega();
 // NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
 
 // SG -> SG
-void spawnfunc_ammo_shells()         { spawnfunc_item_shells();         }
+spawnfunc(ammo_shells)         { spawnfunc_item_shells(this);         }
 
 // MG -> MG
-void spawnfunc_ammo_bullets()        { spawnfunc_item_bullets();        }
+spawnfunc(ammo_bullets)        { spawnfunc_item_bullets(this);        }
 
 // GL -> Mortar
-void spawnfunc_ammo_grenades()       { spawnfunc_item_rockets();        }
+spawnfunc(ammo_grenades)       { spawnfunc_item_rockets(this);        }
 
 // LG -> Lightning
-void spawnfunc_weapon_lightning()    { spawnfunc_weapon_electro();      }
-void spawnfunc_ammo_lightning()      { spawnfunc_item_cells();          }
+spawnfunc(weapon_lightning)    { spawnfunc_weapon_electro(this);      }
+spawnfunc(ammo_lightning)      { spawnfunc_item_cells(this);          }
 
 // Plasma -> Hagar
-void spawnfunc_weapon_plasmagun()    { spawnfunc_weapon_hagar();        }
-void spawnfunc_ammo_cells()          { spawnfunc_item_rockets();        }
+spawnfunc(weapon_plasmagun)    { spawnfunc_weapon_hagar(this);        }
+spawnfunc(ammo_cells)          { spawnfunc_item_rockets(this);        }
 
 // Rail -> Vortex
-void spawnfunc_weapon_railgun()      { spawnfunc_weapon_vortex();          }
-void spawnfunc_ammo_slugs()          { spawnfunc_item_cells();          }
+spawnfunc(weapon_railgun)      { spawnfunc_weapon_vortex(this);          }
+spawnfunc(ammo_slugs)          { spawnfunc_item_cells(this);          }
 
 // BFG -> Crylink
-void spawnfunc_weapon_bfg()          { spawnfunc_weapon_crylink();      }
-void spawnfunc_ammo_bfg()            { spawnfunc_item_cells();          }
+spawnfunc(weapon_bfg)          { spawnfunc_weapon_crylink(this);      }
+spawnfunc(ammo_bfg)            { spawnfunc_item_cells(this);          }
 
 // RL -> RL
-void spawnfunc_ammo_rockets()        { spawnfunc_item_rockets();        }
+spawnfunc(ammo_rockets)        { spawnfunc_item_rockets(this);        }
 
 // Armor
-void spawnfunc_item_armor_body()     { spawnfunc_item_armor_large();    }
-void spawnfunc_item_armor_combat()   { spawnfunc_item_armor_big();      }
-void spawnfunc_item_armor_shard()    { spawnfunc_item_armor_small();    }
-void spawnfunc_item_enviro()         { spawnfunc_item_invincible();     }
+spawnfunc(item_armor_body)     { spawnfunc_item_armor_mega(this);    }
+spawnfunc(item_armor_combat)   { spawnfunc_item_armor_big(this);      }
+spawnfunc(item_armor_shard)    { spawnfunc_item_armor_small(this);    }
+spawnfunc(item_enviro)         { spawnfunc_item_invincible(this);     }
+
+.float wait;
+.float delay;
 
 // weapon remove ent from df
-void target_init_verify()
+void target_init_verify(entity this)
 {
        entity trigger, targ;
-       for(trigger = world; (trigger = find(trigger, classname, "trigger_multiple")); )
-               for(targ = world; (targ = find(targ, targetname, trigger.target)); )
+       for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
+               for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
                        if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
                        {
                                trigger.wait = 0;
@@ -84,79 +86,76 @@ void target_init_verify()
                        }
 }
 
-void spawnfunc_target_init()
-{SELFPARAM();
-       self.spawnflags = 0; // remove all weapons except the ones listed below
-       self.netname = "shotgun"; // keep these weapons through the remove trigger
-       spawnfunc_target_items();
-       InitializeEntity(self, target_init_verify, INITPRIO_FINDTARGET);
+spawnfunc(target_init)
+{
+       this.spawnflags = 0; // remove all weapons except the ones listed below
+       this.netname = "shotgun"; // keep these weapons through the remove trigger
+       spawnfunc_target_items(this);
+       InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
 }
 
 // weapon give ent from defrag
-void target_give_init()
-{SELFPARAM();
-       entity targ;
-       for (targ = world; (targ = find(targ, targetname, self.target)); ) {
-               if (targ.classname == "weapon_rocketlauncher" || targ.classname == "weapon_devastator") {
-                       self.ammo_rockets += targ.count * WEP_CVAR(devastator, ammo);
-                       self.netname = "devastator";
+void target_give_init(entity this)
+{
+       IL_EACH(g_items, it.targetname == this.target,
+       {
+               if (it.classname == "weapon_rocketlauncher" || it.classname == "weapon_devastator") {
+                       this.ammo_rockets += it.count * WEP_CVAR(devastator, ammo);
+                       this.netname = "devastator";
                }
-               else if (targ.classname == "weapon_plasmagun") {
-                       self.ammo_rockets += targ.count * WEP_CVAR_PRI(hagar, ammo); // WEAPONTODO
-                       if(self.netname == "")
-                               self.netname = "hagar";
+               else if (it.classname == "weapon_plasmagun") {
+                       this.ammo_rockets += it.count * WEP_CVAR_PRI(hagar, ammo); // WEAPONTODO
+                       if(this.netname == "")
+                               this.netname = "hagar";
                        else
-                               self.netname = strcat(self.netname, " hagar");
+                               this.netname = strcat(this.netname, " hagar");
                }
-               else if (targ.classname == "weapon_bfg") {
-                       self.ammo_cells += targ.count * WEP_CVAR_PRI(crylink, ammo);
-                       if(self.netname == "")
-                               self.netname = "crylink";
+               else if (it.classname == "weapon_bfg") {
+                       this.ammo_cells += it.count * WEP_CVAR_PRI(crylink, ammo);
+                       if(this.netname == "")
+                               this.netname = "crylink";
                        else
-                               self.netname = strcat(self.netname, " crylink");
+                               this.netname = strcat(this.netname, " crylink");
                }
-               else if (targ.classname == "weapon_grenadelauncher" || targ.classname == "weapon_mortar") {
-                       self.ammo_rockets += targ.count * WEP_CVAR_PRI(mortar, ammo); // WEAPONTODO
-                       if(self.netname == "")
-                               self.netname = "mortar";
+               else if (it.classname == "weapon_grenadelauncher" || it.classname == "weapon_mortar") {
+                       this.ammo_rockets += it.count * WEP_CVAR_PRI(mortar, ammo); // WEAPONTODO
+                       if(this.netname == "")
+                               this.netname = "mortar";
                        else
-                               self.netname = strcat(self.netname, " mortar");
+                               this.netname = strcat(this.netname, " mortar");
                }
-               else if (targ.classname == "item_armor_body")
-                       self.armorvalue = 100;
-               else if (targ.classname == "item_health_mega")
-                       self.health = 200;
-               //remove(targ); // removing ents in init functions causes havoc, workaround:
-        targ.think = SUB_Remove;
-        targ.nextthink = time;
-       }
-       self.spawnflags = 2;
-       spawnfunc_target_items();
-       InitializeEntity(self, target_init_verify, INITPRIO_FINDTARGET);
+               else if (it.classname == "item_armor_body")
+                       this.armorvalue = 100;
+               else if (it.classname == "item_health_mega")
+                       this.health = 200;
+               //remove(it); // removing ents in init functions causes havoc, workaround:
+        setthink(it, SUB_Remove);
+        it.nextthink = time;
+       });
+       this.spawnflags = 2;
+       spawnfunc_target_items(this);
+       InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
 }
 
-void spawnfunc_target_give()
-{SELFPARAM();
-       InitializeEntity(self, target_give_init, INITPRIO_FINDTARGET);
+spawnfunc(target_give)
+{
+       InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
 }
 
-//void spawnfunc_item_flight()       /* handled by buffs mutator or jetpack */
-//void spawnfunc_item_haste()        /* handled by buffs mutator */
-//void spawnfunc_item_health()       /* handled in t_quake.qc */
-//void spawnfunc_item_health_large() /* handled in t_items.qc */
-//void spawnfunc_item_health_small() /* handled in t_items.qc */
-//void spawnfunc_item_health_mega()  /* handled in t_items.qc */
-//void spawnfunc_item_invis()        /* handled by buffs mutator */
-//void spawnfunc_item_regen()        /* handled by buffs mutator */
+//spawnfunc(item_flight)       /* handled by jetpack */
+//spawnfunc(item_haste)        /* handled by buffs mutator */
+//spawnfunc(item_health)       /* handled in t_quake.qc */
+//spawnfunc(item_health_large) /* handled in t_items.qc */
+//spawnfunc(item_health_small) /* handled in t_items.qc */
+//spawnfunc(item_health_mega)  /* handled in t_items.qc */
+//spawnfunc(item_invis)        /* handled by buffs mutator */
+//spawnfunc(item_regen)        /* handled by buffs mutator */
 
 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
 
-void spawnfunc_item_flight()
-{SELFPARAM();
-       if(!cvar("g_buffs") || !cvar("g_buffs_flight"))
-               spawnfunc_item_jetpack();
-       else
-               buff_Init_Compat(self, BUFF_FLIGHT);
+spawnfunc(item_flight)
+{
+       spawnfunc_item_jetpack(this);
 }
 
 .float notteam;
@@ -165,31 +164,31 @@ void spawnfunc_item_flight()
 .float notq3a;
 .float notta;
 .string gametype;
-float DoesQ3ARemoveThisEntity()
-{SELFPARAM();
+bool DoesQ3ARemoveThisEntity(entity this)
+{
        // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
 
-       if(self.notq3a)
+       if(this.notq3a)
                if(!teamplay || g_tdm || g_ctf)
-                       return 1;
+                       return true;
 
-       if(self.notta)
+       if(this.notta)
                if (!(!teamplay || g_tdm || g_ctf))
-                       return 1;
+                       return true;
 
-       if(self.notsingle)
+       if(this.notsingle)
                if(maxclients == 1)
-                       return 1;
+                       return true;
 
-       if(self.notteam)
+       if(this.notteam)
                if(teamplay)
-                       return 1;
+                       return true;
 
-       if(self.notfree)
+       if(this.notfree)
                if(!teamplay)
-                       return 1;
+                       return true;
 
-       if(self.gametype)
+       if(this.gametype)
        {
                string gametypename;
                // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
@@ -201,9 +200,9 @@ float DoesQ3ARemoveThisEntity()
                if(maxclients == 1)
                        gametypename = "single";
                // we do not have the other types (oneflag, obelisk, harvester, teamtournament)
-               if(strstrofs(self.gametype, gametypename, 0) < 0)
-                       return 1;
+               if(strstrofs(this.gametype, gametypename, 0) < 0)
+                       return true;
        }
 
-       return 0;
+       return false;
 }