Jump to content

Photo

Not a request for a new script


  • Please log in to reply
21 replies to this topic

#1 ZebraStallion

ZebraStallion

    Follower of Destiny

  • Members

Posted 09 November 2008 - 10:38 AM

I have a simple request. Actually I have two. They aren't really hard requests, because it doesn't involve making any new scripts.


1. Could somebody help me find the most recnet/best version of the roll script? I can't seem to find it...

2. I can't seem to connect my global scripts. Could somebody help me connect these scripts?
- The roll script from #1
- The fairy/climbing script from this thread.
- The potions script (Power potion, defense potion, etc.) scroll down to see the one I have, if there is any better ones could you post it please?
- The bombchu script from this thread.


Here's the potion script I have. (Made by Joe123)
CODE
//This function checks whether Link has an empty bottle or not when given a potion
void runpotion(int set1, int set2, int set3, int m){
    if(m == 0) m = 1;
    if(Link->Item[I_BTTL1]){
        Link->Item[set1] = true;
        Link->Item[I_BTTL1] = false;
        Quit();
    }else{
        if(Link->Item[I_BTTL2]){
            Link->Item[set2] = true;
            Link->Item[I_BTTL2] = false;
            Quit();
        }else{    
            if(Link->Item[I_BTTL3]){
                Link->Item[set3] = true;
                Link->Item[I_BTTL3] = false;
                Quit();
            }else Screen->Message(m);
        }
    }
}

            //Power Potion
            if(swordtimer >= 0){
                swordtimer--;
                if(swordtimer == 0){
                    Link->Item[I_RING2] = false;
                    Link->Item[I_RING3] = false;
                    if(Link->Item[I_SWORD4]) Link->Item[I_SWORD4] = false;
                    else Link->Item[I_SWORD2] = false;
                }
            }
            //Defence Potion
            if(ringtimer >= 0){
                ringtimer --;
                if(ringtimer == 0){
                    Link->Item[I_RING1] = false;
                    Link->Item[I_RING3] = false;
                }
            }
            //Use Potion Effect
            if(usepotion > 0){
                if(usepotion == 50) Game->PlaySound(SFX_POTN);
                if(usepotion <= 25) Screen->DrawTile(3, Link->X, Link->Y, ptile+5-Floor(usepotion/5), 1, 1, 11, 1, 0, 0, 0, 0, true, 128);
                usepotion--;




Big thanks to whoever has time to do this and does it for me. I will really appreciate it. You will also get a spot on the Pearl Of Shadows credits list.



#2 ZebraStallion

ZebraStallion

    Follower of Destiny

  • Members

Posted 10 November 2008 - 10:34 PM

Could someone at least tell me how to? icon_puppyeyes.gif

A good roll script would also be nice. icon_heh.gif


#3 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 11 November 2008 - 12:11 AM

I think the latest roll script is here. However, it has the press R to use shield part added to it as well.

As far as combining those scripts you listed, the rolling script and bombchu scripts can't be combined without rewriting them (since they contain a while loop with a Waitframe() inside of the infinite loop, which would prevent portions of the scripts from running at certain times.) The potion script looks like it is missing sections of it... There appears to be nothing that will call runpotion(), and the following if statements are just sitting there outside of a function, which will prevent the script from being compiled. However, the fairy/climbing script was written so that another script can easily be added to it. Did you pull that potion script out of aKttH? If so, I can try to pull out the parts necessary to make the potions useable, or the Master Scripter himself can add his own updated version of the potion script icon_smile.gif (since my copy of aKttH is from May, and I'm pretty sure he has fixed up the script a little.)

Edited by Elmensajero, 11 November 2008 - 12:12 AM.


#4 ZebraStallion

ZebraStallion

    Follower of Destiny

  • Members

Posted 11 November 2008 - 12:20 AM

QUOTE(Elmensajero @ Nov 10 2008, 11:11 PM) View Post

I think the latest roll script is here. However, it has the press R to use shield part added to it as well.

As far as combining those scripts you listed, the rolling script and bombchu scripts can't be combined without rewriting them (since they contain a while loop with a Waitframe() inside of the infinite loop, which would prevent portions of the scripts from running at certain times.) The potion script looks like it is missing sections of it... There appears to be nothing that will call runpotion(), and the following if statements are just sitting there outside of a function, which will prevent the script from being compiled. However, the fairy/climbing script was written so that another script can easily be added to it. Did you pull that potion script out of aKttH? If so, I can try to pull out the parts necessary to make the potions useable, or the Master Scripter himself can add his own updated version of the potion script icon_smile.gif (since my copy of aKttH is from May, and I'm pretty sure he has fixed up the script a little.)

1. Thanks! But I probably won't be able to use it because of the shield thing. icon_sorry.gif

2. Sounds confusing... That'd be great if you could make the potions script more useable though. Thanks!

Wait, so how do I combine them? icon_eek.gif I think I will probably mess up if I do... Do you think that maybe you can combine them for me? [bribe] I'll give you a spot on the credits list for my quest. [/bribe] icon_razz.gif It's okay if you don't want to though. I understand it could be a lot of work.

#5 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 11 November 2008 - 12:40 AM

I can't modify the rolling/bombchu script this week cause I am rather busy (since I would have to change them to make them work with the rest of your scripts), but I could probably get that potion script for you sometime soon. I am going to wait for Joe123 to read this thread first though, just in case he already has one available...

Edited by Elmensajero, 11 November 2008 - 12:40 AM.


#6 Joe123

Joe123

    Retired

  • Members

Posted 11 November 2008 - 07:03 AM

Yeah, I've already got a version of the bombchu and the roll script that use voids and don't have a while loop (well, the rolling script does but I've decided that's ok), and I've improved the potion script a little too, although it's still pretty ridiculous to use just cause of the nature of items in ZQuest.

I don't mind putting those three together, I'll have a look this evening.

#7 Joe123

Joe123

    Retired

  • Members

Posted 11 November 2008 - 01:58 PM

CODE
//Bombchu
const int bombchuflag = 98; //Flag the bombchu can pass through (even if solid)
const int bombchutile = 21752; //Set the tile for your weapon here. Up, Down, Left, Right it should be on the tilepage.
const int bombchuframes = 2; //Set the number of animation frames here.
const int bombchuaspeed = 10;//Set the animation speed here
const int bombchucset = 7; //Set the CSet here
    
const int bombchudmg = 2;  //Set the damage here
const int bombchuspeed = 1; //Set the speed of the bombchu here
    
int bombchuattack = 0;
int bombchux = 0;
int bombchuy = 0;
int bdir = 0;


//Rolling
const int DustTile    = 0; //Tile for dust-kickup
const int DustCset    = 0; //Cset
const int RollSFX    = 0; //SFX to play when rolling
const int F_NOROLL    = 98;//Flag Link can't roll onto

bool NoRoll;
int RollX[5];
int RollY[5];
int RollCounter;
int DustFrame;

//Fairy
const int CMB_FAIRY            = 0;    // Set here the first of the 4 Fairy combos, in the order Up, Down, Left, Right
bool HasFairy = true;
bool FairyInit = true;
int FairyMovementCounter;
int FairyMovementMax = 30;

//Climbing
const int F_LADDER = 98;    //ladder flag

//Solidity Check, by Saffith
bool isSolid(int x,int y){
if(x<0 || x>255 || y<0 || y>175) return false;
int mask = 1111b;
if(x%16<8) mask &= 0011b;
else mask &= 1100b;
if(y%16<8) mask &= 0101b;
else mask &= 1010b;
int ret = Screen->ComboS[ComboAt(x,y)]&mask;
return ret != 0;
}

