Jump to content

Photo

Combo type forcing Link to jump


  • Please log in to reply
7 replies to this topic

#1 Phosphor

Phosphor

    Pixelating

  • Members

Posted 19 June 2017 - 08:45 PM

The script is in the name. I need a script that forces a combo, when stepped on or cycled to underneath Link, forces him to jump like he's using Roc's feather.



#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 19 June 2017 - 11:16 PM

Do you want this to be global, or an ffc-based script?
 
 
 
 
const int CF_FORCEJUMP = 102; //Default is script 5. 
const int CMB_FORCEJUMP = 0;  //A specific combo ID. 
const int CT_FORCEDJUMP = 146; //Script 5
const int FORCED_JUMP_HEIGHT = 16; //The Link->Jump value. 
//FFCs will use this value as their default if their D0 arg is less than 1. 

//Settings. Set to 1 to enable, 0 to disable. 
const int FORCEDJUMP_USE_TYPE = 1;
const int FORCEDJUMP_USE_COMBOID = 1;
const int FORCEDJUMP_USE_FLAG = 1;

//Call before Waitdraw in your global active script. 
void ForcedJump(){
	for ( int q = 0; q < 176; q++ ) {
		if (
				( FORCEDJUMP_USE_FLAG && (Screen->ComboF[q] == CF_FORCEJUMP || Screen->ComboI[q] == CF_FORCEJUMP) )
				|| ( FORCEDJUMP_USE_COMBOID && Screen->ComboD[q] == CMB_FORCEJUMP ) 
				|| ( FORCEDJUMP_USE_TYPE && Screen->ComboT[q] == CT_FORCEDJUMP ) )
			
		{
			if ( Link->Jump <= 0 ) {
				if ( _____CMBCollision(q) ){
					Link->Jump = FORCED_JUMP_HEIGHT;
				}
			}
		}
	}
}

//FFC for this

ffc script ForcedJump{
	void run(int jumpheight){
		while(true){
			____ForcedJump(jumpheight);
			Waitframe();
		}
	}
	void ____ForcedJump(int h){
		if ( (h<<0) <= 0 ) h = FORCED_JUMP_HEIGHT;
		for ( int q = 0; q < 176; q++ ) {
			if (
				( FORCEDJUMP_USE_FLAG && (Screen->ComboF[q] == CF_FORCEJUMP || Screen->ComboI[q] == CF_FORCEJUMP) )
				|| ( FORCEDJUMP_USE_COMBOID && Screen->ComboD[q] == CMB_FORCEJUMP ) 
				|| ( FORCEDJUMP_USE_TYPE && Screen->ComboT[q] == CT_FORCEDJUMP ) )
			
			{
				if ( Link->Jump <= 0 ) {
					if ( _____CMBCollision(q) ) {
						Link->Jump = h;
					}
				}
			}
		}
	}
}

bool _____CMBCollision(int cmb){
	int c[4];
	c[0] = Link->X+Link->HitXOffset+Link->DrawXOffset;
	c[1] = Link->Y+Link->HitYOffset+Link->DrawYOffset;
	c[2] = c[0]+(Link->HitWidth);
	c[3] = c[1]+(Link->HitHeight);
	if ( !RectCollision( ComboX(cmb), ComboY(cmb), (ComboX(cmb)+16), (ComboY(cmb)+16), c[0], c[1], c[2], c[3]) ) return false;
	else if ( !(Distance(CenterLinkX(), CenterLinkY(), (ComboX(cmb)+8), (ComboY(cmb)+8)) < 8) ) return false;
	return true;
}

Edited by ZoriaRPG, 20 June 2017 - 02:05 AM.


#3 Phosphor

Phosphor

    Pixelating

  • Members

Posted 19 June 2017 - 11:33 PM

Definitely FFC based. Globals are a pain to work with for me. How might I set the ffc up?


Edited by Phosphor, 19 June 2017 - 11:35 PM.


#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 20 June 2017 - 02:13 AM

Definitely FFC based. Globals are a pain to work with for me. How might I set the ffc up?

 

First, because I'm a moron, you will want to grab the updated code, above.

 

Then, put it in a file, or append it to your script buffer, and set up its constants (the settings, and properties). If you want to use a combo type, but not a specific combo ID, and not a combo flag, change the settings to:

 

const int FORCEDJUMP_USE_TYPE = 1;
const int FORCEDJUMP_USE_COMBOID = 0;
const int FORCEDJUMP_USE_FLAG = 0;

 

These three settings determine what combo properties are checked. The script can check if any of them are valid, so you can enable more than one, but you should probably choose only one of the three options. You may reference the valid combo types and flags in std_constants.zh. You must assign one of these constant settings to the literal value of a flag, or type.

 

You cannot for example do this in 2.50.x:

 

const int CF_FORCEJUMP = CF_SCRIPT5;

 

Use only the numeric literal for that type when assigning it:

 

const int CF_FORCEJUMP = 102; //( 102 == CF_SCRIPT5 )

 

Then, set the properties as needed:

 

const int CF_FORCEJUMP = 102; //Default is script 5.
const int CMB_FORCEJUMP = 0; //A specific combo ID.
const int CT_FORCEDJUMP = 146; //Script 5
const int FORCED_JUMP_HEIGHT = 16; //The Link->Jump value.

 

FORCED_JUMP_HEIGHT is used by the ffc is you leave its D0 arg at 0.0000. If you want a specific jump value, set D1 of the ffc to that value. If you want to be able to easily add this to any screen, set the constant to your preferred default. This works as Link->Jump as explained in ZScript.txt, which is a tad confusing, so just play with the value until you find one that you like.

 

