Jump to content

Photo

Freeform Shutters

Global

  • This topic is locked This topic is locked
19 replies to this topic

#1 Fox

Fox

    Will the Hero rise again?

  • Members
  • Real Name:Scott
  • Gender:Male
  • Location:Southern California

Posted 07 March 2013 - 08:49 PM

Freeform Shutters


Description

This script allows you to place shutters manually on the screen wherever you want. No longer are you constricted to the door combo sets that place your doors at the center edge of your screen. These shutters will act like Z1 shutters - they'll push you into the screen and close behind you. They require no FFCs to set up - in fact, once the (extremely simple) combos are set up, all you need to do is put the shutter down and place a combo flag that determines the type of shutter. This script includes the following shutter types:
  • One-way shutters
  • Shutters that open after killing all enemies in the room
  • Shutters that open when temporary secrets (or tiered secrets) are triggered
  • Shutters that open after the permanent secret screen flag is set
  • Shutters that require another script to open
The end result is shutters you can place anywhere. They'll work exactly like Z1 shutters instead of the approximation you can get with trigger combos, and they're simpler to set up, too!

Screenshots and Demo

Images

Download the Demo
The demo will give you an idea of how it all works. Note that I've included an additional simple script in the demo to demonstrate shutters that are controlled by script. In the game, pressing both A and B at the same time will open "script shutters." Probably not the best use of the script shutters, but hopefully it conveys the possibilities. Be sure to look at the combo setup - I placed the shutter in favorite combos, so you can quickly scroll to it. It's simple - shutters always work in pairs: closed shutter, then open shutter.

Code

It's big, so download the code here.

Setup

I'll divide this section into four parts: setting up the script, setting up combos, placing the combos on the screen, and advanced shutters.

Script Setup
First, save the code above into a new text file called shutterControl.z.

Next, if you don't have any scripts at all this is simple. Just save the following as a new file and compile it in ZQuest:
script

Then assign the script to "Active" under Global. You're done, and can move on to part 2!

If you already have some scripts, then in your main script, just below any other imported files, add the line
import "shutterControl.z"

Next, in your global script, you should have an infinite loop. At the end of the infinite loop, just before waitFrame(), add the following lines:
shutterControl();
updatePrev();

Your global script should now look something like this. If you don't have a global script, you can go ahead and just take this one:
Global Script


Combo Setup
Set up your combos so that each closed-shutter combo is followed by an open-shutter combo. This is the case even for multiple-combo shutters - each closed combo in the shutter needs to be directly followed by an open shutter combo. See the screenshot above to see exactly what I mean.

The only other requirement is to select combo type "Script 1" for the closed shutter combos. Open shutter combos can be anything else or nothing at all - just not "Script 1."

Screen Placement
If you just place the shutters anywhere on the edges of the screen now, they'll work perfectly as enemy shutters. You can also place them away from the edge of the screen, but you need to place shutter "Script 1" combos from the edge where Link will enter the screen up through the shutters. See the demo for an example.

If you want different functionality, place combo flags on every shutter combo you want to change as follows:
  • Temporary Secrets open shutters: Combo Flag 98 (General Purpose 1)
  • Permanent Secret Screen State opens shutters: Combo Flag 99 (General Purpose 2)
  • One-Way Shutters: Combo Flag 100 (General Purpose 3)
  • Separate Script opens shutters: Combo Flag 101 (General Purpose 3)
Additionally, if you want the "Temporary Secrets Open Shutters" option, there's one last bit of setup - you'll need to place a "secret" flag on layer 1 in the top-left corner. These are flags 16-31. When secrets are triggered, this flag disappears, and the shutter notices and opens.

Advanced Shutters
Not really too advanced, but you can create shutters that open via other scripts. Each time you enter a room, the global bool "shutterFlag" is set to false. if any other script changes this variable to true, the "script shutters" - i.e., the shutters with combo flag 101 placed on them - will open. Note that this isn't permanent - each time you enter the room, the shutter will close.

Resources

Nothing that doesn't come bundled with ZC.

Acknowledgements

I want to thank LinktheMaster and Nick for their help on this project. LinktheMaster was patient with my billions of questions about ZScript throughout the entire writing process of the script. That's billions, with a 'b'. I was about two-thirds of the way through the script before I realized Nick had already done something very similar - his advice throughout was also extremely helpful. Thanks!
  • Keaton likes this

#2 Anthus

Anthus

    the wild-eyed boy from freecloud

  • Forum Moderators
  • Gender:Male
  • Location:Ohio

Posted 12 March 2013 - 01:02 PM

This is pretty cool. I think I'll give this a try. Paired with lock blocks, there's really no need to use NES rooms now icon_biggrin.gif

#3 Evan20000

Evan20000

    P͏҉ę͟w͜� ̢͝!

  • Members
  • Real Name:B̵̴̡̕a҉̵̷ņ̢͘͢͜n̷̷ę́͢d̢̨͟͞
  • Gender:Unspecified
  • Location:B̕҉̶͘͝a̶̵҉͝ǹ̵̛͘n̵e̸͜͜͢d҉̶

Posted 04 April 2013 - 12:52 PM

I'm probably doing something horribly wrong, but when I followed the instructions above it didn't work and it seems to be interfering with ghost. O_o

I stared at my script file for at least an hour comparing it to the one in the sample quest and I'm unsure what went wrong. icon_frown.gif

#4 Fox

Fox

    Will the Hero rise again?

  • Members
  • Real Name:Scott
  • Gender:Male
  • Location:Southern California

Posted 04 April 2013 - 10:47 PM

