UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: Naminator999 on June 19, 2014, 05:19:44 am

Title: Screen Shake?
Post by: Naminator999 on June 19, 2014, 05:19:44 am
Hi.

Im making a map that is located on a spaceship and want the screen to shake for a few seconds at random intervals with a minimum and maximum wait time.

Could someone please help me script this?

Thanks.
Title: Re: Screen Shake?
Post by: Ege115 on June 19, 2014, 07:40:09 am
Here you go, note the script is untested. If it doesn't work, I'll fix it.
Code Snippet
Plaintext
#include maps\_utility;
#include common_scripts\utility;
#include maps\_zombiemode_utility;

main()
{
thread shake_world();
}

shake_world()
{
        while(1)
        {
               players = get_players();
       for(i=0;i<players.size;i++)
      {
              Earthquake( 3, 4, players[i].origin, 700 );// NUMBER 3 IS HOW BIG THE QUAKE IS, 4 IS THE DURATION OF THE QUAKE IN SECONDS, AND 700 IS EFFECT OF THE QUAKE RADIUS
              //players[i] playsound( "SOUND_NAME" );//JUST ADDED THIS IF YOU WANT A SOUND FOR THE QUAKE, REMOVE THE // AT THE START OF THIS LINE AND ADD A SOUND NAME, IF YOU WANT TO
              }
        wait 20; //CHANGE THIS TO HOW LONG IT TAKES FOR THE EARTHQUAKE TO COME BACK, IN THIS CASE IT WILL COME AFTER EACH 20 SECOND
         }
}
Title: Re: Screen Shake?
Post by: DeletedUser on June 19, 2014, 07:43:37 am
Code Snippet
Plaintext
shake()
{
for(;;){
earthquake(0.3,10,(0,0,0),1000000);
wait(RandomFloat(300));
}
}
Ege, your script makes the earthquake stronger when there are more players.
Title: Re: Screen Shake?
Post by: Ege115 on June 19, 2014, 07:50:40 am
Code Snippet
Plaintext
shake()
{
for(;;){
earthquake(0.3,10,(0,0,0),1000000);
wait(RandomFloat(300));
}
}
Ege, your script makes the earthquake stronger when there are more players.
Oh yea, you're right. It loops all the players and then it adds some extra values. Sorry my bad, corrected it now. Thanks Ray.
Title: Re: Screen Shake?
Post by: daedra descent on June 19, 2014, 07:50:58 am
Probably want to make the time in between waits random.

Code Snippet
Plaintext
wait = RandomIntRange( 20, 60 ); // change to whatever
          wait(wait);

Like that.
Title: Re: Screen Shake?
Post by: DeletedUser on June 19, 2014, 07:53:49 am
Oh yea, you're right. It loops all the players and then it adds some extra values. Sorry my bad, corrected it now. Thanks Ray.
GODDAMMIT EGE, now it looks just like my script!
Title: Re: Screen Shake?
Post by: Ege115 on June 19, 2014, 07:58:31 am
GODDAMMIT EGE, now it looks just like my script!
I assumed you wanted me to corrrect my script with your example. Sorry, I change it then.::)
Title: Re: Screen Shake?
Post by: DidUknowiPwn on June 19, 2014, 03:51:29 pm
Probably want to make the time in between waits random.

Code Snippet
Plaintext
wait = RandomIntRange( 20, 60 ); // change to whatever
          wait(wait);

Like that.
randomIntRange is max + 1, so 60 would be 61.
Title: Re: Screen Shake?
Post by: Naminator999 on June 25, 2014, 04:15:32 am
If i'm using UGX Mod would i need to add the wait for voting to complete code.

Code Snippet
Plaintext
level waittill("ugxm_voting_complete");
Title: Re: Screen Shake?
Post by: DeletedUser on June 25, 2014, 06:26:33 am
If i'm using UGX Mod would i need to add the wait for voting to complete code.

Code Snippet
Plaintext
level waittill("ugxm_voting_complete");
If you're calling the thread AFTER the zombiemode, there's no need for that.
Title: Re: Screen Shake?
Post by: Naminator999 on June 25, 2014, 06:28:24 am
If you're calling the thread AFTER the zombiemode, there's no need for that.

Ok. Thanks

Post Merge: June 25, 2014, 06:42:20 am
Code Snippet
Plaintext
shake()
{
for(;;){
earthquake(0.3,10,(0,0,0),1000000);
wait(RandomFloat(300));
}
}

Hey Ray. How do add a delay so that the shaking does not start straight away after spawning.

Also how do i add a minimim wait between shakes.

I tried daedras wait code but i kept getting a bad syntax error.

Probably want to make the time in between waits random.

Code Snippet
Plaintext
wait = RandomIntRange( 20, 60 ); // change to whatever
          wait(wait);

Like that.
Title: Re: Screen Shake?
Post by: daedra descent on June 25, 2014, 07:06:46 am
Ok. Thanks

Post Merge: June 25, 2014, 06:42:20 am
Hey Ray. How do add a delay so that the shaking does not start straight away after spawning.

Also how do i add a minimim wait between shakes.

I tried daedras wait code but i kept getting a bad syntax error.

delete the extra tab on the wait line.
Title: Re: Screen Shake?
Post by: Naminator999 on June 25, 2014, 07:09:51 am
delete the extra tab on the wait line.
Still get bad syntax error.

Here's the code
Code Snippet
Plaintext
//Screen Shake
shake()
{
for(;;){
earthquake(0.3,3,(0,0,0),1000);
wait = RandomIntRange( 20, 60 ); // change to whatever
wait(wait);
}
}
Title: Re: Screen Shake?
Post by: DeletedUser on June 25, 2014, 07:20:37 am
Use my code, as it should affect the whole map. Add a wait(10); before the for loop.
Title: Re: Screen Shake?
Post by: Naminator999 on June 25, 2014, 07:23:05 am
Use my code, as it should affect the whole map. Add a wait(10); before the for loop.

What about a min and max wait time between shakes. I don't want the screen to shake 2 seconds after it already has you see nor too far apart
Title: Re: Screen Shake?
Post by: DeletedUser on June 25, 2014, 08:48:32 am
What about a min and max wait time between shakes. I don't want the screen to shake 2 seconds after it already has you see nor too far apart
wait(RandomFloatRange(20,300));
Title: Re: Screen Shake?
Post by: Naminator999 on June 25, 2014, 08:49:56 am
wait(RandomFloatRange(20,300));

Thanks. What if i want a sound to play when the screen shakes?