]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_items.qc
Merge branch 'master' into terencehill/itemstime
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_items.qc
index 03af802e71c12d8b762c0e34df606ba8c096ee3d..c31926550293dd2f0e9eb49b8f80b6723d751bdf 100644 (file)
@@ -1,31 +1,32 @@
-#if defined(CSQC)
-    #include "../dpdefs/csprogsdefs.qh"
-    #include "../common/util.qh"
-    #include "../common/buffs.qh"
-    #include "../common/weapons/weapons.qh"
-    #include "../client/autocvars.qh"
-    #include "../client/movetypes.qh"
-    #include "../client/main.qh"
-    #include "../csqcmodellib/common.qh"
-    #include "../csqcmodellib/cl_model.qh"
-    #include "t_items.qh"
-#elif defined(MENUQC)
-#elif defined(SVQC)
-    #include "../dpdefs/progsdefs.qh"
-    #include "../dpdefs/dpextensions.qh"
-    #include "../warpzonelib/util_server.qh"
-    #include "../common/constants.qh"
-    #include "../common/util.qh"
-    #include "../common/monsters/monsters.qh"
-    #include "../common/weapons/weapons.qh"
+#include "t_items.qh"
+
+#include "../common/items/all.qc"
+
+#if defined(SVQC)
+    #include "_all.qh"
+
+    #include "waypointsprites.qh"
+
+    #include "bot/bot.qh"
+    #include "bot/waypoints.qh"
+
+    #include "mutators/mutators_include.qh"
+
+    #include "weapons/common.qh"
+    #include "weapons/selection.qh"
     #include "weapons/weaponsystem.qh"
-    #include "t_items.qh"
-    #include "autocvars.qh"
-    #include "constants.qh"
-    #include "defs.qh"
-    #include "../common/notifications.qh"
+
+    #include "../common/constants.qh"
     #include "../common/deathtypes.qh"
-    #include "mutators/mutators_include.qh"
+    #include "../common/notifications.qh"
+       #include "../common/triggers/subs.qh"
+    #include "../common/util.qh"
+
+    #include "../common/monsters/all.qh"
+
+    #include "../common/weapons/all.qh"
+
+    #include "../warpzonelib/util_server.qh"
 #endif
 
 #ifdef CSQC
@@ -229,7 +230,7 @@ void ItemRead(float _IsNew)
 #endif
 
 #ifdef SVQC
-float ItemSend(entity to, float sf)
+bool ItemSend(entity to, int sf)
 {
     if(self.gravity)
         sf |= ISF_DROP;
@@ -411,6 +412,159 @@ void Item_Think()
        }
 }
 
