123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699 |
- entity stemp, otemp, s, old;
- void() trigger_reactivate =
- {
- self.solid = SOLID_TRIGGER;
- };
- float SPAWNFLAG_NOMESSAGE = 1;
- float SPAWNFLAG_NOTOUCH = 1;
- 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 =
- {
- 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";
- }
-
- 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();
- };
- void() trigger_relay =
- {
- self.use = SUB_UseTargets;
- };
- void() trigger_secret =
- {
- 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 =
- {
- local string junk;
- 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 (activator, "$qc_more_go");
- else if (self.count == 3)
- centerprint (activator, "$qc_three_more");
- else if (self.count == 2)
- centerprint (activator, "$qc_two_more");
- else
- centerprint (activator, "$qc_one_more");
- }
- return;
- }
-
- if (activator.classname == "player"
- && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
- centerprint(activator, "$qc_sequence_completed");
- self.enemy = activator;
- multi_trigger ();
- };
- void() trigger_counter =
- {
- self.wait = -1;
- if (!self.count)
- self.count = 2;
- self.use = counter_use;
- };
- float PLAYER_ONLY = 1;
- float SILENT = 2;
- float CTF_ONLY = 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 =
- {
- 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() 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 =
- {
- 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)
- {
- 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;
- }
- other.flags = other.flags - other.flags & FL_ONGROUND;
- };
- void() 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 =
- {
- local vector o;
- if (self.spawnflags & CTF_ONLY)
- {
- if (teamplay < TEAM_CTF || teamplay > TEAM_CTF_ALT)
- {
- remove (self);
- return;
- }
- }
- 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_on =
- {
- self.solid = SOLID_TRIGGER;
- self.nextthink = -1;
- };
- void() hurt_touch =
- {
- if (other.takedamage)
- {
- self.solid = SOLID_NOT;
- T_Damage (other, self, self, self.dmg);
- self.think = hurt_on;
- self.nextthink = time + 1;
- }
- return;
- };
- void() trigger_hurt =
- {
- InitTrigger ();
- self.touch = hurt_touch;
- if (!self.dmg)
- self.dmg = 5;
- };
- float PUSH_ONCE = 1;
- float PUSH_TOGL = 2;
- float PUSH_ACTIVE = 4;
- void() trigger_push_touch =
- {
- if (!(self.spawnflags & PUSH_ACTIVE))
- return;
-
- if (other.classname == "grenade")
- other.velocity = self.speed * self.movedir * 10;
- else if (other.classname == "MiniGrenade")
- other.velocity = self.speed * self.movedir * 10;
- else if (other.classname == "MultiGrenade")
- other.velocity = self.speed * self.movedir * 10;
- else if (other.health > 0)
- {
- 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 (self.spawnflags & PUSH_ONCE)
- remove(self);
- };
- void() trigger_push_use =
- {
- if (self.spawnflags & PUSH_ACTIVE)
- self.spawnflags = self.spawnflags - PUSH_ACTIVE;
- else
- self.spawnflags = self.spawnflags + PUSH_ACTIVE;
- };
- void() trigger_push =
- {
- if (self.spawnflags & PUSH_TOGL)
- self.use = trigger_push_use;
- else
- self.spawnflags = self.spawnflags + PUSH_ACTIVE;
- InitTrigger ();
- precache_sound ("ambience/windfly.wav");
- self.touch = trigger_push_touch;
- if (!self.speed)
- self.speed = 1000;
- };
- void() trigger_monsterjump_touch =
- {
- if ( other.flags & (FL_MONSTER | FL_FLY | FL_SWIM) != FL_MONSTER )
- 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;
- };
|