bool bombchucheck(int x, int y){
    if((isSolid(x,y) && Screen->ComboF[ComboAt(x,y)] != bombchuflag && Screen->ComboI[ComboAt(x,y)] != bombchuflag)
     || (Screen->ComboF[ComboAt(x,y)] == 6 || Screen->ComboI[ComboAt(x,y)] == 6 ||Screen->ComboF[ComboAt(x,y)] == 11 || Screen->ComboI[ComboAt(x,y)] == 11)) return true;
}

void noaction(){
    Link->InputR = false;
    Link->InputL = false;
    Link->InputA = false;
    Link->InputB = false;
    Link->InputUp = false;
    Link->InputDown = false;
    Link->InputRight = false;
    Link->InputLeft = false;
}

//Checks for both placed and inherent flags on a location, to reduce checks
bool ComboFI(int x,int y,int combotype){
if(Screen->ComboF[ComboAt(x,y)] == combotype
|| Screen->ComboI[ComboAt(x,y)] == combotype) return true;
}

global script slot_2{
    void run(){
    bool lastL;
    int ScreenNumber;
        while(true){
            //Call bombchu functions
            if(bombchuattack == 2) run_bombchu();
            if(bombchuattack == 1) start_bombchu();
            
            //Call Roll functions
            if(Link->InputL && !lastL && Link->Action == LA_WALKING && Link->Z == 0 && !NoRoll && !Epona && !Falling) Roll();
            
            //Call the Fairy functions
            if(HasFairy) Fairy(ScreenNumber);
            
            ScreenNumber = Game->GetCurScreen();
            lastL = Link->InputL;
            Waitframe();
        }
    }
    
    void run_bombchu() {
        lweapon bombchu;
        lweapon explosion;
        int HP = 0;
        bool found = false;
        for(int i = 1; i <= Screen->NumLWeapons(); i+= 1) {
            bombchu = Screen->LoadLWeapon(i);
            if(bombchu->ID == LW_SCRIPT1) {
                found = true;
                HP = Link->HP;
                if(Link->InputUp) bdir = 0;
                if(Link->InputDown) bdir = 1;
                if(Link->InputLeft) bdir = 2;
                if(Link->InputRight) bdir = 3;
                if(bdir == 0 && bombchucheck(bombchu->X+8,bombchu->Y+4)
                || (bdir == 1 && bombchucheck(bombchu->X+8,bombchu->Y+12))
                || (bdir == 2 && bombchucheck(bombchu->X+4,bombchu->Y+8))
                || (bdir == 3 && bombchucheck(bombchu->X+12,bombchu->Y+8))) bombchu->DeadState = 0;
                bombchu->Dir = bdir;
                bombchu->Tile = bombchutile+(bdir*bombchuframes);
                bombchu->OriginalTile = bombchutile+(bdir*bombchuframes);
                bombchux = bombchu->X;
                bombchuy = bombchu->Y;
                noaction();
                if(Link->HP < HP) bombchu->DeadState = 0;
                break;
            }
        }
        
        if(found == false) {
            explosion = Screen->CreateLWeapon(LW_SBOMB);
            explosion->Damage = bombchudmg;
            explosion->X = bombchux;
            explosion->Y = bombchuy;
            
            Link->Action = 0;
            bombchuattack = 0;
            
        }
    }
    
    void start_bombchu() {
        if(Link->X > 15 && Link->X < 241 && Link->Y > 15 && Link->Y < 153){
            lweapon bombchu = Screen->CreateLWeapon(LW_SCRIPT1);
            bdir = Link->Dir;
            bombchu->OriginalTile = bombchutile+(bdir*bombchuframes);
            bombchu->Tile = bombchutile+(bdir*bombchuframes);
            bombchu->NumFrames = bombchuframes;
            bombchu->ASpeed = bombchuaspeed;
            bombchu->CSet = bombchucset;
            bombchux = 0; bombchuy = 0;
            if(bdir>1) bombchux = (((bdir-2)*2)-1)*16;
            if(bdir<2) bombchuy = ((bdir*2)-1)*16;
            bombchu->X = Link->X+bombchux;
            bombchu->Y = Link->Y+bombchuy;
            bombchu->Step = bombchuspeed;
            Link->Action = LA_ATTACKING;
            Game->Counter[6]--;
            bombchuattack = 2;
        }else{
            bdir = Link->Dir;
            bombchux = 0; bombchuy = 0;
            if(bdir>1) bombchux = (((bdir-2)*2)-1)*16;
            if(bdir<2) bombchuy = ((bdir*2)-1)*16;
            lweapon explosion = Screen->CreateLWeapon(LW_SBOMB);
            explosion->X = Link->X+bombchux;
            explosion->Y = Link->Y+bombchuy;
            explosion->Damage = bombchudmg;
            Link->Action = 0;
            bombchuattack = 0;
        }
    }
    
    //Fairy functions
    void Fairy(int ScreenNumber){
        ffc Fairy = Screen->LoadFFC(32);
        bool ChangeDir;
        if(FairyInit){
            Fairy->Flags[0] = true;
            Fairy->Flags[3] = true;
            Fairy->Data = CMB_FAIRY+1;
            FairyInit = false;
            Fairy->X = Rand(28) + Link->X-16;
            Fairy->Y = Rand(28) + Link->Y-16;
        }
        if(ScreenNumber != Game->GetCurScreen()){
            Fairy->X = Rand(28) + Link->X-16;
            Fairy->Y = Rand(28) + Link->Y-16;
        }
        if(FairyMovementCounter == FairyMovementMax){
            Fairy->Vx = (Rand(5)/10+0.4)*(Rand(2)*2-1);
            Fairy->Vy = (Rand(5)/10+0.4)*(Rand(2)*2-1);
            ChangeDir = true;
            FairyMovementCounter = 0;
        }
        if(Distance(Fairy->X,Fairy->Y,Link->X,Link->Y) > 32){
            if(Fairy->X < Link->X) Fairy->Vx = (Rand(5)/10+1);
            else Fairy->Vx = -(Rand(5)/10+1);
            if(Fairy->Y < Link->Y) Fairy->Vy = (Rand(5)/10+1);
            else Fairy->Vy = -(Rand(5)/10+1);
            ChangeDir = true;
        }
        if(ChangeDir){
            if(Fairy->Vy < 0 && (Abs(Fairy->Vx) < 0.6)) Fairy->Data = CMB_FAIRY;
            else if(Fairy->Vy > 0 && (Abs(Fairy->Vx) < 0.6)) Fairy->Data = CMB_FAIRY+1;
            else if(Fairy->Vx < 0) Fairy->Data = CMB_FAIRY+2;
            else if(Fairy->Vx > 0) Fairy->Data = CMB_FAIRY+3;
            ChangeDir = false;
        }
        FairyMovementCounter++;
    }
    
    //Beefster's Roll functions
    void Roll(){
        int i;
        Link->Jump = 2;
        RollCounter = 20;
        DustFrame = 1;
        for(i=0;i<5;i++){
            RollX[i] = -1;
            RollY[i] = -1;
        }
        Game->PlaySound(RollSFX);
        while(RollCounter > 0){
            Link->Z = 0;
            NoAction();
            if(RollCounter%2 == 0){
                if(Link->Dir < 2) RollX[0] = Link->X+2;
                else if(Link->Dir < 3) RollX[0] = Link->X;
                else RollX[0] = Link->X+4;
                RollY[0] = Link->Y;
                for(i=4;i>0;i--){
                    RollX[i] = RollX[i-1];
                    RollY[i] = RollY[i-1];
                }
                if(DustFrame >= 5){
                    RollX[0] = -1;
                    RollY[0] = -1;
                }
                DustFrame++;
            }
            for(i=0;i<5;i++) if(RollX[i] != -1 && RollY[i] != -1) Screen->DrawTile(2,RollX[i],RollY[i],DustTile+i,1,1,DustCSet,1,0,0,0,0,true,128);
            if(Link->Dir < 1){if(RollCheck(Link->X+8,Link->Y+6,Vertical)) Link->Y -= 2;}
            else if(Link->Dir < 2){if(RollCheck(Link->X+8,Link->Y+18,Vertical)) Link->Y += 2;}
            else if(Link->Dir < 3){if(RollCheck(Link->X,Link->Y+12,Horizontal)) Link->X -= 2;}
            else if(Link->Dir < 4){if(RollCheck(Link->X+16,Link->Y+12,Horizontal)) Link->X += 2;}
            
            RollCounter--;
        Waitframe();
        }
        Link->Jump = 0;
    }
    //Check whether Link can roll onto a tile
    bool RollCheck(int x, int y, bool xy){
     int xoffset; int yoffset;
     if(xy) xoffset = 4;
     else yoffset = 3;
     if(!isSolid(x-xoffset,y-yoffset) && !isSolid(x+xoffset,y+yoffset)
     && !ComboFI(x-xoffset,y-yoffset,F_NOROLL)
     && !ComboFI(x+xoffset,y+yoffset,F_NOROLL)) return true;
    }
    
    //Climbing functions
    void Climbing(bool before){
        if(before){
            if(OnLadder()){
                Link->InputA = false;
                Link->InputB = false;
                Link->InputL = false;
            }
        }else{
            if(OnLadder()) Link->Dir = 0;
        }
    }
    //Check whether Link is on a ladder combo
    bool OnLadder(){
     if(ComboFI(Link->X+8,Link->Y+8,F_LADDER) && Link->Z == 0) return true;
    }
}