Set the flag, type, and combo ID constants to the flag, type, and specific combo ID that you are using for this combo. You only need to set properties that you are actually using. This only works on layer 0.

 

If you need it on a higher layer, then you will need to specify that in your posts.

 

If you want to add it to your global active script, and make it automatic, you need only add a call to ForcedJump() immediately before your Waitdraw() instruction. If your global active script does not have a Waitdraw() instruction, then it is broken.

 

Once you have the settings as you desire, compile, assign the ffc to a slot, and set one of the ffcs on every screen for which you need this effect to the script ForcedJump, and set its data to an invisible combo higher than combo ID 0. Be sure to set the FFC Data to 1 or higher when setting it up. If the ffc data (combo ID) is 0, it will not run a script.


  • ShadowTiger likes this

#5 Phosphor

Phosphor

    Pixelating

  • Members

Posted 20 June 2017 - 11:32 PM

Hm. When I set the script up, it forces link to constantly jump while occupying the tile the flag is on, even if he's in the air. Do you think there's any way to prevent it from forcing him to jump over and over while on/over the tile? Or for a max height to be added to it? The way it behaves seems like an interesting way to implement something like vertical fans, but you can stand on it and go infinitely high.

 

Edit: With some fiddling, I got the original use for the script to work flawlessly, though I would like to maybe have an alternate version of the script with a cap on height so I can use it for upwards-facing fans.


Edited by Phosphor, 20 June 2017 - 11:38 PM.


#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 21 June 2017 - 06:06 AM

Hm. When I set the script up, it forces link to constantly jump while occupying the tile the flag is on, even if he's in the air. Do you think there's any way to prevent it from forcing him to jump over and over while on/over the tile? Or for a max height to be added to it? The way it behaves seems like an interesting way to implement something like vertical fans, but you can stand on it and go infinitely high.

 

Edit: With some fiddling, I got the original use for the script to work flawlessly, though I would like to maybe have an alternate version of the script with a cap on height so I can use it for upwards-facing fans.

 

What version of ZC are you using? This relies on Link->Jump returning the proper value, which does not happen in 2.50.0 and 2.50.1.


Edited by ZoriaRPG, 21 June 2017 - 06:06 AM.


#7 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 21 June 2017 - 06:25 AM

Replace both instances of "Link->Jump <= 0" with "Link->Z == 0".


Edited by Avataro, 21 June 2017 - 06:25 AM.


#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 21 June 2017 - 12:51 PM

That would suffice. In fact, it would be better to manually short-circuit it based on that:

 

const int CF_FORCEJUMP = 102; //Default is script 5.
const int CMB_FORCEJUMP = 0;  //A specific combo ID.
const int CT_FORCEDJUMP = 146; //Script 5
const int FORCED_JUMP_HEIGHT = 16; //The Link->Jump value.
//FFCs will use this value as their default if their D0 arg is less than 1.

//Settings. Set to 1 to enable, 0 to disable.
const int FORCEDJUMP_USE_TYPE = 1;
const int FORCEDJUMP_USE_COMBOID = 1;
const int FORCEDJUMP_USE_FLAG = 1;

//Call before Waitdraw in your global active script.
void ForcedJump(){
    if ( Link->Jump <= 0 ) {
        for ( int q = 0; q < 176; q++ ) {
            if (
                    ( FORCEDJUMP_USE_FLAG && (Screen->ComboF[q] == CF_FORCEJUMP || Screen->ComboI[q] == CF_FORCEJUMP) )
                    || ( FORCEDJUMP_USE_COMBOID && Screen->ComboD[q] == CMB_FORCEJUMP )
                    || ( FORCEDJUMP_USE_TYPE && Screen->ComboT[q] == CT_FORCEDJUMP ) )
                
            {
                
                if ( _____CMBCollision(q) ){
                    Link->Jump = FORCED_JUMP_HEIGHT;
                }
            }
        }
    }
}

//FFC for this

ffc script ForcedJump{
    void run(int jumpheight){
        while(true){
            ____ForcedJump(jumpheight);
            Waitframe();
        }
    }
    void ____ForcedJump(int h){
        if ( (h<<0) <= 0 ) h = FORCED_JUMP_HEIGHT;
        if ( Link->Z <= 0 ) {
            for ( int q = 0; q < 176; q++ ) {
                if (
                    ( FORCEDJUMP_USE_FLAG && (Screen->ComboF[q] == CF_FORCEJUMP || Screen->ComboI[q] == CF_FORCEJUMP) )
                    || ( FORCEDJUMP_USE_COMBOID && Screen->ComboD[q] == CMB_FORCEJUMP )
                    || ( FORCEDJUMP_USE_TYPE && Screen->ComboT[q] == CT_FORCEDJUMP ) )
                
                {
                
                    if ( _____CMBCollision(q) ) {
                        Link->Jump = h;
                    }
                
                }
            }
        }
    }
}

bool _____CMBCollision(int cmb){
    int c[4];
    c[0] = Link->X+Link->HitXOffset+Link->DrawXOffset;
    c[1] = Link->Y+Link->HitYOffset+Link->DrawYOffset;
    c[2] = c[0]+(Link->HitWidth);
    c[3] = c[1]+(Link->HitHeight);
    if ( !RectCollision( ComboX(cmb), ComboY(cmb), (ComboX(cmb)+16), (ComboY(cmb)+16), c[0], c[1], c[2], c[3]) ) return false;
    else if ( !(Distance(CenterLinkX(), CenterLinkY(), (ComboX(cmb)+8), (ComboY(cmb)+8)) < 8) ) return false;
    return true;
}



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users