PDA

View Full Version : [Code Sniplet] - Earthquake


Wad'a'Holic
September 26th, 2005, 05:11 PM
Hey guys!
Screwing around with Fraggle-script one day and I made this. Hope it helps, one of the most effective ways to create an earthquake effect cos it shakes the object not the camera.



// Scripted Interaction : Object earthquake
int objectEarthquakeAmount;
script 71
{
while(objectEarthquakeAmount>0)
{
objmomx(trigger, 5);wait(5);
objmomx(trigger, -5);wait(5);
objmomy(trigger, 5);wait(5);
objmomy(trigger, -5);wait(5);
objmomz(trigger, 5);wait(5);
objmomz(trigger, -5);wait(5);
objectEarthquakeAmount--;
wait(1);
}
}



Add that to your script. Then when you want the earthquake effect to start, put this in...



objectEarthquakeAmount=5;
startscript(71);



NOTE: This script shakes the 'trigger' object, example, if a zombie walks over a line that activates the earthquake, he will shake and not the player. Please keep this in mind.

ALSO to keep in mind, you can change the objectEarthquakeAmount=5; to another number to change the earthquake shake time.

Hope to hear your comments and feedback on the effect. Free to use without credit :D

-Wad'a'Holic

iori
September 26th, 2005, 07:16 PM
This was created by Darkwolf a year or two ago. Same idea, but note it uses the 'rnd' command to randomize things a bit.


/* Pseudo Earthquake
by DarkWolf */

[scripts]
include("things.h");

script 1
{
int tics;
fixed randx;
fixed randy;
fixed randz;
while(tics < 30) //desired seconds * 10
{
randx = (rnd() / 75) - 1.5; //should it be 'prnd' for demo compatability?
randy = (rnd() / 75) - 1.5;
randz = (rnd() / 200); //optional
objmomx(playerobj(0), randx);
objmomy(playerobj(0), randy);
objmomz(playerobj(0), randz);
wait(10);
tics++;
}
}
startscript(1);

Danimetal
September 27th, 2005, 12:42 AM
I used Darkwolf method, but apart from shaking (the Z coordinate was a bit unstable so I removed it) it made you completely vulnerable.

iori
September 27th, 2005, 11:02 AM
Earthquakes are done best when it only shakes the screen I find. They are good for audio/visual cues that something has happened elsewhere in the level, barring they aren't overused.

Danimetal
September 27th, 2005, 01:30 PM
That´s why we need Hexen stuff and that´s why we´ll probably have it... ´Cos Hexen had earthquakes, didn´t it?.

DooMAD
September 28th, 2005, 12:41 PM
Yep, Hexen has a simple linetype for earthquakes. It must be an object shake, rather than just the camera, as it has no effect when you have no clipping on.

Danimetal
September 28th, 2005, 03:15 PM
That will render all earthquake scripts useless... I would start some more Hexen editing if just DoomBuilder didn´t crash each time I use the Hexen format.