User Tag List

Results 1 to 2 of 2

Thread: Bridge Generator

  1. #1
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,142
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.56%

    Bridge Generator



    Code:
    ffc script BridgeGenerator {
        void run(int D, int delay, int snd) {
            int origD = this->Data;
            this->Data = 0;
            
            int myPos = ComboAt(this->X, this->Y);
            
            if(Screen->D[D] != 0) {
                int dir = GetDir(myPos);
                
                while(Screen->ComboF[myPos] != CF_SCRIPT2) {
                    
                    Screen->ComboD[myPos] = origD;
                    
                    if(dir == DIR_UP) {
                        this->Y -= 16;
                    } else if(dir == DIR_DOWN) {
                        this->Y += 16;
                    } else if(dir == DIR_LEFT) {
                        this->X -= 16;
                    } else if(dir == DIR_RIGHT) {
                        this->X += 16;
                    }
                    
                    if(this->X < 0 || this->X >= 256 || this-> Y < 0 || this->Y >= 176) break;
                    
                    myPos = ComboAt(this->X, this->Y);
                }
                
                return;
            }
            
            while(Screen->D[D] == 0) {
                Waitframe();
            }
            
            
            int dir = GetDir(myPos);
                
                while(Screen->ComboF[myPos] != CF_SCRIPT2) {
                    
                    Screen->ComboD[myPos] = origD;
                    
                    if(dir == DIR_UP) {
                        this->Y -= 16;
                    } else if(dir == DIR_DOWN) {
                        this->Y += 16;
                    } else if(dir == DIR_LEFT) {
                        this->X -= 16;
                    } else if(dir == DIR_RIGHT) {
                        this->X += 16;
                    }
                    
                    if(this->X < 0 || this->X >= 256 || this-> Y < 0 || this->Y >= 176) break;
                    
                    myPos = ComboAt(this->X, this->Y);
                    
                    if(snd != 0) Game->PlaySound(snd);
                    
                    Waitframes(delay);
                }
                
                return;
            
        }
        
        int GetDir(int pos) {
            if(Screen->ComboF[pos - 16] == CF_SCRIPT1) return DIR_UP;
            if(Screen->ComboF[pos + 16] == CF_SCRIPT1) return DIR_DOWN;
            if(Screen->ComboF[pos - 1] == CF_SCRIPT1) return DIR_LEFT;
            if(Screen->ComboF[pos + 1] == CF_SCRIPT1) return DIR_RIGHT;
            
            int s[] = "Hey idiot, try setting the flags on the bridge you just made!";
            TraceS(s);
            return DIR_UP;
        }
    }
    This script allows you to create bridges like those found in the Gameboy Zelda games that create themselves one tile at a time (eg, the bridge in Oracle of Ages just to the West of Lynna City). It is triggered by "listening" to one of the Screen->D variables, and properly handles the case where it's already been triggered before (eg, if Link leaves the screen, but comes back).

    Arguments:
    D0 - The Screen->D slot to listen to. It will activate the moment Screen->D[D] becomes non-zero
    D1 - How long to wait between bridge segments appearing.
    D2 - The sound effect to play when a bridge segment appears.

    Usage:
    This ranks a MEDIUM on the complexity scale.

    First, place an FFC on the spot where the bridge should start. Make its combo the combo of the bridge. Also, enable the "Run script at screen init" option to avoid graphical glitches.

    Next, you need to place two flags on the map. The first one should be "General Purpose 1", and should be placed immediately next to the FFC, in the direction you want the bridge to go. The second flag should be "General Purpose 2", and should be placed where you want the bridge to end. It should be placed just AFTER the last bridge tile (eg, one tile past). (imaging the bridge as a beam of light, and the flag as a wall blocking the beam of light)

    Check the video for details.

    When the bridge creates itself, it first looks for the first flag to know what direction to build in. If it doesn't find it, it will trace an error to Allegro.log, and default to UP. Then, it will build until it finds the second flag. If it doesn't find that, it will stop at the edge of the screen.
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  2. #2
    Octorok Christian's Avatar
    Join Date
    Dec 2008
    Age
    34
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    740
    Level
    9
    vBActivity - Bars
    Lv. Percent
    56.74%
    For some reason this doesn't seem to be working for me in Build 1346 do you mind fixing it?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social