Jump to content

Photo

[Request] Press R to make Link Roll


  • Please log in to reply
23 replies to this topic

#16 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Location:Newport News, VA

Posted 01 June 2012 - 07:36 PM

Okay, that problem is fixed, but there's a new problem........now the rolling animation starts but stops at the first frame and Link doesn't roll.

I'm sorry if I'm bothering you. I know this is frustrating. icon_frown.gif

#17 Purplemandown

Purplemandown

    The Old Guard

  • Members
  • Real Name:Nathan
  • Location:Milwaukee, WI

Posted 01 June 2012 - 07:42 PM

It's not a bother, it's just that I am dumbfounded at how such a simple script could be causing so many problems...

Give this one a shot. I set it so it will roll even if link is walking (Though no other action). If it doesn't work, I swear, I'm going to punch a brick wall icon_lol.gif .

Just kidding, of course. But if this isn't it, I have no clue how to fix it.

The worst part of all of this is that I just used the first version of this for a roll attack script of mine... So I'm gonna have to troubleshoot THAT monster (whole sword script is like 2000 lines long so far... ugh)

CODE
import "std.zh"

global script slot_2{
    void run(){
        lweapon overlay;
        int rolltimer;
        int randStore;
        int rollSpeed = 300;
        int rollDur = 30; //in frames
        int firstSFX = 55;
        int rollSprite = 97; //The first of the 4 rolling sprites (in weapon/misc.)  In order, up, down, left, right.
        while(true){
            if((Link->PressR == false) && (rolltimer == 0)){
                overlay->DeadState = 0;
                Link->CollDetection = false;
                Link->Invisible = false;
            }
            else if((Link->PressR == true)&&(rolltimer == 0)){
                rolltimer = rollDur;
                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 = true;

                Link->Invisible = true;
                randStore = Rand(3);
                if(randStore == 0){
                    Game->PlaySound(firstSFX);
                }
                else if(randStore == 1){
                    Game->PlaySound(firstSFX + 1);
                }
                else{
                    Game->PlaySound(firstSFX + 2);
                }
            }
            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((Link->Action > LA_WALKING)){
                rolltimer = 0;
            }
            Waitframe();
        }
    }
}

Edited by Purplemandown, 01 June 2012 - 07:47 PM.


#18 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Location:Newport News, VA

Posted 01 June 2012 - 08:02 PM

Okay, that fixed it. There is only one minor problem remaining. If you can manage to press the R button fast enough against a solid object, you can trigger the sprite error again, this is easily fixed by making the player wait a certain amount of frames before allowing the input of R again.

Other than that, everything is working nicely!

#19 Purplemandown

Purplemandown

    The Old Guard

  • Members
  • Real Name:Nathan
  • Location:Milwaukee, WI

Posted 01 June 2012 - 08:07 PM

Oh God please don't have let this screw anything up... icon_lol.gif

CODE
import "std.zh"

global script slot_2{
    void run(){
        lweapon overlay;
        int rolltimer;
        int rollwait;
        int randStore;
        int rollSpeed = 300;
        int rollDur = 30; //in frames
        int cooldown = 15;
        int firstSFX = 55;
        int rollSprite = 97; //The first of the 4 rolling sprites (in weapon/misc.)  In order, up, down, left, right.
        while(true){
            if(((Link->PressR == false) && (rolltimer == 0))&&(rollwait == 0)){
                overlay->DeadState = 0;
                Link->CollDetection = false;
                Link->Invisible = false;
            }
            else if((Link->PressR == true)&&(rolltimer == 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 = true;

                Link->Invisible = true;
                randStore = Rand(3);
                if(randStore == 0){
                    Game->PlaySound(firstSFX);
                }
                else if(randStore == 1){
                    Game->PlaySound(firstSFX + 1);
                }
                else{
                    Game->PlaySound(firstSFX + 2);
                }
            }
            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){
                rollwait--;
            }
            if((Link->Action > LA_WALKING)){
                rolltimer = 0;
            }
            Waitframe();
        }
    }
}


That should do it (I hope)... *fingerscrossed*

#20 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Location:Newport News, VA

Posted 01 June 2012 - 08:17 PM

Nope, that made it worse. Now it's easier to trigger it and the roll sprites continue to roll while Link is back where he was if he was walking normally.

#21 Purplemandown

Purplemandown

    The Old Guard

  • Members
  • Real Name:Nathan
  • Location:Milwaukee, WI

Posted 01 June 2012 - 08:19 PM

icon_sweat.gif

I put it in the wrong if statement...

Try this:

CODE
import "std.zh"

global script slot_2{
    void run(){
        lweapon overlay;
        int rolltimer;
        int rollwait;
        int randStore;
        int rollSpeed = 300;
        int rollDur = 30; //in frames
        int cooldown = 15;
        int firstSFX = 55;
        int rollSprite = 97; //The first of the 4 rolling sprites (in weapon/misc.)  In order, up, down, left, right.
        while(true){
            if((Link->PressR == false) && (rolltimer == 0)){
                overlay->DeadState = 0;
                Link->CollDetection = false;
                Link->Invisible = false;
            }
            else if(((Link->PressR == 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 = true;

                Link->Invisible = true;
                randStore = Rand(3);
                if(randStore == 0){
                    Game->PlaySound(firstSFX);
                }
                else if(randStore == 1){
                    Game->PlaySound(firstSFX + 1);
                }
                else{
                    Game->PlaySound(firstSFX + 2);
                }
            }
            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){
                rollwait--;
            }
            if((Link->Action > LA_WALKING)){
                rolltimer = 0;
            }
            Waitframe();
        }
    }
}


(I hate code sometimes... icon_lol.gif )

#22 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Location:Newport News, VA

Posted 01 June 2012 - 08:28 PM

That did it!!! Nice work! Hey, you don't mind if I modify this in any way to include functions from Zepinho's engine would you? I wwant to add certain funtions and checks to it so it works well with the engine and I just wanted your permission.

Sorry I put you to all that trouble. icon_frown.gif

#23 Purplemandown

Purplemandown

    The Old Guard

  • Members
  • Real Name:Nathan
  • Location:Milwaukee, WI

Posted 01 June 2012 - 08:32 PM

Go right ahead. I figure I put enough work into it to let it go.

And it was no trouble. The main script was from my sword script I've been working on (which, I just realized, is pretty much unreleaseable at this point. It does what I need, but it's a global script with 20ish waitframe() calls. Not exactly "propper scripting", but hey, it works for me.)

So yeah, knock yourself out. Do what you need to do.

#24 Xenix

Xenix

    Well excuse me princess.

  • Members
  • Real Name:Chris
  • Location:Newport News, VA

Posted 01 June 2012 - 08:41 PM

Thanks purplemandown! This will really help out a lot!


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users