Jump to content

Photo

Switch Palace Blocks


  • Please log in to reply
18 replies to this topic

#1 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 10 March 2018 - 07:42 PM

In Super Mario World, visiting a red Switch Palace turns all the red outlines into solid blocks
 

SuperMarioWorld-StarWorld-StarWorld4.jpg

 

I wanted to do a similar effect, where once Link gets a certain item, all the combos of a certain ID permanently change to the next combo in the combo list.

 

Thanks for any help!


  • Anthus and Jared like this

#2 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 10 March 2018 - 08:04 PM

The simplest way to do this:

const int SwitchPalace_ItemID = 123;
const int SwitchPalace_ComboID = 888;

global script Active{
	void run(){
		while(true){
			if ( Link->Item[SwitchPalace_ItemID] ) { //if link has the item
				for (int i = 0; i <= 175; i++) { //check all combos
					if ( Screen->ComboD[i] == SwitchPalace_ComboID ) //if its the right combo
						Screen->ComboD[i] ++; //change to the next in the combo list
				}
			}
			Waitframe();
		}
	}
}

If you have too many scripts iterating through all combos though, FPS might go down in the worst case. Just this would be fine though.


Edited by Avataro, 10 March 2018 - 08:30 PM.


#3 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 10 March 2018 - 09:47 PM

About how many is too many?



#4 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 10 March 2018 - 10:16 PM

Depends on the computer, but I've had trouble with just about 6 functions like these + 2 distance checks. But it's been awhile, it might have not been the only cause.



#5 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 10 March 2018 - 10:29 PM

Would I be able to substitute the combo ID for a group of combo IDs?

Such as replacing
const int SwitchPalace_ComboID = 888;

with
const int SwitchPalace_ComboID = 16, 18, 20, 22;



#6 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 10 March 2018 - 11:07 PM

For most scripts I prefer to make them FFC scripts for this reason. That way the code is only running on screens with the blocks where it will be needed, where an FFC with the script is placed down. The more you pile onto the global, the slower it's going to become, so it's better to reserve it for events that are...global.



#7 ywkls

ywkls

    Master

  • Members

Posted 10 March 2018 - 11:24 PM

Or you could use this script...
 
Linked Secrets

 

This would do almost precisely what was requested, letting you affect secrets anywhere this ffc was placed in the whole quest.

 

It works with both weapon and step triggers.

 

You're welcome.


  • Anthus likes this

#8 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 11 March 2018 - 02:37 AM

That's pretty hard to understand ywkls. I do want it to be activated by having an item though.

I think Avataro's should work with a multiple combo edit.


Edited by Cukeman, 11 March 2018 - 08:09 AM.


#9 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 11 March 2018 - 12:04 PM

const int SwitchPalace1_ItemID = 123;
const int SwitchPalace1_ComboID = 16;
const int SwitchPalace2_ItemID = 124;
const int SwitchPalace2_ComboID = 18;
const int SwitchPalace3_ItemID = 125;
const int SwitchPalace3_ComboID = 20;
const int SwitchPalace4_ItemID = 126;
const int SwitchPalace4_ComboID = 22;

ffc script SwitchPalaces{
	void run(){
		while(true){
			for (int i = 0; i <= 175; i++) {
				if ( (Link->Item[SwitchPalace1_ItemID] && Screen->ComboD[i] == SwitchPalace1_ComboID)
				|| (Link->Item[SwitchPalace2_ItemID] && Screen->ComboD[i] == SwitchPalace2_ComboID)
				|| (Link->Item[SwitchPalace3_ItemID] && Screen->ComboD[i] == SwitchPalace3_ComboID)
				|| (Link->Item[SwitchPalace4_ItemID] && Screen->ComboD[i] == SwitchPalace4_ComboID) )
					Screen->ComboD[i] ++;
			}
			Waitframe();
		}
	}
}

Alright new script. As per Moosh's suggestion it's an FFC script now, so place it on any screen where there are switch palace blocks, and be sure to always check "run script at screen init" in it's FFC flags.



#10 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 11 March 2018 - 12:22 PM

You shouldn't even need to put it in a while(true) loop, since it only needs to be done when you enter the screen (with the possible exception of the room where you find the item).

 

I'd just have:

ffc script SwitchPalaces{
	void run(){
		for (int i = 0; i <= 175; i++) {
			if ( (Link->Item[SwitchPalace1_ItemID] && Screen->ComboD[i] == SwitchPalace1_ComboID)
			|| (Link->Item[SwitchPalace2_ItemID] && Screen->ComboD[i] == SwitchPalace2_ComboID)
			|| (Link->Item[SwitchPalace3_ItemID] && Screen->ComboD[i] == SwitchPalace3_ComboID)
			|| (Link->Item[SwitchPalace4_ItemID] && Screen->ComboD[i] == SwitchPalace4_ComboID) )
				Screen->ComboD[i] ++;
		}
	}
}

And you can add an item script to the "switch" items to make them do the exact same thing when you pick them up.


Edited by Jamian, 11 March 2018 - 12:24 PM.

  • Avaro likes this

#11 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 11 March 2018 - 02:30 PM

^ This guy would know. His quest literally has switch palace blocks with their mario design.


  • Anthus likes this

#12 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 12 March 2018 - 01:07 AM

And you can add an item script to the "switch" items to make them do the exact same thing when you pick them up.


Sorry, an item script to make them do what when you pick them up?

#13 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 12 March 2018 - 07:32 AM

For most scripts I prefer to make them FFC scripts for this reason. That way the code is only running on screens with the blocks where it will be needed, where an FFC with the script is placed down. The more you pile onto the global, the slower it's going to become, so it's better to reserve it for events that are...global.


I disagree wholeheartedly here. You risk far more with general timing bugs than with slowdown issues; plus, wasting ffcs is not very viable if you want ghosted enemies and weapons, or other effects. It's also tedious and easy to miss screens, adding gameplay bugs into quests.

In general, you need only iterate combos per layer once per frame, then do whatever checks you want to do, per combo; rather than adding additional iteration instances, however, additional iterations are more practical in some cases.

In this case, you need only iterate once per screen, on screen transition, so a global approach risks nothing.

Spoiler


Anyway, this would likely be the most efficient way to do it:
if (changedScreen() )
{
    for ( q = 0; q < 176; ++q )
    {
        if ( Link->Item[I_RED_SWITCHES] )
        {
            if ( Screen->ComboD[q] == CMB_BLANK_RED_BLOCK ) { Screen->ComboD[q] = CMB_RED_BLOCK; }
        }
    }
}



#14 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 12 March 2018 - 09:00 AM

Sorry, an item script to make them do what when you pick them up?

You can copy Jamian's script, replace "ffc" with "item" and use that as the pickup scripts for your 4 items.



#15 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 12 March 2018 - 05:19 PM

Sorry, an item script to make them do what when you pick them up?

 

Make them change the appropriate combos.

 

In the solution I suggested, you only check if combos need to be changed upon entering the room. Once it's been done, there's no reason to keep checking until the player moves to another room, so the script only does it once, and then quits.

 

But if you have, say, red blocks in the room where you get the "red switch" item, you need these blocks to change upon picking up the item. Then you'd also need to perform the combo changes at the moment you pick up the item.


  • Cukeman likes this


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users