global script slot_3{
    void run(){
        bombchuattack = 0;
    }
}

item script bombchu{
    void run(){
        if(Game->Counter[6] > 0) bombchuattack = 1;
    }
}


Looking back at these bottle scripts, I've just realised again quite how complicated they are.
I'm afraid, to that end, I'm not going to put them in the script for you.
You'll have to either sort it out yourself, or get someone else to do it.
It really is just more complicated than I can be bothered with, sorry.

CODE
//Checks whether Link has an empty bottle or not when given a potion
void RunPotion(int set1, int set2, int set3, int m){
    if(Link->Item[I_BTTL1]){
        Link->Item[set1] = true;
        Link->Item[I_BTTL1] = false;
    }else if(Link->Item[I_BTTL2]){
        Link->Item[set2] = true;
        Link->Item[I_BTTL2] = false;
    }else if(Link->Item[I_BTTL3]){
        Link->Item[set3] = true;
        Link->Item[I_BTTL3] = false;
    }else Screen->Message(m);
}

//within global script
            //Call the Potion functions
            if(UsePotion >= 0) PotionEffect();
            if(SwordTimer >= 0) PowerPotion();
            if(RingTimer >= 0) DefencePotion();
            
//after void run of global script
    //Functions for the 'sparkle' effect when Link uses a Potion
    void PotionEffect(){
        Link->Action = LA_FROZEN;
        if(UsePotion == 50) Game->PlaySound(SFX_POTION);
        else if(UsePotion <= 25) Screen->DrawTile(3,Link->X,Link->Y,T_POTION+5-Floor(UsePotion/5),1,1,11,1,0,0,0,0,true,128);
        if(UsePotion == 0) Link->Action = 0;
        UsePotion--;
    }    
    //Power Potion functions
    void PowerPotion(){
        if(SwordTimer == 0){
            Link->Item[I_RING2] = false;
            Link->Item[I_RING3] = false;
            if(Link->Item[I_SWORD4]) Link->Item[I_SWORD4] = false;
            else Link->Item[I_SWORD2] = false;
        }
        SwordTimer--;
    }
    //Defence Potion functions
    void DefencePotion(){
        if(RingTimer == 0){
            Link->Item[I_RING1] = false;
            Link->Item[I_RING3] = false;
        }
        RingTimer --;
    }
    
//item scripts
//These item scripts are the pickup scripts for the potions
item script LifePotionPickup{
    void run(int m){
        Screen->Message(m);
        RunPotion(I_LPTN1,I_LPTN2,I_LPTN3,1);
    }
}

item script MagicPotionPickup{
    void run(int m){
        Screen->Message(m);
        RunPotion(I_MPTN1,I_MPTN2,I_MPTN3,1);
    }
}

item script AttackPotionPickup{
    void run(int m){
        Screen->Message(m);
        RunPotion(I_APTN1,I_APTN2,I_APTN3,1);
    }
}

item script DefencePotionPickup{
    void run(int m){
        Screen->Message(m);
        RunPotion(I_DPTN1,I_DPTN2,I_DPTN3,1);
    }
}

item script EmptyBottlePickup{
    void run(int m, int n){
        if(Link->Item[I_BTTL2]){Link->Item[I_BTTL3] = true; Screen->Message(m);}
        else if(Link->Item[I_BTTL1]){Link->Item[I_BTTL2] = true; Screen->Message(m);}
        else{Link->Item[I_BTTL1] = true; Screen->Message(n);}
    }
}

//These item scripts are the action scripts for the potions
item script LifePotionAction{
    void run(int foo, int place){
        Link->HP += 128;
        if(Link->HP > Link->MaxHP) Link->HP = Link->MaxHP;
        if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_LPTN1] = false;}
        else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_LPTN2] = false;}
        else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_LPTN3] = false;}
        UsePotion = 50;
    }
}

item script MagicPotionAction{
    void run(int foo, int place){
        Link->MP = 256;
        if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_MPTN1] = false;}
        else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_MPTN2] = false;}
        else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_MPTN3] = false;}
        UsePotion = 50;
    }
}

item script AttackPotionAction{
    void run(int foo, int place){
        if(!Link->Item[I_RING1]) Link->Item[I_RING2] = true;
        else Link->Item[I_RING3] = true;
        if(Link->Item[I_SWORD3]) Link->Item[I_SWORD4] = true;
        else Link->Item[I_SWORD2] = true;
        if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_APTN1] = false;}
        else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_APTN2] = false;}
        else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_APTN3] = false;}
        SwordTimer = (Minute*3)/4;
        UsePotion = 50;
    }
}

item script DefencePotionAction{
    void run(int foo, int place){
        if(!Link->Item[I_RING2]) Link->Item[I_RING1] = true;
        else Link->Item[I_RING3] = true;
        if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_DPTN1] = false;}
        else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_DPTN2] = false;}
        else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_DPTN3] = false;}
        RingTimer = (Minute*3)/4;
        UsePotion = 50;
    }
}


You'll need to declare a load of integers for that bit too.

#8 ZebraStallion

ZebraStallion

    Follower of Destiny

  • Members

Posted 11 November 2008 - 05:59 PM

Well, thanks! I really appreciate it!

Anyone want to try the potion script...?

