]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
clean up content flags checks for killing items/flags
authorRudolf Polzer <divverent@alientrap.org>
Sat, 31 Mar 2012 11:06:38 +0000 (13:06 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Sat, 31 Mar 2012 11:06:38 +0000 (13:06 +0200)
qcsrc/server/ctf.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/gamemode_keyhunt.qc
qcsrc/server/t_items.qc

index f5835377d982ea2ded4998baf629d3711883b787..d84075cf4c959b725d97de65c6d85b2ec498dcf5 100644 (file)
@@ -416,6 +416,7 @@ void flag_cap_ring_spawn(vector org)
        shockwave_spawn("models/ctf/shockwavetransring.md3", org - '0 0 15', -0.8, 0, 1);
 }
 
+// TODO add FlagDamage, replace weird hurttrigger handling inside trigger_hurt code by it
 void FlagTouch()
 {
        if(gameover) return;
@@ -423,14 +424,24 @@ void FlagTouch()
        float t;
        entity player;
        string s, s0, h0, h1;
+
+       if (self.cnt == FLAG_CARRY)
+               return;
+
+       if (self.cnt == FLAG_DROPPED)
+       {
+               if(ITEM_TOUCH_NEEDKILL())
+               {
+                       self.pain_finished = 0; // return immediately
+                       return;
+               }
+       }
+
        if (other.classname != "player")
                return;
        if (other.health < 1) // ignore dead players
                return;
 
-       if (self.cnt == FLAG_CARRY)
-               return;
-
        if (self.cnt == FLAG_BASE)
        if (other.team == self.team)
        if (other.flagcarried) // he's got a flag
index 7065542b1902db6b65b7faa35612b55d854aa5eb..1359c056692298f68ce457d95d13537e1398a9b8 100644 (file)
@@ -1986,6 +1986,9 @@ float WarpZone_Projectile_Touch_ImpactFilter_Callback()
 }
 #define PROJECTILE_TOUCH if(WarpZone_Projectile_Touch()) return
 
+#define ITEM_TOUCH_NEEDKILL() (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
+#define ITEM_DAMAGE_NEEDKILL(dt) (((dt) == DEATH_HURTTRIGGER) || ((dt) == DEATH_SLIME) || ((dt) == DEATH_LAVA) || ((dt) == DEATH_SWAMP))
+
 void URI_Get_Callback(float id, float status, string data)
 {
        if(url_URI_Get_Callback(id, status, data))
index d3f4fdc87e8fa328bfc87dd000f79c6ccbe1e38d..bc8e85f35da34fcec837b503c38df659ac5eacea 100644 (file)
@@ -412,6 +412,13 @@ void kh_Key_Damage(entity inflictor, entity attacker, float damage, float deatht
 {
        if(self.owner)
                return;
+       if(ITEM_DAMAGE_NEEDKILL(deathtype))
+       {
+               // touching lava, or hurt trigger
+               // what shall we do?
+               // immediately return is bad
+               // maybe start a shorter countdown?
+       }
        if(vlen(force) <= 0)
                return;
        if(time > self.pushltime)
@@ -441,6 +448,15 @@ void kh_Key_Touch()  // runs many, many times when a key has been dropped and ca
 
        if(self.owner) // already carried
                return;
+
+       if(ITEM_TOUCH_NEEDKILL())
+       {
+               // touching sky, or nodrop
+               // what shall we do?
+               // immediately return is bad
+               // maybe start a shorter countdown?
+       }
+
        if(other.classname != "player")
                return;
        if(other.deadflag != DEAD_NO)
index 1e9d6a753c426c0708a8c6e6b79b6ec86f027950..5b9a2e5f99b9bc5e1c20d4bbbbbaa8414ffa58f9 100644 (file)
@@ -493,11 +493,15 @@ void Item_Touch (void)
        entity e, head;
 
        // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
-       if (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
+       if(self.classname == "droppedweapon")
        {
-               remove(self);
-               return;
+               if (ITEM_TOUCH_NEEDKILL())
+               {
+                       remove(self);
+                       return;
+               }
        }
+
        if (other.classname != "player")
                return;
        if (other.deadflag)
@@ -732,6 +736,11 @@ 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)
+{
+       if(ITEM_DAMAGE_NEEDKILL(deathtype))
+               RemoveItem();
+}
 
 .float is_item;
 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)
@@ -753,6 +762,9 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                self.think = RemoveItem;
                self.nextthink = time + 20;
 
+               self.takedamage = DAMAGE_YES;
+               self.event_damage = Item_Damage;
+
                if(self.strength_finished || self.invincible_finished || self.superweapons_finished)
                /*
                if(self.items == 0)