From: Samual Date: Fri, 30 Mar 2012 19:59:53 +0000 (-0400) Subject: Automatically return the flag if it touches trigger_hurt or lava/slime X-Git-Tag: xonotic-v0.7.0~240^2~156 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=478ea8ab1b400c5bf5fbe4d69780e897f66d4025;p=xonotic%2Fxonotic-data.pk3dir.git Automatically return the flag if it touches trigger_hurt or lava/slime --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 9e78f9453..14701d62f 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -604,6 +604,7 @@ set g_ctf_flag_health 0 set g_ctf_flag_take_damage 0 set g_ctf_flag_dropped_waypoint 2 "show dropped flag waypointsprite when a flag is lost. 1 = team only, 2 = for all players" set g_ctf_flag_pickup_verbosename 1 "show the name of the person who picked up the flag too" +set g_ctf_flag_return_when_unreachable 1 "automatically return the flag if it falls into lava/slime/trigger hurt" set g_ctf_shield_max_ratio 0 "shield at most this percentage of a team from the enemy flag (try: 0.4 for 40%)" set g_ctf_shield_min_negscore 20 "shield the player from the flag if he's got this negative amount of points or less" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 6eeca7b70..c80857725 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -776,6 +776,7 @@ float autocvar_g_ctf_flag_pickup_verbosename; string autocvar_g_ctf_flag_red_model; float autocvar_g_ctf_flag_red_skin; float autocvar_g_ctf_flag_returntime; +float autocvar_g_ctf_flag_return_when_unreachable; float autocvar_g_ctf_flag_take_damage; float autocvar_g_ctf_flagcarrier_selfdamage; float autocvar_g_ctf_flagcarrier_selfforce; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 62d65791d..097f213b6 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -200,6 +200,7 @@ void setanim(entity e, vector anim, float looping, float override, float restart .float watersound_finished; .float iscreature; .float damagedbycontents; +.float damagedbytriggers; .vector oldvelocity; .float pauseregen_finished; diff --git a/qcsrc/server/g_triggers.qc b/qcsrc/server/g_triggers.qc index 4e97136ce..ab12fc326 100644 --- a/qcsrc/server/g_triggers.qc +++ b/qcsrc/server/g_triggers.qc @@ -466,16 +466,19 @@ void trigger_hurt_touch() Damage (other, self, own, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0'); } } + else if(other.damagedbytriggers) + { + if(other.takedamage) + { + EXACTTRIGGER_TOUCH; + Damage(other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0'); + } + } else { if (!other.owner) { - if (other.items & IT_KEY1 || other.items & IT_KEY2) // reset flag - { - EXACTTRIGGER_TOUCH; - other.pain_finished = min(other.pain_finished, time + 2); - } - else if (other.classname == "rune") // reset runes + if (other.classname == "rune") // reset runes { EXACTTRIGGER_TOUCH; other.nextthink = min(other.nextthink, time + 1); diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index a02be4fd2..d57c565c9 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -382,6 +382,13 @@ void ctf_CheckFlagReturn(entity flag) void ctf_FlagDamage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) { + if(deathtype == DEATH_HURTTRIGGER || deathtype == DEATH_SLIME || deathtype == DEATH_LAVA) + { + // automatically kill the flag and return it + self.health = 0; + ctf_CheckFlagReturn(self); + } + if(autocvar_g_ctf_flag_take_damage) { self.health = self.health - damage; @@ -448,15 +455,6 @@ void ctf_FlagTouch() { if(gameover) { return; } if(!self) { return; } - if((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) - || ((trace_dpstartcontents | trace_dphitcontents) & (DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_NODROP))) - { // The flag fell off the map or into lava/slime, respawn it since players can't get to it - bprint("The ", self.netname, " fell somewhere it couldn't be reached and has returned to base\n"); - sound (self, CH_TRIGGER, self.snd_flag_respawn, VOL_BASE, ATTN_NONE); - ctf_EventLog("returned", self.team, world); - ctf_RespawnFlag(self); - return; - } if(other.deadflag != DEAD_NO) { return; } if(other.classname != "player") { // The flag just touched an object, most likely the world @@ -572,6 +570,8 @@ void ctf_FlagSetup(float teamnumber, entity flag) // called when spawning a flag flag.max_flag_health = ((autocvar_g_ctf_flag_take_damage && autocvar_g_ctf_flag_health) ? autocvar_g_ctf_flag_health : 100); flag.health = flag.max_flag_health; flag.event_damage = ctf_FlagDamage; + flag.damagedbytriggers = autocvar_g_ctf_flag_return_when_unreachable; + flag.damagedbycontents = autocvar_g_ctf_flag_return_when_unreachable; flag.velocity = '0 0 0'; flag.mangle = flag.angles; flag.reset = ctf_Reset;