]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/items/items.qc
Merge branch 'master' into terencehill/replicatevars_enhancements
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / items / items.qc
index 7408b4de8f7ab7dadbd6aa9e557a9e7a78a85bd4..57b245a252a167b2beb7b069f1b2f12bac1ccbfd 100644 (file)
@@ -12,6 +12,7 @@
 #include <common/mutators/mutator/powerups/_mod.qh>
 #include <common/mutators/mutator/status_effects/_mod.qh>
 #include <common/notifications/all.qh>
+#include <common/resources/resources.qh>
 #include <common/util.qh>
 #include <common/weapons/_all.qh>
 #include <common/wepent.qh>
@@ -63,9 +64,9 @@ bool ItemSend(entity this, entity to, int sf)
                        LOG_TRACE("^1WARNING!^7 this.mdl is unset for item ", this.classname, "expect a crash just about now");
 
                WriteString(MSG_ENTITY, this.mdl);
+               WriteByte(MSG_ENTITY, bound(0, this.skin, 255));
        }
 
-
        if(sf & ISF_COLORMAP)
        {
                WriteShort(MSG_ENTITY, this.colormap);
@@ -447,7 +448,7 @@ void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names,
        }
 }
 
-bool Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax)
+bool Item_GiveAmmoTo(entity item, entity player, Resource res_type, float ammomax)
 {
        float amount = GetResource(item, res_type);
        if (amount == 0)
@@ -483,7 +484,7 @@ bool Item_GiveTo(entity item, entity player)
        // if the player is using their best weapon before items are given, they
        // probably want to switch to an even better weapon after items are given
 
-       if(CS_CVAR(player).autoswitch)
+       if(CS_CVAR(player).cvar_cl_autoswitch)
        {
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
@@ -551,22 +552,42 @@ bool Item_GiveTo(entity item, entity player)
        if (item.strength_finished)
        {
                pickedup = true;
-               StatusEffects_apply(STATUSEFFECT_Strength, player, max(StatusEffects_gettime(STATUSEFFECT_Strength, player), time) + item.strength_finished, 0);
+               float t = max(StatusEffects_gettime(STATUSEFFECT_Strength, player), time);
+               if (autocvar_g_powerups_stack)
+                       t += item.strength_finished;
+               else
+                       t = max(t, time + item.strength_finished);
+               StatusEffects_apply(STATUSEFFECT_Strength, player, t, 0);
        }
        if (item.invincible_finished)
        {
                pickedup = true;
-               StatusEffects_apply(STATUSEFFECT_Shield, player, max(StatusEffects_gettime(STATUSEFFECT_Shield, player), time) + item.invincible_finished, 0);
+               float t = max(StatusEffects_gettime(STATUSEFFECT_Shield, player), time);
+               if (autocvar_g_powerups_stack)
+                       t += item.invincible_finished;
+               else
+                       t = max(t, time + item.invincible_finished);
+               StatusEffects_apply(STATUSEFFECT_Shield, player, t, 0);
        }
        if (item.speed_finished)
        {
                pickedup = true;
-               StatusEffects_apply(STATUSEFFECT_Speed, player, max(StatusEffects_gettime(STATUSEFFECT_Speed, player), time) + item.speed_finished, 0);
+               float t = max(StatusEffects_gettime(STATUSEFFECT_Speed, player), time);
+               if (autocvar_g_powerups_stack)
+                       t += item.speed_finished;
+               else
+                       t = max(t, time + item.speed_finished);
+               StatusEffects_apply(STATUSEFFECT_Speed, player, t, 0);
        }
        if (item.invisibility_finished)
        {
                pickedup = true;
-               StatusEffects_apply(STATUSEFFECT_Invisibility, player, max(StatusEffects_gettime(STATUSEFFECT_Invisibility, player), time) + item.invisibility_finished, 0);
+               float t = max(StatusEffects_gettime(STATUSEFFECT_Invisibility, player), time);
+               if (autocvar_g_powerups_stack)
+                       t += item.invisibility_finished;
+               else
+                       t = max(t, time + item.invisibility_finished);
+               StatusEffects_apply(STATUSEFFECT_Invisibility, player, t, 0);
        }
        if (item.superweapons_finished)
        {
@@ -961,7 +982,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
 
                // Savage: remove thrown items after a certain period of time ("garbage collection")
                setthink(this, RemoveItem);
-               this.nextthink = time + 20;
+               this.nextthink = time + autocvar_g_items_dropped_lifetime;
 
                this.takedamage = DAMAGE_YES;
                this.event_damage = Item_Damage;
@@ -1071,6 +1092,10 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
        setmodel(this, MDL_Null); // precision set below
        //this.effects |= EF_LOWPRECISION;
 
+       // support skinned models for powerups
+       this.skin = def.m_skin;
+       this.glowmod = def.m_color;
+
        setsize (this, this.pos1 =  def.m_mins, this.pos2 = def.m_maxs);
 
        this.SendFlags |= ISF_SIZE;
@@ -1426,7 +1451,7 @@ void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .floa
        else if(v0 > v1)
                e.(regenfield) = max(e.(regenfield), time + regentime);
 }
-bool GiveResourceValue(entity e, int res_type, int op, int val)
+bool GiveResourceValue(entity e, Resource res_type, int op, int val)
 {
        int v0 = GetResource(e, res_type);
        float new_val = 0;
@@ -1488,7 +1513,7 @@ float GiveItems(entity e, float beginarg, float endarg)
 
        int _switchweapon = 0;
 
-       if(CS_CVAR(e).autoswitch)
+       if(CS_CVAR(e).cvar_cl_autoswitch)
        {
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {