]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_items.qc
Merge branch 'TimePath/hudpanels_registry' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_items.qc
index 68cc43fb9f5db601ee61975ecdeb5440cd712b56..964b05e1bd2f69099745e91c212191d8f356b209 100644 (file)
@@ -5,9 +5,6 @@
 #if defined(SVQC)
     #include "_all.qh"
 
-    #include "bot/bot.qh"
-    #include "bot/waypoints.qh"
-
     #include "mutators/mutators_include.qh"
 
     #include "weapons/common.qh"
@@ -28,8 +25,8 @@
 #endif
 
 #ifdef CSQC
-void ItemDraw()
-{SELFPARAM();
+void ItemDraw(entity self)
+{
     if(self.gravity)
     {
         Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
@@ -64,8 +61,8 @@ void ItemDraw()
     }
 }
 
-void ItemDrawSimple()
-{SELFPARAM();
+void ItemDrawSimple(entity this)
+{
     if(self.gravity)
     {
         Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
@@ -246,8 +243,8 @@ void ItemRead(float _IsNew)
 #endif
 
 #ifdef SVQC
-bool ItemSend(entity to, int sf)
-{SELFPARAM();
+bool ItemSend(entity this, entity to, int sf)
+{
        if(self.gravity)
                sf |= ISF_DROP;
        else
@@ -476,7 +473,7 @@ void Item_RespawnCountdown (void)
                                {
                                        entity wi = get_weaponinfo(self.weapon);
                                        if (wi.m_id) {
-                                               entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_POWERUP);
+                                               entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Weapon);
                                                wp.wp_extra = wi.m_id;
                                                break;
                                        }
@@ -484,7 +481,7 @@ void Item_RespawnCountdown (void)
                                {
                                        entity ii = self.itemdef;
                                        if (ii.m_id) {
-                                               entity wp = WaypointSprite_Spawn(WP_Item, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_POWERUP);
+                                               entity wp = WaypointSprite_Spawn(WP_Item, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Item);
                                                wp.wp_extra = ii.m_id;
                                                break;
                                        }
@@ -654,7 +651,7 @@ float Item_GiveTo(entity item, entity player)
                        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                        if(it & WepSet_FromWeapon(i))
                        {
-                               W_DropEvent(WR_PICKUP, player, i, item);
+                               W_DropEvent(wr_pickup, player, i, item);
                                W_GiveWeapon(player, i);
                        }
                }
@@ -1197,21 +1194,14 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
        }
 }
 
-string Item_Model(string item_mdl)
-{
-       string output = strcat("models/items/", item_mdl);
-       MUTATOR_CALLHOOK(ItemModel, item_mdl, output);
-       return strzone(item_model_output);
-}
-
 void StartItemA (entity a)
 {SELFPARAM();
     self.itemdef = a;
-    StartItem(Item_Model(a.m_model), a.m_sound, a.m_respawntime(), a.m_respawntimejitter(), a.m_name, a.m_itemid, 0, a.m_itemflags, a.m_pickupevalfunc, a.m_botvalue);
+    StartItem(strzone(a.m_model.model_str()), a.m_sound, a.m_respawntime(), a.m_respawntimejitter(), a.m_name, a.m_itemid, 0, a.m_itemflags, a.m_pickupevalfunc, a.m_botvalue);
 }
 
-void spawnfunc_item_rockets()
-{SELFPARAM();
+spawnfunc(item_rockets)
+{
        if(!self.ammo_rockets)
                self.ammo_rockets = g_pickup_rockets;
        if(!self.pickup_anyway)
@@ -1219,14 +1209,14 @@ void spawnfunc_item_rockets()
     StartItemA (ITEM_Rockets);
 }
 
-void spawnfunc_item_bullets()
-{SELFPARAM();
+spawnfunc(item_bullets)
+{
        if(!weaponswapping)
        if(autocvar_sv_q3acompat_machineshotgunswap)
        if(self.classname != "droppedweapon")
        {
                weaponswapping = true;
-               spawnfunc_item_shells();
+               spawnfunc_item_shells(this);
                weaponswapping = false;
                return;
        }
@@ -1238,8 +1228,8 @@ void spawnfunc_item_bullets()
     StartItemA (ITEM_Bullets);
 }
 
-void spawnfunc_item_cells()
-{SELFPARAM();
+spawnfunc(item_cells)
+{
        if(!self.ammo_cells)
                self.ammo_cells = g_pickup_cells;
        if(!self.pickup_anyway)
@@ -1247,8 +1237,8 @@ void spawnfunc_item_cells()
        StartItemA (ITEM_Cells);
 }
 
-void spawnfunc_item_plasma()
-{SELFPARAM();
+spawnfunc(item_plasma)
+{
        if(!self.ammo_plasma)
                self.ammo_plasma = g_pickup_plasma;
        if(!self.pickup_anyway)
@@ -1256,14 +1246,14 @@ void spawnfunc_item_plasma()
        StartItemA (ITEM_Plasma);
 }
 
-void spawnfunc_item_shells()
-{SELFPARAM();
+spawnfunc(item_shells)
+{
        if(!weaponswapping)
        if(autocvar_sv_q3acompat_machineshotgunswap)
        if(self.classname != "droppedweapon")
        {
                weaponswapping = true;
-               spawnfunc_item_bullets();
+               spawnfunc_item_bullets(this);
                weaponswapping = false;
                return;
        }
@@ -1275,8 +1265,8 @@ void spawnfunc_item_shells()
        StartItemA (ITEM_Shells);
 }
 
-void spawnfunc_item_armor_small()
-{SELFPARAM();
+spawnfunc(item_armor_small)
+{
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armorsmall;
        if(!self.max_armorvalue)
@@ -1286,8 +1276,8 @@ void spawnfunc_item_armor_small()
        StartItemA (ITEM_ArmorSmall);
 }
 
-void spawnfunc_item_armor_medium()
-{SELFPARAM();
+spawnfunc(item_armor_medium)
+{
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armormedium;
        if(!self.max_armorvalue)
@@ -1297,8 +1287,8 @@ void spawnfunc_item_armor_medium()
        StartItemA (ITEM_ArmorMedium);
 }
 
-void spawnfunc_item_armor_big()
-{SELFPARAM();
+spawnfunc(item_armor_big)
+{
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armorbig;
        if(!self.max_armorvalue)
@@ -1308,8 +1298,8 @@ void spawnfunc_item_armor_big()
        StartItemA (ITEM_ArmorLarge);
 }
 
-void spawnfunc_item_armor_large()
-{SELFPARAM();
+spawnfunc(item_armor_large)
+{
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armorlarge;
        if(!self.max_armorvalue)
@@ -1319,8 +1309,8 @@ void spawnfunc_item_armor_large()
        StartItemA (ITEM_ArmorMega);
 }
 
-void spawnfunc_item_health_small()
-{SELFPARAM();
+spawnfunc(item_health_small)
+{
        if(!self.max_health)
                self.max_health = g_pickup_healthsmall_max;
        if(!self.health)
@@ -1330,8 +1320,8 @@ void spawnfunc_item_health_small()
        StartItemA (ITEM_HealthSmall);
 }
 
-void spawnfunc_item_health_medium()
-{SELFPARAM();
+spawnfunc(item_health_medium)
+{
        if(!self.max_health)
                self.max_health = g_pickup_healthmedium_max;
        if(!self.health)
@@ -1341,8 +1331,8 @@ void spawnfunc_item_health_medium()
     StartItemA (ITEM_HealthMedium);
 }
 
-void spawnfunc_item_health_large()
-{SELFPARAM();
+spawnfunc(item_health_large)
+{
        if(!self.max_health)
                self.max_health = g_pickup_healthlarge_max;
        if(!self.health)
@@ -1352,8 +1342,8 @@ void spawnfunc_item_health_large()
        StartItemA (ITEM_HealthLarge);
 }
 
-void spawnfunc_item_health_mega()
-{SELFPARAM();
+spawnfunc(item_health_mega)
+{
     if(!self.max_health)
         self.max_health = g_pickup_healthmega_max;
     if(!self.health)
@@ -1364,28 +1354,28 @@ void spawnfunc_item_health_mega()
 }
 
 // support old misnamed entities
-void spawnfunc_item_armor1() { spawnfunc_item_armor_small(); }  // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
-void spawnfunc_item_armor25() { spawnfunc_item_armor_large(); }
-void spawnfunc_item_health1() { spawnfunc_item_health_small(); }
-void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
-void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
+spawnfunc(item_armor1) { spawnfunc_item_armor_small(this); }  // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
+spawnfunc(item_armor25) { spawnfunc_item_armor_large(this); }
+spawnfunc(item_health1) { spawnfunc_item_health_small(this); }
+spawnfunc(item_health25) { spawnfunc_item_health_medium(this); }
+spawnfunc(item_health100) { spawnfunc_item_health_mega(this); }
 
-void spawnfunc_item_strength()
-{SELFPARAM();
+spawnfunc(item_strength)
+{
                if(!self.strength_finished)
                        self.strength_finished = autocvar_g_balance_powerup_strength_time;
                StartItemA (ITEM_Strength);
 }
 
-void spawnfunc_item_invincible()
-{SELFPARAM();
+spawnfunc(item_invincible)
+{
                if(!self.invincible_finished)
                        self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
                StartItemA (ITEM_Shield);
 }
 
 // compatibility:
-void spawnfunc_item_quad() {SELFPARAM(); self.classname = "item_strength";spawnfunc_item_strength();}
+spawnfunc(item_quad) { self.classname = "item_strength";spawnfunc_item_strength(this);}
 
 void target_items_use()
 {SELFPARAM();
@@ -1411,8 +1401,8 @@ void target_items_use()
                centerprint(activator, self.message);
 }
 
-void spawnfunc_target_items (void)
-{SELFPARAM();
+spawnfunc(target_items)
+{
        float n, i, j;
        entity e;
        string s;
@@ -1451,8 +1441,10 @@ void spawnfunc_target_items (void)
                                        if(s == e.netname)
                                        {
                                                self.weapons |= WepSet_FromWeapon(j);
-                                               if(self.spawnflags == 0 || self.spawnflags == 2)
-                                                       WEP_ACTION(e.weapon, WR_INIT);
+                                               if(self.spawnflags == 0 || self.spawnflags == 2) {
+                                                       Weapon w = get_weaponinfo(e.weapon);
+                                                       w.wr_init(w);
+                                               }
                                                break;
                                        }
                                }
@@ -1522,15 +1514,16 @@ void spawnfunc_target_items (void)
                        e = get_weaponinfo(j);
                        if(argv(i) == e.netname)
                        {
-                               WEP_ACTION(e.weapon, WR_INIT);
+                               Weapon w = get_weaponinfo(e.weapon);
+                               w.wr_init(w);
                                break;
                        }
                }
        }
 }
 
-void spawnfunc_item_fuel(void)
-{SELFPARAM();
+spawnfunc(item_fuel)
+{
        if(!self.ammo_fuel)
                self.ammo_fuel = g_pickup_fuel;
        if(!self.pickup_anyway)
@@ -1538,23 +1531,23 @@ void spawnfunc_item_fuel(void)
        StartItemA (ITEM_JetpackFuel);
 }
 
-void spawnfunc_item_fuel_regen(void)
+spawnfunc(item_fuel_regen)
 {
        if(start_items & ITEM_JetpackRegen.m_itemid)
        {
-               spawnfunc_item_fuel();
+               spawnfunc_item_fuel(this);
                return;
        }
        StartItemA (ITEM_JetpackRegen);
 }
 
-void spawnfunc_item_jetpack(void)
-{SELFPARAM();
+spawnfunc(item_jetpack)
+{
        if(!self.ammo_fuel)
                self.ammo_fuel = g_pickup_fuel_jetpack;
        if(start_items & ITEM_Jetpack.m_itemid)
        {
-               spawnfunc_item_fuel();
+               spawnfunc_item_fuel(this);
                return;
        }
        StartItemA (ITEM_Jetpack);
@@ -1835,8 +1828,10 @@ float GiveItems(entity e, float beginarg, float endarg)
                {
                        POSTGIVE_WEAPON(e, j, SND(WEAPONPICKUP), string_null);
                        if (!(save_weapons & WepSet_FromWeapon(j)))
-                               if(e.weapons & WepSet_FromWeapon(j))
-                                       WEP_ACTION(wi.weapon, WR_INIT);
+                               if(e.weapons & WepSet_FromWeapon(j)) {
+                                       Weapon w = get_weaponinfo(wi.weapon);
+                                       w.wr_init(w);
+                               }
                }
        }
        POSTGIVE_VALUE(e, strength_finished, 1, SND(POWERUP), SND(POWEROFF));