Your response that you're probably doing something horribly wrong is conflicting with my natural instinct to assume that I've coded something horribly wrong. We'll get to the bottom of this!

I've never used ghost, so it's possible there's a conflict somewhere. Could you give me some details about what's going wrong? Is the script even compiling? What errors are you getting? Can you show me exactly what you did?

#5 Evan20000

Evan20000

    P͏҉ę͟w͜� ̢͝!

  • Members
  • Real Name:B̵̴̡̕a҉̵̷ņ̢͘͢͜n̷̷ę́͢d̢̨͟͞
  • Gender:Unspecified
  • Location:B̕҉̶͘͝a̶̵҉͝ǹ̵̛͘n̵e̸͜͜͢d҉̶

Posted 05 April 2013 - 02:17 AM

I ended up putting
"import "shutterControl.z"
with the rest of my imports and put
"shutterControl();
updatePrev();"
before my waitframe.
I then put the .z file itself with the rest of my headers in a folder (I don't think this matters given that it compiled okay) that are imported (even though it's not a header).

I ended up eventually getting a ghost-friendly substitute shutter script, but I'm plenty willing to help you test and figure out what's going on.

As for the errors themselves, ghost simply doesn't run (Chain Chomps are immobile, stalfos walk like vanilla walking enemies) and whenever I walk off a screen and into a shutter, I'm greeted with a solid combo. I also hear the shutter SFX in odd locations (even in rooms without shutters).

#6 Saffith

Saffith

    IPv7 user

  • ZC Developers
  • Gender:Male

Posted 05 April 2013 - 07:12 AM

Did you start a new game after you loaded the script? I don't see another reason why it would cause problems.

#7 Evan20000

Evan20000

    P͏҉ę͟w͜� ̢͝!

  • Members
  • Real Name:B̵̴̡̕a҉̵̷ņ̢͘͢͜n̷̷ę́͢d̢̨͟͞
  • Gender:Unspecified
  • Location:B̕҉̶͘͝a̶̵҉͝ǹ̵̛͘n̵e̸͜͜͢d҉̶

Posted 05 April 2013 - 03:13 PM

Just retested with a fresh save file. It seems to be working. I should have tried that earlier. >_>

#8 Fox

Fox

    Will the Hero rise again?

  • Members
  • Real Name:Scott
  • Gender:Male
  • Location:Southern California

Posted 05 April 2013 - 04:15 PM

Thanks for helping, Saffith. I'm glad you were able to get it working, Evan. Let me know if you run into any other problems. icon_smile.gif

#9 -DuCkTApE-

-DuCkTApE-

    The "Mask" will take over...

  • Members
  • Gender:Male

Posted 17 April 2013 - 05:58 PM

I need help combining all of these bc i cant get it to work!

CODE
import "std.zh"

const int CT_SIDEVIEWLADDER =142; //The combo type for the ladder combo change it as you need. By default it's the Script 1 combo type.

ffc script SideView_Ladder
{
    void run(){
        while (true){
            int underlink=ComboAt(Link->X+8, Link->Y+15);
            if (Screen->ComboT[underlink]==CT_SIDEVIEWLADDER){
                Link->Jump=0;
                    if (Link->InputUp){
                        if ( Screen->isSolid(Link->X+1, Link->Y-1) == false &&  Screen->isSolid(Link->X+8, Link->Y-1) == false &&  
                        Screen->isSolid(Link->X+14, Link->Y-1) == false){
                            Link->Y-=1;  
                        }
                    }
                    else if (Link->InputDown){
                        if ( Screen->isSolid(Link->X+1, Link->Y+1) == false &&  Screen->isSolid(Link->X+8, Link->Y+1) == false &&  
                        Screen->isSolid(Link->X+14, Link->Y+1) == false ){  
                            Link->Y+=1;
                        }
                    }
            }
        Waitframe();
        }
    }
}

const int WSP_FALLING        = 88; //Weapon/Misc. sprite for Link falling down a hole
const int WSP_LAVA            = 89; //Weapon/Misc. sprite for Link drowning in lava
const int SFX_FALLING        = 62; //SFX for falling down a hole
const int SFX_LAVA            = 61; //SFX for drowning in lava
const int CMB_AUTOWARP        = 43; //Combo ID of a transparent AutoWarp A combotype

const int CT_HOLELAVA        = 11; //Combotype to give hole functionality to (default is Left Statue)

