]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/compat/quake3.qc
target_give: support count fields of speed and invis powerups
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / compat / quake3.qc
index 4c50ea51f66822002ca47d48f9509b2f20df34c3..32c42d35400a151550fd309a038ad2513525900f 100644 (file)
@@ -1,18 +1,22 @@
 #include "quake3.qh"
 
-#include <server/client.qh>
-#include <common/weapons/_all.qh>
-#include <common/stats.qh>
-#include <server/items/items.qh>
-#include <server/items/spawning.qh>
-#include <server/resources.qh>
-#include <server/world.qh>
 #include <common/gamemodes/_mod.qh>
 #include <common/gamemodes/gamemode/ctf/sv_ctf.qh>
-#include <common/mapobjects/triggers.qh>
 #include <common/mapobjects/trigger/counter.qh>
+#include <common/mapobjects/triggers.qh>
 #include <common/mutators/mutator/buffs/buffs.qh>
+#include <common/mutators/mutator/buffs/sv_buffs.qh>
+#include <common/mutators/mutator/powerups/_mod.qh>
+#include <common/mutators/mutator/status_effects/_mod.qh>
 #include <common/notifications/all.qh>
+#include <common/stats.qh>
+#include <common/weapons/_all.qh>
+#include <common/weapons/_all.qh>
+#include <server/client.qh>
+#include <server/items/items.qh>
+#include <server/items/spawning.qh>
+#include <server/resources.qh>
+#include <server/world.qh>
 
 /***********************
  * QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
@@ -166,17 +170,19 @@ void target_init_use(entity this, entity actor, entity trigger)
 
        if (!(this.spawnflags & 8))
        {
-               STAT(STRENGTH_FINISHED, actor) = 0;
-               STAT(INVINCIBLE_FINISHED, actor) = 0;
-               if(STAT(BUFFS, actor)) // TODO: make a dropbuffs function to handle this
+               FOREACH(StatusEffect, it.instanceOfPowerups,
+               {
+                       it.m_remove(it, actor, STATUSEFFECT_REMOVE_NORMAL);
+               });
+               entity heldbuff = buff_FirstFromFlags(actor);
+               if(heldbuff) // TODO: make a dropbuffs function to handle this
                {
-                       int buffid = buff_FirstFromFlags(STAT(BUFFS, actor)).m_id;
+                       int buffid = heldbuff.m_id;
                        Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
                        sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
                        if(!IS_INDEPENDENT_PLAYER(actor))
                                Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
-                       STAT(BUFFS, actor) = 0;
-                       STAT(BUFF_TIME, actor) = 0;
+                       buff_RemoveAll(actor, STATUSEFFECT_REMOVE_NORMAL);
                }
        }
 
@@ -201,9 +207,9 @@ void target_give_init(entity this)
        {
                if (it.classname == "item_buff")
                {
-                       entity buff = buff_FirstFromFlags(STAT(BUFFS, it));
+                       entity buff = it.buffdef;
                        this.netname = cons(this.netname, buff.netname);
-                       STAT(BUFF_TIME, this) += it.count;
+                       this.buffs_finished += it.count;
                }
                else
                {
@@ -219,12 +225,16 @@ void target_give_init(entity this)
                                this.invincible_finished += it.invincible_finished;
                        else if (it.strength_finished)
                                this.strength_finished += it.strength_finished;
+                       else if (it.speed_finished)
+                               this.speed_finished += it.speed_finished;
+                       else if (it.invisibility_finished)
+                               this.invisibility_finished += it.invisibility_finished;
                        else if (it.health)
                                this.health += it.health;
                        else if (it.armorvalue)
                                this.armorvalue += it.armorvalue;
 
-                       this.netname = cons(this.netname, it.netname);
+                       this.netname = cons(this.netname, (it.itemdef.m_weapon) ? it.itemdef.m_weapon.netname : it.itemdef.netname);
                }
 
                //remove(it); // removing ents in init functions causes havoc, workaround:
@@ -299,6 +309,7 @@ bool DoesQ3ARemoveThisEntity(entity this)
        if(this.notta)
                return true;
 
+       // FIXME: singleplayer does not use maxclients 1 as that would prevent bots
        if(this.notsingle)
                if(maxclients == 1)
                        return true;