1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060 |
- float COUNTER_LOOPS = 2;
- float MONSTER_ONLY = 8;
- void() trigger_reactivate =
- {
- self.solid = SOLID_TRIGGER;
- };
- void() multi_wait =
- {
- if (self.max_health)
- {
- self.health = self.max_health;
- self.takedamage = DAMAGE_YES;
- self.solid = SOLID_BBOX;
- }
- };
- void() multi_trigger =
- {
- if (self.nextthink > time)
- {
- return;
- }
- if (self.classname == "trigger_secret")
- {
- if (self.enemy.classname != "player")
- return;
- found_secrets = found_secrets + 1;
- WriteByte (MSG_ALL, SVC_FOUNDSECRET);
-
- msg_entity = self.enemy;
- WriteByte (MSG_ONE, SVC_ACHIEVEMENT);
- WriteString(MSG_ONE, "ACH_FIND_SECRET");
- }
- if (self.noise)
- sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
- self.takedamage = DAMAGE_NO;
- activator = self.enemy;
-
- SUB_UseTargets();
- if (self.wait > 0)
- {
- self.think = multi_wait;
- self.nextthink = time + self.wait;
- }
- else
- {
-
- self.touch = SUB_Null;
- self.nextthink = time + 0.1;
- self.think = SUB_Remove;
- }
- };
- void() multi_killed =
- {
- self.enemy = damage_attacker;
- multi_trigger();
- };
- void() multi_use =
- {
- self.enemy = activator;
- multi_trigger();
- };
- void() multi_touch =
- {
- if (other.classname != "player")
- return;
-
- if (self.movedir != '0 0 0')
- {
- makevectors (other.angles);
- if (v_forward * self.movedir < 0)
- return;
- }
-
- self.enemy = other;
- multi_trigger ();
- };
- void() trigger_multiple =
- {
- INHIBIT_COOP
- self.netname = "trigger_multiple";
- if (self.sounds == 1)
- {
- precache_sound ("misc/secret.wav");
- self.noise = "misc/secret.wav";
- }
- else if (self.sounds == 2)
- {
- precache_sound ("misc/talk.wav");
- self.noise = "misc/talk.wav";
- }
- else if (self.sounds == 3)
- {
- precache_sound ("misc/trigger1.wav");
- self.noise = "misc/trigger1.wav";
- }
- self.sounds = 0;
- if(self.spawnflags & SPAWNFLAG_TRIGGER_FIRST)
- {
- self.use = trigger_multiple;
- self.spawnflags &~= SPAWNFLAG_TRIGGER_FIRST;
- return;
- }
-
- if (!self.wait)
- self.wait = 0.2;
- self.use = multi_use;
- InitTrigger ();
- if (self.health)
- {
- if (self.spawnflags & SPAWNFLAG_NOTOUCH)
- objerror ("health and notouch don't make sense\n");
- self.max_health = self.health;
- self.th_die = multi_killed;
- self.takedamage = DAMAGE_YES;
- self.solid = SOLID_BBOX;
- setorigin (self, self.origin);
- }
- else
- {
- if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
- {
- self.touch = multi_touch;
- }
- }
- };
- void() trigger_once =
- {
- self.wait = -1;
- trigger_multiple();
- self.netname = "trigger_once";
- };
- void() trigger_relay =
- {
- INHIBIT_COOP
- if (RemovedOutsideCoop()) return;
- self.use = SUB_UseTargets;
- };
- void() trigger_secret =
- {
- INHIBIT_COOP
- total_secrets = total_secrets + 1;
- self.wait = -1;
- if (!self.message)
- self.message = "$qc_found_secret";
- if (!self.sounds)
- self.sounds = 1;
-
- if (self.sounds == 1)
- {
- precache_sound ("misc/secret.wav");
- self.noise = "misc/secret.wav";
- }
- else if (self.sounds == 2)
- {
- precache_sound ("misc/talk.wav");
- self.noise = "misc/talk.wav";
- }
- trigger_multiple ();
- };
- void() counter_use =
- {
- self.count = self.count - 1;
- if (self.count < 0)
- return;
-
- if (self.count != 0)
- {
- if (activator.classname == "player"
- && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
- {
- if (self.count >= 4)
- {
- centerprint_all ("$qc_more_go");
- }
- else if (self.count == 3)
- {
- centerprint_all ("$qc_three_more");
- }
- else if (self.count == 2)
- {
- centerprint_all ("$qc_two_more");
- }
- else
- {
- centerprint_all ("$qc_one_more");
- }
- }
- return;
- }
-
- if (activator.classname == "player" && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
- {
- centerprint_all("$qc_sequence_completed");
- }
- self.enemy = activator;
-
-
- if (self.spawnflags & COUNTER_LOOPS)
- self.count = self.wait;
-
- multi_trigger ();
- };
- void() trigger_counter =
- {
- INHIBIT_COOP
- if (RemovedOutsideCoop()) return;
-
-
-
-
- if (!self.count)
- self.count = 2;
-
- if (!self.wait)
- self.wait = self.count;
- self.use = counter_use;
- };
- void() counter_timed_think =
- {
- self.count = self.cnt;
- }
- void() counter_timed_use =
- {
- self.count = self.count - 1;
- if (self.count < 0)
- return;
-
- self.nextthink = time + self.delay;
- if (self.count != 0)
- {
- if (activator.classname == "player"
- && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
- {
- if (self.count >= 4)
- {
- centerprint_all ("$qc_more_go");
- }
- else if (self.count == 3)
- {
- centerprint_all ("$qc_three_more");
- }
- else if (self.count == 2)
- {
- centerprint_all ("$qc_two_more");
- }
- else
- {
- centerprint_all ("$qc_one_more");
- }
- }
- return;
- }
-
- if (activator.classname == "player" && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
- {
- centerprint_all("$qc_sequence_completed");
- }
- self.enemy = activator;
- self.delay = 0;
- self.nextthink = -1;
- self.think = SUB_Null;
- multi_trigger ();
- remove(self);
- };
- void() trigger_counter_timed =
- {
- INHIBIT_COOP
- if (RemovedOutsideCoop()) return;
- self.wait = -1;
- if (!self.count)
- self.count = 2;
- if (!self.delay)
- self.delay = 2;
-
- self.cnt = self.count;
- self.use = counter_timed_use;
- self.think = counter_timed_think;
- };
- float PLAYER_ONLY = 1;
- float SILENT = 2;
- float IGNORE_TARGETNAME = 4;
- void() play_teleport =
- {
- local float v;
- local string tmpstr;
- v = random() * 5;
- if (v < 1)
- tmpstr = "misc/r_tele1.wav";
- else if (v < 2)
- tmpstr = "misc/r_tele2.wav";
- else if (v < 3)
- tmpstr = "misc/r_tele3.wav";
- else if (v < 4)
- tmpstr = "misc/r_tele4.wav";
- else
- tmpstr = "misc/r_tele5.wav";
- sound (self, CHAN_VOICE, tmpstr, 1, ATTN_NORM);
- remove (self);
- };
- void(vector org) spawn_tfog =
- {
- entity s = spawn ();
- s.origin = org;
- s.nextthink = time + 0.2;
- s.think = play_teleport;
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_TELEPORT);
- WriteCoord (MSG_BROADCAST, org_x);
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- };
- void(vector org) spawn_tfog_silent =
- {
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_TELEPORT);
- WriteCoord (MSG_BROADCAST, org_x);
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- };
- void() tdeath_touch =
- {
- if (other == self.owner)
- return;
- if (other.classname == "player")
- {
- if (other.invincible_finished > time)
- self.classname = "teledeath2";
- if (self.owner.classname != "player")
- {
- T_Damage (self.owner, self, self, 50000);
- return;
- }
-
- }
- if (other.health)
- {
- T_Damage (other, self, self, 50000);
- }
- };
- void(vector org, entity death_owner) spawn_tdeath_fast =
- {
- local entity death;
- death = spawn();
- death.classname = "teledeath";
- death.movetype = MOVETYPE_NONE;
- death.solid = SOLID_TRIGGER;
- death.angles = '0 0 0';
- setsize (death, death_owner.mins - '1 1 1', death_owner.maxs + '1 1 1');
- setorigin (death, org);
- death.touch = tdeath_touch;
- death.nextthink = time + 0.01;
- death.think = SUB_Remove;
- death.owner = death_owner;
-
- force_retouch = 2;
- };
- void(vector org, entity death_owner) spawn_tdeath =
- {
- local entity death;
- death = spawn();
- death.classname = "teledeath";
- death.movetype = MOVETYPE_NONE;
- death.solid = SOLID_TRIGGER;
- death.angles = '0 0 0';
- setsize (death, death_owner.mins - '1 1 1', death_owner.maxs + '1 1 1');
- setorigin (death, org);
- death.touch = tdeath_touch;
- death.nextthink = time + 0.2;
- death.think = SUB_Remove;
- death.owner = death_owner;
-
- force_retouch = 2;
- };
- void() teleport_touch =
- {
- local entity t;
- local vector org;
- if (self.targetname && (self.spawnflags & IGNORE_TARGETNAME) == 0)
- {
- if (self.nextthink < time)
- {
- return;
- }
- }
- if (self.spawnflags & PLAYER_ONLY)
- {
- if (other.classname != "player")
- return;
- }
- if (other.health <= 0 || other.solid != SOLID_SLIDEBOX)
- return;
- SUB_UseTargets ();
- spawn_tfog (other.origin);
- t = find (world, targetname, self.target);
- if (!t)
- objerror ("couldn't find target");
-
- makevectors (t.mangle);
- org = t.origin + 32 * v_forward;
- spawn_tfog (org);
- spawn_tdeath(t.origin, other);
- if (!other.health)
- {
- other.origin = t.origin;
- other.velocity = (v_forward * other.velocity_x) + (v_forward * other.velocity_y);
- return;
- }
- setorigin (other, t.origin);
- other.angles = t.mangle;
- if (other.classname == "player")
- {
- other.fixangle = 1;
- other.teleport_time = time + 0.7;
- if (other.flags & FL_ONGROUND)
- other.flags = other.flags - FL_ONGROUND;
- other.velocity = v_forward * 300;
- if(!coop && !deathmatch)
- {
- FogPushSettingsFrom(other, t, 0);
- }
- }
- other.flags = other.flags - other.flags & FL_ONGROUND;
- };
- void() info_teleport_destination =
- {
- self.netname = "info_teleport_destination";
-
- self.mangle = self.angles;
- self.angles = '0 0 0';
- self.model = "";
- self.origin = self.origin + '0 0 27';
- if (!self.targetname)
- objerror ("no targetname");
- };
- void() teleport_use =
- {
- self.nextthink = time + 0.2;
- force_retouch = 2;
- self.think = SUB_Null;
- };
- void() trigger_teleport =
- {
- self.netname = "trigger_teleport";
- local vector o;
- InitTrigger ();
- self.touch = teleport_touch;
-
- if (!self.target)
- objerror ("no target");
- self.use = teleport_use;
- if (!(self.spawnflags & SILENT))
- {
- precache_sound ("ambience/hum1.wav");
- o = (self.mins + self.maxs)*0.5;
- ambientsound (o, "ambience/hum1.wav",0.5 , ATTN_STATIC);
- }
- };
- void() trigger_skill_touch =
- {
- if (other.classname != "player")
- return;
-
- cvar_set ("skill", self.message);
- };
- void() trigger_setskill =
- {
- InitTrigger ();
- self.touch = trigger_skill_touch;
- };
- void() trigger_onlyregistered_touch =
- {
- if (other.classname != "player")
- return;
- if (self.attack_finished > time)
- return;
- self.attack_finished = time + 2;
- if (cvar("registered"))
- {
- self.message = "";
- SUB_UseTargets ();
- remove (self);
- }
- else
- {
- if (self.message != "")
- {
- centerprint (other, self.message);
- sound (other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM);
- }
- }
- };
- void() trigger_onlyregistered =
- {
- precache_sound ("misc/talk.wav");
- InitTrigger ();
- self.touch = trigger_onlyregistered_touch;
- };
- void hurt_use()
- {
- self.state = 1 - self.state;
- }
- void() hurt_on =
- {
- self.solid = SOLID_TRIGGER;
- self.nextthink = -1;
- };
- void() hurt_touch =
- {
- if(self.state) return;
- if (other.takedamage)
- {
-
-
- if ((self.spawnflags & MONSTER_ONLY) && !(other.flags & FL_MONSTER))
- return;
-
- self.solid = SOLID_NOT;
- T_Damage (other, self, self, self.dmg);
- self.think = hurt_on;
- self.nextthink = time + self.wait;
- }
- };
- void() trigger_hurt =
- {
- self.netname = "trigger_hurt";
- InitTrigger ();
- self.touch = hurt_touch;
- if (!self.dmg)
- self.dmg = 5;
- if (!self.wait)
- self.wait = 1;
- if(self.spawnflags & START_OFF)
- {
- self.state = 1;
- }
- self.use = hurt_use;
- };
- float PUSH_ONCE = 1;
- float ADDITIVE_PUSH = 2;
- float PUSH_START_OFF = 4;
- void() trigger_push_touch =
- {
-
-
- if (horde_ent)
- {
- if (other.spawnflags & PUSH_START_OFF)
- other.spawnflags-= PUSH_START_OFF;
-
- if ((other.classname != "player"))
- {
- if ((other.classname == "item_artifact_invulnerability") || (other.classname == "item_artifact_super_damage"))
- {
- if (self.spawnflags & ADDITIVE_PUSH)
- other.velocity = other.velocity + (self.speed * self.movedir * 10 * frametime);
- else
- other.velocity = self.speed * self.movedir * 10;
- }
- return;
- }
- }
-
- if (other.health > 0 || other.classname == "grenade")
- {
- if(other.flags & FL_INSHELTER) return;
- if (self.spawnflags & ADDITIVE_PUSH)
- other.velocity = other.velocity + self.speed * self.movedir * 10 * frametime;
- else
- other.velocity = self.speed * self.movedir * 10;
- if (other.classname == "player")
- {
- if (other.fly_sound < time)
- {
- other.fly_sound = time + 1.5;
- sound (other, CHAN_AUTO, "ambience/windfly.wav", 1, ATTN_NORM);
- }
- }
- if(other.flags & FL_MONSTER) other.flags (-) FL_ONGROUND;
- }
- if (self.spawnflags & PUSH_ONCE)
- remove(self);
- };
- void() trigger_push_use =
- {
- if(self.solid == SOLID_TRIGGER)
- {
- dprint("trigger_push: switched off\n");
- self.solid = SOLID_NOT;
- }
- else
- {
- dprint("trigger_push: switched on\n");
- self.solid = SOLID_TRIGGER;
- force_retouch = 1;
- }
- }
- void() trigger_push =
- {
- self.netname = "trigger_push";
- InitTrigger ();
- precache_sound ("ambience/windfly.wav");
- self.touch = trigger_push_touch;
- self.use = trigger_push_use;
- if(self.spawnflags & PUSH_START_OFF) self.solid = SOLID_NOT;
- if (!self.speed)
- self.speed = 1000;
- };
- const float SHELTER_FLIPPED = 1;
- void() trigger_shelter_portal_touch =
- {
- if (other.health > 0 || other.classname == "grenade")
- {
- vector offs = other.origin - self.pos1;
- float dot = offs * self.pos2;
- if(dot >= 0)
- {
- other.flags (+) FL_INSHELTER;
- }
- else
- {
- other.flags (-) FL_INSHELTER;
- }
- }
- }
- void() trigger_shelter_portal =
- {
- InitTrigger ();
- self.touch = trigger_shelter_portal_touch;
- self.pos1 = self.mins + (self.size * 0.5);
- if(self.size_x < self.size_y)
- {
- if(self.size_x < self.size_z)
- self.pos2 = '1 0 0';
- else
- self.pos2 = '0 0 1';
- }
- else
- {
- if(self.size_y < self.size_z)
- self.pos2 = '0 1 0';
- else
- self.pos2 = '0 0 1';
- }
- if(self.spawnflags & SHELTER_FLIPPED) self.pos2 *= -1;
- };
- void() trigger_monsterjump_touch =
- {
- if ( other.flags & (FL_MONSTER | FL_FLY | FL_SWIM) != FL_MONSTER )
- return;
-
-
-
- if (self.spawnflags & 64)
- {
- if (!(other.spawnflags & 64))
- {
- dprint("monster didn't have spawnflag 8!\n");
- return;
- }
- }
- other.velocity_x = self.movedir_x * self.speed;
- other.velocity_y = self.movedir_y * self.speed;
-
- if ( !(other.flags & FL_ONGROUND) )
- return;
-
- other.flags = other.flags - FL_ONGROUND;
- other.velocity_z = self.height;
- };
- void() trigger_monsterjump =
- {
- if (!self.speed)
- self.speed = 200;
- if (!self.height)
- self.height = 200;
- if (self.angles == '0 0 0')
- self.angles = '0 360 0';
- InitTrigger ();
- self.touch = trigger_monsterjump_touch;
- };
- const float NO_DAMAGE = 1;
- void() trigger_explosion_activate =
- {
- self.delay = 0;
- SUB_UseTargets ();
-
- if (!(self.spawnflags & NO_DAMAGE))
- T_RadiusDamage (self, self.owner, 120, self);
-
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_EXPLOSION);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
-
- BecomeExplosion();
- }
- void() trigger_explosion_use =
- {
- if(self.delay > 0)
- {
- self.think = trigger_explosion_activate;
- self.nextthink = time + self.delay;
- }
- else
- {
- trigger_explosion_activate();
- }
- }
- void() trigger_explosion =
- {
- INHIBIT_COOP
- if (RemovedOutsideCoop()) return;
-
- self.use = trigger_explosion_use;
- };
- float REPEATER_ON = 1;
- void() repeater_think =
- {
- SUB_UseTargets();
- self.nextthink = time + self.wait + (self.pausetime * random());
- };
- void() repeater_use =
- {
- if (self.spawnflags & REPEATER_ON)
- {
-
- self.spawnflags = self.spawnflags - REPEATER_ON;
- self.nextthink = 0;
- self.think = SUB_Null;
- }
- else
- {
-
- self.spawnflags = self.spawnflags + REPEATER_ON;
- self.nextthink = time + self.wait + (self.pausetime * random());
- self.think = repeater_think;
- }
- };
- void() trigger_repeater =
- {
- INHIBIT_COOP
- if (RemovedOutsideCoop()) return;
- if (!self.wait)
- {
- self.wait = 1;
- }
- self.use = repeater_use;
- if (self.spawnflags & REPEATER_ON)
- {
- self.nextthink = time + self.wait + (self.pausetime * random());
- self.think = repeater_think;
- }
- else
- {
- self.nextthink = 0;
- self.think = SUB_Null;
- }
- };
- float IGNORE_FIRST_TOUCH = 16;
- float IGNORE_EMPTIED = 32;
- void() trigger_multitouch_think =
- {
- bprint("untouched\n");
- self.wait = 0;
- if (!(self.spawnflags & IGNORE_EMPTIED))
- SUB_UseTargets();
- };
- void() trigger_multitouch_touch =
- {
- if (other.classname != "player")
- return;
- if (other.health <= 0)
- return;
-
- if (self.wait == 0)
- {
- self.wait = 1;
- bprint(" first touch\n");
- if (!(self.spawnflags & IGNORE_FIRST_TOUCH))
- SUB_UseTargets();
- }
-
-
- self.think = trigger_multitouch_think;
- self.nextthink = time + 0.2;
- };
- void() trigger_multitouch =
- {
- InitTrigger ();
- self.touch = trigger_multitouch_touch;
- self.wait = 0;
- };
|