bool Falling;
ffc script HoleLava{
    void run(int lava, int warpto, int warptype, int damage){
        int graphic = WSP_FALLING; int sfx = SFX_FALLING;
        if(lava){ graphic = WSP_LAVA; sfx = SFX_LAVA; }
        if(this->X == 0 && this->Y == 0){
            Waitframes(5);
            this->X = Link->X; this->Y = Link->Y;
        }
        if(damage == 0) damage = 8;
    
        while(true){
            while(!OnPitCombo()) Waitframe();
            int pitclk = 0;
            while(OnPitCombo() && pitclk++ < 4) WaitCancelFeather();
            if(pitclk >= 5) Fall(this,sfx,graphic,damage,warpto,warptype);
        }
    }
    void Fall(ffc pos, int sfx, int graphic, int damage, int warpto, int warptype){
        Falling = true;
        Game->PlaySound(sfx);
        
        for(int i=1;i<=Screen->NumLWeapons();i++){
            lweapon l = Screen->LoadLWeapon(i);
            if(l->ID == LW_SWORD) l->DeadState = WDS_DEAD;
        }
        
        int wait = CreateGraphic(graphic);
        Link->CollDetection = false; Link->Invisible = true;
        for(int i=0;i<30;i++) WaitNoAction();
        Link->CollDetection = true; Link->Invisible = false;

        if(warpto) Warp(pos, warptype);

        Link->X = pos->X; Link->Y = pos->Y;
        Link->HP -= damage;
        Game->PlaySound(SFX_OUCH);
        Falling = false;
    }
    void Warp(ffc Warp, int warptype){
        int orig = Warp->Data;
        Warp->Data = CMB_AUTOWARP+warptype;
        Warp->Flags[FFCF_CARRYOVER] = true;
        Waitframe();
        Warp->Data = orig;
        Warp->Flags[FFCF_CARRYOVER] = false;
        Link->Z = Link->Y;
        Quit();
    }
    bool OnPitCombo(){
        return (Screen->ComboT[ComboAt(Link->X+8,Link->Y+8)] == CT_HOLELAVA && Link->Z <= 0 && Link->Action != LA_FROZEN);
    }
    int CreateGraphic(int sprite){
        lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);
        l->HitXOffset = 500;
        l->UseSprite(sprite);
        l->DeadState = l->NumFrames*l->ASpeed;
        l->X = Link->X; l->Y = Link->Y;
        return l->DeadState;
    }
    void WaitCancelFeather(){
        if(GetEquipmentA() == I_ROCSFEATHER && Link->InputA) Link->InputA = false;
        if(GetEquipmentB() == I_ROCSFEATHER && Link->InputB) Link->InputB = false;
        Waitframe();
    }
}

item script Message{
    void run(int m){
        Screen->Message(m);
    }
}

//Old version: supports only 4-piece heart containers
//Messages can be set automatically or manually
//D0 = First message
//D1-3 = Second-fourth messages; default to strings after D0
item script heartPieceMessageOld{
    void run (int m1, int m2, int m3, int m4){
        //Set m2-4 to follow m1 if not set explicitly
        if ( m2 == 0 ) m2 = m1+1;
        if ( m3 == 0 ) m3 = m1+2;
        if ( m4 == 0 ) m4 = m1+3;
        
        //Play the appropriate message
        if ( Game->Generic[GEN_HEARTPIECES] == 0 )
            Screen->Message(m1);
        if ( Game->Generic[GEN_HEARTPIECES] == 1 )
            Screen->Message(m2);
        if ( Game->Generic[GEN_HEARTPIECES] == 2 )
            Screen->Message(m3);
        if ( Game->Generic[GEN_HEARTPIECES] == 3 )
            Screen->Message(m4);
    }
}

//D0 = Midi to change to during battle
//D1 = Midi to change to after battle
//For both: 0 = stop music, 999 = DMap default, -1 = no change
ffc script bossMidi{
    void run(int bossMidNum, int afterMidNum){
        if ( bossMidNum == 999 ) //If midi ID is 999, use DMap default
            bossMidNum = Game->DMapMIDI[Game->GetCurDMap()];
        if ( afterMidNum == 999 )
            afterMidNum = Game->DMapMIDI[Game->GetCurDMap()];
        Waitframes(4); //Wait for enemies to appear
        if ( Screen->NumNPCs() && bossMidNum >= 0) //If there are enemies
            Game->PlayMIDI(bossMidNum); //Play boss music
        while ( Screen->NumNPCs() ) //Wait until it/they all die
            Waitframe();
        if ( afterMidNum >= 0 ) //Then play after battle music
            Game->PlayMIDI(afterMidNum);
    }
}

ffc script BigEnemy{
    void run(int enemyNum){
        Waitframes(4);
        npc n = Screen->LoadNPC(enemyNum);
        if(!n->isValid()) Quit();
        n->Extend = 3;
        n->HitWidth = 32;
        n->HitHeight = 32;
        n->TileWidth = 2;
        n->TileHeight = 2;
    }
}

global script shutters {
    void run() {
    while(true) {
            // other functions here...
        shutterControl();
        updatePrev();
        Waitframe();
    }
    }
}

