X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fg_triggers.qc;h=3ad43b0c36dbf0815ef87145ff6d101aef4e248b;hb=900269c6bbf7fabfb9ab8976d8eace8ea7027271;hp=54cb530fe47502e84cc81b922e14ad075a4b48dc;hpb=6dac08025d0ee0e26007b045167b6484598cf429;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/g_triggers.qc b/qcsrc/server/g_triggers.qc index 54cb530fe..3ad43b0c3 100644 --- a/qcsrc/server/g_triggers.qc +++ b/qcsrc/server/g_triggers.qc @@ -88,6 +88,9 @@ void SUB_UseTargets() stemp = self; otemp = other; + if(stemp.target_random) + RandomSelection_Init(); + for(i = 0; i < 4; ++i) { switch(i) @@ -103,15 +106,29 @@ void SUB_UseTargets() for(t = world; (t = find(t, targetname, s)); ) if(t.use) { - //print(stemp.classname, " ", stemp.targetname, " -> ", t.classname, " ", t.targetname, "\n"); - self = t; - other = stemp; - activator = act; - self.use(); + if(stemp.target_random) + { + RandomSelection_Add(t, 0, string_null, 1, 0); + } + else + { + self = t; + other = stemp; + activator = act; + self.use(); + } } } } + if(stemp.target_random && RandomSelection_chosen_ent) + { + self = RandomSelection_chosen_ent; + other = stemp; + activator = act; + self.use(); + } + activator = act; self = stemp; other = otemp; @@ -189,14 +206,12 @@ void multi_use() void multi_touch() { if not(self.spawnflags & 2) - { if not(other.iscreature) return; - if(self.team) - if(self.team == other.team) + if(self.team) + if((self.spawnflags & 4 == 0) == (self.team != other.team)) return; - } // if the trigger has an angles field, check player's facing direction if (self.movedir != '0 0 0') @@ -413,6 +428,14 @@ void spawnfunc_trigger_counter() self.reset = counter_reset; }; +void trigger_hurt_use() +{ + if(activator.classname == "player") + self.enemy = activator; + else + self.enemy = world; // let's just destroy it, if taking over is too much work +} + .float triggerhurttime; void trigger_hurt_touch() { @@ -431,7 +454,16 @@ void trigger_hurt_touch() { EXACTTRIGGER_TOUCH; other.triggerhurttime = time + 1; - Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0'); + + entity own; + own = self.enemy; + if(own.classname != "player") + { + own = self; + self.enemy = world; // I still hate you all + } + + Damage (other, self, own, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0'); } } else @@ -467,6 +499,8 @@ void spawnfunc_trigger_hurt() EXACTTRIGGER_INIT; self.active = ACTIVE_ACTIVE; self.touch = trigger_hurt_touch; + self.use = trigger_hurt_use; + self.enemy = world; // I hate you all if (!self.dmg) self.dmg = 1000; if (!self.message) @@ -1705,6 +1739,7 @@ void follow_init() attach_sameorigin(dst, src, self.message); } + dst.solid = SOLID_NOT; // solid doesn't work with attachment remove(self); } else