Jump to content

Photo

Dash Button


  • Please log in to reply
2 replies to this topic

#1 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 17 February 2024 - 09:31 PM

I'm looking for a Zelda 3 build-friendly script where you can dash while holding a button (L in my case). It doesn't need to use different running tiles, but dust sprites would be nice. An SFX while running would be nice too. And it would need to use magic, as that is what I'm using for my quest. Configurable magic and speed would be awesome.

 

Thank you!



#2 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 17 February 2024 - 11:12 PM

Here's a very basic dash script. It's a generic script, so no global combining needed, just set it to run in init data:
 

// Cost and frequency for dash
const int DASH_MP_COST = 4;
const int DASH_MP_FREQ = 8;
// Frequency for SFX
const int DASH_SFX_FREQ = 4;
// Frequency for spawning particles
const int DASH_PARTICLE_FREQ = 4;

// Poof sprite when dashing
const int SPR_DASH = 88;
// Looping sound for dashing
const int SFX_DASH = 1;

// Step speeds for walking and dashing. 100 = 1 pixel per second
const int BASE_STEP = 150;
const int DASH_STEP = 250;

bool PressDash()
{
	return Link->InputL;
}

bool CanDash()
{
	if(Link->Z>0)
		return false;
	if(!Link->MP)
		return false;
	if(Link->Action!=LA_WALKING)
		return false;
	return true;
}

generic script Dash
{
	void run()
	{
		int sfxTimer = 0;
		int sprTimer = 0;
		int mpTimer = 0;
		while(true)
		{
			if(PressDash()&&CanDash())
			{
				Hero->Step = DASH_STEP;
				if(sfxTimer)
					--sfxTimer;
				else
				{
					Game->PlaySound(SFX_DASH);
					sfxTimer = DASH_SFX_FREQ;
					
				}
				if(sprTimer)
					--sprTimer;
				else
				{
					lweapon l = CreateLWeaponAt(LW_SPARKLE, Link->X+Rand(-8, 8), Link->Y+Rand(6, 10));
					l->UseSprite(SPR_DASH);					
					sprTimer = DASH_PARTICLE_FREQ;	
				}
				if(mpTimer)
					--mpTimer;
				else
				{
					Link->MP = Max(Link->MP-DASH_MP_COST, 0);
					mpTimer = DASH_MP_FREQ;
				}
			}
			else
			{
				Hero->Step = BASE_STEP;
				sfxTimer = 0;
				sprTimer = 0;
				mpTimer = 0;
			}
			Waitframe();
		}
	}
}

Also I'm assuming you're using MP for stamina rather than traditional MP, so have a script for better regen too while we're at it:

Friends don't let friends use fixed MP regen rates


  • Twilight Knight and Jared like this

#3 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 17 February 2024 - 11:32 PM

This is perfect Moosh! And yes, I am doing stamina!

 

I will try these out tomorrow. You're the best!




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users