#9 ZebraStallion

ZebraStallion

    Follower of Destiny

  • Members

Posted 11 December 2008 - 09:46 PM

Okay, well I guess I don't REALLY need the potion script... (But I really want it!!! icon_razz.gif )

I have another request. Could somebody please add the pegasus boot script to this?

Thanks for all of the help and thanks for putting up with me. icon_razz.gif

#10 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 11 December 2008 - 11:49 PM

Sure i can do that for you. Do want it to be added to the previous global scripts joe already combined?

#11 Joe123

Joe123

    Retired

  • Members

Posted 12 December 2008 - 03:07 AM

You could have a go yourself?
Maybe I should've put that thread somewhere more obvious.

No-one really reads pinned threads do they...

EDIT:
Also, nice avatar ZS.
Snap! ^_^

#12 ZebraStallion

ZebraStallion

    Follower of Destiny

  • Members

Posted 12 December 2008 - 04:08 PM

Well I tried:

CODE

//Bombchu
const int bombchuflag = 98; //Flag the bombchu can pass through (even if solid)
const int bombchutile = 21752; //Set the tile for your weapon here. Up, Down, Left, Right it should be on the tilepage.
const int bombchuframes = 2; //Set the number of animation frames here.
const int bombchuaspeed = 10;//Set the animation speed here
const int bombchucset = 7; //Set the CSet here
    
const int bombchudmg = 2;  //Set the damage here
const int bombchuspeed = 1; //Set the speed of the bombchu here
    
int bombchuattack = 0;
int bombchux = 0;
int bombchuy = 0;
int bdir = 0;


//Rolling
const int DustTile    = 0; //Tile for dust-kickup
const int DustCset    = 0; //Cset
const int RollSFX    = 0; //SFX to play when rolling
const int F_NOROLL    = 98;//Flag Link can't roll onto

bool NoRoll;
int RollX[5];
int RollY[5];
int RollCounter;
int DustFrame;

//Fairy
const int CMB_FAIRY            = 0;    // Set here the first of the 4 Fairy combos, in the order Up, Down, Left, Right
bool HasFairy = true;
bool FairyInit = true;
int FairyMovementCounter;
int FairyMovementMax = 30;

//Climbing
const int F_LADDER = 98;    //ladder flag

//Solidity Check, by Saffith
bool isSolid(int x,int y){
if(x<0 || x>255 || y<0 || y>175) return false;
int mask = 1111b;
if(x%16<8) mask &= 0011b;
else mask &= 1100b;
if(y%16<8) mask &= 0101b;
else mask &= 1010b;
int ret = Screen->ComboS[ComboAt(x,y)]&mask;
return ret != 0;
}

bool bombchucheck(int x, int y){
    if((isSolid(x,y) && Screen->ComboF[ComboAt(x,y)] != bombchuflag && Screen->ComboI[ComboAt(x,y)] != bombchuflag)
     || (Screen->ComboF[ComboAt(x,y)] == 6 || Screen->ComboI[ComboAt(x,y)] == 6 ||Screen->ComboF[ComboAt(x,y)] == 11 || Screen->ComboI[ComboAt(x,y)] == 11)) return true;
}

void noaction(){
    Link->InputR = false;
    Link->InputL = false;
    Link->InputA = false;
    Link->InputB = false;
    Link->InputUp = false;
    Link->InputDown = false;
    Link->InputRight = false;
    Link->InputLeft = false;
}

//Checks for both placed and inherent flags on a location, to reduce checks
bool ComboFI(int x,int y,int combotype){
if(Screen->ComboF[ComboAt(x,y)] == combotype
|| Screen->ComboI[ComboAt(x,y)] == combotype) return true;
}

//Pegasus
const int CF_DASH            = 98;        //Flag that Link can't dash through if walkable, and will break if solid
const int SFX_DASH            = 67;        //Dashing SFX
const int SFX_HITWALL        = 68;        //Hitting a wall
const int SFX_PEGASUSBREAK    = 66;        //SFX to play when breaking a Pegasus Boot block
const int T_DUST            = 27544;    //Dust Kick-up tile
const int DustAFrames        = 4;        //Dust Kick-up animation frames
const int DustASpeed        = 4;        //Dust Kick-up animation speed
const int DustCSet            = 3;        //Dust Kick-up CSet
const int DashSFXLength        = 9;        //Time between repeating Dash SFX

//Variables
bool PegasusDash;
bool PegasusCollision;
int DashCounter;
int StoreInput;
int StoreHP;

//Functions
//Check inherent and regular flags at the same time
bool ComboFI(int x,int y,int combotype){
if(Screen->ComboF[ComboAt(x,y)] == combotype
|| Screen->ComboI[ComboAt(x,y)] == combotype) return true;
}
//Stops all Link's inputs
void NoAction(){
    Link->InputUp = false;
    Link->InputDown = false;
    Link->InputLeft = false;
    Link->InputRight = false;
    Link->InputR = false;
    Link->InputL = false;
    Link->InputA = false;
    Link->InputB = false;
}