ffc script real_npcV2 {
  void run(int m, int gmitem, int f, int d, int def_dir, int npcissolid, int gm_min, int gm_max) {
    int d_x;
    int d_y;
    int a_x;
    int a_y;
    int ir;
    int tho=(this->TileHeight*16-16);
    int orig_d = this->Data;
    int Apressed2;  
    int Appr2;
    int onscreenedge;
    if(d == 0) d = 48;
  
  
    while(true) {
        //This detects if link is on the edge of the screen
        if (Link->X<8 || Link->Y<8 || Link->X>232 || Link->Y>152){onscreenedge=1;} else {onscreenedge=0;}

        //This checks if you're above or below the NPC to create an overhead effect
        if (Link->Y<this->Y-8+tho && onscreenedge==0){this->Flags[FFCF_OVERLAY] = true;} else {this->Flags[FFCF_OVERLAY] = false;}

        //This detects if A was pressed, allowing you to exit messages with the A button
        if (Link->InputA)
        {
            if (Apressed2==1){Apressed2=0;}
        else
        {
            if (Appr2==0){Apressed2=1; Appr2=1;}}
        }
        else
        {
            Apressed2=0;
            Appr2=0;
        }

        d_x = this->X - Link->X;
        d_y = this->Y+(this->TileHeight*16-16) - Link->Y;
        a_x = Abs(d_x);
        a_y = Abs(d_y);
    
        if(f != 0) {
            if(a_x < d && a_y < d) {
                  if(a_x <= a_y) {
                    if(d_y >= 0) {
                          this->Data = orig_d + DIR_DOWN;
                    } else {
                        this->Data = orig_d + DIR_UP;
                    }
                } else {
                    if(d_x >= 0) {
                        this->Data = orig_d + DIR_LEFT;
                    } else {
                        this->Data = orig_d + DIR_RIGHT;
                    }
                  }
            } else {
                this->Data = orig_d + def_dir;
            }
        }
        
        //This checks if you have item D1, and makes the NPC disappear if you do.
        if (Link->Item[gmitem] == true){this->X=-256; this->Y=-256;}
        else
        {

            //This enables horizontal guard mode.
            if (gm_max>0)
            {
                if (Link->X>gm_min-32 && Link->X<gm_max+32 && Link->Y>this->Y+tho-32 && Link->Y<this->Y+tho+32) {ir=1;}
                else {ir=0;}
                if (Link->X<this->X-2 && this->X>gm_min && ir==1)
                {
                    if (Link->X>gm_min){this->Vx= (- this->X + Link->X)/4;}
                    else{this->Vx= (- this->X + gm_min)/4;}
                }
                if (Link->X>this->X+2 && this->X<gm_max && ir==1)
                {
                    if (Link->X<gm_max){this->Vx= (Link->X - this->X)/4;}
                    else{this->Vx= (gm_max - this->X)/4;}
                }
                if (Link->X<this->X+2 && Link->X>this->X-2){this->Vx=0;}
                if (ir==0){this->Vx=0;}
                if (this->X<gm_min+1){
                    if (this->Vx<0) this->Vx=0;
                        this->X=gm_min;
                }
                if (this->X>gm_max-1){
                    if (this->Vx>0) this->Vx=0;
                    this->X=gm_max;
            }
        }

        //This enables vertical guard mode.
        if (gm_max<0)
        {
            if (Link->Y>-gm_min-32 && Link->Y<-gm_max+32 && Link->X>this->X-32 && Link->X<this->X+32) {ir=1;}
            else {ir=0;}
            if (Link->Y<this->Y-2+tho && this->Y+tho>-gm_min && ir==1)
            {
                if (Link->Y>-gm_min){this->Vy= (- this->Y-tho + Link->Y)/4;}
                else {this->Vy= (- this->Y-tho + -gm_min)/4;}
            }
            if (Link->Y>this->Y+2+tho && this->Y+tho<-gm_max && ir==1)
            {
                if (Link->Y<-gm_max){this->Vy= (Link->Y - this->Y-tho)/4;}
                else {this->Vy= (-gm_max - this->Y-tho)/4;}
            }
                if (Link->Y<this->Y+2+tho && Link->Y>this->Y-2+tho){this->Vy=0;}
                if (ir==0){this->Vy=0;}
                if (this->Y+tho<-gm_min+1){
                    if (this->Vy<0)this->Vy=0;
                    this->Y=-gm_min-tho;
                }
                if (this->Y+tho>-gm_max-1){
                    if (this->Vy>0)this->Vy=0;
                    this->Y=-gm_max-tho;
                }
            }

        }

        if (this->Vy>0)this->Data = orig_d + DIR_UP;
        if (this->Vy<0)this->Data = orig_d + DIR_DOWN;
        if (this->Vx>0)this->Data = orig_d + DIR_RIGHT;
        if (this->Vx<0)this->Data = orig_d + DIR_LEFT;
    
        if(Apressed2==1 && a_x < 24 && a_y < 24) {
            //This is all checking if Link is facing the NPC while to the left, to the right, above, or below the NPC
            if (Link->X<this->X-8 && Link->Y>this->Y+tho-12 && Link->Y<this->Y+tho+8 && Link->Dir == DIR_RIGHT || Link->X>this->X+8 && Link->Y>this->Y+tho-12 && Link->Y<this->Y+tho+8 && Link->Dir == DIR_LEFT || Link->Y<this->Y+tho-8 && Link->X>this->X-8 && Link->X<this->X+8 && Link->Dir == DIR_DOWN || Link->Y>this->Y+tho+8 && Link->X>this->X-8 && Link->X<this->X+8 && Link->Dir == DIR_UP){
                Apressed2=0;
                Screen->Message(m);
                Link->InputA = false;
            }
        }

        //This enables the NPC to be solid without having to lay a solid combo under it.
        if (npcissolid>0){
            if ((Abs(Link->X - this->X) < 10) &&
                (Link->Y <= this->Y+tho + 12) && (Link->Y > this->Y+tho+8)){Link->Y = this->Y+tho+12;}
            
            if ((Abs(Link->Y - this->Y-tho) < 10) &&
                (Link->X >= this->X - 12) && (Link->X < this->X-8)){Link->X = this->X-12;}
        
            if ((Abs(Link->X - this->X) < 10) &&
                (Link->Y >= this->Y+tho - 12) && (Link->Y < this->Y+tho-8)){Link->Y = this->Y+tho-12;}
        
            if ((Abs(Link->Y - this->Y-tho) < 10) &&
                (Link->X <= this->X + 12) && (Link->X > this->X+8)){Link->X = this->X+12;}
        }
        
        Waitframe();
    }
  }
}

