Jump to content

Photo

Running Boots


  • Please log in to reply
14 replies to this topic

#1 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 12 September 2017 - 05:50 PM

Would it be possible for someone to make a script for a running boots item?

Basically, this would be an equipment item (not a weapon, but like a ring, or the ladder), which lets you 'sprint' (i.e. move faster, probably about 1.5x speed) by pressing the R button.

 

EDIT: Just remembered: Ideally, this should cost magic as well.


Edited by klop422, 13 September 2017 - 07:32 AM.


#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 15 September 2017 - 04:39 AM

I know that I already have speed boost items. If you want a true line charge (Pegasis Boots), ywkls has a decent-enough version of that, but a general speed boost is in my Link's Awakening alpha package.

It is one of the effects of collecting 'Piece of Power' items, in the demo.

Edited by ZoriaRPG, 15 September 2017 - 04:40 AM.

  • ywkls likes this

#3 ywkls

ywkls

    Master

  • Members

Posted 15 September 2017 - 09:26 AM

I know that I already have speed boost items. If you want a true line charge (Pegasis Boots), ywkls has a decent-enough version of that, but a general speed boost is in my Link's Awakening alpha package.

It is one of the effects of collecting 'Piece of Power' items, in the demo.

I was thinking about offering what I have. There is a Pegasus Boots script in the database, too.

 

It can be found here.

 

Making the item use magic is another kettle of fish, but not one which can't be dealt with.



#4 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 15 September 2017 - 04:07 PM

ZoriaRPG, I can't find the Link's Awakening alpha package you're referring to, unless you mean this: https://www.purezc.n...=scripts&id=192

In any case, it isn't quite what I'm looking for as far as I can tell.

Oh, and I'm not looking for the Pegasus Boots. Sorry if I didn't make that completely clear before.



#5 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 16 September 2017 - 12:18 AM

I have this script which allows Link to toggle running on/off with L after he gets the item (I believe it prevents Link from using items while he is running). It's been ages since I used this script, so I probably don't remember all the ins and outs, but I thought I'd share in case it's easy to use/modify or if it's helpful in any way:

// before Waitdraw();
fastRun();

void fastRun()
{float    Lspeed=Lspeedpercent/100;
    if(Game->Counter[CR_SCRIPT10]==1)
    {  //make input false when item wasnt lifted yet
        Link->InputL=false;
    }
   
    if(curscreen!=Game->GetCurScreen()&&curmap==Game->GetCurMap()){
        Waitframes(10);
        curscreen=Game->GetCurScreen();
        lastX=Link->X;
        lastY=Link->Y;
    }
    if(curmap!=Game->GetCurMap()&&curscreen==Game->GetCurScreen()){
        Waitframes(10);
        curmap=Game->GetCurMap();
        lastX=Link->X;
        lastY=Link->Y;
    }
    if(curmap!=Game->GetCurMap()&&curscreen!=Game->GetCurScreen()){
        Waitframes(10);
        curscreen=Game->GetCurScreen();
        curmap=Game->GetCurMap();
        lastX=Link->X;
        lastY=Link->Y;
    }    
 
    if(Link->InputL&&downtime<0){ //checkj if L pressed if so toggle between running and not running state
        pressdL=!pressdL;
        downtime=10;  
    }
    if(downtime>-1){  // the downtime makes sure there are no glitches by the toggle button like toggle between running and not running too fast
        downtime-=1;
    }
 
    if(pressdL){ //Test if L was pressed
 
        Link->InputA=false;
 
        Link->InputB=false;
        Link->X+=round((Lspeed-1)*(Link->X-lastX));
        Link->Y+=round((Lspeed-1)*(Link->Y-lastY));
    }
   
    lastX=Link->X;
    lastY=Link->Y;
}
 
int round(float f){
   
    if(f<0.5&&f>-0.5){
        return 0;
    }else{
    int diff=f;
    int num=0;
    if(diff>0){
    while(diff>1){
    diff-=1;
    num+=1;
    }
    if(diff<0.5){
    return num;
    }else{
    return num+1;
    }
    }else{
        while(diff<-1){
    diff+=1;
    num-=1;
    }
    if(diff>-0.5){
    return num;
    }else{
    return num-1;
    }
}
}
}

  • peteandwally likes this

#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 16 September 2017 - 01:43 AM

I have this script which allows Link to toggle running on/off with L after he gets the item (I believe it prevents Link from using items while he is running). It's been ages since I used this script, so I probably don't remember all the ins and outs, but I thought I'd share in case it's easy to use/modify or if it's helpful in any way:

// before Waitdraw();
fastRun();

void fastRun()
{float    Lspeed=Lspeedpercent/100;
    if(Game->Counter[CR_SCRIPT10]==1)
    {  //make input false when item wasnt lifted yet
        Link->InputL=false;
    }
   
    if(curscreen!=Game->GetCurScreen()&&curmap==Game->GetCurMap()){
        Waitframes(10);
        curscreen=Game->GetCurScreen();
        lastX=Link->X;
        lastY=Link->Y;
    }
    if(curmap!=Game->GetCurMap()&&curscreen==Game->GetCurScreen()){
        Waitframes(10);
        curmap=Game->GetCurMap();
        lastX=Link->X;
        lastY=Link->Y;
    }
    if(curmap!=Game->GetCurMap()&&curscreen!=Game->GetCurScreen()){
        Waitframes(10);
        curscreen=Game->GetCurScreen();
        curmap=Game->GetCurMap();
        lastX=Link->X;
        lastY=Link->Y;
    }    
 
    if(Link->InputL&&downtime<0){ //checkj if L pressed if so toggle between running and not running state
        pressdL=!pressdL;
        downtime=10;  
    }
    if(downtime>-1){  // the downtime makes sure there are no glitches by the toggle button like toggle between running and not running too fast
        downtime-=1;
    }
 
    if(pressdL){ //Test if L was pressed
 
        Link->InputA=false;
 
        Link->InputB=false;
        Link->X+=round((Lspeed-1)*(Link->X-lastX));
        Link->Y+=round((Lspeed-1)*(Link->Y-lastY));
    }
   
    lastX=Link->X;
    lastY=Link->Y;
}
 
int round(float f){
   
    if(f<0.5&&f>-0.5){
        return 0;
    }else{
    int diff=f;
    int num=0;
    if(diff>0){
    while(diff>1){
    diff-=1;
    num+=1;
    }
    if(diff<0.5){
    return num;
    }else{
    return num+1;
    }
    }else{
        while(diff<-1){
    diff+=1;
    num-=1;
    }
    if(diff>-0.5){
    return num;
    }else{
    return num-1;
    }
}
}
}


I'm not sure what this is trying to do, but it is failing to check for Solidity values, so that sets an immediatewarning flag.

ZoriaRPG, I can't find the Link's Awakening alpha package you're referring to, unless you mean this: https://www.purezc.n...=scripts&id=192
In any case, it isn't quite what I'm looking for as far as I can tell.
Oh, and I'm not looking for the Pegasus Boots. Sorry if I didn't make that completely clear before.

ZoriaRPG, I can't find the Link's Awakening alpha package you're referring to, unless you mean this: https://www.purezc.n...=scripts&id=192
In any case, it isn't quite what I'm looking for as far as I can tell.
Oh, and I'm not looking for the Pegasus Boots. Sorry if I didn't make that completely clear before.


This one:

https://www.purezc.n...=scripts&id=196

Grab a few pieces of power.
Incidentally, the round() function above is bonkers.

int Round(float v){
    int n = ( v << 0 ); //integer
    float n1 = v - ( v << 0 ); //decimal
    if ( n < 0 ) {
        if ( n1 >= 0.5 ) return n-1; //negative number rounding towards lower values.
        // -4.5 rounds to 5.0
        else return n;
    }
    else { //positive numbers
        if ( n1 >= 0.5 ) return n+1;  
        else return n;
    }
    return n; //emergency default, returns truncation.
}


#7 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 17 September 2017 - 10:00 AM

Alright, so this is the part which speeds up Link (I think):

void WalkSpeed(){
	int linkX;
	int linkY;
	if ( Z4_ItemsAndTimers[POWER_BOOSTED] ) { //Check to see if Link has a Piece of Power power-up boost...
		if ( Link->Action == LA_HOLD1LAND ) return;
		if ( Link->Action == LA_WALKING && !LinkJump() && Link->Z == 0 ) { //If he isnt attacking, swimming, hurt, or casting, and h
			if ( Link->InputDown && !IsSideview() //If the player presses down, and we aren't in sideview mode...
				&& !Screen->isSolid(Link->X,Link->Y+17) //SW Check Solidity
				&& !Screen->isSolid(Link->X+7,Link->Y+17) //S Check Solidity
				&& !Screen->isSolid(Link->X+15,Link->Y+17) //SE Check Solidity
			) {
				//We use a timer to choke the walk speed. Without it, Link would move the full additional number of
				//pixels PER FRAME. THus, a walk speed bonus of +1 would be +60 pixels (almost four tiles) PER SECOND!
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) {  //If our timer is fresh, or has reset...
					Link->Y += WALK_SPEED_POWERUP; //Let Link move faster...
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
			else if ( Link->InputUp && !IsSideview()  //If the player presses up, and we aren't in sideview mode...
				&& !Screen->isSolid(Link->X,Link->Y+6) //NW Check Solidity
				&& !Screen->isSolid(Link->X+7,Link->Y+6) //N Check Solidity
				&& !Screen->isSolid(Link->X+15,Link->Y+6) //NE Check Solidity
			) {
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->Y -= WALK_SPEED_POWERUP; //Increase the distance the player moves down, by this constant.
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
			else if ( Link->InputRight && !Screen->isSolid(Link->X+17,Link->Y+8) //If the player presses right, check NE solidity...
				&& !Screen->isSolid(Link->X+17,Link->Y+15) //and check SE Solidity 
			) { 
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->X += WALK_SPEED_POWERUP; //Increase the distance the player moves down, by this constant.
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
			else if ( Link->InputLeft && !Screen->isSolid(Link->X-2,Link->Y+8)  //If the player presses right, check NW solidity...
				&& !Screen->isSolid(Link->X-2,Link->Y+15) //SW Check Solidity
			) {
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->X -= WALK_SPEED_POWERUP; //Increase the distance the player moves down, by this constant.
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
		}
	}
	if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] > 0 && Z4_ItemsAndTimers[POWER_WALK_TIMER] != WALK_TIME ) Z4_ItemsAndTimers[POWER_WALK_TIMER]--; 
	//Decrement the timer if it is greater than zero, and not = to WALK_TIME.
	if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] <= 0 ) Z4_ItemsAndTimers[POWER_WALK_TIMER] = WALK_TIME; //If it's back to zero, reset it.
}

So, since I'm not actually using a Piece of Power but an equipment item, I assume I get rid of the outermost IF statement (Z4_ItemsAndTimers[POWER_BOOSTED] ).

I hate to seem demanding, but how do I make this speed boost only happen when pressing R, and how do I make it use magic?


Edited by klop422, 17 September 2017 - 10:01 AM.


#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 18 September 2017 - 05:42 AM

Alright, so this is the part which speeds up Link (I think):

void WalkSpeed(){
	int linkX;
	int linkY;
	if ( Z4_ItemsAndTimers[POWER_BOOSTED] ) { //Check to see if Link has a Piece of Power power-up boost...
		if ( Link->Action == LA_HOLD1LAND ) return;
		if ( Link->Action == LA_WALKING && !LinkJump() && Link->Z == 0 ) { //If he isnt attacking, swimming, hurt, or casting, and h
			if ( Link->InputDown && !IsSideview() //If the player presses down, and we aren't in sideview mode...
				&& !Screen->isSolid(Link->X,Link->Y+17) //SW Check Solidity
				&& !Screen->isSolid(Link->X+7,Link->Y+17) //S Check Solidity
				&& !Screen->isSolid(Link->X+15,Link->Y+17) //SE Check Solidity
			) {
				//We use a timer to choke the walk speed. Without it, Link would move the full additional number of
				//pixels PER FRAME. THus, a walk speed bonus of +1 would be +60 pixels (almost four tiles) PER SECOND!
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) {  //If our timer is fresh, or has reset...
					Link->Y += WALK_SPEED_POWERUP; //Let Link move faster...
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
			else if ( Link->InputUp && !IsSideview()  //If the player presses up, and we aren't in sideview mode...
				&& !Screen->isSolid(Link->X,Link->Y+6) //NW Check Solidity
				&& !Screen->isSolid(Link->X+7,Link->Y+6) //N Check Solidity
				&& !Screen->isSolid(Link->X+15,Link->Y+6) //NE Check Solidity
			) {
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->Y -= WALK_SPEED_POWERUP; //Increase the distance the player moves down, by this constant.
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
			else if ( Link->InputRight && !Screen->isSolid(Link->X+17,Link->Y+8) //If the player presses right, check NE solidity...
				&& !Screen->isSolid(Link->X+17,Link->Y+15) //and check SE Solidity 
			) { 
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->X += WALK_SPEED_POWERUP; //Increase the distance the player moves down, by this constant.
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
			else if ( Link->InputLeft && !Screen->isSolid(Link->X-2,Link->Y+8)  //If the player presses right, check NW solidity...
				&& !Screen->isSolid(Link->X-2,Link->Y+15) //SW Check Solidity
			) {
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->X -= WALK_SPEED_POWERUP; //Increase the distance the player moves down, by this constant.
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
		}
	}
	if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] > 0 && Z4_ItemsAndTimers[POWER_WALK_TIMER] != WALK_TIME ) Z4_ItemsAndTimers[POWER_WALK_TIMER]--; 
	//Decrement the timer if it is greater than zero, and not = to WALK_TIME.
	if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] <= 0 ) Z4_ItemsAndTimers[POWER_WALK_TIMER] = WALK_TIME; //If it's back to zero, reset it.
}

So, since I'm not actually using a Piece of Power but an equipment item, I assume I get rid of the outermost IF statement (Z4_ItemsAndTimers[POWER_BOOSTED] ).

I hate to seem demanding, but how do I make this speed boost only happen when pressing R, and how do I make it use magic?

 

Well, first, you probably want to preserve the Z4 arrays, to save your sanity. You can add this line  to your global script, calling it ( DoRButtonRun() ) prior to calling the WalkSpeed() function:

DoRButtonRun(); //Call prior to WalkSpeed()

Then drop these into your script buffer at a global scope:

const int RUN_MP_COST_DIVISOR = 20; //The number of frames of delay between reducing Link's MP while running.
const int RUN_MP_COST = 4; //The MP cost of running, reduced every N frames, as defined above.
 
//Call only one time, prior to Waitdraw().
void DoRBuittonRun(){
    if ( Link->InputR ) {
        if ( Link->MP < RUN_MP_COST ) { Z4_ItemsAndTimers[POWER_BOOSTED] = 0; return; }
        else {
            Z4_ItemsAndTimers[POWER_BOOSTED] = 1;
            if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] % RUN_MP_COST_DIVISOR == 0 ) {
                Link->MP -= RUN_MP_COST;
            }
        }
    }
}

That should simply drop in and replace the need for pieces of power, and run the magic cost on pressing+holding R.


Edited by ZoriaRPG, 18 September 2017 - 05:50 AM.


#9 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 26 September 2017 - 06:36 AM

Would it be possible for someone to make a script for a running boots item?
Basically, this would be an equipment item (not a weapon, but like a ring, or the ladder), which lets you 'sprint' (i.e. move faster, probably about 1.5x speed) by pressing the R button.
 
EDIT: Just remembered: Ideally, this should cost magic as well.


Did the code that I provided work for you?

#10 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 27 September 2017 - 08:23 AM

Oh, yeah, sorry, I got distracted with other things I needed a little more urgently, and forgot to get back on you.

 

I'm still not 100% sure on how this should be set up. I've put the DoRButtonRun() in the global script, as well as putting in the function, outside of any other script (which I'm pretty sure means it's at a global scope). I also copied over these lines from the Link's Awakening:

int Z4_ItemsAndTimers[26]; //Array to hold the values for the Z4 items. 
const int POWER_BOOSTED = 4; //This == 1 if the player has a Piece of Power power-up boost.
const int POWER_WALK_TIMER = 24; //The timer for WalkSpeed().

because they're the only ones that seem to be used in what you gave me. I wasn't sure how to set which item is the running boots in ZQuest.

 

In any case, nothing changed. ZQuest compiled the script fine, but nothing happened. I think this might have been because I didn't set up the item properly, but as I say, I wasn't sure how to do that.



#11 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 27 September 2017 - 10:24 AM

Oh, yeah, sorry, I got distracted with other things I needed a little more urgently, and forgot to get back on you.

 

I'm still not 100% sure on how this should be set up. I've put the DoRButtonRun() in the global script, as well as putting in the function, outside of any other script (which I'm pretty sure means it's at a global scope). I also copied over these lines from the Link's Awakening:

int Z4_ItemsAndTimers[26]; //Array to hold the values for the Z4 items. 
const int POWER_BOOSTED = 4; //This == 1 if the player has a Piece of Power power-up boost.
const int POWER_WALK_TIMER = 24; //The timer for WalkSpeed().

because they're the only ones that seem to be used in what you gave me. I wasn't sure how to set which item is the running boots in ZQuest.

 

In any case, nothing changed. ZQuest compiled the script fine, but nothing happened. I think this might have been because I didn't set up the item properly, but as I say, I wasn't sure how to do that.

 

Did you call both functions prior to Waitdraw() in your global active script?



#12 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 27 September 2017 - 04:00 PM

Yes.

I did forget to actually put in the Walkspeed Function anywhere, (embarrassing...) but I've put it in now, and still nothing seems to happen.

 

Here's everything I've copied to my ZScript File:

global script Music_ZH_Global_Active{
	void run(){
		while(true){
			DoRButtonRun();
			WalkSpeed();

			WandSound(30);
			Waitdraw();
			Waitframe();
		}
	}
}

int Z4_ItemsAndTimers[26]; //Array to hold the values for the Z4 items.
const int WALK_SPEED_POWERUP = 4; //Number of extra Pixels Link walks when he has a Piece of Power
const int POWER_BOOSTED = 4; //This == 1 if the player has a Piece of Power power-up boost.
const int POWER_WALK_TIMER = 24; //The timer for WalkSpeed().
const int WALK_TIME = 8; //Increase this value to slow the speed at which Link walks when sped up, 
			  //and to speed him up when slowed down.

int LinkJump(){
	int jmp = Floor(Link->Jump); //Floor Link->Jump to ensure that a value of 0.050 is '0'.
	return jmp; //Return the floored value.
}

void WalkSpeed(){
	int linkX;
	int linkY;
	if ( Z4_ItemsAndTimers[POWER_BOOSTED] ) { //Check to see if Link has a Piece of Power power-up boost...
		if ( Link->Action == LA_HOLD1LAND ) return;
		if ( Link->Action == LA_WALKING && !LinkJump() && Link->Z == 0 ) { //If he isnt attacking, swimming, hurt, or casting, and h
			if ( Link->InputDown && !IsSideview() //If the player presses down, and we aren't in sideview mode...
				&& !Screen->isSolid(Link->X,Link->Y+17) //SW Check Solidity
				&& !Screen->isSolid(Link->X+7,Link->Y+17) //S Check Solidity
				&& !Screen->isSolid(Link->X+15,Link->Y+17) //SE Check Solidity
			) {
				//We use a timer to choke the walk speed. Without it, Link would move the full additional number of
				//pixels PER FRAME. THus, a walk speed bonus of +1 would be +60 pixels (almost four tiles) PER SECOND!
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) {  //If our timer is fresh, or has reset...
					Link->Y += WALK_SPEED_POWERUP; //Let Link move faster...
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
			else if ( Link->InputUp && !IsSideview()  //If the player presses up, and we aren't in sideview mode...
				&& !Screen->isSolid(Link->X,Link->Y+6) //NW Check Solidity
				&& !Screen->isSolid(Link->X+7,Link->Y+6) //N Check Solidity
				&& !Screen->isSolid(Link->X+15,Link->Y+6) //NE Check Solidity
			) {
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->Y -= WALK_SPEED_POWERUP; //Increase the distance the player moves down, by this constant.
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
			else if ( Link->InputRight && !Screen->isSolid(Link->X+17,Link->Y+8) //If the player presses right, check NE solidity...
				&& !Screen->isSolid(Link->X+17,Link->Y+15) //and check SE Solidity 
			) { 
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->X += WALK_SPEED_POWERUP; //Increase the distance the player moves down, by this constant.
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
			else if ( Link->InputLeft && !Screen->isSolid(Link->X-2,Link->Y+8)  //If the player presses right, check NW solidity...
				&& !Screen->isSolid(Link->X-2,Link->Y+15) //SW Check Solidity
			) {
				if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->X -= WALK_SPEED_POWERUP; //Increase the distance the player moves down, by this constant.
					Z4_ItemsAndTimers[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
		}
	}
	if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] > 0 && Z4_ItemsAndTimers[POWER_WALK_TIMER] != WALK_TIME ) Z4_ItemsAndTimers[POWER_WALK_TIMER]--; 
	//Decrement the timer if it is greater than zero, and not = to WALK_TIME.
	if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] <= 0 ) Z4_ItemsAndTimers[POWER_WALK_TIMER] = WALK_TIME; //If it's back to zero, reset it.
}

const int RUN_MP_COST_DIVISOR = 20; //The number of frames of delay between reducing Link's MP while running.
const int RUN_MP_COST = 4; //The MP cost of running, reduced every N frames, as defined above.//Call only one time, prior to Waitdraw().

void DoRButtonRun(){
    if ( Link->InputR ) {
        if ( Link->MP < RUN_MP_COST ) { Z4_ItemsAndTimers[POWER_BOOSTED] = 0; return; }
        else {
            Z4_ItemsAndTimers[POWER_BOOSTED] = 1;
            if ( Z4_ItemsAndTimers[POWER_WALK_TIMER] % RUN_MP_COST_DIVISOR == 0 ) {
                Link->MP -= RUN_MP_COST;
            }
        }
    }



#13 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 28 September 2017 - 05:16 AM

Yes.
I did forget to actually put in the Walkspeed Function anywhere, (embarrassing...) but I've put it in now, and still nothing seems to happen.
 
[...]



Very well. here is a partial rewrite, that I tested (Test File).

It may need some extra testing around water combos, and solid combos, to ensure that Link does not run partially into, or through them, but it seemed to work perfectly for me.
 
import "std.zh"

int RunningBoots[26]; //Array to hold the values for the Z4 items.
const int WALK_SPEED_POWERUP = 4; //Number of extra Pixels Link walks when he has a Piece of Power
const int POWER_WALK_TIMER = 24; //The timer for WalkSpeed().
const int WALK_TIME = 8; //Increase this value to slow the speed at which Link walks when sped up, 
			  //and to speed him up when slowed down.
			  
const int RUN_MP_COST = 4; //The MP cost of running, reduced every N frames, as defined above.//Call only one time, prior to Waitdraw().
const int RUN_COST_TIME = 12; //How many frames to wait between reductions in MP while running.  


const int RUN_COST_TIMER = 25; //Index for the timer that is used to reduce MP. 


const int GAME_FRAME = 0; //Index for storing the game frame. 


global script Music_ZH_Global_Active{
	void run(){
		InitRunningCode();
		while(true){
			DoGameFrameUpdate();
			DoRButtonRun();
			

			WandSound(30);
			Waitdraw();
			Waitframe();
		}
	}
}

void DoRunCost(){
	if ( RunningBoots[RUN_COST_TIMER] == 0 ) {
		Link->MP -= RUN_MP_COST;
		RunningBoots[RUN_COST_TIMER] = RUN_COST_TIME;
		
	}
	if ( RunningBoots[RUN_COST_TIMER] > 0 ) {
		RunningBoots[RUN_COST_TIMER]--;
	}
}

int GetWalkSpeedPixels(){
	return Cond( (RunningBoots[GAME_FRAME] % 2 == 0 ), (WALK_SPEED_POWERUP * 1.5), WALK_SPEED_POWERUP);
}
		
void InitRunningCode(){ RunningBoots[POWER_WALK_TIMER] = WALK_TIME; RunningBoots[RUN_COST_TIMER]= 0; RunningBoots[GAME_FRAME] = 0; }

void DoGameFrameUpdate() { 
	if ( RunningBoots[GAME_FRAME] < 60 ) RunningBoots[GAME_FRAME]++;
	else RunningBoots[GAME_FRAME] = 0; 
}

int IsLinkJump(){
	return ( Link->Jump << 0 );//Floor Link->Jump to ensure that a value of 0.050 is '0'.
}

void DoRButtonRun(){
	int linkX;
	int linkY;
	if ( Link->InputR && Link->MP >= RUN_MP_COST ) { //Check to see if Link has enough MP
		
		if ( Link->Action == LA_HOLD1LAND ) return;
		if ( Link->Action == LA_WALKING && !IsLinkJump() && Link->Z == 0 ) { //If he isnt attacking, swimming, hurt, or casting, and h
			if ( Link->InputDown && !IsSideview() //If the player presses down, and we aren't in sideview mode...
				&& !Screen->isSolid(Link->X,Link->Y+17) //SW Check Solidity
				&& !Screen->isSolid(Link->X+7,Link->Y+17) //S Check Solidity
				&& !Screen->isSolid(Link->X+15,Link->Y+17) //SE Check Solidity
			) {
				//We use a timer to choke the walk speed. Without it, Link would move the full additional number of
				//pixels PER FRAME. THus, a walk speed bonus of +1 would be +60 pixels (almost four tiles) PER SECOND!
				if ( RunningBoots[POWER_WALK_TIMER] == WALK_TIME ) {  //If our timer is fresh, or has reset...
					Link->Y += GetWalkSpeedPixels(); //Let Link move faster...
					DoRunCost(); //Deduct the cost.
					RunningBoots[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
				
			}
			else if ( Link->InputUp && !IsSideview()  //If the player presses up, and we aren't in sideview mode...
				&& !Screen->isSolid(Link->X,Link->Y+6) //NW Check Solidity
				&& !Screen->isSolid(Link->X+7,Link->Y+6) //N Check Solidity
				&& !Screen->isSolid(Link->X+15,Link->Y+6) //NE Check Solidity
			) {
				if ( RunningBoots[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->Y -= GetWalkSpeedPixels(); //Increase the distance the player moves down, by this constant.
					DoRunCost(); //Deduct the cost.
					RunningBoots[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
			else if ( Link->InputRight && !Screen->isSolid(Link->X+17,Link->Y+8) //If the player presses right, check NE solidity...
				&& !Screen->isSolid(Link->X+17,Link->Y+15) //and check SE Solidity 
			) { 
				if ( RunningBoots[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->X += GetWalkSpeedPixels(); //Increase the distance the player moves down, by this constant.
					DoRunCost(); //Deduct the cost.
					RunningBoots[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}
			}
			else if ( Link->InputLeft && !Screen->isSolid(Link->X-2,Link->Y+8)  //If the player presses right, check NW solidity...
				&& !Screen->isSolid(Link->X-2,Link->Y+15) //SW Check Solidity
			) {
				if ( RunningBoots[POWER_WALK_TIMER] == WALK_TIME ) { //If our timer is fresh, or has reset...
					Link->X -= GetWalkSpeedPixels(); //Increase the distance the player moves down, by this constant.
					DoRunCost(); //Deduct the cost.
					RunningBoots[POWER_WALK_TIMER]--; //Decrement the timer, to start the ball rolling.
				}

			}
		}
	}
	if ( RunningBoots[POWER_WALK_TIMER] > 0 && RunningBoots[POWER_WALK_TIMER] != WALK_TIME ) RunningBoots[POWER_WALK_TIMER]--; 
	//Decrement the timer if it is greater than zero, and not = to WALK_TIME.
	if ( RunningBoots[POWER_WALK_TIMER] <= 0 ) RunningBoots[POWER_WALK_TIMER] = WALK_TIME; //If it's back to zero, reset it.
}

Edited by ZoriaRPG, 28 September 2017 - 05:24 AM.


#14 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 28 September 2017 - 05:53 PM

It seems to work well. It didn't work on a file I already started, which I think may have been the issue before (other scripts have previously worked without starting a new file, but none were global, which I think may have caused my confusion). If so, then sorry for bothering you more than I should have :/. There is a very minor issue, being that with diagonal movement Link moves a little less smoothly, but it's not a major thing, and collisions and water seem to work very well - I did clip a couple pixels into the top of the box in the middle of the test file's screen, but, again, functionally not really relevant.

 

In any case, thank you. I'll try myself to adapt this slightly to only work when you have the item (shouldn't be too difficult - just a constant to hold which item you need and a check in the DoRButtonRun() function).



#15 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 28 September 2017 - 07:10 PM

It seems to work well. It didn't work on a file I already started, which I think may have been the issue before (other scripts have previously worked without starting a new file, but none were global, which I think may have caused my confusion). If so, then sorry for bothering you more than I should have :/. There is a very minor issue, being that with diagonal movement Link moves a little less smoothly, but it's not a major thing, and collisions and water seem to work very well - I did clip a couple pixels into the top of the box in the middle of the test file's screen, but, again, functionally not really relevant.
 
In any case, thank you. I'll try myself to adapt this slightly to only work when you have the item (shouldn't be too difficult - just a constant to hold which item you need and a check in the DoRButtonRun() function).


You added an array, so you need a clean save file.

 

Oh, you do want this tied to an item? I thought that you specifically did not want that.

In your global active script, replace this:

DoRButtonRun();

with

if ( Link->Item[I_ALLOW_RUN] ) DoRButtonRun();

and add

const int I_ALLOW_RUN = n;

Where n is the numerical ID of the item, somewhere near the top with all of the other settings.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users