global script slot_2{
    void run(){
    bool lastL;
    int ScreenNumber;
        while(true){
            //Call bombchu functions
            if(bombchuattack == 2) run_bombchu();
            if(bombchuattack == 1) start_bombchu();
            
            //Call Roll functions
            if(Link->InputL && !lastL && Link->Action == LA_WALKING && Link->Z == 0 && !NoRoll && !Epona && !Falling) Roll();
            
            //Call the Fairy functions
            if(HasFairy) Fairy(ScreenNumber);
            
            ScreenNumber = Game->GetCurScreen();
            lastL = Link->InputL;
            Waitframe();
        }
    }
    
    void run_bombchu() {
        lweapon bombchu;
        lweapon explosion;
        int HP = 0;
        bool found = false;
        for(int i = 1; i <= Screen->NumLWeapons(); i+= 1) {
            bombchu = Screen->LoadLWeapon(i);
            if(bombchu->ID == LW_SCRIPT1) {
                found = true;
                HP = Link->HP;
                if(Link->InputUp) bdir = 0;
                if(Link->InputDown) bdir = 1;
                if(Link->InputLeft) bdir = 2;
                if(Link->InputRight) bdir = 3;
                if(bdir == 0 && bombchucheck(bombchu->X+8,bombchu->Y+4)
                || (bdir == 1 && bombchucheck(bombchu->X+8,bombchu->Y+12))
                || (bdir == 2 && bombchucheck(bombchu->X+4,bombchu->Y+8))
                || (bdir == 3 && bombchucheck(bombchu->X+12,bombchu->Y+8))) bombchu->DeadState = 0;
                bombchu->Dir = bdir;
                bombchu->Tile = bombchutile+(bdir*bombchuframes);
                bombchu->OriginalTile = bombchutile+(bdir*bombchuframes);
                bombchux = bombchu->X;
                bombchuy = bombchu->Y;
                noaction();
                if(Link->HP < HP) bombchu->DeadState = 0;
                break;
            }
        }
        
        if(found == false) {
            explosion = Screen->CreateLWeapon(LW_SBOMB);
            explosion->Damage = bombchudmg;
            explosion->X = bombchux;
            explosion->Y = bombchuy;
            
            Link->Action = 0;
            bombchuattack = 0;
            
        }
    }
    
    void start_bombchu() {
        if(Link->X > 15 && Link->X < 241 && Link->Y > 15 && Link->Y < 153){
            lweapon bombchu = Screen->CreateLWeapon(LW_SCRIPT1);
            bdir = Link->Dir;
            bombchu->OriginalTile = bombchutile+(bdir*bombchuframes);
            bombchu->Tile = bombchutile+(bdir*bombchuframes);
            bombchu->NumFrames = bombchuframes;
            bombchu->ASpeed = bombchuaspeed;
            bombchu->CSet = bombchucset;
            bombchux = 0; bombchuy = 0;
            if(bdir>1) bombchux = (((bdir-2)*2)-1)*16;
            if(bdir<2) bombchuy = ((bdir*2)-1)*16;
            bombchu->X = Link->X+bombchux;
            bombchu->Y = Link->Y+bombchuy;
            bombchu->Step = bombchuspeed;
            Link->Action = LA_ATTACKING;
            Game->Counter[6]--;
            bombchuattack = 2;
        }else{
            bdir = Link->Dir;
            bombchux = 0; bombchuy = 0;
            if(bdir>1) bombchux = (((bdir-2)*2)-1)*16;
            if(bdir<2) bombchuy = ((bdir*2)-1)*16;
            lweapon explosion = Screen->CreateLWeapon(LW_SBOMB);
            explosion->X = Link->X+bombchux;
            explosion->Y = Link->Y+bombchuy;
            explosion->Damage = bombchudmg;
            Link->Action = 0;
            bombchuattack = 0;
        }
    }
    
//Call Pegasus Boots functions
            if(PegasusDash) PegasusBoots();
            //Other global script functions go here
            
            
            StoreHP = Link->HP;
//Pegasus Boots
    void PegasusBoots(){
        if(!PegasusCollision){
            int loc = ComboAt(Link->X+8,Link->Y+8);
            //Check if Link should be dashing
            if(((StoreInput == 1 && !Link->InputA)
            || (StoreInput == 2 && !Link->InputB))
            || StoreHP < Link->HP
            || Screen->ComboT[loc] == CT_WATER){
                PegasusDash = false;
                DashCounter = 0;
            }
            //Stop all actions
            NoAction();
            //Movement
            if(DashCounter > 10){
                if(Link->Dir == 0 && DashCheck(Link->X+8,Link->Y+6,true) != 2){
                    Link->Y--;
                    Link->InputUp = true;
                }else if(Link->Dir == 1 && DashCheck(Link->X+8,Link->Y+18,true) != 2){
                    Link->Y++;
                    Link->InputDown = true;
                }else if(Link->Dir == 2 && DashCheck(Link->X,Link->Y+12,false) != 2){
                    Link->X--;
                    Link->InputLeft = true;
                }else if(Link->Dir == 3 && DashCheck(Link->X+16,Link->Y+12,false) != 2){
                    Link->X++;
                    Link->InputRight = true;
                }else{
                    PegasusCollision = true;
                    DashCounter = 0;
                }
            }
            //Break Pegasus Blocks
            if(ComboFI(Link->X+8,Link->Y+8,CF_DASH) && Screen->ComboS[loc] == 1111b){
                Screen->ComboD[loc]++;
                if(Screen->ComboF[loc] == CF_DASH) Screen->ComboF[loc] = 0;
                Game->PlaySound(SFX_PEGASUSBREAK);
            }
            //Dust tile animation
            lweapon Dust;
            if(DashCounter%4 == 0){
                for(int j=1;j<=Screen->NumLWeapons();j++){
                    Dust = Screen->LoadLWeapon(j);
                    if(Dust->ID != LW_SCRIPT10) continue;
                    if(Link->Dir < 1) Dust->Y-=3;
                    else if(Link->Dir < 2) Dust->Y+=3;
                    else if(Link->Dir < 3) Dust->X-=3;
                    else if(Link->Dir < 4) Dust->X+=3;
                }
                Dust = Screen->CreateLWeapon(LW_SCRIPT10);
                Dust->OriginalTile = T_DUST;
                Dust->CSet = DustCSet;
                Dust->Y = Link->Y;
                Dust->X = Link->X;
                Dust->NumFrames = DustAFrames;
                Dust->ASpeed = DustASpeed;
                Dust->DeadState = DustAFrames*DustASpeed;
            }
            //Play SFX
            if(DashCounter%DashSFXLength == 0) Game->PlaySound(SFX_DASH);
        }else{
            //Bounceback after hitting a wall
            NoAction();
            if(DashCounter == 1){
                Screen->ClearSprites(SL_LWPNS);
                Game->PlaySound(SFX_HITWALL);
                Screen->Quake = 10;
            }else if(DashCounter == 10){
                PegasusDash = false;
                PegasusCollision = false;
                DashCounter = 0;
            }
            if(Link->Dir == 0 && DashCheck(Link->X+8,Link->Y+6,true) == 0) Link->Y++;
            else if(Link->Dir == 1 && DashCheck(Link->X+8,Link->Y+18,true) == 0) Link->Y--;
            else if(Link->Dir == 2 && DashCheck(Link->X+18,Link->Y+8,false) == 0) Link->X++;
            else if(Link->Dir == 3 && DashCheck(Link->X-2,Link->Y+8,false) == 0) Link->X--;
            if(DashCounter < 5) Link->Z++;
        }
        DashCounter++;
    }
    //Check whether Link can dash onto a combo
    int DashCheck(int x, int y, bool xy){
     int xoffset; int yoffset;
     bool Solid;
     if(xy) xoffset = 4;
     else yoffset = 3;
     if(isSolid(x-xoffset,y-yoffset) || isSolid(x+xoffset,y+yoffset)) Solid = true;
     if(!Solid && !ComboFI(x-xoffset,y-yoffset,CF_DASH)
     && !ComboFI(x+xoffset,y+yoffset,CF_DASH)) return 0;
     else if(Solid && (ComboFI(x-xoffset,y-yoffset,CF_DASH)
     || ComboFI(x+xoffset,y+yoffset,CF_DASH))) return 1;
     else return 2;
    }
}
    //Fairy functions
    void Fairy(int ScreenNumber){
        ffc Fairy = Screen->LoadFFC(32);
        bool ChangeDir;
        if(FairyInit){
            Fairy->Flags[0] = true;
            Fairy->Flags[3] = true;
            Fairy->Data = CMB_FAIRY+1;
            FairyInit = false;
            Fairy->X = Rand(28) + Link->X-16;
            Fairy->Y = Rand(28) + Link->Y-16;
        }
        if(ScreenNumber != Game->GetCurScreen()){
            Fairy->X = Rand(28) + Link->X-16;
            Fairy->Y = Rand(28) + Link->Y-16;
        }
        if(FairyMovementCounter == FairyMovementMax){
            Fairy->Vx = (Rand(5)/10+0.4)*(Rand(2)*2-1);
            Fairy->Vy = (Rand(5)/10+0.4)*(Rand(2)*2-1);
            ChangeDir = true;
            FairyMovementCounter = 0;
        }
        if(Distance(Fairy->X,Fairy->Y,Link->X,Link->Y) > 32){
            if(Fairy->X < Link->X) Fairy->Vx = (Rand(5)/10+1);
            else Fairy->Vx = -(Rand(5)/10+1);
            if(Fairy->Y < Link->Y) Fairy->Vy = (Rand(5)/10+1);
            else Fairy->Vy = -(Rand(5)/10+1);
            ChangeDir = true;
        }
        if(ChangeDir){
            if(Fairy->Vy < 0 && (Abs(Fairy->Vx) < 0.6)) Fairy->Data = CMB_FAIRY;
            else if(Fairy->Vy > 0 && (Abs(Fairy->Vx) < 0.6)) Fairy->Data = CMB_FAIRY+1;
            else if(Fairy->Vx < 0) Fairy->Data = CMB_FAIRY+2;
            else if(Fairy->Vx > 0) Fairy->Data = CMB_FAIRY+3;
            ChangeDir = false;
        }
        FairyMovementCounter++;
    }
    
    //Beefster's Roll functions
    void Roll(){
        int i;
        Link->Jump = 2;
        RollCounter = 20;
        DustFrame = 1;
        for(i=0;i<5;i++){
            RollX[i] = -1;
            RollY[i] = -1;
        }
        Game->PlaySound(RollSFX);
        while(RollCounter > 0){
            Link->Z = 0;
            NoAction();
            if(RollCounter%2 == 0){
                if(Link->Dir < 2) RollX[0] = Link->X+2;
                else if(Link->Dir < 3) RollX[0] = Link->X;
                else RollX[0] = Link->X+4;
                RollY[0] = Link->Y;
                for(i=4;i>0;i--){
                    RollX[i] = RollX[i-1];
                    RollY[i] = RollY[i-1];
                }
                if(DustFrame >= 5){
                    RollX[0] = -1;
                    RollY[0] = -1;
                }
                DustFrame++;
            }
            for(i=0;i<5;i++) if(RollX[i] != -1 && RollY[i] != -1) Screen->DrawTile(2,RollX[i],RollY[i],DustTile+i,1,1,DustCSet,1,0,0,0,0,true,128);
            if(Link->Dir < 1){if(RollCheck(Link->X+8,Link->Y+6,Vertical)) Link->Y -= 2;}
            else if(Link->Dir < 2){if(RollCheck(Link->X+8,Link->Y+18,Vertical)) Link->Y += 2;}
            else if(Link->Dir < 3){if(RollCheck(Link->X,Link->Y+12,Horizontal)) Link->X -= 2;}
            else if(Link->Dir < 4){if(RollCheck(Link->X+16,Link->Y+12,Horizontal)) Link->X += 2;}
            
            RollCounter--;
        Waitframe();
        }
        Link->Jump = 0;
    }
    //Check whether Link can roll onto a tile
    bool RollCheck(int x, int y, bool xy){
     int xoffset; int yoffset;
     if(xy) xoffset = 4;
     else yoffset = 3;
     if(!isSolid(x-xoffset,y-yoffset) && !isSolid(x+xoffset,y+yoffset)
     && !ComboFI(x-xoffset,y-yoffset,F_NOROLL)
     && !ComboFI(x+xoffset,y+yoffset,F_NOROLL)) return true;
    }
    
    //Climbing functions
    void Climbing(bool before){
        if(before){
            if(OnLadder()){
                Link->InputA = false;
                Link->InputB = false;
                Link->InputL = false;
            }
        }else{
            if(OnLadder()) Link->Dir = 0;
        }
    }
    //Check whether Link is on a ladder combo
    bool OnLadder(){
     if(ComboFI(Link->X+8,Link->Y+8,F_LADDER) && Link->Z == 0) return true;
    }
}

global script slot_3{
    void run(){
        bombchuattack = 0;
    PegasusDash = false;
        PegasusCollision = false;
    }
}

item script bombchu{
    void run(){
        if(Game->Counter[6] > 0) bombchuattack = 1;
    }
}


item script PegasusBoots{
    void run(){
        if(Screen->ComboT[ComboAt(Link->X+8,Link->Y+8)] == CT_WATER
        || ComboFI(Link->X+8,Link->Y+8,CF_DASH)) Quit();
        PegasusDash = true;
        if(Link->InputB && !Link->InputA) StoreInput = 2;
        else if(Link->InputA && !Link->InputB) StoreInput = 1;
    }
}


QUOTE
Sure i can do that for you. Do want it to be added to the previous global scripts joe already combined?

If mine isn't correct, then that would be great! icon_biggrin.gif


#13 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 12 December 2008 - 04:53 PM

Yea you did =p you messed up in some lines and had unnecessary lines.
make sure you practice that tutorial joe made in the scripting database.
CODE

"import.std.zh"

//Bombchu constants
const int bombchuflag = 98; //Flag the bombchu can pass through (even if solid)
const int bombchutile = 21752; //Set the tile for your weapon here. Up, Down, Left, Right it should be on the tilepage.
const int bombchuframes = 2; //Set the number of animation frames here.
const int bombchuaspeed = 10;//Set the animation speed here
const int bombchucset = 7; //Set the CSet here
    
const int bombchudmg = 2;  //Set the damage here
const int bombchuspeed = 1; //Set the speed of the bombchu here
    
int bombchuattack = 0;
int bombchux = 0;
int bombchuy = 0;
int bdir = 0;


//Rolling constants
const int DustTile    = 0; //Tile for dust-kickup
const int DustCset    = 0; //Cset
const int RollSFX    = 0; //SFX to play when rolling
const int F_NOROLL    = 98;//Flag Link can't roll onto

bool NoRoll;
int RollX[5];
int RollY[5];
int RollCounter;
int DustFrame;

//Fairy constants
const int CMB_FAIRY            = 0;    // Set here the first of the 4 Fairy combos, in the order Up, Down, Left, Right
bool HasFairy = true;
bool FairyInit = true;
int FairyMovementCounter;
int FairyMovementMax = 30;

//Climbing constants
const int F_LADDER = 98;    //ladder flag

//Pegasus constants
const int CF_DASH            = 98;        //Flag that Link can't dash through if walkable, and will break if solid
const int SFX_DASH            = 67;        //Dashing SFX
const int SFX_HITWALL        = 68;        //Hitting a wall
const int SFX_PEGASUSBREAK    = 66;        //SFX to play when breaking a Pegasus Boot block
const int T_DUST            = 27544;    //Dust Kick-up tile
const int DustAFrames        = 4;        //Dust Kick-up animation frames
const int DustASpeed        = 4;        //Dust Kick-up animation speed
const int DustCSet            = 3;        //Dust Kick-up CSet
const int DashSFXLength        = 9;        //Time between repeating Dash SFX

//Variables
bool PegasusDash;
bool PegasusCollision;
int DashCounter;
int StoreInput;
int StoreHP;

//Solidity Check, by Saffith
bool isSolid(int x,int y){
if(x<0 || x>255 || y<0 || y>175) return false;
int mask = 1111b;
if(x%16<8) mask &= 0011b;
else mask &= 1100b;
if(y%16<8) mask &= 0101b;
else mask &= 1010b;
int ret = Screen->ComboS[ComboAt(x,y)]&mask;
return ret != 0;
}

bool bombchucheck(int x, int y){
    if((isSolid(x,y) && Screen->ComboF[ComboAt(x,y)] != bombchuflag && Screen->ComboI[ComboAt(x,y)] != bombchuflag)
     || (Screen->ComboF[ComboAt(x,y)] == 6 || Screen->ComboI[ComboAt(x,y)] == 6 ||Screen->ComboF[ComboAt(x,y)] == 11 || Screen->ComboI[ComboAt(x,y)] == 11)) return true;
}

//Checks for both placed and inherent flags on a location, to reduce checks
bool ComboFI(int x,int y,int combotype){
if(Screen->ComboF[ComboAt(x,y)] == combotype
|| Screen->ComboI[ComboAt(x,y)] == combotype) return true;
}

