From: Rudolf Polzer Date: Sat, 31 Mar 2012 11:06:38 +0000 (+0200) Subject: clean up content flags checks for killing items/flags X-Git-Tag: xonotic-v0.7.0~111^2~32 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=40cc357c2c4732d3d035240cfab34b9097f51f34;p=xonotic%2Fxonotic-data.pk3dir.git clean up content flags checks for killing items/flags --- diff --git a/qcsrc/server/ctf.qc b/qcsrc/server/ctf.qc index f5835377d..d84075cf4 100644 --- a/qcsrc/server/ctf.qc +++ b/qcsrc/server/ctf.qc @@ -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 diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 7065542b1..1359c0566 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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)) diff --git a/qcsrc/server/mutators/gamemode_keyhunt.qc b/qcsrc/server/mutators/gamemode_keyhunt.qc index d3f4fdc87..bc8e85f35 100644 --- a/qcsrc/server/mutators/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/gamemode_keyhunt.qc @@ -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) diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 1e9d6a753..5b9a2e5f9 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -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)