123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- /* Copyright (C) 1996-2022 id Software LLC
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- See file, 'COPYING', for details.
- */
- // earthquake
- // ============================================================
- // Level-Wide Earthquakes
- // ============================================================
- float EQ_RANDOM = 1;
- void() stop_earthquake;
- void() earthquake_rumble =
- {
- if (self.attack_finished < time)
- stop_earthquake();
- else
- {
- sound( self, CHAN_VOICE, "equake/rumble.wav", 1, ATTN_NONE );
- self.think = earthquake_rumble;
- self.nextthink = time + 1;
- }
- };
- void() start_earthquake =
- {
- earthquake_active = 1;
- if ( self.spawnflags & EQ_RANDOM )
- self.attack_finished = time + random() * self.delay;
- else
- self.attack_finished = time + self.delay;
- earthquake_rumble();
- };
- void() stop_earthquake =
- {
- earthquake_active = 0;
- self.think = start_earthquake;
- if ( self.spawnflags & EQ_RANDOM )
- self.nextthink = time + random() * self.wait;
- else
- self.nextthink = time + self.wait;
- };
- /*QUAKED earthquake (0 1 0) (-8 -8 -8) (8 8 8) Random
- The Earthquake generator.
- delay - duration of the tremor (default 20)
- wait - time between tremors (default 60)
- weapon - richter scale of movement (default 40)
- RANDOM affects the times only. It will change the randomly between
- 0-n where n is the duration or time between.
- weapon - if you give a weapon value of 40, the X and Y displacement
- can vary between -20 and +20, a range of 40.
- */
- void() earthquake =
- {
- if (!self.delay)
- self.delay = 20;
- if (!self.wait)
- self.wait = 60;
- if (!self.weapon)
- self.weapon = 40;
-
- precache_sound ("equake/rumble.wav");
- earthquake_active = 0;
- earthquake_intensity = self.weapon * 0.5;
-
- setsize (self, '0 0 0', '0 0 0');
- self.think = stop_earthquake;
- self.nextthink = time + 1;
- };
- // ============================================================
- // Earthquake trigger
- // ============================================================
- void() earthquake_touch =
- {
- if (self.delay)
- {
- if ( self.attack_finished < time )
- {
- sound ( self, CHAN_VOICE, "equake/rumble.wav", 1, ATTN_NORM );
- self.attack_finished = time + 1;
- }
-
- if ( other.classname == "player" )
- {
- if ( other.flags & FL_ONGROUND )
- {
- other.velocity_x = other.velocity_x +
- (random() * self.weapon * 2) -
- self.weapon;
- other.velocity_y = other.velocity_y +
- (random() * self.weapon * 2) -
- self.weapon;
- other.velocity_z = other.velocity_z +
- (random() * self.weapon * 2) -
- self.weapon;
- }
- }
- }
- };
- void() earthquake_use =
- {
- self.delay = !self.delay;
- };
- /*QUAKED trigger_earthquake (.5 .5 .5) ?
- The Earthquake generator.
- Anytime a person is in an active field, they shake. If the trigger is a target, it will be OFF until triggered. It will then toggle between ON and OFF.
- weapon - richter scale of movement (default 40)
- weapon - if you give a weapon value of 40, the X and Y displacement
- can vary between -20 and +20, a range of 40.
- */
- void() trigger_earthquake =
- {
- precache_sound ("equake/rumble.wav");
-
- if (!self.weapon)
- self.weapon = 40;
-
- self.weapon = self.weapon * 0.5;
- self.delay = 1;
- self.touch = earthquake_touch;
- if (self.targetname)
- {
- self.use = earthquake_use;
- self.delay = 0;
- }
- InitTrigger();
- };
- void() kill_earthquake =
- {
- local entity eq;
- if ( other.classname != "player" )
- return;
-
- eq = find (world, classname, "earthquake");
- if (eq != world)
- {
- earthquake_active = 0;
- remove (eq);
- }
- };
- /*QUAKED trigger_earthquake_kill (.5 .5 .5) ?
- Trigger to kill the level-wide earthquake.
- */
- void() trigger_earthquake_kill =
- {
- self.touch = kill_earthquake;
- InitTrigger();
- };
|