//Functions
//Check inherent and regular flags at the same time
bool ComboFI(int x,int y,int combotype){
if(Screen->ComboF[ComboAt(x,y)] == combotype
|| Screen->ComboI[ComboAt(x,y)] == combotype) return true;
}

//Stops all of links actions
void noaction(){
    Link->InputR = false;
    Link->InputL = false;
    Link->InputA = false;
    Link->InputB = false;
    Link->InputUp = false;
    Link->InputDown = false;
    Link->InputRight = false;
    Link->InputLeft = false;
}

global script slot_2{
    void run(){
    bool lastL;
    int ScreenNumber;
        while(true){
            //Call bombchu functions
            if(bombchuattack == 2) run_bombchu();
            if(bombchuattack == 1) start_bombchu();
            
            //Call Roll functions
            if(Link->InputL && !lastL && Link->Action == LA_WALKING && Link->Z == 0 && !NoRoll && !Epona && !Falling) Roll();

            //Call Pegasus Boots functions
            if(PegasusDash) PegasusBoots();                      
            StoreHP = Link->HP;
            
            //Call the Fairy functions
            if(HasFairy) Fairy(ScreenNumber);
            
            ScreenNumber = Game->GetCurScreen();
            lastL = Link->InputL;
            Waitframe();
        }
    }
    //bombchu functions
    void run_bombchu() {
        lweapon bombchu;
        lweapon explosion;
        int HP = 0;
        bool found = false;
        for(int i = 1; i <= Screen->NumLWeapons(); i+= 1) {
            bombchu = Screen->LoadLWeapon(i);
            if(bombchu->ID == LW_SCRIPT1) {
                found = true;
                HP = Link->HP;
                if(Link->InputUp) bdir = 0;
                if(Link->InputDown) bdir = 1;
                if(Link->InputLeft) bdir = 2;
                if(Link->InputRight) bdir = 3;
                if(bdir == 0 && bombchucheck(bombchu->X+8,bombchu->Y+4)
                || (bdir == 1 && bombchucheck(bombchu->X+8,bombchu->Y+12))
                || (bdir == 2 && bombchucheck(bombchu->X+4,bombchu->Y+8))
                || (bdir == 3 && bombchucheck(bombchu->X+12,bombchu->Y+8))) bombchu->DeadState = 0;
                bombchu->Dir = bdir;
                bombchu->Tile = bombchutile+(bdir*bombchuframes);
                bombchu->OriginalTile = bombchutile+(bdir*bombchuframes);
                bombchux = bombchu->X;
                bombchuy = bombchu->Y;
                noaction();
                if(Link->HP < HP) bombchu->DeadState = 0;
                break;
            }
        }
        
        if(found == false) {
            explosion = Screen->CreateLWeapon(LW_SBOMB);
            explosion->Damage = bombchudmg;
            explosion->X = bombchux;
            explosion->Y = bombchuy;
            
            Link->Action = 0;
            bombchuattack = 0;
            
        }
    }
    
    void start_bombchu() {
        if(Link->X > 15 && Link->X < 241 && Link->Y > 15 && Link->Y < 153){
            lweapon bombchu = Screen->CreateLWeapon(LW_SCRIPT1);
            bdir = Link->Dir;
            bombchu->OriginalTile = bombchutile+(bdir*bombchuframes);
            bombchu->Tile = bombchutile+(bdir*bombchuframes);
            bombchu->NumFrames = bombchuframes;
            bombchu->ASpeed = bombchuaspeed;
            bombchu->CSet = bombchucset;
            bombchux = 0; bombchuy = 0;
            if(bdir>1) bombchux = (((bdir-2)*2)-1)*16;
            if(bdir<2) bombchuy = ((bdir*2)-1)*16;
            bombchu->X = Link->X+bombchux;
            bombchu->Y = Link->Y+bombchuy;
            bombchu->Step = bombchuspeed;
            Link->Action = LA_ATTACKING;
            Game->Counter[6]--;
            bombchuattack = 2;
        }else{
            bdir = Link->Dir;
            bombchux = 0; bombchuy = 0;
            if(bdir>1) bombchux = (((bdir-2)*2)-1)*16;
            if(bdir<2) bombchuy = ((bdir*2)-1)*16;
            lweapon explosion = Screen->CreateLWeapon(LW_SBOMB);
            explosion->X = Link->X+bombchux;
            explosion->Y = Link->Y+bombchuy;
            explosion->Damage = bombchudmg;
            Link->Action = 0;
            bombchuattack = 0;
        }
    }
    
    //Pegasus Boots functions
    void PegasusBoots(){
        if(!PegasusCollision){
            int loc = ComboAt(Link->X+8,Link->Y+8);
            //Check if Link should be dashing
            if(((StoreInput == 1 && !Link->InputA)
            || (StoreInput == 2 && !Link->InputB))
            || StoreHP < Link->HP
            || Screen->ComboT[loc] == CT_WATER){
                PegasusDash = false;
                DashCounter = 0;
            }
            //Stop all actions
            NoAction();
            //Movement
            if(DashCounter > 10){
                if(Link->Dir == 0 && DashCheck(Link->X+8,Link->Y+6,true) != 2){
                    Link->Y--;
                    Link->InputUp = true;
                }else if(Link->Dir == 1 && DashCheck(Link->X+8,Link->Y+18,true) != 2){
                    Link->Y++;
                    Link->InputDown = true;
                }else if(Link->Dir == 2 && DashCheck(Link->X,Link->Y+12,false) != 2){
                    Link->X--;
                    Link->InputLeft = true;
                }else if(Link->Dir == 3 && DashCheck(Link->X+16,Link->Y+12,false) != 2){
                    Link->X++;
                    Link->InputRight = true;
                }else{
                    PegasusCollision = true;
                    DashCounter = 0;
                }
            }
            //Break Pegasus Blocks
            if(ComboFI(Link->X+8,Link->Y+8,CF_DASH) && Screen->ComboS[loc] == 1111b){
                Screen->ComboD[loc]++;
                if(Screen->ComboF[loc] == CF_DASH) Screen->ComboF[loc] = 0;
                Game->PlaySound(SFX_PEGASUSBREAK);
            }
            //Dust tile animation
            lweapon Dust;
            if(DashCounter%4 == 0){
                for(int j=1;j<=Screen->NumLWeapons();j++){
                    Dust = Screen->LoadLWeapon(j);
                    if(Dust->ID != LW_SCRIPT10) continue;
                    if(Link->Dir < 1) Dust->Y-=3;
                    else if(Link->Dir < 2) Dust->Y+=3;
                    else if(Link->Dir < 3) Dust->X-=3;
                    else if(Link->Dir < 4) Dust->X+=3;
                }
                Dust = Screen->CreateLWeapon(LW_SCRIPT10);
                Dust->OriginalTile = T_DUST;
                Dust->CSet = DustCSet;
                Dust->Y = Link->Y;
                Dust->X = Link->X;
                Dust->NumFrames = DustAFrames;
                Dust->ASpeed = DustASpeed;
                Dust->DeadState = DustAFrames*DustASpeed;
            }
            //Play SFX
            if(DashCounter%DashSFXLength == 0) Game->PlaySound(SFX_DASH);
        }else{
            //Bounceback after hitting a wall
            NoAction();
            if(DashCounter == 1){
                Screen->ClearSprites(SL_LWPNS);
                Game->PlaySound(SFX_HITWALL);
                Screen->Quake = 10;
            }else if(DashCounter == 10){
                PegasusDash = false;
                PegasusCollision = false;
                DashCounter = 0;
            }
            if(Link->Dir == 0 && DashCheck(Link->X+8,Link->Y+6,true) == 0) Link->Y++;
            else if(Link->Dir == 1 && DashCheck(Link->X+8,Link->Y+18,true) == 0) Link->Y--;
            else if(Link->Dir == 2 && DashCheck(Link->X+18,Link->Y+8,false) == 0) Link->X++;
            else if(Link->Dir == 3 && DashCheck(Link->X-2,Link->Y+8,false) == 0) Link->X--;
            if(DashCounter < 5) Link->Z++;
        }
        DashCounter++;
    }
    //Check whether Link can dash onto a combo
    int DashCheck(int x, int y, bool xy){
     int xoffset; int yoffset;
     bool Solid;
     if(xy) xoffset = 4;
     else yoffset = 3;
     if(isSolid(x-xoffset,y-yoffset) || isSolid(x+xoffset,y+yoffset)) Solid = true;
     if(!Solid && !ComboFI(x-xoffset,y-yoffset,CF_DASH)
     && !ComboFI(x+xoffset,y+yoffset,CF_DASH)) return 0;
     else if(Solid && (ComboFI(x-xoffset,y-yoffset,CF_DASH)
     || ComboFI(x+xoffset,y+yoffset,CF_DASH))) return 1;
     else return 2;
    }
}
    //Fairy functions
    void Fairy(int ScreenNumber){
        ffc Fairy = Screen->LoadFFC(32);
        bool ChangeDir;
        if(FairyInit){
            Fairy->Flags[0] = true;
            Fairy->Flags[3] = true;
            Fairy->Data = CMB_FAIRY+1;
            FairyInit = false;
            Fairy->X = Rand(28) + Link->X-16;
            Fairy->Y = Rand(28) + Link->Y-16;
        }
        if(ScreenNumber != Game->GetCurScreen()){
            Fairy->X = Rand(28) + Link->X-16;
            Fairy->Y = Rand(28) + Link->Y-16;
        }
        if(FairyMovementCounter == FairyMovementMax){
            Fairy->Vx = (Rand(5)/10+0.4)*(Rand(2)*2-1);
            Fairy->Vy = (Rand(5)/10+0.4)*(Rand(2)*2-1);
            ChangeDir = true;
            FairyMovementCounter = 0;
        }
        if(Distance(Fairy->X,Fairy->Y,Link->X,Link->Y) > 32){
            if(Fairy->X < Link->X) Fairy->Vx = (Rand(5)/10+1);
            else Fairy->Vx = -(Rand(5)/10+1);
            if(Fairy->Y < Link->Y) Fairy->Vy = (Rand(5)/10+1);
            else Fairy->Vy = -(Rand(5)/10+1);
            ChangeDir = true;
        }
        if(ChangeDir){
            if(Fairy->Vy < 0 && (Abs(Fairy->Vx) < 0.6)) Fairy->Data = CMB_FAIRY;
            else if(Fairy->Vy > 0 && (Abs(Fairy->Vx) < 0.6)) Fairy->Data = CMB_FAIRY+1;
            else if(Fairy->Vx < 0) Fairy->Data = CMB_FAIRY+2;
            else if(Fairy->Vx > 0) Fairy->Data = CMB_FAIRY+3;
            ChangeDir = false;
        }
        FairyMovementCounter++;
    }
    
    //Beefster's Roll functions
    void Roll(){
        int i;
        Link->Jump = 2;
        RollCounter = 20;
        DustFrame = 1;
        for(i=0;i<5;i++){
            RollX[i] = -1;
            RollY[i] = -1;
        }
        Game->PlaySound(RollSFX);
        while(RollCounter > 0){
            Link->Z = 0;
            NoAction();
            if(RollCounter%2 == 0){
                if(Link->Dir < 2) RollX[0] = Link->X+2;
                else if(Link->Dir < 3) RollX[0] = Link->X;
                else RollX[0] = Link->X+4;
                RollY[0] = Link->Y;
                for(i=4;i>0;i--){
                    RollX[i] = RollX[i-1];
                    RollY[i] = RollY[i-1];
                }
                if(DustFrame >= 5){
                    RollX[0] = -1;
                    RollY[0] = -1;
                }
                DustFrame++;
            }
            for(i=0;i<5;i++) if(RollX[i] != -1 && RollY[i] != -1) Screen->DrawTile(2,RollX[i],RollY[i],DustTile+i,1,1,DustCSet,1,0,0,0,0,true,128);
            if(Link->Dir < 1){if(RollCheck(Link->X+8,Link->Y+6,Vertical)) Link->Y -= 2;}
            else if(Link->Dir < 2){if(RollCheck(Link->X+8,Link->Y+18,Vertical)) Link->Y += 2;}
            else if(Link->Dir < 3){if(RollCheck(Link->X,Link->Y+12,Horizontal)) Link->X -= 2;}
            else if(Link->Dir < 4){if(RollCheck(Link->X+16,Link->Y+12,Horizontal)) Link->X += 2;}
            
            RollCounter--;
        Waitframe();
        }
        Link->Jump = 0;
    }
    //Check whether Link can roll onto a tile
    bool RollCheck(int x, int y, bool xy){
     int xoffset; int yoffset;
     if(xy) xoffset = 4;
     else yoffset = 3;
     if(!isSolid(x-xoffset,y-yoffset) && !isSolid(x+xoffset,y+yoffset)
     && !ComboFI(x-xoffset,y-yoffset,F_NOROLL)
     && !ComboFI(x+xoffset,y+yoffset,F_NOROLL)) return true;
    }
    
    //Climbing functions
    void Climbing(bool before){
        if(before){
            if(OnLadder()){
                Link->InputA = false;
                Link->InputB = false;
                Link->InputL = false;
            }
        }else{
            if(OnLadder()) Link->Dir = 0;
        }
    }
    //Check whether Link is on a ladder combo
    bool OnLadder(){
     if(ComboFI(Link->X+8,Link->Y+8,F_LADDER) && Link->Z == 0) return true;
    }
}