+float it_armor_large_time;
+float it_health_mega_time;
+float it_invisible_time;
+float it_speed_time;
+float it_extralife_time;
+float it_strength_time;
+float it_shield_time;
+float it_fuelregen_time;
+float it_jetpack_time;
+float it_superweapons_time;
+
+void Item_ItemsTime_Init()
+{
+       it_armor_large_time = -1;
+       it_health_mega_time = -1;
+       it_invisible_time = -1;
+       it_speed_time = -1;
+       it_extralife_time = -1;
+       it_strength_time = -1;
+       it_shield_time = -1;
+       it_fuelregen_time = -1;
+       it_jetpack_time = -1;
+       it_superweapons_time = -1;
+}
+void Item_ItemsTime_Reset()
+{
+       it_armor_large_time = (it_armor_large_time == -1) ? -1 : 0;
+       it_health_mega_time = (it_health_mega_time == -1) ? -1 : 0;
+       it_invisible_time   = (it_invisible_time   == -1) ? -1 : 0;
+       it_speed_time       = (it_speed_time       == -1) ? -1 : 0;
+       it_extralife_time   = (it_extralife_time   == -1) ? -1 : 0;
+       it_strength_time    = (it_strength_time    == -1) ? -1 : 0;
+       it_shield_time      = (it_shield_time      == -1) ? -1 : 0;
+       it_fuelregen_time   = (it_fuelregen_time   == -1) ? -1 : 0;
+       it_jetpack_time     = (it_jetpack_time     == -1) ? -1 : 0;
+       it_superweapons_time= (it_superweapons_time== -1) ? -1 : 0;
+}
+void Item_ItemsTime_ResetForPlayer(entity e)
+{
+       e.item_armor_large_time = (it_armor_large_time == -1) ? -1 : 0;
+       e.item_health_mega_time = (it_health_mega_time == -1) ? -1 : 0;
+       e.item_invisible_time   = (it_invisible_time   == -1) ? -1 : 0;
+       e.item_speed_time       = (it_speed_time       == -1) ? -1 : 0;
+       e.item_extralife_time   = (it_extralife_time   == -1) ? -1 : 0;
+       e.item_strength_time    = (it_strength_time    == -1) ? -1 : 0;
+       e.item_shield_time      = (it_shield_time      == -1) ? -1 : 0;
+       e.item_fuelregen_time   = (it_fuelregen_time   == -1) ? -1 : 0;
+       e.item_jetpack_time     = (it_jetpack_time     == -1) ? -1 : 0;
+       e.item_superweapons_time= (it_superweapons_time== -1) ? -1 : 0;
+}
+void Item_ItemsTime_Get(entity e)
+{
+       e.item_armor_large_time = it_armor_large_time;
+       e.item_health_mega_time = it_health_mega_time;
+       e.item_invisible_time = it_invisible_time;
+       e.item_speed_time = it_speed_time;
+       e.item_extralife_time = it_extralife_time;
+       e.item_strength_time = it_strength_time;
+       e.item_shield_time = it_shield_time;
+       e.item_fuelregen_time = it_fuelregen_time;
+       e.item_jetpack_time = it_jetpack_time;
+       e.item_superweapons_time = it_superweapons_time;
+}
+float Item_ItemsTime_UpdateTime_Check(float item_time, float t)
+{
+       if(t == 0 && item_time == -1)
+               return TRUE;
+       if(time < t && (item_time <= time || t < item_time))
+               return TRUE;
+       return FALSE;
+}
+void Item_ItemsTime_UpdateTime(entity e, float t)
+{
+       if(g_instagib)
+       {
+               switch(e.items)
+               {
+                       case IT_STRENGTH://"item-invis"
+                               if(Item_ItemsTime_UpdateTime_Check(it_invisible_time, t))
+                                       it_invisible_time = t;
+                               break;
+                       case IT_NAILS://"item-extralife"
+                               if(Item_ItemsTime_UpdateTime_Check(it_extralife_time, t))
+                                       it_extralife_time = t;
+                               break;
+                       case IT_INVINCIBLE://"item-speed"
+                               if(Item_ItemsTime_UpdateTime_Check(it_speed_time, t))
+                                       it_speed_time = t;
+                               break;
+               }
+       }
+       else
+       {
+               switch(e.items)
+               {
+                       case IT_HEALTH:
+                               if(!autocvar_sv_itemstime)
+                                       break;
+                               //if (e.classname == "item_health_mega")
+                                       if(Item_ItemsTime_UpdateTime_Check(it_health_mega_time, t))
+                                               it_health_mega_time = t;
+                               break;
+                       case IT_ARMOR:
+                               if(!autocvar_sv_itemstime)
+                                       break;
+                               if (e.classname == "item_armor_large")
+                                       if(Item_ItemsTime_UpdateTime_Check(it_armor_large_time, t))
+                                               it_armor_large_time = t;
+                               break;
+                       case IT_STRENGTH://"item-strength"
+                               if(Item_ItemsTime_UpdateTime_Check(it_strength_time, t))
+                                       it_strength_time = t;
+                               break;
+                       case IT_INVINCIBLE://"item-shield"
+                               if(Item_ItemsTime_UpdateTime_Check(it_shield_time, t))
+                                       it_shield_time = t;
+                               break;
+                       default:
+                               if(e.weapons & WEPSET_SUPERWEAPONS)
+                                       if(Item_ItemsTime_UpdateTime_Check(it_superweapons_time, t))
+                                                       it_superweapons_time = t;
+               }
+       }
+       switch(e.items)
+       {
+               case IT_FUEL_REGEN://"item-fuelregen"
+                       if(Item_ItemsTime_UpdateTime_Check(it_fuelregen_time, t))
+                               it_fuelregen_time = t;
+                       break;
+               case IT_JETPACK://"item-jetpack"
+                       if(Item_ItemsTime_UpdateTime_Check(it_jetpack_time, t))
+                               it_jetpack_time = t;
+                       break;
+       }
+}
+void Item_ItemsTime_GetForAll()
+{
+       entity e;
+       if(warmup_stage)
+       {
+               FOR_EACH_REALCLIENT(e)
+                       Item_ItemsTime_Get(e);
+       }
+       else
+       {
+               FOR_EACH_REALCLIENT(e)
+               {
+                       if (e.classname != "player")
+                               Item_ItemsTime_Get(e);
+               }
+       }
+}
+
 void Item_Respawn (void)
 {
        Item_Show(self, 1);
@@ -423,6 +577,12 @@ void Item_Respawn (void)
                sound (self, CH_TRIGGER, "misc/itemrespawn.wav", VOL_BASE, ATTEN_NORM); // play respawn sound
        setorigin (self, self.origin);
 
+       if(self.flags & FL_POWERUP || self.classname == "item_armor_large" || self.items == IT_HEALTH || (self.weapons & WEPSET_SUPERWEAPONS))
+       {
+               Item_ItemsTime_UpdateTime(self, 0);
+               Item_ItemsTime_GetForAll();
+       }
+
        self.think = Item_Think;
        self.nextthink = time;
 
@@ -453,6 +613,14 @@ void Item_RespawnCountdown (void)
                                case IT_JETPACK:    name = "item-jetpack"; rgb = '0.5 0.5 0.5'; break;
                                case IT_STRENGTH:   name = "item-strength"; rgb = '0 0 1'; break;
                                case IT_INVINCIBLE: name = "item-shield"; rgb = '1 0 1'; break;
+                               case IT_HEALTH:
+                                       //if (self.classname == "item_health_mega")
+                                               {name = "item_health_mega"; rgb = '1 0 0';}
+                                       break;
+                               case IT_ARMOR:
+                                       if (self.classname == "item_armor_large")
+                                               {name = "item_armor_large"; rgb = '0 1 0';}
+                                       break;
                        }
                        item_name = name;
                        item_color = rgb;
