Jump to content

Photo

Total noob question, but...


  • Please log in to reply
24 replies to this topic

#1 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 25 April 2017 - 01:53 AM

How do you make an item script run an ffc script? I've never needed to do it before, and I can't seem to find the right documentation.



#2 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 25 April 2017 - 02:32 AM

item script ExampleItem{
	void run(int msg){
		int exampleFFC[] = "ExampleFFC"; //Make a string for the name of your FFC script
		//An array like this can pass stuff to the 8 D_ arguments on the FFC script
		int Args[8];
		Args[0] = msg;
		//The RunFFCScript function takes two arguments.
		//The first is the slot number for the FFC script. This is made simpler with the GetFFCScript() function which can grab it from a string.
		//The second is a size 8 array which holds the arguments for the script. If it has none, you can leave this as 0.
		RunFFCScript(Game->GetFFCScript(exampleFFC), Args);
	}
}

ffc script ExampleFFC{
	void run(int msg){
		Screen->Message(msg);
		while(true){
			Link->HP--;
			Waitframe();
		}
	}
}

You use the RunFFCScript() function from ffcscript.zh like so. Make sure FFCS_INVISIBLE_COMBO is set up correctly in ffcscript.zh for the tileset you're using. Most have 1 as a blank combo so the default works, a few need it to be changed.


  • Binx likes this

#3 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 25 April 2017 - 02:34 AM

Awesome, thank you. EDIT: Oh, while I'm at it, how do I freeze all action on screen?

 

EDIT: Oh, good news, I think I finally understand how arrays work.


Edited by Binx, 25 April 2017 - 02:36 AM.


#4 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 25 April 2017 - 02:42 AM

Awesome, thank you. EDIT: Oh, while I'm at it, how do I freeze all action on screen?

There's two combo types called Screen Freeze. One freezes everything on the screen except for FFC scripts, the other only freezes FFC scripts. The typical way to freeze the screen is in your global script load two FFCs (typically 31 and 32), and set their combos to the two screen freeze combos.



#5 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 25 April 2017 - 03:42 AM

Ok, so, I tried this and I obviously did something wrong, coz it seems to work very strangely. 