global script slot_3{
    void run(){
        bombchuattack = 0;
    PegasusDash = false;
        PegasusCollision = false;
    }
}

item script bombchu{
    void run(){
        if(Game->Counter[6] > 0) bombchuattack = 1;
    }
}


item script PegasusBoots{
    void run(){
        if(Screen->ComboT[ComboAt(Link->X+8,Link->Y+8)] == CT_WATER
        || ComboFI(Link->X+8,Link->Y+8,CF_DASH)) Quit();
        PegasusDash = true;
        if(Link->InputB && !Link->InputA) StoreInput = 2;
        else if(Link->InputA && !Link->InputB) StoreInput = 1;
    }
}



there you go ;-)

Edited by Christian, 12 December 2008 - 05:02 PM.


#14 Joe123

Joe123

    Retired

  • Members

Posted 12 December 2008 - 05:40 PM

The one you did is fine, except that you copying over the brace after the part of the script containing the main chunk of the pegasus boot code (so the one that's not tabbed out at all), that'll make it not compile, and that you missed out copying in the part that says 'if(PegasusDash) PegasusBoots();' into the 'while' part of the global script.

Chris' won't work either, because he didn't get rid of that extra brace.

#15 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 12 December 2008 - 05:52 PM

I also forgot to take out that extra script where you check both flags and inherent flags. So if you delete that extra one also.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users