]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/t_items.qc
Merge branch 'Mario/strength_stat_field' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / t_items.qc
index 213410543961917eea730055a65f123f2060d111..0fcc35a31cbaf069b0533f76149a67125e2fdef3 100644 (file)
@@ -23,6 +23,7 @@
     #include <common/weapons/_all.qh>
 
     #include <common/mutators/mutator/buffs/buffs.qh>
+       #include <common/mutators/mutator/buffs/sv_buffs.qh>
 
     #include "../lib/warpzone/util_server.qh"
 #elif defined(CSQC)
@@ -1618,28 +1619,36 @@ float GiveWeapon(entity e, float wpn, float op, float val)
 bool GiveBuff(entity e, Buff thebuff, int op, int val)
 {
        bool had_buff = (STAT(BUFFS, e) & thebuff.m_itemid);
+       float new_buff_time = ((had_buff) ? STAT(BUFF_TIME, e) : 0);
        switch (op)
        {
                case OP_SET:
-                       STAT(BUFF_TIME, e) = val;
+                       new_buff_time = val;
                        break;
                case OP_MIN:
-                       STAT(BUFF_TIME, e) = max(STAT(BUFF_TIME, e), val);
+                       new_buff_time = max(new_buff_time, val);
                        break;
                case OP_MAX:
-                       STAT(BUFF_TIME, e) = min(STAT(BUFF_TIME, e), val);
+                       new_buff_time = min(new_buff_time, val);
                        break;
                case OP_PLUS:
-                       STAT(BUFF_TIME, e) += val;
+                       new_buff_time += val;
                        break;
                case OP_MINUS:
-                       STAT(BUFF_TIME, e) -= val;
+                       new_buff_time -= val;
                        break;
        }
-       if(STAT(BUFF_TIME, e) <= 0)
+       if(new_buff_time <= 0)
+       {
+               if(had_buff)
+                       STAT(BUFF_TIME, e) = new_buff_time;
                STAT(BUFFS, e) &= ~thebuff.m_itemid;
+       }
        else
+       {
+               STAT(BUFF_TIME, e) = new_buff_time;
                STAT(BUFFS, e) = thebuff.m_itemid; // NOTE: replaces any existing buffs on the player!
+       }
        bool have_buff = (STAT(BUFFS, e) & thebuff.m_itemid);
        return (had_buff != have_buff);
 }
@@ -1827,7 +1836,7 @@ float GiveItems(entity e, float beginarg, float endarg)
                                got += GiveResourceValue(e, RES_FUEL, op, val);
                                break;
                        default:
-                               FOREACH(Buffs, it != BUFF_Null && Buff_UndeprecateName(cmd) == it.netname,
+                               FOREACH(Buffs, it != BUFF_Null && buff_Available(it) && Buff_UndeprecateName(cmd) == it.netname,
                                {
                                        got += GiveBuff(e, it, op, val);
                                        break;