Jump to content

Photo

[2.55] Scripted Roc's Feather


  • Please log in to reply
4 replies to this topic

#1 Jenny

Jenny

    Hero of Time

  • Contributors
  • Real Name:Jennette

Posted 26 September 2021 - 06:54 AM

As always, unsure of the feasibility of this as I'm not a scripter but:

I'd like a Roc's Feather that has variant jump heights depending on how long you hold the B button, so there could be a "short jump" if you tap it and a "long jump" if you hold it.

 

Any help is appreciated.


  • Shane and Bagu like this

#2 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 26 September 2021 - 05:51 PM

item script RocsFeather{
	//Returns true if item button is held on A or B
	bool ButtonHeld(itemdata idat){
		if(GetEquipmentA()==idat->ID&&Link->InputA)
			return true;
		if(GetEquipmentB()==idat->ID&&Link->InputB)
			return true;
	}
	void run(int jumpHeight, int decay){
		//Don't jump during actions
		if(Link->Action!=LA_NONE&&Link->Action!=LA_WALKING)
			Quit();
			
		//Check if Link can jump
		if(IsSideview()){ //In sideview this checks solidity under him (very basic, will need added hacks with scripts)
			if(OnSidePlatform(Link->X, Link->Y))
				Link->Jump = jumpHeight;
			else
				Quit();
		}
		else{ //In top-down it's as simple as checking Link->Z
			if(Link->Z<=0)
				Link->Jump = jumpHeight;
			else
				Quit();
		}
		
		//Play the sound and wait until he hits his peak
		Game->PlaySound(SFX_JUMP);
		while(Link->Jump>0){
			//Dampen the jump when the button isn't being held
			if(!ButtonHeld(this))
				Link->Jump = Max(Link->Jump-decay, 0);
			Waitframe();
		}
	}
}

Simple, somewhat lazy item script.

D0: Starting jump value (I went with 3.2 in testing)

D1: Decay value (I went with 0.32)

 

When the button isn't being held, Link's jump value gets subtracted by decay, this stops at the peak of Link's jump arc, so it doesn't affect the falling action at all. The higher the decay the more control the player has over where to stop their jump. You can set it to a high number for an instant stop but it'll look choppier as a result.


  • Twilight Knight, Jenny and Bagu like this

#3 Emily

Emily

    Scripter / Dev

  • ZC Developers
  • Pronouns:She / Her

Posted 26 September 2021 - 11:27 PM

item script RocsFeather{
	//Returns true if item button is held on A or B
	bool ButtonHeld(itemdata idat){
		if(GetEquipmentA()==idat->ID&&Link->InputA)
			return true;
		if(GetEquipmentB()==idat->ID&&Link->InputB)
			return true;
	}
	void run(int jumpHeight, int decay){
		//Don't jump during actions
		if(Link->Action!=LA_NONE&&Link->Action!=LA_WALKING)
			Quit();
			
		//Check if Link can jump
		if(IsSideview()){ //In sideview this checks solidity under him (very basic, will need added hacks with scripts)
			if(OnSidePlatform(Link->X, Link->Y))
				Link->Jump = jumpHeight;
			else
				Quit();
		}
		else{ //In top-down it's as simple as checking Link->Z
			if(Link->Z<=0)
				Link->Jump = jumpHeight;
			else
				Quit();
		}
		
		//Play the sound and wait until he hits his peak
		Game->PlaySound(SFX_JUMP);
		while(Link->Jump>0){
			//Dampen the jump when the button isn't being held
			if(!ButtonHeld(this))
				Link->Jump = Max(Link->Jump-decay, 0);
			Waitframe();
		}
	}
}

Simple, somewhat lazy item script.

D0: Starting jump value (I went with 3.2 in testing)

D1: Decay value (I went with 0.32)

 

When the button isn't being held, Link's jump value gets subtracted by decay, this stops at the peak of Link's jump arc, so it doesn't affect the falling action at all. The higher the decay the more control the player has over where to stop their jump. You can set it to a high number for an instant stop but it'll look choppier as a result.

 

This won't handle X/Y buttons


  • Alucard648 likes this

#4 Aefre

Aefre

    artist guy

  • Members
  • Real Name:Jarik
  • Location:Oregon

Posted 06 August 2022 - 10:35 PM

Would it be simple enough to add X/Y support in?

 

This won't handle X/Y buttons



#5 Emily

Emily

    Scripter / Dev

  • ZC Developers
  • Pronouns:She / Her

Posted 06 August 2022 - 11:32 PM

Would it be simple enough to add X/Y support in?

Use 'Hero->ItemA' instead of 'GetEquipmentA'

and then you can use '->ItemB', '->ItemX', '->ItemY'




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users