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: