Jump to content

Photo

Roll Script Help


  • Please log in to reply
13 replies to this topic

#1 RephireZeKasual217

RephireZeKasual217

    Initiate

  • Members

Posted 13 January 2018 - 12:25 AM

Okay so i have this roll script but i would like to have dust travel behind link when he rolls.

----------------------------------------------------------

import "std.zh"
 
global script slot_2{
    void run(){
        lweapon overlay;
        int rolltimer;
        int rollwait;
        int randStore;
        int rollSpeed = 300;
        int rollDur = 20;
        int cooldown = 6;
        int firstSFX = 1;
        int rollSprite = 105;
        while(true){
 
            if((Link->PressEx1 == false) && (rolltimer == 0)){
                overlay->DeadState = 0;
                Link->CollDetection = true;
                Link->Invisible = false;
            }
            else if(Link->Jump){
                Link->PressEx1 = false;
            }
            else if(Link->Action > LA_SWIMMING){
                Link->PressEx1 = false;
            }
            else if(Link->Action > LA_ATTACKING){
                Link->PressEx1 = false;
            }
            else if(Link->Action > LA_CHARGING){
                Link->PressEx1 = false;
            }
            else if(Link->Action > LA_SPINNING){
                Link->PressEx1 = false;
            }
            else if(((Link->PressEx1 == true)&&(rolltimer == 0))&&(rollwait == 0)){
                rolltimer = rollDur;
                rollwait = rollDur + cooldown;
                overlay = Screen->CreateLWeapon(LW_SCRIPT1);
                overlay->Dir = Link->Dir;
                overlay->X = Link->X;
                overlay->Y = Link->Y;
                overlay->CollDetection = false;
                if(Link->Dir == DIR_UP){
                    overlay->UseSprite(rollSprite);
                }
                else if(Link->Dir == DIR_DOWN){
                    overlay->UseSprite(rollSprite + 1);
                }
                else if(Link->Dir == DIR_LEFT){
                    overlay->UseSprite(rollSprite + 2);
                }
                else if(Link->Dir == DIR_RIGHT){
                    overlay->UseSprite(rollSprite + 3);
                }
                Link->CollDetection = false;
 
                Link->Invisible = true;
                randStore = Rand(0);
                if(randStore == 0){
                    Game->PlaySound(firstSFX);
                }
            }
            else if(rolltimer > 0){
                if(overlay->isValid() == true){
                    if(CanWalk(overlay->X, overlay->Y, overlay->Dir, rollSpeed/100, false) == true){
                        overlay->Step = rollSpeed;
                    }
                    else{
                        overlay->Step = 0;
                    }
                    Link->X = overlay->X;
                    Link->Y = overlay->Y;
                    rolltimer--;
                }
                else{
                    rolltimer = 0;
                    overlay->DeadState = 0;
                    Link->CollDetection = false;
                    Link->Invisible = false;
                }
            }
            if(rollwait > 0){
                Link->InputA = false;
                Link->InputB = false;
                Link->InputEx2 = false;
                rollwait--;
            }
            if((Link->Action > LA_WALKING)){
                rolltimer = 0;
            }
            Waitframe();
        }
    }
}
----------------------------------------------------------


#2 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 14 January 2018 - 03:20 AM

 

Okay so i have this roll script but i would like to have dust travel behind link when he rolls.

----------------------------------------------------------

import "std.zh"
 
global script slot_2{
    void run(){
        lweapon overlay;
        int rolltimer;
        int rollwait;
        int randStore;
        int rollSpeed = 300;
        int rollDur = 20;
        int cooldown = 6;
        int firstSFX = 1;
        int rollSprite = 105;
        while(true){
 
            if((Link->PressEx1 == false) && (rolltimer == 0)){
                overlay->DeadState = 0;
                Link->CollDetection = true;
                Link->Invisible = false;
            }
            else if(Link->Jump){
                Link->PressEx1 = false;
            }
            else if(Link->Action > LA_SWIMMING){
                Link->PressEx1 = false;
            }
            else if(Link->Action > LA_ATTACKING){
                Link->PressEx1 = false;
            }
            else if(Link->Action > LA_CHARGING){
                Link->PressEx1 = false;
            }
            else if(Link->Action > LA_SPINNING){
                Link->PressEx1 = false;
            }
            else if(((Link->PressEx1 == true)&&(rolltimer == 0))&&(rollwait == 0)){
                rolltimer = rollDur;
                rollwait = rollDur + cooldown;
                overlay = Screen->CreateLWeapon(LW_SCRIPT1);
                overlay->Dir = Link->Dir;
                overlay->X = Link->X;
                overlay->Y = Link->Y;
                overlay->CollDetection = false;
                if(Link->Dir == DIR_UP){
                    overlay->UseSprite(rollSprite);
                }
                else if(Link->Dir == DIR_DOWN){
                    overlay->UseSprite(rollSprite + 1);
                }
                else if(Link->Dir == DIR_LEFT){
                    overlay->UseSprite(rollSprite + 2);
                }
                else if(Link->Dir == DIR_RIGHT){
                    overlay->UseSprite(rollSprite + 3);
                }
                Link->CollDetection = false;
 
                Link->Invisible = true;
                randStore = Rand(0);
                if(randStore == 0){
                    Game->PlaySound(firstSFX);
                }
            }
            else if(rolltimer > 0){
                if(overlay->isValid() == true){
                    if(CanWalk(overlay->X, overlay->Y, overlay->Dir, rollSpeed/100, false) == true){
                        overlay->Step = rollSpeed;
                    }
                    else{
                        overlay->Step = 0;
                    }
                    Link->X = overlay->X;
                    Link->Y = overlay->Y;
                    rolltimer--;
                }
                else{
                    rolltimer = 0;
                    overlay->DeadState = 0;
                    Link->CollDetection = false;
                    Link->Invisible = false;
                }
            }
            if(rollwait > 0){
                Link->InputA = false;
                Link->InputB = false;
                Link->InputEx2 = false;
                rollwait--;
            }
            if((Link->Action > LA_WALKING)){
                rolltimer = 0;
            }
            Waitframe();
        }
    }
}
----------------------------------------------------------

 

Hi

 

I might can help you with this but i have to ask is this the only global script you are gonna use?

 

and one more thing what tileset are you using since if i am able to do it i make an little testquest about it...


Edited by judasrising, 14 January 2018 - 03:24 AM.


#3 RephireZeKasual217

RephireZeKasual217

    Initiate

  • Members

Posted 14 January 2018 - 06:52 PM

Yes it is, and as for the tileset, the EZGBZ tileset. but it really doesn't matter to me which tileset to use. Thank you!



#4 Aefre

Aefre

    artist guy

  • Members
  • Real Name:Jarik
  • Location:Oregon

Posted 19 January 2018 - 03:37 PM

Is this topic still active?

 

I would also like to use this roll with dust script if possible :P



#5 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 20 January 2018 - 02:33 AM

Is this topic still active?
 
I would also like to use this roll with dust script if possible :P


I am trying to figure it out how i can add the dust part still..


Edited by judasrising, 22 January 2018 - 04:26 AM.


#6 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 22 January 2018 - 03:21 AM

 i might found a solution for this thing i post here or sent pm if my solution works well...

 

EDIT: nope i did not work so i give up on this one sadly.


Edited by judasrising, 22 January 2018 - 04:26 AM.


#7 justin

justin

    Adept

  • Members

Posted 23 January 2018 - 12:36 PM

try this.

compiled but untested.

the original version was pretty messy and inefficient so I cleaned it up a lot. It may not function exactly the same way anymore, report back if the behavior isn't exactly as desired and I'll tweak it.

 

note, rolling and dust will not draw during scrolling. I'm working on updating my Pegasus Boots script to use Moosh's scrollingDraws.zh, so I might be inclined to add it here.

 

If this works and you know who created the original script I'll add it to the database.

import "std.zh"

const int ROLL_SPEED		= 300;
const int ROLL_DUR 		= 20;	// number of frames roll takes
const int ROLL_COOLDOWN 	= 6;	// number of frames after a roll before Link can roll again, all Link actions cancelled during this period
const int ROLL_SPRITE 		= 105;
const int ROLL_SFX		= 1;

const int T_DUST		= 27420;	// Dust Kick-up tile
const int DustAFrames		= 2;		// Dust Kick-up animation frames
const int DustASpeed		= 4;		// Dust Kick-up animation speed
const int DustCSet		= 2;		// Dust Kick-up CSet

						// make sure these don't conflict with other LWeapon types in your script file
const int LW_ROLLINGLINK	= 40;		// Lweapon type to use for rolling link sprite, default 40 is LW_SCRIPT10
const int LW_DUST		= 39;		// Lweapon type to use for dust sprite, default 39 is LW_SCRIPT9

int rollTimer;

bool BreakRoll(){
	if(Link->Jump) return true;
	if(Link->Action > LA_WALKING) return true;
	return false;
}

void LinkRoll(){
	if(rollTimer > 0){   // already rolling
		lweapon rollingLink; int i;
		for(int i=Screen->NumLWeapons();i>0;--i){
			rollingLink = Screen->LoadLWeapon(i);
			if(rollingLink->ID == LW_ROLLINGLINK) break;
		}
		if(BreakRoll() || i==0) rollTimer = ROLL_COOLDOWN; // force stop roll

		if(rollTimer > ROLL_COOLDOWN){
			//still rolling, adjust roll sprite and Link positions accordingly
			if(rollingLink->isValid()){
				if(CanWalk(rollingLink->X, rollingLink->Y, rollingLink->Dir, ROLL_SPEED/100, false)) rollingLink->Step = ROLL_SPEED;
				else rollingLink->Step = 0;
				Link->X = rollingLink->X;
				Link->Y = rollingLink->Y;
				DustDrawLW(rollingLink->Dir);
			}
			else{
				rollTimer = ROLL_COOLDOWN;
				Remove(rollingLink);
				Link->Invisible = false;
			}
		}
		else{
			// end rolling due to force stop or timer run down
			if(rollTimer == ROLL_COOLDOWN){   // stop roll, enter cool down period
				Remove(rollingLink);
				Link->Invisible = false;
			}
			NoAction();  // Link can't do anything within cool down period
		}

		--rollTimer;
		return;
	}
	
	//not currently rolling, will roll if Ex1 pressed
	if(Link->InputEx1){
		if(BreakRoll()) return;
		
		rollTimer = ROLL_DUR + ROLL_COOLDOWN;
		lweapon rollingLink = Screen->CreateLWeapon(LW_ROLLINGLINK);
		rollingLink->Dir = Link->Dir;
		rollingLink->X = Link->X;
		rollingLink->Y = Link->Y;
		rollingLink->CollDetection = false;
		rollingLink->UseSprite(ROLL_SPRITE + rollingLink->Dir);
		Link->Invisible = true;
                Game->PlaySound(ROLL_SFX);
	}
}

void DustDrawLW(int dir){
	lweapon Dust;
	if(rollTimer%4 == 0){
		for(int j=Screen->NumLWeapons();j>0;--j){
			Dust = Screen->LoadLWeapon(j);
			if(Dust->ID != LW_DUST) continue;
			if	(Dust->Dir == DIR_UP) 	 Dust->Y-=3;
			else if	(Dust->Dir == DIR_DOWN)  Dust->Y+=3;
			else if	(Dust->Dir == DIR_LEFT)	 Dust->X-=3;
			else if	(Dust->Dir == DIR_RIGHT) Dust->X+=3;
		}//end for loop

		Dust = Screen->CreateLWeapon(LW_DUST);
		Dust->OriginalTile = T_DUST;
		Dust->CSet = DustCSet;
		Dust->Y = Link->Y+8;
		Dust->X = Link->X;
		Dust->Dir = dir;
		Dust->NumFrames = DustAFrames;
		Dust->ASpeed = DustASpeed;
		Dust->DeadState = DustAFrames*DustASpeed;
	}//end dust if
}

global script slot_2{
	void run(){
		while(true){
 			LinkRoll();

			Waitdraw();

			Waitframe();
		}
	}
}




#8 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 23 January 2018 - 12:41 PM

 

try this.

compiled but untested.

the original version was pretty messy and inefficient so I cleaned it up a lot. It may not function exactly the same way anymore, report back if the behavior isn't exactly as desired and I'll tweak it.

 

note, rolling and dust will not draw during scrolling. I'm working on updating my Pegasus Boots script to use Moosh's scrollingDraws.zh, so I might be inclined to add it here.

 

If this works and you know who created the original script I'll add it to the database.

import "std.zh"

const int ROLL_SPEED		= 300;
const int ROLL_DUR 		= 20;	// number of frames roll takes
const int ROLL_COOLDOWN 	= 6;	// number of frames after a roll before Link can roll again, all Link actions cancelled during this period
const int ROLL_SPRITE 		= 105;
const int ROLL_SFX		= 1;

const int T_DUST		= 27420;	// Dust Kick-up tile
const int DustAFrames		= 2;		// Dust Kick-up animation frames
const int DustASpeed		= 4;		// Dust Kick-up animation speed
const int DustCSet		= 2;		// Dust Kick-up CSet

						// make sure these don't conflict with other LWeapon types in your script file
const int LW_ROLLINGLINK	= 40;		// Lweapon type to use for rolling link sprite, default 40 is LW_SCRIPT10
const int LW_DUST		= 39;		// Lweapon type to use for dust sprite, default 39 is LW_SCRIPT9

int rollTimer;

bool BreakRoll(){
	if(Link->Jump) return true;
	if(Link->Action > LA_WALKING) return true;
	return false;
}

void LinkRoll(){
	if(rollTimer > 0){   // already rolling
		lweapon rollingLink; int i;
		for(int i=Screen->NumLWeapons();i>0;--i){
			rollingLink = Screen->LoadLWeapon(i);
			if(rollingLink->ID == LW_ROLLINGLINK) break;
		}
		if(BreakRoll() || i==0) rollTimer = ROLL_COOLDOWN; // force stop roll

		if(rollTimer > ROLL_COOLDOWN){
			//still rolling, adjust roll sprite and Link positions accordingly
			if(rollingLink->isValid()){
				if(CanWalk(rollingLink->X, rollingLink->Y, rollingLink->Dir, ROLL_SPEED/100, false)) rollingLink->Step = ROLL_SPEED;
				else rollingLink->Step = 0;
				Link->X = rollingLink->X;
				Link->Y = rollingLink->Y;
				DustDrawLW(rollingLink->Dir);
			}
			else{
				rollTimer = ROLL_COOLDOWN;
				Remove(rollingLink);
				Link->Invisible = false;
			}
		}
		else{
			// end rolling due to force stop or timer run down
			if(rollTimer == ROLL_COOLDOWN){   // stop roll, enter cool down period
				Remove(rollingLink);
				Link->Invisible = false;
			}
			NoAction();  // Link can't do anything within cool down period
		}

		--rollTimer;
		return;
	}
	
	//not currently rolling, will roll if Ex1 pressed
	if(Link->InputEx1){
		if(BreakRoll()) return;
		
		rollTimer = ROLL_DUR + ROLL_COOLDOWN;
		lweapon rollingLink = Screen->CreateLWeapon(LW_ROLLINGLINK);
		rollingLink->Dir = Link->Dir;
		rollingLink->X = Link->X;
		rollingLink->Y = Link->Y;
		rollingLink->CollDetection = false;
		rollingLink->UseSprite(ROLL_SPRITE + rollingLink->Dir);
		Link->Invisible = true;
                Game->PlaySound(ROLL_SFX);
	}
}

void DustDrawLW(int dir){
	lweapon Dust;
	if(rollTimer%4 == 0){
		for(int j=Screen->NumLWeapons();j>0;--j){
			Dust = Screen->LoadLWeapon(j);
			if(Dust->ID != LW_DUST) continue;
			if	(Dust->Dir == DIR_UP) 	 Dust->Y-=3;
			else if	(Dust->Dir == DIR_DOWN)  Dust->Y+=3;
			else if	(Dust->Dir == DIR_LEFT)	 Dust->X-=3;
			else if	(Dust->Dir == DIR_RIGHT) Dust->X+=3;
		}//end for loop

		Dust = Screen->CreateLWeapon(LW_DUST);
		Dust->OriginalTile = T_DUST;
		Dust->CSet = DustCSet;
		Dust->Y = Link->Y+8;
		Dust->X = Link->X;
		Dust->Dir = dir;
		Dust->NumFrames = DustAFrames;
		Dust->ASpeed = DustASpeed;
		Dust->DeadState = DustAFrames*DustASpeed;
	}//end dust if
}

global script slot_2{
	void run(){
		while(true){
 			LinkRoll();

			Waitdraw();

			Waitframe();
		}
	}
}


That sounds good that you work on an update for the pegasus boots script to use scrollingDraws.zh by Moosh  i am using the Pegasus boots myself and having som gfx issue with when i enter the next screen and i feel that is something with that i am using scrolligDraws.zh



#9 justin

justin

    Adept

  • Members

Posted 23 January 2018 - 06:18 PM

Well updating Pegasus to use scrollingDraws.zh was the intention, but then I got sidetracked by optimizing the whole script.

Can you describe the graphical issue you are having with the pegasus script?

Edited by justin, 23 January 2018 - 06:21 PM.


#10 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 23 January 2018 - 06:25 PM

Not drawing dust during scrolling doesn't sound bad to me.



#11 justin

justin

    Adept

  • Members

Posted 23 January 2018 - 08:34 PM

Not drawing dust during scrolling doesn't sound bad to me.


Its already in the pegasus boots script, and I'll admit it does look better than not drawing it during scrolling. I haven't used the roll script so I don't know how it would look either way.

#12 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 24 January 2018 - 05:20 AM

Well updating Pegasus to use scrollingDraws.zh was the intention, but then I got sidetracked by optimizing the whole script.

Can you describe the graphical issue you are having with the pegasus script?

Pm sent



#13 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 25 January 2018 - 06:01 AM

For the lweapon type, you always want LW_SPARKLE. Sparkle lweapons havea lufespan equal to the number of frames in their animation, so, they are ideal for sprited effects.

I also advise that you move its collusion box offscreen, and move its sprite using drawoffsets, so that it doesn't vanish on screen edges.

Keep the actual x,y coordinates of the weapon inside the coordinates of the screen by at least one pixel. This will prevent it breaking on some dmap types.

Move it with a formula of:

l->X = 1; 
l->Y = 1;
l->HitYOffset = -32768;
l->DrawXOffset = Link->X - 1;
l->DrawYOffset = Link->Y - 1;
P.S. IDR if I fixed weapon->Behind for lweapons, orfor eweapons, but in 2.53, you can set it to draw under Link. One of the two worked in 2.50->2.50.2; so trying that might also look better.

#14 RephireZeKasual217

RephireZeKasual217

    Initiate

  • Members

Posted 14 February 2018 - 02:07 AM

Wow... I leave this topic for a month and so much discussion came from it. I sorta forgot about it for a bit and dealt with having no dust when you roll. But don't let me discourage the progress, and I'll gladly used the finished product!:)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users