ffc script FFCJumpCliff{

    void run(int verticalmovement, int horizontalmovement, int directiontopress) {
    
        int directiontopressmoreleft;
        int directiontopressmoreright;
        int LinkHmovementdone = 0;
        bool ffcsentlinkjumping = false;
    
        if (directiontopress==DIR_DOWN) {
            directiontopressmoreleft = DIR_RIGHTDOWN;
            directiontopressmoreright = DIR_LEFTDOWN;
        }
    
        else {
            if (directiontopress==DIR_UP) {
                directiontopressmoreleft = DIR_LEFTUP;
                directiontopressmoreright = DIR_RIGHTUP;
            }
            else {
                if (directiontopress==DIR_LEFT) {
                    directiontopressmoreleft = DIR_LEFTDOWN;
                    directiontopressmoreright = DIR_LEFTUP;
                }
                else {
                    if (directiontopress==DIR_RIGHT) {
                        directiontopressmoreleft = DIR_RIGHTUP;
                        directiontopressmoreright = DIR_RIGHTDOWN;
                    }
                    else {
                        if (directiontopress==DIR_LEFTDOWN) {
                            directiontopressmoreleft = DIR_DOWN;
                            directiontopressmoreright = DIR_LEFT;
                        }
                        else {
                            if (directiontopress==DIR_RIGHTDOWN) {
                                directiontopressmoreleft = DIR_RIGHT;
                                directiontopressmoreright = DIR_DOWN;
                            }
                            else {
                                if (directiontopress==DIR_LEFTUP) {
                                    directiontopressmoreleft = DIR_LEFT;
                                    directiontopressmoreright = DIR_UP;
                                }
                                else {
                                    if (directiontopress==DIR_RIGHTUP) {
                                        directiontopressmoreleft = DIR_UP;
                                        directiontopressmoreright = DIR_RIGHT;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }


        while (true){
    
            if (Link->Z==0) {
                LinkHmovementdone=0;
                ffcsentlinkjumping = false;
            }
    
            if ( (ffcsentlinkjumping)&&(LinkHmovementdone<Abs(horizontalmovement)) ) {
                if (horizontalmovement<0) {Link->X--;}
                if (horizontalmovement>0) {Link->X++;}
                LinkHmovementdone++;
            }
    
            if ( (LinkCollision(this))
                && ( (Link->Dir==directiontopress)
                ||(Link->Dir==directiontopressmoreleft)
                ||(Link->Dir==directiontopressmoreright) ) ) {
                
                if (Link->Z==0) Game->PlaySound(SFX_JUMP);
                ffcsentlinkjumping=true;
                Link->Y=Link->Y+verticalmovement;
                Link->Z=Link->Z+verticalmovement;
            }
            
            Waitframe();
        }
    }
}


It worked all fine until i added this script. Is it in wrong?

#10 Fox

Fox

    Will the Hero rise again?

  • Members
  • Real Name:Scott
  • Gender:Male
  • Location:Southern California

Posted 17 April 2013 - 08:46 PM

When you are having problems, it helps to diagnose what's going wrong when you write the actual error message you're getting.

That said, it doesn't look like you're importing shutterControl.z. Under the "Code" subsection, I gave a download link to this file. Make sure it's in the same folder as your main script file. Then, at the top of the file you just pasted here, just under the line
CODE
import "std.zh"

add the line
CODE
import "shutterControl.z"


If that doesn't work, please let me know what kind of error you get when you try to compile.

#11 -DuCkTApE-

-DuCkTApE-

    The "Mask" will take over...

  • Members
  • Gender:Male

Posted 21 April 2013 - 07:37 AM

It says,

PASS 1: PARSING
PASS 2: PREPROCESSING
CAN'T OPEN IMPUT FILE
TMP, LINE 2: ERROR PO1 : FAILURE TO PARSE IMPORTED FILE SHUTTERCONTROL.Z.

import "std.zh"
import "shutterControl.z"
global script shutters {
void run() {
	 while(true) {
		 shutterControl();
		 updatePrev();
		 Waitframe();
	 }
}
}
const int CT_SIDEVIEWLADDER =142; //The combo type for the ladder combo change it as you need. By default it's the Script 1 combo type.
ffc script SideView_Ladder
{
void run(){
	 while (true){
		 int underlink=ComboAt(Link->X+8, Link->Y+15);
		 if (Screen->ComboT[underlink]==CT_SIDEVIEWLADDER){
			 Link->Jump=0;
				 if (Link->InputUp){
					 if ( Screen->isSolid(Link->X+1, Link->Y-1) == false && Screen->isSolid(Link->X+8, Link->Y-1) == false &&
					 Screen->isSolid(Link->X+14, Link->Y-1) == false){
						 Link->Y-=1;
					 }
				 }
				 else if (Link->InputDown){
					 if ( Screen->isSolid(Link->X+1, Link->Y+1) == false && Screen->isSolid(Link->X+8, Link->Y+1) == false &&
					 Screen->isSolid(Link->X+14, Link->Y+1) == false ){
						 Link->Y+=1;
					 }
				 }
		 }
	 Waitframe();
	 }
}
}
const int WSP_FALLING	 = 88; //Weapon/Misc. sprite for Link falling down a hole
const int WSP_LAVA		 = 89; //Weapon/Misc. sprite for Link drowning in lava
const int SFX_FALLING	 = 62; //SFX for falling down a hole
const int SFX_LAVA		 = 61; //SFX for drowning in lava
const int CMB_AUTOWARP	 = 43; //Combo ID of a transparent AutoWarp A combotype
const int CT_HOLELAVA	 = 11; //Combotype to give hole functionality to (default is Left Statue)
bool Falling;
ffc script HoleLava{
void run(int lava, int warpto, int warptype, int damage){
	 int graphic = WSP_FALLING; int sfx = SFX_FALLING;
	 if(lava){ graphic = WSP_LAVA; sfx = SFX_LAVA; }
	 if(this->X == 0 && this->Y == 0){
		 Waitframes(5);
		 this->X = Link->X; this->Y = Link->Y;
	 }
	 if(damage == 0) damage = 8;

	 while(true){
		 while(!OnPitCombo()) Waitframe();
		 int pitclk = 0;
		 while(OnPitCombo() && pitclk++ < 4) WaitCancelFeather();
		 if(pitclk >= 5) Fall(this,sfx,graphic,damage,warpto,warptype);
	 }
}
void Fall(ffc pos, int sfx, int graphic, int damage, int warpto, int warptype){
	 Falling = true;
	 Game->PlaySound(sfx);
	
	 for(int i=1;i<=Screen->NumLWeapons();i++){
		 lweapon l = Screen->LoadLWeapon(i);
		 if(l->ID == LW_SWORD) l->DeadState = WDS_DEAD;
	 }
	
	 int wait = CreateGraphic(graphic);
	 Link->CollDetection = false; Link->Invisible = true;
	 for(int i=0;i<30;i++) WaitNoAction();
	 Link->CollDetection = true; Link->Invisible = false;
	 if(warpto) Warp(pos, warptype);
	 Link->X = pos->X; Link->Y = pos->Y;
	 Link->HP -= damage;
	 Game->PlaySound(SFX_OUCH);
	 Falling = false;
}
void Warp(ffc Warp, int warptype){
	 int orig = Warp->Data;
	 Warp->Data = CMB_AUTOWARP+warptype;
	 Warp->Flags[FFCF_CARRYOVER] = true;
	 Waitframe();
	 Warp->Data = orig;
	 Warp->Flags[FFCF_CARRYOVER] = false;
	 Link->Z = Link->Y;
	 Quit();
}
bool OnPitCombo(){
	 return (Screen->ComboT[ComboAt(Link->X+8,Link->Y+8)] == CT_HOLELAVA && Link->Z <= 0 && Link->Action != LA_FROZEN);
}
int CreateGraphic(int sprite){
	 lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);
	 l->HitXOffset = 500;
	 l->UseSprite(sprite);
	 l->DeadState = l->NumFrames*l->ASpeed;
	 l->X = Link->X; l->Y = Link->Y;
	 return l->DeadState;
}
void WaitCancelFeather(){
	 if(GetEquipmentA() == I_ROCSFEATHER && Link->InputA) Link->InputA = false;
	 if(GetEquipmentB() == I_ROCSFEATHER && Link->InputB) Link->InputB = false;
	 Waitframe();
}
}
item script Message{
void run(int m){
	 Screen->Message(m);
}
}
//Old version: supports only 4-piece heart containers
//Messages can be set automatically or manually
//D0 = First message
//D1-3 = Second-fourth messages; default to strings after D0
item script heartPieceMessageOld{
void run (int m1, int m2, int m3, int m4){
	 //Set m2-4 to follow m1 if not set explicitly
	 if ( m2 == 0 ) m2 = m1+1;
	 if ( m3 == 0 ) m3 = m1+2;
	 if ( m4 == 0 ) m4 = m1+3;
	
	 //Play the appropriate message
	 if ( Game->Generic[GEN_HEARTPIECES] == 0 )
		 Screen->Message(m1);
	 if ( Game->Generic[GEN_HEARTPIECES] == 1 )
		 Screen->Message(m2);
	 if ( Game->Generic[GEN_HEARTPIECES] == 2 )
		 Screen->Message(m3);
	 if ( Game->Generic[GEN_HEARTPIECES] == 3 )
		 Screen->Message(m4);
}
}
//D0 = Midi to change to during battle
//D1 = Midi to change to after battle
//For both: 0 = stop music, 999 = DMap default, -1 = no change
ffc script bossMidi{
void run(int bossMidNum, int afterMidNum){
	 if ( bossMidNum == 999 ) //If midi ID is 999, use DMap default
		 bossMidNum = Game->DMapMIDI[Game->GetCurDMap()];
	 if ( afterMidNum == 999 )
		 afterMidNum = Game->DMapMIDI[Game->GetCurDMap()];
	 Waitframes(4); //Wait for enemies to appear
	 if ( Screen->NumNPCs() && bossMidNum >= 0) //If there are enemies
		 Game->PlayMIDI(bossMidNum); //Play boss music
	 while ( Screen->NumNPCs() ) //Wait until it/they all die
		 Waitframe();
	 if ( afterMidNum >= 0 ) //Then play after battle music
		 Game->PlayMIDI(afterMidNum);
}
}
ffc script BigEnemy{
void run(int enemyNum){
	 Waitframes(4);
	 npc n = Screen->LoadNPC(enemyNum);
	 if(!n->isValid()) Quit();
	 n->Extend = 3;
	 n->HitWidth = 32;
	 n->HitHeight = 32;
	 n->TileWidth = 2;
	 n->TileHeight = 2;
}
}
ffc script real_npcV2 {
void run(int m, int gmitem, int f, int d, int def_dir, int npcissolid, int gm_min, int gm_max) {
int d_x;
int d_y;
int a_x;
int a_y;
int ir;
int tho=(this->TileHeight*16-16);
int orig_d = this->Data;
int Apressed2;
int Appr2;
int onscreenedge;
if(d == 0) d = 48;


while(true) {
	 //This detects if link is on the edge of the screen
	 if (Link->X<8 || Link->Y<8 || Link->X>232 || Link->Y>152){onscreenedge=1;} else {onscreenedge=0;}
	 //This checks if you're above or below the NPC to create an overhead effect
	 if (Link->Y<this->Y-8+tho && onscreenedge==0){this->Flags[FFCF_OVERLAY] = true;} else {this->Flags[FFCF_OVERLAY] = false;}
	 //This detects if A was pressed, allowing you to exit messages with the A button
	 if (Link->InputA)
	 {
		 if (Apressed2==1){Apressed2=0;}
	 else
	 {
		 if (Appr2==0){Apressed2=1; Appr2=1;}}
	 }
	 else
	 {
		 Apressed2=0;
		 Appr2=0;
	 }
	 d_x = this->X - Link->X;
	 d_y = this->Y+(this->TileHeight*16-16) - Link->Y;
	 a_x = Abs(d_x);
	 a_y = Abs(d_y);
	
	 if(f != 0) {
		 if(a_x < d && a_y < d) {
				 if(a_x <= a_y) {
				 if(d_y >= 0) {
						 this->Data = orig_d + DIR_DOWN;
				 } else {
					 this->Data = orig_d + DIR_UP;
				 }
			 } else {
				 if(d_x >= 0) {
					 this->Data = orig_d + DIR_LEFT;
				 } else {
					 this->Data = orig_d + DIR_RIGHT;
				 }
				 }
		 } else {
			 this->Data = orig_d + def_dir;
		 }
	 }
	
	 //This checks if you have item D1, and makes the NPC disappear if you do.
	 if (Link->Item[gmitem] == true){this->X=-256; this->Y=-256;}
	 else
	 {
		 //This enables horizontal guard mode.
		 if (gm_max>0)
		 {
			 if (Link->X>gm_min-32 && Link->X<gm_max+32 && Link->Y>this->Y+tho-32 && Link->Y<this->Y+tho+32) {ir=1;}
			 else {ir=0;}
			 if (Link->X<this->X-2 && this->X>gm_min && ir==1)
			 {
				 if (Link->X>gm_min){this->Vx= (- this->X + Link->X)/4;}
				 else{this->Vx= (- this->X + gm_min)/4;}
			 }
			 if (Link->X>this->X+2 && this->X<gm_max && ir==1)
			 {
				 if (Link->X<gm_max){this->Vx= (Link->X - this->X)/4;}
				 else{this->Vx= (gm_max - this->X)/4;}
			 }
			 if (Link->X<this->X+2 && Link->X>this->X-2){this->Vx=0;}
			 if (ir==0){this->Vx=0;}
			 if (this->X<gm_min+1){
				 if (this->Vx<0) this->Vx=0;
					 this->X=gm_min;
			 }
			 if (this->X>gm_max-1){
				 if (this->Vx>0) this->Vx=0;
				 this->X=gm_max;
		 }
	 }
	 //This enables vertical guard mode.
	 if (gm_max<0)
	 {
		 if (Link->Y>-gm_min-32 && Link->Y<-gm_max+32 && Link->X>this->X-32 && Link->X<this->X+32) {ir=1;}
		 else {ir=0;}
		 if (Link->Y<this->Y-2+tho && this->Y+tho>-gm_min && ir==1)
		 {
			 if (Link->Y>-gm_min){this->Vy= (- this->Y-tho + Link->Y)/4;}
			 else {this->Vy= (- this->Y-tho + -gm_min)/4;}
		 }
		 if (Link->Y>this->Y+2+tho && this->Y+tho<-gm_max && ir==1)
		 {
			 if (Link->Y<-gm_max){this->Vy= (Link->Y - this->Y-tho)/4;}
			 else {this->Vy= (-gm_max - this->Y-tho)/4;}
		 }
			 if (Link->Y<this->Y+2+tho && Link->Y>this->Y-2+tho){this->Vy=0;}
			 if (ir==0){this->Vy=0;}
			 if (this->Y+tho<-gm_min+1){
				 if (this->Vy<0)this->Vy=0;
				 this->Y=-gm_min-tho;
			 }
			 if (this->Y+tho>-gm_max-1){
				 if (this->Vy>0)this->Vy=0;
				 this->Y=-gm_max-tho;
			 }
		 }
	 }
	 if (this->Vy>0)this->Data = orig_d + DIR_UP;
	 if (this->Vy<0)this->Data = orig_d + DIR_DOWN;
	 if (this->Vx>0)this->Data = orig_d + DIR_RIGHT;
	 if (this->Vx<0)this->Data = orig_d + DIR_LEFT;
	
	 if(Apressed2==1 && a_x < 24 && a_y < 24) {
		 //This is all checking if Link is facing the NPC while to the left, to the right, above, or below the NPC
		 if (Link->X<this->X-8 && Link->Y>this->Y+tho-12 && Link->Y<this->Y+tho+8 && Link->Dir == DIR_RIGHT || Link->X>this->X+8 && Link->Y>this->Y+tho-12 && Link->Y<this->Y+tho+8 && Link->Dir == DIR_LEFT || Link->Y<this->Y+tho-8 && Link->X>this->X-8 && Link->X<this->X+8 && Link->Dir == DIR_DOWN || Link->Y>this->Y+tho+8 && Link->X>this->X-8 && Link->X<this->X+8 && Link->Dir == DIR_UP){
			 Apressed2=0;
			 Screen->Message(m);
			 Link->InputA = false;
		 }
	 }
	 //This enables the NPC to be solid without having to lay a solid combo under it.
	 if (npcissolid>0){
		 if ((Abs(Link->X - this->X) < 10) &&
			 (Link->Y <= this->Y+tho + 12) && (Link->Y > this->Y+tho+ <img src='http://www.purezc.com/forums/public/style_emoticons/<#EMO_DIR#>/icon_cool.gif' class='bbc_emoticon' alt='8)' />){Link->Y = this->Y+tho+12;}
		
		 if ((Abs(Link->Y - this->Y-tho) < 10) &&
			 (Link->X >= this->X - 12) && (Link->X < this->X- <img src='http://www.purezc.com/forums/public/style_emoticons/<#EMO_DIR#>/icon_cool.gif' class='bbc_emoticon' alt='8)' />){Link->X = this->X-12;}
	
		 if ((Abs(Link->X - this->X) < 10) &&
			 (Link->Y >= this->Y+tho - 12) && (Link->Y < this->Y+tho- <img src='http://www.purezc.com/forums/public/style_emoticons/<#EMO_DIR#>/icon_cool.gif' class='bbc_emoticon' alt='8)' />){Link->Y = this->Y+tho-12;}
	
		 if ((Abs(Link->Y - this->Y-tho) < 10) &&
			 (Link->X <= this->X + 12) && (Link->X > this->X+ <img src='http://www.purezc.com/forums/public/style_emoticons/<#EMO_DIR#>/icon_cool.gif' class='bbc_emoticon' alt='8)' />){Link->X = this->X+12;}
	 }
	
	 Waitframe();
}
}
}
ffc script FFCJumpCliff{
void run(int verticalmovement, int horizontalmovement, int directiontopress) {

	 int directiontopressmoreleft;
	 int directiontopressmoreright;
	 int LinkHmovementdone = 0;
	 bool ffcsentlinkjumping = false;

	 if (directiontopress==DIR_DOWN) {
		 directiontopressmoreleft = DIR_RIGHTDOWN;
		 directiontopressmoreright = DIR_LEFTDOWN;
	 }

	 else {
		 if (directiontopress==DIR_UP) {
			 directiontopressmoreleft = DIR_LEFTUP;
			 directiontopressmoreright = DIR_RIGHTUP;
		 }
		 else {
			 if (directiontopress==DIR_LEFT) {
				 directiontopressmoreleft = DIR_LEFTDOWN;
				 directiontopressmoreright = DIR_LEFTUP;
			 }
			 else {
				 if (directiontopress==DIR_RIGHT) {
					 directiontopressmoreleft = DIR_RIGHTUP;
					 directiontopressmoreright = DIR_RIGHTDOWN;
				 }
				 else {
					 if (directiontopress==DIR_LEFTDOWN) {
						 directiontopressmoreleft = DIR_DOWN;
						 directiontopressmoreright = DIR_LEFT;
					 }
					 else {
						 if (directiontopress==DIR_RIGHTDOWN) {
							 directiontopressmoreleft = DIR_RIGHT;
							 directiontopressmoreright = DIR_DOWN;
						 }
						 else {
							 if (directiontopress==DIR_LEFTUP) {
								 directiontopressmoreleft = DIR_LEFT;
								 directiontopressmoreright = DIR_UP;
							 }
							 else {
								 if (directiontopress==DIR_RIGHTUP) {
									 directiontopressmoreleft = DIR_UP;
									 directiontopressmoreright = DIR_RIGHT;
								 }
							 }
						 }
					 }
				 }
			 }
		 }
	 }

	 while (true){

		 if (Link->Z==0) {
			 LinkHmovementdone=0;
			 ffcsentlinkjumping = false;
		 }

		 if ( (ffcsentlinkjumping)&&(LinkHmovementdone<Abs(horizontalmovement)) ) {
			 if (horizontalmovement<0) {Link->X--;}
			 if (horizontalmovement>0) {Link->X++;}
			 LinkHmovementdone++;
		 }

		 if ( (LinkCollision(this))
			 && ( (Link->Dir==directiontopress)
			 ||(Link->Dir==directiontopressmoreleft)
			 ||(Link->Dir==directiontopressmoreright) ) ) {
			
			 if (Link->Z==0) Game->PlaySound(SFX_JUMP);
			 ffcsentlinkjumping=true;
			 Link->Y=Link->Y+verticalmovement;
			 Link->Z=Link->Z+verticalmovement;
		 }
		
		 Waitframe();
	 }
}
}

Edited by -DuCkTApE-, 21 April 2013 - 07:48 AM.


#12 Fox

Fox

    Will the Hero rise again?

  • Members
  • Real Name:Scott
  • Gender:Male
  • Location:Southern California

Posted 21 April 2013 - 03:55 PM

It says,

PASS 1: PARSING
PASS 2: PREPROCESSING
CAN'T OPEN IMPUT FILE
TMP, LINE 2: ERROR PO1 : FAILURE TO PARSE IMPORTED FILE SHUTTERCONTROL.Z.


When it says "Failure to parse imported file shutterControl.z", it means it's having trouble opening that file. Have you downloaded the script? It's included as a link under the "code" section. It needs to go into your ZC directory. It also needs to be named shutterControl.z (and note this is case-sensitive). This is NOT the global script you've already included in your main file - this is another script entirely. Let me know if you've done this.

#13 -DuCkTApE-

-DuCkTApE-

    The "Mask" will take over...

  • Members
  • Gender:Male

Posted 21 April 2013 - 04:54 PM

That fixed it! :D Thanks!

#14 Keaton

Keaton

    Someone's post is being read.

  • Members
  • Real Name:Someone Else
  • Gender:Male
  • Location:Somewhere

Posted 24 April 2013 - 01:43 PM

This is beautiful. Thank you!
You should provide the A+B script. That'd be a neat puzzle to throw in a quest.

Edited by Someone, 24 April 2013 - 01:46 PM.


#15 Kyle

Kyle

    Initiate

  • Members
  • Real Name:Kyle
  • Gender:Male
  • Location:CA

Posted 19 January 2014 - 11:50 AM

Is there a way to make 2x3 doors with this script?





Also tagged with one or more of these keywords: Global

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users