@@ -472,7 +640,11 @@ void Item_RespawnCountdown (void)
                        {
                                WaypointSprite_Spawn(name, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_POWERUP, rgb);
                                if(self.waypointsprite_attached)
+                               {
+                                       if (self.items == IT_HEALTH || self.items == IT_ARMOR)
+                                               WaypointSprite_UpdateRule(self.waypointsprite_attached, 0, SPRITERULE_SPECTATOR);
                                        WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, time + ITEM_RESPAWN_TICKS);
+                               }
                        }
                        else
                        {
@@ -504,16 +676,57 @@ void Item_RespawnThink()
 
 void Item_ScheduleRespawnIn(entity e, float t)
 {
-       if((e.flags & FL_POWERUP) || (e.weapons & WEPSET_SUPERWEAPONS))
+       if((e.flags & FL_POWERUP) || (e.weapons & WEPSET_SUPERWEAPONS) || e.classname == "item_armor_large" || e.items == IT_HEALTH)
        {
+               entity head;
                e.think = Item_RespawnCountdown;
                e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
+               e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
                e.count = 0;
+               if(e.weapons & WEPSET_SUPERWEAPONS)
+               {
+                       for(t = e.scheduledrespawntime, head = world; (head = nextent(head)); )
+                       {
+                               if(e == head)
+                                       continue;
+                               if(clienttype(head) == CLIENTTYPE_NOTACLIENT)
+                               if(head.weapons & WEPSET_SUPERWEAPONS)
+                               if(head.classname != "weapon_info")
+                               {
+                                       if(head.scheduledrespawntime <= time)
+                                       {
+                                               t = 0;
+                                               break;
+                                       }
+                                       if(head.scheduledrespawntime < t)
+                                               t = head.scheduledrespawntime;
+                               }
+                       }
+               }
+               else
+               {
+                       for(t = e.scheduledrespawntime, head = world; (head = find(head, classname, e.classname)); )
+                       {
+                               // in instagib .classname is "instagib" for every item
+                               if(e == head || (g_instagib && e.items != head.items))
+                                       continue;
+                               if(head.scheduledrespawntime <= time)
+                               {
+                                       t = 0;
+                                       break;
+                               }
+                               if(head.scheduledrespawntime < t)
+                                       t = head.scheduledrespawntime;
+                       }
+               }
+               Item_ItemsTime_UpdateTime(e, t);
+               Item_ItemsTime_GetForAll();
        }
        else
        {
                e.think = Item_RespawnThink;
                e.nextthink = time;
+               e.scheduledrespawntime = time + t;
                e.wait = time + t;
        }
 }
@@ -537,23 +750,23 @@ void Item_ScheduleInitialRespawn(entity e)
 
 float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode)
 {
-       if (!item.ammotype)
+       if (!item.(ammotype))
                return false;
 
        if (item.spawnshieldtime)
        {
-               if ((player.ammotype < ammomax) || item.pickup_anyway)
+               if ((player.(ammotype) < ammomax) || item.pickup_anyway)
                {
-                       player.ammotype = bound(player.ammotype, ammomax, player.ammotype + item.ammotype);
+                       player.(ammotype) = bound(player.(ammotype), ammomax, player.(ammotype) + item.(ammotype));
                        goto YEAH;
                }
        }
        else if(g_weapon_stay == 2)
        {
-               float mi = min(item.ammotype, ammomax);
-               if (player.ammotype < mi)
+               float mi = min(item.(ammotype), ammomax);
+               if (player.(ammotype) < mi)
                {
-                       player.ammotype = mi;
+                       player.(ammotype) = mi;
                        goto YEAH;
                }
        }
@@ -664,6 +877,8 @@ float Item_GiveTo(entity item, entity player)
        return 1;
 }
 