item script SONG_OBSTACLE
{
    void run (int SFX, int Combo1, int Combo2, int Combo3, int Combo4, int Combo5, int Combo6)
    {
        int Song_Obstacle[] = "Song_Obstacle";
        int Args[7] = {SFX, Combo1, Combo2, Combo3, Combo4, Combo5,Combo6};
        RunFFCScript(Game->GetFFCScript(Song_Obstacle), Args);
    }
}
 ffc script Song_Obstacle
{
    void run (int SFX, int Combo1, int Combo2, int Combo3, int Combo4, int Combo5, int Combo6)
{
    while (true)
    {
    Game->PlaySound(SFX);
  for (int i = 0; i < 176; i++){ 
  if (Screen->ComboD[i] == Combo1) {
        Screen->ComboD[i] = Combo2;}       
  if (Screen->ComboD[i] == Combo3) {
        Screen->ComboD[i] = Combo4;}
  if (Screen->ComboD[i] == Combo5) {
        Screen->ComboD[i] = Combo6;}
}

   Waitframe();    
}
}

It changes the combos fine, but it doesn't play the SFX until I change screens.



#6 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 25 April 2017 - 04:26 AM

Place the line playing the SFX before the while loop, not inside of it. I also don't know what the script is supposed to be doing, but from the looks of it you don't need a while loop at all.



#7 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 25 April 2017 - 01:18 PM

Well, it's not even close to finished, but there's going to be two versions when done, the first (as above) will ideally freeze all action on screen (the part I haven't gotten to, yet ), play the SFX file, unfreeze the screen after the SFX finishes playing, then changes the three combos into the other three. The other one will do the same thing, but instead of changing combos, it will check if you have one of two specific items (I_CHILDLINK, I_ADULTLINK) and play an animation, then warp you to a dmap, screen, and position based on which of the two items you have. Basically, it's a set of 9 items that replace the whistle item.



#8 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 25 April 2017 - 01:40 PM

You don't need a while loop (those are used when some instructions need to be repeated every frame). Here you want to play the SFX, freeze the screen for the amount of time the SFX lasts, then change the combos. All of that only needs to be done once, and then the script can end.



#9 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 25 April 2017 - 01:53 PM

Oh, right. Ok, so I can remove the while loop, easy enough... Um.. so how do I set the Screen Freeze up? I think I understand how to call up the FFC in that slot, but I can't find anything on how to assign a specific combo to that FFC. And I'm a little lost on how to make it only last as long as the SFX


Edited by Binx, 25 April 2017 - 01:54 PM.


#10 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 25 April 2017 - 02:15 PM

I'm going off the top of my head here. PlaySound() doesn't return anything. So your only choice is to create a loop to waitframe() for the length of the sound in frames.

Side note, perhaps PlaySound() could be made to return 1 while a sound is playing.

#11 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 25 April 2017 - 02:42 PM

Oh, well that will be fun. In the meantime, I broke it, Tried to set it to only change the combos if Link's standing on a specific combo, and instead it just doesn't do anything. So, yeah:

item script SONG_OBSTACLE
{
    void run (int SFX, int Combo1, int Combo2, int Combo3, int Combo4, int Combo5, int Combo6, int trigger)
    {
        int Song_Obstacle[] = "Song_Obstacle";
        int Args[8] = {SFX, Combo1, Combo2, Combo3, Combo4, Combo5,Combo6, trigger};
        RunFFCScript(Game->GetFFCScript(Song_Obstacle), Args);
    }
}

ffc script Song_Obstacle
{
    void run (int SFX, int Combo1, int Combo2, int Combo3, int Combo4, int Combo5, int Combo6, int trigger)
{
Game->PlaySound(SFX);
  for (int i = 0; i < 176; i++)
  { 
if (ComboAt(Link->X, Link->Y) == trigger)
{
  if (Screen->ComboD[i] == Combo1) {
        Screen->ComboD[i] = Combo2;}       
  if (Screen->ComboD[i] == Combo3) {
        Screen->ComboD[i] = Combo4;}
  if (Screen->ComboD[i] == Combo5) {
        Screen->ComboD[i] = Combo6;}
}
else if (ComboAt(Link->X, Link->Y) != trigger)
return;
}

}  
}


I'm not sure what I missed.

EDIT: the SFX files that would be playing range from 5 to 11 seconds and I'm out of arguments, would I have to hard-code different versions of the script for every song? Or just another if/else statement to determine which SFX is being played? (If SFX = a, do stuff; if SFX = b, do stuff...)


Edited by Binx, 25 April 2017 - 02:58 PM.


#12 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 25 April 2017 - 02:58 PM

Your problem is how your checking for your trigger.

ComboAt() returns the pos of a combo. So currently if trigger is 1 then that means Link (the top left corner of Link) must be on combo 1, which is at the top left corner of the screen. Regardless of what ID, type or flag that combo has.

First you want to check your location of Link by his centre. (Link->X+8 and Link->Y+8). This'll give you a much better account on what combo Link is standing on. Then you need to decide if a location is what you want to check for. Or is it combo type or a flag?
As an example, A check for combo type at Link's location would look like this, with trigger being the type:
Screen->ComboT[ComboAt(Link->X+8, Link->Y+8)] == trigger;

Also your else if() is not required.

#13 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 25 April 2017 - 03:12 PM

No, it's definitely the combo ID of the combo Link is standing on that I'm looking for, not its type. I tried checking
 

 if (Screen->ComboD[ComboAt(Link->X+8 and Link->Y+8)] == trigger)

but that just made it give me an error "Line 133: unexpected identifier,expecting RParen on token and tmp."

 

EDIT: Had typed out the command, missed  few things, copied the line directly from the code


Edited by Binx, 25 April 2017 - 03:26 PM.


#14 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 25 April 2017 - 03:22 PM

your missing one ] and one ) and one = ,on that line you pasted.

I noticed your edit. You have more than one song? How are these songs determined? I'm going to need a better explanation on how this item works.

#15 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 25 April 2017 - 03:40 PM

your missing one ] and one ) and one = ,on that line you pasted.

I noticed your edit. You have more than one song? How are these songs determined? I'm going to need a better explanation on how this item works.

Yeah, that was my mistake, I just typed it out, rather than copying the line. Fixed above. EDIT: To be clear, I had the ),], and = in my script, I just failed to type it out, correctly, here. It is still giving me the error

 

Three of the songs are for obstacles (Saria's Song, Zelda's Lullaby, Song of Time), and each has a different set of combos they can change. The other 6 are each going to be warp songs, that take you to a specific DMap, Screen and x,y position (two for each, one for the child timeline, one for the adult timeline, it will check to see if you have a specific item before determining the warp screen). So, for example, the Song of Time can remove certain blocks, drain the well in Kakariko Village, and open the Door of Time, Saria's Song will let you get out of the forest, open some secrets and warp you to identical screens by turning the trigger combo into a direct warp (although I haven't quite figured out how to make it change that combo only if I want that room to warp, maybe I just need to make a separate FFC as a trigger and manually place it onscreen?), Zelda's Lullaby has an entirely different set of combos that change from either of the other songs. The warp songs all work the same, just use different destinations, so playing the Minuet of Forest would warp you to DMap 0, screen 09, if you have I_CHILDLINK in your inventory, and DMap 20, screen 9 if you have I_ADULTLINK in your inventory. EDIT: Oh, and they're all separate items, I'm just planning to load the same item script into each item's action slot, and use the arguments to determine the combos to be changed or the place to warp to (depending if I use the obstacle or warping script for the item)


Edited by Binx, 25 April 2017 - 04:05 PM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users