Page 1 of 1

Script for Stuka that flies into a tree and explodes (?)

Posted: October 18th, 2009, 4:17 pm
by Lennard
I wanna make a script, which flies a Stuka into a tree and explodes with a big boom and a lot of smoke after the crash, now I already got the Stuka flying into the tree, but how can i make a explosion in the tree at the time that it flies into it?

Here's my script for the Stuka ( I used the tutorial )
main()
{

level thread planes();
}

planes()
{
level.PlaneSpeed = 1.5;

stuka1 = getent ("stuka1","targetname");

temp = getent (stuka1.target,"targetname");
stuka1.dest = temp.origin;
stuka1.start = stuka1.origin;
stuka1 hide();

wait 2;

while (1)
{
stuka1 thread plane_flyby("stuka_flyby");
wait .15;

wait 60;
}
}


plane_flyby(sound)
{
// If you specified a sound to play then play it
if (isdefined (sound))
self playsound (sound);

wait 15;

self show();

self moveto(self.dest, level.PlaneSpeed, 0.1, 0.1);

wait level.PlaneSpeed;

self hide();
self.origin = self.start;
}
Now there is also a diff weird thing, I didnt fill in any sounds, but I do hear one? Not that it's not good, it's actually perfect, but I don't know how I did it.

Thx for the help

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 18th, 2009, 5:20 pm
by waywaaaard
Your sound issue: I guess aren't really into scripting at the moment but in the plane flyby function you are using this piece of code

Code: Select all

self playsound (sound);
which basically plays the sound "stuka_flyby"

No you follow the code and see where the plane model is hidden again, you couldn't now spawn there and effect like explosion, smoke etc

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 18th, 2009, 5:23 pm
by Lennard
Ah ok, that problem is solved than, but to explain it a little bit easier.

It's just like a mortar exploding on the ground.
Do you know how to make that?

Basically all I want is a script that causes an explosion after the impact of the plane, a little bit easier explained.

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 18th, 2009, 5:35 pm
by waywaaaard
try this

Code: Select all


main()
{

level thread planes();
}

planes()
{
level.PlaneSpeed = 1.5;

stuka1 = getent ("stuka1","targetname");

temp = getent (stuka1.target,"targetname");
stuka1.dest = temp.origin;
stuka1.start = stuka1.origin;
stuka1 hide();

wait 2;

while (1)
{
stuka1 thread plane_flyby("stuka_flyby");
wait .15;

wait 60;
}
}


plane_flyby(sound)
{
// If you specified a sound to play then play it
if (isdefined (sound))
self playsound (sound);

wait 15;

self show();
self moveto(self.dest, level.PlaneSpeed, 0.1, 0.1);
wait level.PlaneSpeed;

// added an explosion
boom = loadfx("fx/explosions/mp_bomb.efx");
playfx(boom, self.dest); 

self hide();
self.origin = self.start;
}

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 18th, 2009, 5:49 pm
by Lennard
It doesn't do anything :O? The stuka flew into the tree but there wasn't even a sound of an explosion :?

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 18th, 2009, 6:01 pm
by waywaaaard
mh if you open the console the big one with shift+~ are there any error messages?

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 18th, 2009, 6:08 pm
by Lennard
ain't shift + ~ for Cod2 and Cod4?
This is Cod1, but w/e, I don't see any errors.

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 18th, 2009, 8:02 pm
by Drofder2004
Its been a while, but should you not be preloading your FX at the beginning of the script?

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 18th, 2009, 8:54 pm
by Lennard
what do you mean ? how do I do that ?

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 19th, 2009, 2:58 am
by Nightmare

Code: Select all

boom = loadfx("fx/explosions/mp_bomb.efx");
wait 0.05;
playfx(boom, self.dest); 
Add that wait so the server can go through a frame.

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 19th, 2009, 9:23 am
by Lennard
It says Script Compile Error.

I copied & pasted the code you sent and pasted it at the end of the script, is that right?
main()
{

level thread planes();
}

planes()
{
level.PlaneSpeed = 3.3;

stuka1 = getent ("stuka1","targetname");

temp = getent (stuka1.target,"targetname");
stuka1.dest = temp.origin;
stuka1.start = stuka1.origin;

wait 2;

while (1)
{
stuka1 thread plane_flyby("stuka_flyby");
wait .15;

wait 35;
}
}


plane_flyby(sound)
{
// If you specified a sound to play then play it
if (isdefined (sound))
self playsound (sound);

wait 15;

self show();

self moveto(self.dest, level.PlaneSpeed, 0.1, 0.1);

wait level.PlaneSpeed;

wait 3;

self hide();
self.origin = self.start;
}

boom = loadfx("fx/explosions/mp_bomb.efx");
wait 0.05;
playfx(boom, self.dest);

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 19th, 2009, 12:00 pm
by waywaaaard

Code: Select all

main()
{

level thread planes();
}

planes()
{
level.PlaneSpeed = 1.5;

stuka1 = getent ("stuka1","targetname");

temp = getent (stuka1.target,"targetname");
stuka1.dest = temp.origin;
stuka1.start = stuka1.origin;
stuka1 hide();

wait 2;

while (1)
{
stuka1 thread plane_flyby("stuka_flyby");
wait .15;

wait 60;
}
}


plane_flyby(sound)
{
// If you specified a sound to play then play it
if (isdefined (sound))
self playsound (sound);

wait 15;

self show();
self moveto(self.dest, level.PlaneSpeed, 0.1, 0.1);
wait level.PlaneSpeed;

// added an explosion
boom = loadfx("fx/explosions/mp_bomb.efx");
wait 0.5;
playfx(boom, self.dest);

self hide();
self.origin = self.start;
}

Re: Script for Stuka that flies into a tree and explodes (?)

Posted: October 19th, 2009, 1:39 pm
by Lennard
nope, doesn't work.

i was wondering, doesn't the tree have the be a entity? it's now just a misc_model, coz its now just flying into the tree and nothing else happens..