+.entity itemdef;
+
 void Item_Touch (void)
 {
        entity e, head;
@@ -703,8 +918,9 @@ void Item_Touch (void)
                self.invincible_finished = max(0, self.invincible_finished - time);
                self.superweapons_finished = max(0, self.superweapons_finished - time);
        }
-
-       if(!Item_GiveTo(self, other))
+       entity it = self.itemdef;
+       bool gave = (it && it.instanceOfPickup) ? ITEM_HANDLE(Pickup, it, self, other) : Item_GiveTo(self, other);
+       if (!gave)
        {
                if (self.classname == "droppedweapon")
                {
@@ -725,9 +941,7 @@ void Item_Touch (void)
 
        if (self.classname == "droppedweapon")
                remove (self);
-       else if (!self.spawnshieldtime)
-               return;
-       else
+       else if (self.spawnshieldtime)
        {
                if(self.team)
                {
@@ -811,7 +1025,7 @@ float generic_pickupevalfunc(entity player, entity item) {return item.bot_pickup
 
 float weapon_pickupevalfunc(entity player, entity item)
 {
-       float c, j, position;
+       float c;
 
        // See if I have it already
        if(item.weapons & ~player.weapons)
@@ -834,8 +1048,8 @@ float weapon_pickupevalfunc(entity player, entity item)
        if( bot_custom_weapon && c )
        {
                // Find the highest position on any range
-               position = -1;
-               for(j = 0; j < WEP_LAST ; ++j){
+               int position = -1;
+               for (int j = 0; j < WEP_LAST ; ++j){
                        if(
                                        bot_weapons_far[j] == item.weapon ||
                                        bot_weapons_mid[j] == item.weapon ||
@@ -925,7 +1139,7 @@ float commodity_pickupevalfunc(entity player, entity item)
        return item.bot_pickupbasevalue * c;
 }
 
-void Item_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+void Item_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 {
        if(ITEM_DAMAGE_NEEDKILL(deathtype))
                RemoveItem();
@@ -1086,6 +1300,8 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
 
                if((itemflags & (FL_POWERUP | FL_WEAPON)) || (itemid & (IT_HEALTH | IT_ARMOR | IT_KEY1 | IT_KEY2)))
                        self.target = "###item###"; // for finding the nearest item using find()
+
+               Item_ItemsTime_UpdateTime(self, 0);
        }
 
        self.bot_pickup = true;
@@ -1152,15 +1368,21 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                return;
        }
 }
+
+void StartItemA (entity a)
+{
+    self.itemdef = a;
+    StartItem(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);
+}
+
 void spawnfunc_item_rockets (void) {
        if(!self.ammo_rockets)
                self.ammo_rockets = g_pickup_rockets;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_rockets.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "rockets", IT_ROCKETS, 0, 0, commodity_pickupevalfunc, 3000);
+    StartItemA (ITEM_Rockets);
 }
 
-void spawnfunc_item_shells (void);
 void spawnfunc_item_bullets (void) {
        if(!weaponswapping)
        if(autocvar_sv_q3acompat_machineshotgunswap)
@@ -1176,7 +1398,7 @@ void spawnfunc_item_bullets (void) {
                self.ammo_nails = g_pickup_nails;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_bullets.mdl", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "bullets", IT_NAILS, 0, 0, commodity_pickupevalfunc, 2000);
+    StartItemA (ITEM_Bullets);
 }
 
 void spawnfunc_item_cells (void) {
@@ -1184,7 +1406,7 @@ void spawnfunc_item_cells (void) {
                self.ammo_cells = g_pickup_cells;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "cells", IT_CELLS, 0, 0, commodity_pickupevalfunc, 2000);
+       StartItemA (ITEM_Cells);
 }
 
 void spawnfunc_item_plasma()
@@ -1193,7 +1415,7 @@ void spawnfunc_item_plasma()
                self.ammo_plasma = g_pickup_plasma;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "plasma", IT_PLASMA, 0, 0, commodity_pickupevalfunc, 2000);
+       StartItemA (ITEM_Plasma);
 }
 
 void spawnfunc_item_shells (void) {
@@ -1211,7 +1433,7 @@ void spawnfunc_item_shells (void) {
                self.ammo_shells = g_pickup_shells;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_shells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "shells", IT_SHELLS, 0, 0, commodity_pickupevalfunc, 500);
+       StartItemA (ITEM_Shells);
 }
 
 void spawnfunc_item_armor_small (void) {
@@ -1221,7 +1443,7 @@ void spawnfunc_item_armor_small (void) {
                self.max_armorvalue = g_pickup_armorsmall_max;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_armorsmall_anyway;
-       StartItem ("models/items/item_armor_small.md3", "misc/armor1.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Armor", IT_ARMOR_SHARD, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+       StartItemA (ITEM_ArmorSmall);
 }
 
 void spawnfunc_item_armor_medium (void) {
@@ -1231,7 +1453,7 @@ void spawnfunc_item_armor_medium (void) {
                self.max_armorvalue = g_pickup_armormedium_max;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_armormedium_anyway;
-       StartItem ("models/items/item_armor_medium.md3", "misc/armor10.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "25 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
+       StartItemA (ITEM_ArmorMedium);
 }
 
 void spawnfunc_item_armor_big (void) {
@@ -1241,7 +1463,7 @@ void spawnfunc_item_armor_big (void) {
                self.max_armorvalue = g_pickup_armorbig_max;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_armorbig_anyway;
-       StartItem ("models/items/item_armor_big.md3", "misc/armor17_5.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "50 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
+       StartItemA (ITEM_ArmorBig);
 }
 
 void spawnfunc_item_armor_large (void) {
@@ -1251,7 +1473,7 @@ void spawnfunc_item_armor_large (void) {
                self.max_armorvalue = g_pickup_armorlarge_max;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_armorlarge_anyway;
-       StartItem ("models/items/item_armor_large.md3", "misc/armor25.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
+       StartItemA (ITEM_ArmorLarge);
 }
 
 void spawnfunc_item_health_small (void) {
@@ -1261,7 +1483,7 @@ void spawnfunc_item_health_small (void) {
                self.health = g_pickup_healthsmall;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_healthsmall_anyway;
-       StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+       StartItemA (ITEM_HealthSmall);
 }
 
 void spawnfunc_item_health_medium (void) {
@@ -1271,7 +1493,7 @@ void spawnfunc_item_health_medium (void) {
                self.health = g_pickup_healthmedium;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_healthmedium_anyway;
-       StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
+    StartItemA (ITEM_HealthMedium);
 }
 
 void spawnfunc_item_health_large (void) {
@@ -1281,17 +1503,17 @@ void spawnfunc_item_health_large (void) {
                self.health = g_pickup_healthlarge;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_healthlarge_anyway;
-       StartItem ("models/items/g_h50.md3", "misc/mediumhealth.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
+       StartItemA (ITEM_HealthLarge);
 }
 
 void spawnfunc_item_health_mega (void) {
-               if(!self.max_health)
-                       self.max_health = g_pickup_healthmega_max;
-               if(!self.health)
-                       self.health = g_pickup_healthmega;
-               if(!self.pickup_anyway)
-                       self.pickup_anyway = g_pickup_healthmega_anyway;
-               StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
+    if(!self.max_health)
+        self.max_health = g_pickup_healthmega_max;
+    if(!self.health)
+        self.health = g_pickup_healthmega;
+    if(!self.pickup_anyway)
+        self.pickup_anyway = g_pickup_healthmega_anyway;
+    StartItemA (ITEM_HealthMega);
 }
 
 // support old misnamed entities
@@ -1305,13 +1527,13 @@ void spawnfunc_item_strength (void) {
                precache_sound("weapons/strength_fire.wav");
                if(!self.strength_finished)
                        self.strength_finished = autocvar_g_balance_powerup_strength_time;
-               StartItem ("models/items/g_strength.md3", "misc/powerup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Strength Powerup", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
+               StartItemA (ITEM_Strength);
 }
 
 void spawnfunc_item_invincible (void) {
                if(!self.invincible_finished)
                        self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
-               StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Shield", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 100000);
+               StartItemA (ITEM_Shield);
 }
 
 // compatibility:
@@ -1472,7 +1694,7 @@ void spawnfunc_item_fuel(void)
                self.ammo_fuel = g_pickup_fuel;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/g_fuel.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "Fuel", IT_FUEL, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+       StartItemA (ITEM_JetpackFuel);
 }
 
 void spawnfunc_item_fuel_regen(void)
@@ -1482,7 +1704,7 @@ void spawnfunc_item_fuel_regen(void)
                spawnfunc_item_fuel();
                return;
        }
-       StartItem ("models/items/g_fuelregen.md3", "misc/itempickup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Fuel regenerator", IT_FUEL_REGEN, 0, FL_POWERUP, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+       StartItemA (ITEM_JetpackRegen);
 }
 
 void spawnfunc_item_jetpack(void)
@@ -1494,7 +1716,7 @@ void spawnfunc_item_jetpack(void)
                spawnfunc_item_fuel();
                return;
        }
-       StartItem ("models/items/g_jetpack.md3", "misc/itempickup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Jet pack", IT_JETPACK, 0, FL_POWERUP, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+       StartItemA (ITEM_Jetpack);
 }
 
 float GiveWeapon(entity e, float wpn, float op, float val)
@@ -1530,56 +1752,56 @@ float GiveWeapon(entity e, float wpn, float op, float val)
 float GiveBit(entity e, .float fld, float bit, float op, float val)
 {
        float v0, v1;
-       v0 = (e.fld & bit);
+       v0 = (e.(fld) & bit);
        switch(op)
        {
                case OP_SET:
                        if(val > 0)
-                               e.fld |= bit;
+                               e.(fld) |= bit;
                        else
-                               e.fld &= ~bit;
+                               e.(fld) &= ~bit;
                        break;
                case OP_MIN:
                case OP_PLUS:
                        if(val > 0)
-                               e.fld |= bit;
+                               e.(fld) |= bit;
                        break;
                case OP_MAX:
                        if(val <= 0)
-                               e.fld &= ~bit;
+                               e.(fld) &= ~bit;
                        break;
                case OP_MINUS:
                        if(val > 0)
-                               e.fld &= ~bit;
+                               e.(fld) &= ~bit;
                        break;
        }
-       v1 = (e.fld & bit);
+       v1 = (e.(fld) & bit);
        return (v0 != v1);
 }
 
 float GiveValue(entity e, .float fld, float op, float val)
 {
        float v0, v1;
-       v0 = e.fld;
+       v0 = e.(fld);
        switch(op)
        {
                case OP_SET:
-                       e.fld = val;
+                       e.(fld) = val;
                        break;
                case OP_MIN:
-                       e.fld = max(e.fld, val); // min 100 cells = at least 100 cells
+                       e.(fld) = max(e.(fld), val); // min 100 cells = at least 100 cells
                        break;
                case OP_MAX:
-                       e.fld = min(e.fld, val);
+                       e.(fld) = min(e.(fld), val);
                        break;
                case OP_PLUS:
-                       e.fld += val;
+                       e.(fld) += val;
                        break;
                case OP_MINUS:
-                       e.fld -= val;
+                       e.(fld) -= val;
                        break;
        }
-       v1 = e.fld;
+       v1 = e.(fld);
        return (v0 != v1);
 }
 
@@ -1602,9 +1824,9 @@ void GiveSound(entity e, float v0, float v1, float t, string snd_incr, string sn
 void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .float regenfield, float regentime)
 {
        if(v0 < v1)
-               e.rotfield = max(e.rotfield, time + rottime);
+               e.(rotfield) = max(e.(rotfield), time + rottime);
        else if(v0 > v1)
-               e.regenfield = max(e.regenfield, time + regentime);
+               e.(regenfield) = max(e.(regenfield), time + regentime);
 }
 float GiveItems(entity e, float beginarg, float endarg)
 {