Jump to content

Photo

Where to adding earthquake


  • Please log in to reply
21 replies to this topic

#16 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 18 April 2017 - 12:38 AM

something like that ?


item script KillEnemiesQuake
{
    void run (int sfx)
    {
    while()
		//Trigger on secrets
		if(Screen->State[ST_SECRET] == true)
		{
			Screen->Quake = 30;
			Game->PlaySound(sfx);
			Link->Jump = 1;
		}

		//trigger on all enemies defeated
		else if(Screen->NumNPCs() <= 0)
		{
			Screen->Quake = 30;
			Game-> PlaySound(sfx);
			Link->Jump = 1;
                        quit()
		}
	}
}


Edited by Cedric, 18 April 2017 - 12:39 AM.


#17 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 18 April 2017 - 05:16 AM

Replace while() with while(true) and don't forget the brackets. There needs to be a Waitframe(); instruction at the end of the while loop, otherwise ZC will forever wait for the next frame and freeze.

 

Quit() needs to be in both conditions; however since both conditions do exactly the same thing, you can save space and merge them with || (OR) : if(Screen->State[ST_SECRET]==true || Screen->NumNPCs() <= 0)

 

It should be ffc script and not item script. Item scripts are triggered by items.

 

Note that this script would trigger the earthquake if secrets are activated OR all enemies have been defeated. I would guess you only want one of these, and not both. It would also do this every time you reenter the screen, if the secrets are still activated or if the enemies are still gone. You'd probably want to check for that before the loop, and quit if the earthquake already happened.



#18 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 18 April 2017 - 09:27 AM

Like this huh ?

ffc script KillEnemiesQuake
{
    void run (int sfx)
    {
    while(true);
		//Trigger on secrets
		if(Screen->State[ST_SECRET] == true)
		{
			Screen->Quake = 30;
			Game->PlaySound(sfx);
			Link->Jump = 1;
		}

		//trigger on all enemies defeated
		else if(Screen->NumNPCs() <= 0)
		{
			Screen->Quake = 30;
			Game-> PlaySound(sfx);
			Link->Jump = 1;
                        Quit()
                        Waitframe();
		}
	}
}
that is the right way to make the script working ?

#19 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 18 April 2017 - 01:44 PM

You need to put the while events (every instruction that follows, in your case) between brackets.

 

You need to have Quit(); inside your first "if" condition as well. The way it's currently written, the script will only quit if the enemies have been killed, not if the secrets are activated.

 

Waitframe(); needs to be outside of the conditions.



#20 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 18 April 2017 - 05:07 PM

huh... i'm not sure now :/



#21 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 19 April 2017 - 08:10 AM

Like this:

ffc script Quake{
    void run (int sfx){
        //while(true) will repeat the instructions between its brackets every frame
        while(true){
            //Trigger on secrets, the code between the if brackets is executed only if secrets are activated
            if(Screen->State[ST_SECRET] == true){
                Screen->Quake = 30;
                Game->PlaySound(sfx);
                Link->Jump = 1;
                Quit();
            }
            //Trigger on all enemies defeated, the code between the else if brackets is executed only if all enemies are gone
            else if(Screen->NumNPCs() <= 0)
            {
                Screen->Quake = 30;
                Game-> PlaySound(sfx);
                Link->Jump = 1;
                Quit();
            }
         // You need a Waitframe(); instruction at the end of a while loop, otherwise ZC forever waits for the next frame and freezes
         Waitframe();
         }
    }
}

But this is still relevant:

 

Note that this script would trigger the earthquake if secrets are activated OR all enemies have been defeated. I would guess you only want one of these, and not both. It would also do this every time you reenter the screen, if the secrets are still activated or if the enemies are still gone. You'd probably want to check for that before the loop, and quit if the earthquake already happened.

 



#22 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 19 April 2017 - 09:35 AM

i see now i'll do test it later


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users