]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_items.qc
Remove oldself variables
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_items.qc
index 873f7a53c1f89159e32534626b6609221d15bd23..47165c7732921b1f2c1b21da16658c2c9d7dc352 100644 (file)
@@ -5,8 +5,6 @@
 #if defined(SVQC)
     #include "_all.qh"
 
-    #include "waypointsprites.qh"
-
     #include "bot/bot.qh"
     #include "bot/waypoints.qh"
 
@@ -31,7 +29,7 @@
 
 #ifdef CSQC
 void ItemDraw()
-{
+{SELFPARAM();
     if(self.gravity)
     {
         Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
@@ -67,7 +65,7 @@ void ItemDraw()
 }
 
 void ItemDrawSimple()
-{
+{SELFPARAM();
     if(self.gravity)
     {
         Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
@@ -78,7 +76,7 @@ void ItemDrawSimple()
 }
 
 void ItemRead(float _IsNew)
-{
+{SELFPARAM();
     int sf = ReadByte();
 
     if(sf & ISF_LOCATION)
@@ -174,12 +172,12 @@ void ItemRead(float _IsNew)
                 self.mdl = strzone(sprintf("%s%s.dpm", _fn2, autocvar_cl_simpleitems_postfix));
             else if(fexists(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix)))
                 self.mdl = strzone(sprintf("%s%s.iqm", _fn2, autocvar_cl_simpleitems_postfix));
-            else if(fexists(sprintf("%s%s.obj", _fn2, autocvar_cl_simpleitems_postfix)))
-                self.mdl = strzone(sprintf("%s%s.obj", _fn2, autocvar_cl_simpleitems_postfix));
+            else if(fexists(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix)))
+                self.mdl = strzone(sprintf("%s%s.mdl", _fn2, autocvar_cl_simpleitems_postfix));
             else
             {
                 self.draw = ItemDraw;
-                dprint("Simple item requested for ", _fn, " but no model exsist for it\n");
+                LOG_TRACE("Simple item requested for ", _fn, " but no model exists for it\n");
             }
         }
 
@@ -188,7 +186,7 @@ void ItemRead(float _IsNew)
 
 
         if(self.mdl == "")
-            dprint("^1WARNING!^7 self.mdl is unset for item ", self.classname, " tell tZork aboute this!\n");
+            LOG_TRACE("^1WARNING!^7 self.mdl is unset for item ", self.classname, " tell tZork aboute this!\n");
 
         precache_model(self.mdl);
         setmodel(self, self.mdl);
@@ -231,7 +229,7 @@ void ItemRead(float _IsNew)
 
 #ifdef SVQC
 bool ItemSend(entity to, int sf)
-{
+{SELFPARAM();
     if(self.gravity)
         sf |= ISF_DROP;
     else
@@ -272,7 +270,7 @@ bool ItemSend(entity to, int sf)
     {
 
         if(self.mdl == "")
-            dprint("^1WARNING!^7 self.mdl is unset for item ", self.classname, "exspect a crash just aboute now\n");
+            LOG_TRACE("^1WARNING!^7 self.mdl is unset for item ", self.classname, "exspect a crash just aboute now\n");
 
         WriteString(MSG_ENTITY, self.mdl);
     }
@@ -297,7 +295,7 @@ void ItemUpdate(entity item)
 }
 
 float have_pickup_item(void)
-{
+{SELFPARAM();
        if(self.flags & FL_POWERUP)
        {
                if(autocvar_g_powerups > 0)
@@ -384,7 +382,7 @@ void Item_Show (entity e, float mode)
                e.ItemStatus &= ~ITS_AVAILABLE;
        }
 
-       if (e.items & IT_STRENGTH || e.items & IT_INVINCIBLE)
+       if (e.items & ITEM_Strength.m_itemid || e.items & ITEM_Shield.m_itemid)
            e.ItemStatus |= ITS_POWERUP;
 
        if (autocvar_g_nodepthtestitems)
@@ -403,7 +401,7 @@ void Item_Show (entity e, float mode)
 }
 
 void Item_Think()
-{
+{SELFPARAM();
        self.nextthink = time;
        if(self.origin != self.oldorigin)
        {
@@ -412,193 +410,25 @@ 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_ResetTimes()
-{
-       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_ResetTimesForPlayer(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_SetTimesForPlayer(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;
-}
-
-void Item_ItemsTime_SetTime(entity e, float t)
-{
-       if(!autocvar_sv_itemstime)
-               return;
-
-       if(g_instagib)
-       {
-               switch(e.items)
-               {
-                       case IT_STRENGTH://"item-invis"
-                               it_invisible_time = t;
-                               break;
-                       case IT_NAILS://"item-extralife"
-                               it_extralife_time = t;
-                               break;
-                       case IT_INVINCIBLE://"item-speed"
-                               it_speed_time = t;
-                               break;
-               }
-       }
-       else
-       {
-               switch(e.items)
-               {
-                       case IT_HEALTH:
-                               // if(e.classname == "item_health_mega") // IT_HEALTH unequivocally identifies it
-                                       it_health_mega_time = t;
-                               break;
-                       case IT_ARMOR:
-                               if(e.classname == "item_armor_large") // IT_ARMOR doesn't unequivocally identifies it
-                                       it_armor_large_time = t;
-                               break;
-                       case IT_STRENGTH://"item-strength"
-                               it_strength_time = t;
-                               break;
-                       case IT_INVINCIBLE://"item-shield"
-                               it_shield_time = t;
-                               break;
-                       default:
-                               if(e.weapons & WEPSET_SUPERWEAPONS)
-                                       it_superweapons_time = t;
-               }
-       }
-       switch(e.items)
-       {
-               case IT_FUEL_REGEN://"item-fuelregen"
-                       it_fuelregen_time = t;
-                       break;
-               case IT_JETPACK://"item-jetpack"
-                       it_jetpack_time = t;
-                       break;
-       }
-}
-void Item_ItemsTime_SetTimesForAllPlayers()
-{
-       entity e;
-       if(warmup_stage)
-       {
-               FOR_EACH_REALCLIENT(e)
-                       Item_ItemsTime_SetTimesForPlayer(e);
-       }
-       else
-       {
-               FOR_EACH_REALCLIENT(e)
-               {
-                       if(!IS_PLAYER(e))
-                               Item_ItemsTime_SetTimesForPlayer(e);
-               }
-       }
-}
-
-float Item_ItemsTime_UpdateTime(entity e, float t)
-{
-       entity head;
-       bool isavailable = (t == 0);
-       if(e.weapons & WEPSET_SUPERWEAPONS)
-       {
-               for(head = world; (head = nextent(head)); )
-               {
-                       if(clienttype(head) != CLIENTTYPE_NOTACLIENT || !(head.weapons & WEPSET_SUPERWEAPONS) || head.classname == "weapon_info")
-                               continue;
-                       if(e == head)
-                               continue;
-
-                       if(head.scheduledrespawntime <= time)
-                               isavailable = true;
-                       else if(t == 0 || head.scheduledrespawntime < t)
-                               t = head.scheduledrespawntime;
-               }
-       }
-       else
-       {
-               for(head = world; (head = nextent(head)); )
-               {
-                       if(head.itemdef != e.itemdef)
-                               continue;
-                       if(e == head)
-                               continue;
-
-                       if(head.scheduledrespawntime <= time)
-                               isavailable = true;
-                       else if(t == 0 || head.scheduledrespawntime < t)
-                               t = head.scheduledrespawntime;
-               }
-       }
-       if(isavailable)
-               t = -t; // let know the client there's another available item
-       return t;
-}
+bool Item_ItemsTime_SpectatorOnly(GameItem it);
+bool Item_ItemsTime_Allow(GameItem it, WepSet _weapons);
+float Item_ItemsTime_UpdateTime(entity e, float t);
+void Item_ItemsTime_SetTime(entity e, float t);
+void Item_ItemsTime_SetTimesForAllPlayers();
 
 void Item_Respawn (void)
-{
+{SELFPARAM();
        Item_Show(self, 1);
        // this is ugly...
-       if(self.items == IT_STRENGTH)
+       if(self.items == ITEM_Strength.m_itemid)
                sound (self, CH_TRIGGER, "misc/strength_respawn.wav", VOL_BASE, ATTEN_NORM);    // play respawn sound
-       else if(self.items == IT_INVINCIBLE)
+       else if(self.items == ITEM_Shield.m_itemid)
                sound (self, CH_TRIGGER, "misc/shield_respawn.wav", VOL_BASE, ATTEN_NORM);      // play respawn sound
        else
                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))
+    if (Item_ItemsTime_Allow(self.itemdef, self.weapons))
        {
                float t = Item_ItemsTime_UpdateTime(self, 0);
                Item_ItemsTime_SetTime(self, t);
@@ -608,12 +438,12 @@ void Item_Respawn (void)
        self.think = Item_Think;
        self.nextthink = time;
 
-       //pointparticles(particleeffectnum("item_respawn"), self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
-       pointparticles(particleeffectnum("item_respawn"), self.origin + 0.5 * (self.mins + self.maxs), '0 0 0', 1);
+       //Send_Effect(EFFECT_ITEM_RESPAWN, self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
+       Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
 }
 
 void Item_RespawnCountdown (void)
-{
+{SELFPARAM();
        if(self.count >= ITEM_RESPAWN_TICKS)
        {
                if(self.waypointsprite_attached)
@@ -626,67 +456,36 @@ void Item_RespawnCountdown (void)
                self.count += 1;
                if(self.count == 1)
                {
-                       string name;
-                       vector rgb = '1 0 1';
-                       name = string_null;
-                       switch(self.items)
-                       {
-                               case IT_FUEL_REGEN: name = "item-fuelregen"; rgb = '1 0.5 0'; break;
-                               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;
-                       MUTATOR_CALLHOOK(Item_RespawnCountdown);
-                       name = item_name;
-                       rgb = item_color;
-                       if(self.flags & FL_WEAPON)
-                       {
+                       MUTATOR_CALLHOOK(Item_RespawnCountdown, string_null, '0 0 0');
+                       int wpextra = 0;
+            entity e = self.itemdef;
+            if (e) wpextra = e.m_id;
+                       if (self.flags & FL_WEAPON) {
                                entity wi = get_weaponinfo(self.weapon);
-                               if(wi)
-                               {
-                                       name = wi.wpmodel;
-                                       rgb = '1 0 0';
-                               }
-                       }
-                       if(name)
-                       {
-                               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
-                       {
-                               print("Unknown powerup-marked item is wanting to respawn\n");
-                               localcmd(sprintf("prvm_edict server %d\n", num_for_edict(self)));
+                               if (wi) wpextra = wi.m_id;
                        }
+            entity wp = WaypointSprite_Spawn(WP_Item, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_POWERUP);
+            wp.wp_extra = wpextra;
+            if(self.waypointsprite_attached)
+            {
+                GameItem def = self.itemdef;
+                if (Item_ItemsTime_SpectatorOnly(def))
+                    WaypointSprite_UpdateRule(self.waypointsprite_attached, 0, SPRITERULE_SPECTATOR);
+                WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, time + ITEM_RESPAWN_TICKS);
+            }
                }
 
                if(self.waypointsprite_attached)
                {
+                       setself(self.waypointsprite_attached);
                        entity e;
-                       entity it = self;
-                       self = self.waypointsprite_attached;
                        FOR_EACH_REALCLIENT(e)
                                if(self.waypointsprite_visible_for_player(e))
                                {
                                        msg_entity = e;
-                                       soundto(MSG_ONE, it, CH_TRIGGER, "misc/itemrespawncountdown.wav", VOL_BASE, ATTEN_NORM);        // play respawn sound
+                                       soundto(MSG_ONE, this, CH_TRIGGER, "misc/itemrespawncountdown.wav", VOL_BASE, ATTEN_NORM);      // play respawn sound
                                }
-                       self = it;
+                       setself(this);
 
                        WaypointSprite_Ping(self.waypointsprite_attached);
                        //WaypointSprite_UpdateHealth(self.waypointsprite_attached, self.count);
@@ -697,7 +496,7 @@ void Item_RespawnCountdown (void)
 }
 
 void Item_RespawnThink()
-{
+{SELFPARAM();
        self.nextthink = time;
        if(self.origin != self.oldorigin)
        {
@@ -711,7 +510,7 @@ void Item_RespawnThink()
 
 void Item_ScheduleRespawnIn(entity e, float t)
 {
-       if((e.flags & FL_POWERUP) || (e.weapons & WEPSET_SUPERWEAPONS) || e.classname == "item_armor_large" || e.items == IT_HEALTH)
+       if (Item_ItemsTime_Allow(e.itemdef, e.weapons))
        {
                e.think = Item_RespawnCountdown;
                e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
@@ -877,7 +676,7 @@ float Item_GiveTo(entity item, entity player)
 }
 
 void Item_Touch (void)
-{
+{SELFPARAM();
        entity e, head;
 
        // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
@@ -890,20 +689,15 @@ void Item_Touch (void)
                }
        }
 
-       if (!IS_PLAYER(other))
-               return;
-       if (other.frozen)
-               return;
-       if (other.deadflag)
-               return;
-       if (self.solid != SOLID_TRIGGER)
-               return;
-       if (self.owner == other)
-               return;
-       if (time < self.item_spawnshieldtime)
-               return;
+       if(!(other.flags & FL_PICKUPITEMS)
+       || other.frozen
+       || other.deadflag
+       || (self.solid != SOLID_TRIGGER)
+       || (self.owner == other)
+       || (time < self.item_spawnshieldtime)
+       ) { return;}
 
-       switch(MUTATOR_CALLHOOK(ItemTouch))
+       switch(MUTATOR_CALLHOOK(ItemTouch, self, other))
        {
                case MUT_ITEMTOUCH_RETURN: { return; }
                case MUT_ITEMTOUCH_PICKUP: { goto pickup; }
@@ -933,7 +727,7 @@ void Item_Touch (void)
 
        other.last_pickup = time;
 
-       pointparticles(particleeffectnum("item_pickup"), self.origin, '0 0 0', 1);
+       Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
        sound (other, CH_TRIGGER, self.item_pickupsound, VOL_BASE, ATTEN_NORM);
 
        if (self.classname == "droppedweapon")
@@ -961,7 +755,7 @@ void Item_Touch (void)
 }
 
 void Item_Reset()
-{
+{SELFPARAM();
        Item_Show(self, !self.state);
        setorigin (self, self.origin);
 
@@ -979,13 +773,13 @@ void Item_Reset()
 }
 
 void Item_FindTeam()
-{
+{SELFPARAM();
        entity head, e;
 
        if(self.effects & EF_NODRAW)
        {
                // marker for item team search
-               dprint("Initializing item team ", ftos(self.team), "\n");
+               LOG_TRACE("Initializing item team ", ftos(self.team), "\n");
                RandomSelection_Init();
                for(head = world; (head = findfloat(head, team, self.team)); ) if(head.flags & FL_ITEM)
                        RandomSelection_Add(head, 0, string_null, head.cnt, 0);
@@ -1011,7 +805,8 @@ void Item_FindTeam()
 // Savage: used for item garbage-collection
 // TODO: perhaps nice special effect?
 void RemoveItem(void)
-{
+{SELFPARAM();
+       Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
        remove(self);
 }
 
@@ -1085,17 +880,17 @@ float commodity_pickupevalfunc(entity player, entity item)
                if (!(player.weapons & WepSet_FromWeapon(i)))
                        continue;
 
-               if(wi.items & IT_SHELLS)
+               if(wi.items & ITEM_Shells.m_itemid)
                        need_shells = true;
-               else if(wi.items & IT_NAILS)
+               else if(wi.items & ITEM_Bullets.m_itemid)
                        need_nails = true;
-               else if(wi.items & IT_ROCKETS)
+               else if(wi.items & ITEM_Rockets.m_itemid)
                        need_rockets = true;
-               else if(wi.items & IT_CELLS)
+               else if(wi.items & ITEM_Cells.m_itemid)
                        need_cells = true;
-               else if(wi.items & IT_PLASMA)
+               else if(wi.items & ITEM_Plasma.m_itemid)
                        need_plasma = true;
-               else if(wi.items & IT_FUEL)
+               else if(wi.items & ITEM_JetpackFuel.m_itemid)
                        need_fuel = true;
        }
 
@@ -1143,7 +938,7 @@ void Item_Damage(entity inflictor, entity attacker, float damage, int deathtype,
 }
 
 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, float defaultrespawntimejitter, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
-{
+{SELFPARAM();
        startitem_failed = false;
 
        if(self.model == "")
@@ -1274,8 +1069,8 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                            // why not flags & fl_item?
                                if(otheritem.is_item)
                                {
-                                       dprint("XXX Found duplicated item: ", itemname, vtos(self.origin));
-                                       dprint(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
+                                       LOG_TRACE("XXX Found duplicated item: ", itemname, vtos(self.origin));
+                                       LOG_TRACE(" vs ", otheritem.netname, vtos(otheritem.origin), "\n");
                                        error("Mapper sucks.");
                                }
                        }
@@ -1288,9 +1083,9 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                precache_sound (self.item_pickupsound);
 
                precache_sound ("misc/itemrespawncountdown.wav");
-               if(itemid == IT_STRENGTH)
+               if(itemid == ITEM_Strength.m_itemid)
                        precache_sound ("misc/strength_respawn.wav");
-               else if(itemid == IT_INVINCIBLE)
+               else if(itemid == ITEM_Shield.m_itemid)
                        precache_sound ("misc/shield_respawn.wav");
                else
                        precache_sound ("misc/itemrespawn.wav");
@@ -1358,7 +1153,7 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                self.SendFlags |= ISF_ANGLES;
 
        // call this hook after everything else has been done
-       if(MUTATOR_CALLHOOK(Item_Spawn))
+       if(MUTATOR_CALLHOOK(Item_Spawn, self))
        {
                startitem_failed = true;
                remove(self);
@@ -1366,13 +1161,21 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
        }
 }
 
-void StartItemA (entity a)
+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(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(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);
 }
 
-void spawnfunc_item_rockets (void) {
+void spawnfunc_item_rockets()
+{SELFPARAM();
        if(!self.ammo_rockets)
                self.ammo_rockets = g_pickup_rockets;
        if(!self.pickup_anyway)
@@ -1380,7 +1183,8 @@ void spawnfunc_item_rockets (void) {
     StartItemA (ITEM_Rockets);
 }
 
-void spawnfunc_item_bullets (void) {
+void spawnfunc_item_bullets()
+{SELFPARAM();
        if(!weaponswapping)
        if(autocvar_sv_q3acompat_machineshotgunswap)
        if(self.classname != "droppedweapon")
@@ -1398,7 +1202,8 @@ void spawnfunc_item_bullets (void) {
     StartItemA (ITEM_Bullets);
 }
 
-void spawnfunc_item_cells (void) {
+void spawnfunc_item_cells()
+{SELFPARAM();
        if(!self.ammo_cells)
                self.ammo_cells = g_pickup_cells;
        if(!self.pickup_anyway)
@@ -1407,7 +1212,7 @@ void spawnfunc_item_cells (void) {
 }
 
 void spawnfunc_item_plasma()
-{
+{SELFPARAM();
        if(!self.ammo_plasma)
                self.ammo_plasma = g_pickup_plasma;
        if(!self.pickup_anyway)
@@ -1415,7 +1220,8 @@ void spawnfunc_item_plasma()
        StartItemA (ITEM_Plasma);
 }
 
-void spawnfunc_item_shells (void) {
+void spawnfunc_item_shells()
+{SELFPARAM();
        if(!weaponswapping)
        if(autocvar_sv_q3acompat_machineshotgunswap)
        if(self.classname != "droppedweapon")
@@ -1433,7 +1239,8 @@ void spawnfunc_item_shells (void) {
        StartItemA (ITEM_Shells);
 }
 
-void spawnfunc_item_armor_small (void) {
+void spawnfunc_item_armor_small()
+{SELFPARAM();
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armorsmall;
        if(!self.max_armorvalue)
@@ -1443,7 +1250,8 @@ void spawnfunc_item_armor_small (void) {
        StartItemA (ITEM_ArmorSmall);
 }
 
-void spawnfunc_item_armor_medium (void) {
+void spawnfunc_item_armor_medium()
+{SELFPARAM();
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armormedium;
        if(!self.max_armorvalue)
@@ -1453,27 +1261,30 @@ void spawnfunc_item_armor_medium (void) {
        StartItemA (ITEM_ArmorMedium);
 }
 
-void spawnfunc_item_armor_big (void) {
+void spawnfunc_item_armor_big()
+{SELFPARAM();
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armorbig;
        if(!self.max_armorvalue)
                self.max_armorvalue = g_pickup_armorbig_max;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_armorbig_anyway;
-       StartItemA (ITEM_ArmorBig);
+       StartItemA (ITEM_ArmorLarge);
 }
 
-void spawnfunc_item_armor_large (void) {
+void spawnfunc_item_armor_large()
+{SELFPARAM();
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armorlarge;
        if(!self.max_armorvalue)
                self.max_armorvalue = g_pickup_armorlarge_max;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_armorlarge_anyway;
-       StartItemA (ITEM_ArmorLarge);
+       StartItemA (ITEM_ArmorMega);
 }
 
-void spawnfunc_item_health_small (void) {
+void spawnfunc_item_health_small()
+{SELFPARAM();
        if(!self.max_health)
                self.max_health = g_pickup_healthsmall_max;
        if(!self.health)
@@ -1483,7 +1294,8 @@ void spawnfunc_item_health_small (void) {
        StartItemA (ITEM_HealthSmall);
 }
 
-void spawnfunc_item_health_medium (void) {
+void spawnfunc_item_health_medium()
+{SELFPARAM();
        if(!self.max_health)
                self.max_health = g_pickup_healthmedium_max;
        if(!self.health)
@@ -1493,7 +1305,8 @@ void spawnfunc_item_health_medium (void) {
     StartItemA (ITEM_HealthMedium);
 }
 
-void spawnfunc_item_health_large (void) {
+void spawnfunc_item_health_large()
+{SELFPARAM();
        if(!self.max_health)
                self.max_health = g_pickup_healthlarge_max;
        if(!self.health)
@@ -1503,7 +1316,8 @@ void spawnfunc_item_health_large (void) {
        StartItemA (ITEM_HealthLarge);
 }
 
-void spawnfunc_item_health_mega (void) {
+void spawnfunc_item_health_mega()
+{SELFPARAM();
     if(!self.max_health)
         self.max_health = g_pickup_healthmega_max;
     if(!self.health)
@@ -1520,24 +1334,26 @@ void spawnfunc_item_health1() { spawnfunc_item_health_small(); }
 void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
 
-void spawnfunc_item_strength (void) {
+void spawnfunc_item_strength()
+{SELFPARAM();
                precache_sound("weapons/strength_fire.wav");
                if(!self.strength_finished)
                        self.strength_finished = autocvar_g_balance_powerup_strength_time;
                StartItemA (ITEM_Strength);
 }
 
-void spawnfunc_item_invincible (void) {
+void spawnfunc_item_invincible()
+{SELFPARAM();
                if(!self.invincible_finished)
                        self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
                StartItemA (ITEM_Shield);
 }
 
 // compatibility:
-void spawnfunc_item_quad (void) {self.classname = "item_strength";spawnfunc_item_strength();}
+void spawnfunc_item_quad() {SELFPARAM(); self.classname = "item_strength";spawnfunc_item_strength();}
 
-void target_items_use (void)
-{
+void target_items_use()
+{SELFPARAM();
        if(activator.classname == "droppedweapon")
        {
                EXACTTRIGGER_TOUCH;
@@ -1561,7 +1377,7 @@ void target_items_use (void)
 }
 
 void spawnfunc_target_items (void)
-{
+{SELFPARAM();
        float n, i, j;
        entity e;
        string s;
@@ -1579,7 +1395,7 @@ void spawnfunc_target_items (void)
        precache_sound("misc/armor25.wav");
        precache_sound("misc/powerup.wav");
        precache_sound("misc/poweroff.wav");
-       precache_sound("weapons/weaponpickup.wav");
+       precache_sound(W_Sound("weaponpickup"));
 
        n = tokenize_console(self.netname);
        if(argv(0) == "give")
@@ -1593,11 +1409,11 @@ void spawnfunc_target_items (void)
                        if     (argv(i) == "unlimited_ammo")         self.items |= IT_UNLIMITED_AMMO;
                        else if(argv(i) == "unlimited_weapon_ammo")  self.items |= IT_UNLIMITED_WEAPON_AMMO;
                        else if(argv(i) == "unlimited_superweapons") self.items |= IT_UNLIMITED_SUPERWEAPONS;
-                       else if(argv(i) == "strength")               self.items |= IT_STRENGTH;
-                       else if(argv(i) == "invincible")             self.items |= IT_INVINCIBLE;
+                       else if(argv(i) == "strength")               self.items |= ITEM_Strength.m_itemid;
+                       else if(argv(i) == "invincible")             self.items |= ITEM_Shield.m_itemid;
                        else if(argv(i) == "superweapons")           self.items |= IT_SUPERWEAPON;
-                       else if(argv(i) == "jetpack")                self.items |= IT_JETPACK;
-                       else if(argv(i) == "fuel_regen")             self.items |= IT_FUEL_REGEN;
+                       else if(argv(i) == "jetpack")                self.items |= ITEM_Jetpack.m_itemid;
+                       else if(argv(i) == "fuel_regen")             self.items |= ITEM_JetpackRegen.m_itemid;
                        else
                        {
                                for(j = WEP_FIRST; j <= WEP_LAST; ++j)
@@ -1613,7 +1429,7 @@ void spawnfunc_target_items (void)
                                        }
                                }
                                if(j > WEP_LAST)
-                                       print("target_items: invalid item ", argv(i), "\n");
+                                       LOG_INFO("target_items: invalid item ", argv(i), "\n");
                        }
                }
 
@@ -1647,11 +1463,11 @@ void spawnfunc_target_items (void)
                self.netname = "";
                self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_UNLIMITED_WEAPON_AMMO), "unlimited_weapon_ammo");
                self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_UNLIMITED_SUPERWEAPONS), "unlimited_superweapons");
-               self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.strength_finished * !!(self.items & IT_STRENGTH), "strength");
-               self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.invincible_finished * !!(self.items & IT_INVINCIBLE), "invincible");
+               self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.strength_finished * !!(self.items & ITEM_Strength.m_itemid), "strength");
+               self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.invincible_finished * !!(self.items & ITEM_Shield.m_itemid), "invincible");
                self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, self.superweapons_finished * !!(self.items & IT_SUPERWEAPON), "superweapons");
-               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_JETPACK), "jetpack");
-               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & IT_FUEL_REGEN), "fuel_regen");
+               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & ITEM_Jetpack.m_itemid), "jetpack");
+               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.items & ITEM_JetpackRegen.m_itemid), "fuel_regen");
                if(self.ammo_shells != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_shells), "shells");
                if(self.ammo_nails != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_nails), "nails");
                if(self.ammo_rockets != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_rockets), "rockets");
@@ -1686,7 +1502,7 @@ void spawnfunc_target_items (void)
 }
 
 void spawnfunc_item_fuel(void)
-{
+{SELFPARAM();
        if(!self.ammo_fuel)
                self.ammo_fuel = g_pickup_fuel;
        if(!self.pickup_anyway)
@@ -1696,7 +1512,7 @@ void spawnfunc_item_fuel(void)
 
 void spawnfunc_item_fuel_regen(void)
 {
-       if(start_items & IT_FUEL_REGEN)
+       if(start_items & ITEM_JetpackRegen.m_itemid)
        {
                spawnfunc_item_fuel();
                return;
@@ -1705,10 +1521,10 @@ void spawnfunc_item_fuel_regen(void)
 }
 
 void spawnfunc_item_jetpack(void)
-{
+{SELFPARAM();
        if(!self.ammo_fuel)
                self.ammo_fuel = g_pickup_fuel_jetpack;
-       if(start_items & IT_JETPACK)
+       if(start_items & ITEM_Jetpack.m_itemid)
        {
                spawnfunc_item_fuel();
                return;
@@ -1826,7 +1642,7 @@ void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .floa
                e.(regenfield) = max(e.(regenfield), time + regentime);
 }
 float GiveItems(entity e, float beginarg, float endarg)
-{
+{SELFPARAM();
        float got, i, j, val, op;
        float _switchweapon;
        entity wi;
@@ -1888,13 +1704,13 @@ float GiveItems(entity e, float beginarg, float endarg)
                                op = OP_MINUS;
                                continue;
                        case "ALL":
-                               got += GiveBit(e, items, IT_FUEL_REGEN, op, val);
+                               got += GiveBit(e, items, ITEM_JetpackRegen.m_itemid, op, val);
                                got += GiveValue(e, strength_finished, op, val);
                                got += GiveValue(e, invincible_finished, op, val);
                                got += GiveValue(e, superweapons_finished, op, val);
                                got += GiveBit(e, items, IT_UNLIMITED_AMMO, op, val);
                        case "all":
-                               got += GiveBit(e, items, IT_JETPACK, op, val);
+                               got += GiveBit(e, items, ITEM_Jetpack.m_itemid, op, val);
                                got += GiveValue(e, health, op, val);
                                got += GiveValue(e, armorvalue, op, val);
                        case "allweapons":
@@ -1923,10 +1739,10 @@ float GiveItems(entity e, float beginarg, float endarg)
                                got += GiveBit(e, items, IT_UNLIMITED_SUPERWEAPONS, op, val);
                                break;
                        case "jetpack":
-                               got += GiveBit(e, items, IT_JETPACK, op, val);
+                               got += GiveBit(e, items, ITEM_Jetpack.m_itemid, op, val);
                                break;
                        case "fuel_regen":
-                               got += GiveBit(e, items, IT_FUEL_REGEN, op, val);
+                               got += GiveBit(e, items, ITEM_JetpackRegen.m_itemid, op, val);
                                break;
                        case "strength":
                                got += GiveValue(e, strength_finished, op, val);
@@ -1973,23 +1789,23 @@ float GiveItems(entity e, float beginarg, float endarg)
                                        }
                                }
                                if(j > WEP_LAST)
-                                       print("give: invalid item ", cmd, "\n");
+                                       LOG_INFO("give: invalid item ", cmd, "\n");
                                break;
                }
                val = 999;
                op = OP_SET;
        }
 
-       POSTGIVE_BIT(e, items, IT_FUEL_REGEN, "misc/itempickup.wav", string_null);
+       POSTGIVE_BIT(e, items, ITEM_JetpackRegen.m_itemid, "misc/itempickup.wav", string_null);
        POSTGIVE_BIT(e, items, IT_UNLIMITED_SUPERWEAPONS, "misc/powerup.wav", "misc/poweroff.wav");
        POSTGIVE_BIT(e, items, IT_UNLIMITED_WEAPON_AMMO, "misc/powerup.wav", "misc/poweroff.wav");
-       POSTGIVE_BIT(e, items, IT_JETPACK, "misc/itempickup.wav", string_null);
+       POSTGIVE_BIT(e, items, ITEM_Jetpack.m_itemid, "misc/itempickup.wav", string_null);
        for(j = WEP_FIRST; j <= WEP_LAST; ++j)
        {
                wi = get_weaponinfo(j);
                if(wi.weapon)
                {
-                       POSTGIVE_WEAPON(e, j, "weapons/weaponpickup.wav", string_null);
+                       POSTGIVE_WEAPON(e, j, W_Sound("weaponpickup"), string_null);
                        if (!(save_weapons & WepSet_FromWeapon(j)))
                                if(e.weapons & WepSet_FromWeapon(j))
                                        WEP_ACTION(wi.weapon, WR_INIT);