X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fg_triggers.qc;h=0ab2b423354013da80c2e56215aecd053eebfcca;hp=e177cdec73673d89bf4c812aff5dfaad099c8da6;hb=4a850b012b05774ec7bea9c53c5cbed0bf9bab4e;hpb=7070c733dae8f9a1ae04903615fa41ef14e52e21 diff --git a/qcsrc/server/g_triggers.qc b/qcsrc/server/g_triggers.qc index e177cdec7..0ab2b4233 100644 --- a/qcsrc/server/g_triggers.qc +++ b/qcsrc/server/g_triggers.qc @@ -10,7 +10,7 @@ void DelayThink() activator = self.enemy; SUB_UseTargets (); remove(self); -}; +} /* ============================== @@ -33,7 +33,7 @@ match (string)self.target and call their .use function */ void SUB_UseTargets() { - local entity t, stemp, otemp, act; + entity t, stemp, otemp, act; string s; float i; @@ -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,19 +106,33 @@ 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; -}; +} //============================================================================= @@ -132,7 +149,7 @@ void multi_wait() self.takedamage = DAMAGE_YES; self.solid = SOLID_BBOX; } -}; +} // the trigger was just touched/killed/used @@ -154,7 +171,7 @@ void multi_trigger() } if (self.noise) - sound (self.enemy, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NORM); + sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NORM); // don't trigger again until reset self.takedamage = DAMAGE_NO; @@ -177,14 +194,14 @@ void multi_trigger() // called wheil C code is looping through area links... self.touch = SUB_Null; } -}; +} void multi_use() { self.goalentity = other; self.enemy = activator; multi_trigger(); -}; +} void multi_touch() { @@ -209,7 +226,7 @@ void multi_touch() self.enemy = other; self.goalentity = other; multi_trigger (); -}; +} void multi_eventdamage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) { @@ -301,7 +318,7 @@ void spawnfunc_trigger_multiple() setorigin (self, self.origin); // make sure it links into the world } } -}; +} /*QUAKED spawnfunc_trigger_once (.5 .5 .5) ? notouch @@ -321,7 +338,7 @@ void spawnfunc_trigger_once() { self.wait = -1; spawnfunc_trigger_multiple(); -}; +} //============================================================================= @@ -332,7 +349,7 @@ void spawnfunc_trigger_relay() { self.use = SUB_UseTargets; self.reset = spawnfunc_trigger_relay; // this spawnfunc resets fully -}; +} void delay_use() { @@ -385,7 +402,7 @@ void counter_use() centerprint(activator, "Sequence completed!"); self.enemy = activator; multi_trigger (); -}; +} void counter_reset() { @@ -409,7 +426,7 @@ void spawnfunc_trigger_counter() self.use = counter_use; self.reset = counter_reset; -}; +} void trigger_hurt_use() { @@ -467,7 +484,7 @@ void trigger_hurt_touch() } return; -}; +} /*QUAKED spawnfunc_trigger_hurt (.5 .5 .5) ? Any object touching this will be hurt @@ -497,7 +514,7 @@ void spawnfunc_trigger_hurt() if(trigger_hurt_last) trigger_hurt_last.trigger_hurt_next = self; trigger_hurt_last = self; -}; +} float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end) { @@ -537,11 +554,11 @@ void trigger_heal_touch() { other.health = min(other.health + self.health, self.max_health); other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot); - sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NORM); + sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NORM); } } } -}; +} void spawnfunc_trigger_heal() { @@ -556,7 +573,7 @@ void spawnfunc_trigger_heal() if(self.noise == "") self.noise = "misc/mediumhealth.wav"; precache_sound(self.noise); -}; +} ////////////////////////////////////////////////////////////// @@ -598,12 +615,12 @@ void trigger_gravity_check_think() self.count -= 1; self.nextthink = time; } -}; +} void trigger_gravity_use() { self.state = !self.state; -}; +} void trigger_gravity_touch() { @@ -648,10 +665,10 @@ void trigger_gravity_touch() { other.gravity = g; if(self.noise != "") - sound (other, CHAN_AUTO, self.noise, VOL_BASE, ATTN_NORM); + sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NORM); UpdateCSQCProjectile(self.owner); } -}; +} void spawnfunc_trigger_gravity() { @@ -670,7 +687,7 @@ void spawnfunc_trigger_gravity() if(self.spawnflags & 2) self.state = FALSE; } -}; +} //============================================================================= @@ -704,7 +721,7 @@ void target_speaker_use_activator() else snd = self.noise; msg_entity = activator; - soundto(MSG_ONE, self, CHAN_TRIGGER, snd, VOL_BASE * self.volume, self.atten); + soundto(MSG_ONE, self, CH_TRIGGER, snd, VOL_BASE * self.volume, self.atten); } void target_speaker_use_on() { @@ -730,13 +747,13 @@ void target_speaker_use_on() } else snd = self.noise; - sound(self, CHAN_TRIGGER, snd, VOL_BASE * self.volume, self.atten); + sound(self, CH_TRIGGER_SINGLE, snd, VOL_BASE * self.volume, self.atten); if(self.spawnflags & 3) self.use = target_speaker_use_off; } void target_speaker_use_off() { - sound(self, CHAN_TRIGGER, "misc/null.wav", VOL_BASE * self.volume, self.atten); + sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASE * self.volume, self.atten); self.use = target_speaker_use_on; } void target_speaker_reset() @@ -805,7 +822,7 @@ void spawnfunc_target_speaker() ambientsound (self.origin, self.noise, VOL_BASE * self.volume, self.atten); remove(self); } -}; +} void spawnfunc_func_stardust() { @@ -1008,7 +1025,7 @@ float rainsnow_SendEntity(entity to, float sf) WriteShort(MSG_ENTITY, self.count); WriteByte(MSG_ENTITY, self.cnt); return 1; -}; +} /*QUAKED spawnfunc_func_rain (0 .5 .8) ? This is an invisible area like a trigger, which rain falls inside of. @@ -1045,7 +1062,7 @@ void spawnfunc_func_rain() self.Version = 1; Net_LinkEntity(self, FALSE, 0, rainsnow_SendEntity); -}; +} /*QUAKED spawnfunc_func_snow (0 .5 .8) ? @@ -1083,7 +1100,7 @@ void spawnfunc_func_snow() self.Version = 1; Net_LinkEntity(self, FALSE, 0, rainsnow_SendEntity); -}; +} void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, float deathtype); @@ -1360,24 +1377,7 @@ void trigger_impulse_touch1() if (self.active != ACTIVE_ACTIVE) return; - // FIXME: Better checking for what to push and not. - if not(other.iscreature) - if (other.classname != "corpse") - if (other.classname != "body") - if (other.classname != "gib") - if (other.classname != "missile") - if (other.classname != "rocket") - if (other.classname != "casing") - if (other.classname != "grenade") - if (other.classname != "plasma") - if (other.classname != "plasma_prim") - if (other.classname != "plasma_chain") - if (other.classname != "droppedweapon") - if (other.classname != "nexball_basketball") - if (other.classname != "nexball_football") - return; - - if (other.deadflag && other.iscreature) + if (!isPushable(other)) return; EXACTTRIGGER_TOUCH; @@ -1415,24 +1415,7 @@ void trigger_impulse_touch2() if (self.active != ACTIVE_ACTIVE) return; - // FIXME: Better checking for what to push and not. - if not(other.iscreature) - if (other.classname != "corpse") - if (other.classname != "body") - if (other.classname != "gib") - if (other.classname != "missile") - if (other.classname != "rocket") - if (other.classname != "casing") - if (other.classname != "grenade") - if (other.classname != "plasma") - if (other.classname != "plasma_prim") - if (other.classname != "plasma_chain") - if (other.classname != "droppedweapon") - if (other.classname != "nexball_basketball") - if (other.classname != "nexball_football") - return; - - if (other.deadflag && other.iscreature) + if (!isPushable(other)) return; EXACTTRIGGER_TOUCH; @@ -1456,24 +1439,7 @@ void trigger_impulse_touch3() if (self.active != ACTIVE_ACTIVE) return; - // FIXME: Better checking for what to push and not. - if not(other.iscreature) - if (other.classname != "corpse") - if (other.classname != "body") - if (other.classname != "gib") - if (other.classname != "missile") - if (other.classname != "rocket") - if (other.classname != "casing") - if (other.classname != "grenade") - if (other.classname != "plasma") - if (other.classname != "plasma_prim") - if (other.classname != "plasma_chain") - if (other.classname != "droppedweapon") - if (other.classname != "nexball_basketball") - if (other.classname != "nexball_football") - return; - - if (other.deadflag && other.iscreature) + if (!isPushable(other)) return; EXACTTRIGGER_TOUCH; @@ -1676,7 +1642,7 @@ void spawnfunc_trigger_multivibrator() self.state = 0; self.use = multivibrator_toggle; self.think = multivibrator_send; - self.nextthink = time; + self.nextthink = max(1, time); IFTARGETED multivibrator_reset(); @@ -1722,6 +1688,7 @@ void follow_init() attach_sameorigin(dst, src, self.message); } + dst.solid = SOLID_NOT; // solid doesn't work with attachment remove(self); } else @@ -2151,9 +2118,9 @@ void spawnfunc_target_changelevel_use() localcmd("endmatch\n"); else localcmd(strcat("changelevel ", self.chmap, "\n")); -}; +} void spawnfunc_target_changelevel() { self.use = spawnfunc_target_changelevel_use; -}; +}