]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Automatically return the flag if it touches trigger_hurt or lava/slime
authorSamual <samual@xonotic.org>
Fri, 30 Mar 2012 19:59:53 +0000 (15:59 -0400)
committerSamual <samual@xonotic.org>
Fri, 30 Mar 2012 19:59:53 +0000 (15:59 -0400)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/defs.qh
qcsrc/server/g_triggers.qc
qcsrc/server/mutators/gamemode_ctf.qc

index 9e78f94534250bc32f88b310d971be71f3dbac2d..14701d62f6ffbd6f981f317c012dade42173cfd8 100644 (file)
@@ -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"
index 6eeca7b70ac578fd609642a2ca495950734bb406..c808577254a94e7710e34d3c1521871401ca5a8b 100644 (file)
@@ -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;
index 62d65791dd87640e09a52ca373c51ce5acbcdcc9..097f213b6bfa3040af401e20434d26dd11e50b74 100644 (file)
@@ -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;
index 4e97136ce8b45354b0a1f695ff36ba9f06fad634..ab12fc326569d45f164c4f7d4e6ca2863e4886a0 100644 (file)
@@ -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);
index a02be4fd2e06604295578c13c8546719ec47a2cb..d57c565c9cc7594d30fc795fdbd5bfb5cb239a2e 100644 (file)
@@ -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;