User Tag List

Results 1 to 6 of 6

Thread: Multiblock Trigger

  1. #1
    Wizrobe C-Dawg's Avatar
    Join Date
    Jan 2002
    Posts
    4,205
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,630
    Level
    25
    vBActivity - Bars
    Lv. Percent
    2.86%

    Multiblock Trigger

    Thanks to Saffith for helping finalize and debug this one.

    This is utility script, pretty well described by the in-code comments.

    NOTE: You must specify locations for your blocks using the upper-left corner of the tile.

    Code:
    // ===============================================
    // multiblock_trigger - This FFC will change combo
    // depending on whether certain combos on Layer 0
    // are unwalkable.  As input, this FFC takes eight
    // integers which represent four (X,Y) pairs that the
    // multiblock checks for walkability.  When all are
    // unwalkable, the combo of this FFC will increase by
    // one and a secret noise will chime.  When any are 
    // walkable, they will revert back to their original
    // combo and not make a chime.  By default, the original
    // combo used by this FFC mimics unwalkability.
    // 
    // USE - You can use the multiblock trigger to require
    // Link to push up to four blocks into position.  For
    // less than four, just set all of the inputs to permanently
    // unwalkable combos, like a dungeon wall, or set them
    // all to the same location.  Because this FFC reverts
    // when the tiles are not walkable, it can also be used
    // to create "pressure-sensitive" triggers that must be
    // held down by a block and will deactive when the block
    // moves away.
    // ===============================================
    	
    ffc script multiblock_trigger{
    
    	// CONSTANTS - Change to change this FFC's behavior
    
    	int walkable = 1;	// Whether or not the starting
    				// combo for this FFC is walkable
    				// or not.  For instance, a closed
    				// door should start unwalkable.
    				// 0 = walkable
    				// 1 = unwalkable
    
    	// VARIABLES - Do not change!
    
    	int state = 0;		// Current state of the FFC.
    					// 0 = untriggered
    					// 1 = triggered
    
    	void run (int block1_x, int block1_y, int block2_x, int block2_y, 
    	int block3_x, int block3_y,int block4_x, int block4_y){
    
                    state = 0;
    
    		while(true){
    
    			if(state == 0){
    		
    
    				// Check to see if all blocks in position
    				if (!canMove(block1_x, block1_y) && 
    				!canMove(block2_x, block2_y) &&
    				!canMove(block3_x, block3_y) &&
    				!canMove(block4_x, block4_y)){
    				
    					this->Data = this->Data + 1;
    					Game->PlaySound(27);
    					state = 1;
    				}
    				
    				// Simulate unwalkability 
    				if(walkable == 1){
    
    					if( (Link->InputUp) && (Link->Y < this->Y + 16) &&
    					(Abs(Link->X - this->X) < 16) &&
    					(Link->Y > this->Y)){Link->InputUp = false;}
    				
    					if( (Link->InputDown) && (Link->Y > this->Y - 16) &&
    					(Abs(Link->X - this->X) < 16) &&
    					(Link->Y < this->Y)){Link->InputDown = false;}
    
    					
    					if( (Link->InputLeft) && (Link->X < this->X + 16) &&
    					(Abs(Link->Y - this->Y) < 16) &&
    					(Link->X > this->X)){Link->InputLeft = false;}
    				
    					if( (Link->InputRight) && (Link->X > this->X - 16) &&
    					(Abs(Link->Y - this->Y) < 16) &&
    					(Link->X < this->X)){Link->InputRight = false;}
    				}
    			
    			} // end of state 0
    
    			if (state == 1){
    
    				// Check to see if a block has moved
    				if (canMove(block1_x, block1_y) || 
    				canMove(block2_x, block2_y) ||
    				canMove(block3_x, block3_y) ||
    				canMove(block4_x, block4_y)){
    				
    					this->Data = this->Data - 1;
    					state = 0;
    				}
    
    			} // end of state 1
    
    		Waitframe();
    
    		} // end of while loop
    
    	} // end of void run
    
    	// Collision Detection Function (Thanks Saffith!)
    	bool canMove(int x, int y)
    	{
    		if(x<0 || x>240 || y<0 || y>160)
    			return false;
    		
    		return Screen->ComboS[y+(x>>4)]==0;
    	}
    
    } // end of ffc script

  2. #2
    Developer
    ZC Developer

    Join Date
    Aug 2006
    Location
    Australia
    Age
    37
    Posts
    2,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,869
    Level
    25
    vBActivity - Bars
    Lv. Percent
    40.66%

    Re: Multiblock Trigger

    This doesn't seem to do anything that can't already be done using the current secret tile system. See room [9,33] in NeoFirst for an example that not only uses four blocks, but also requires that they be pushed in a certain order.

  3. #3
    Wizrobe C-Dawg's Avatar
    Join Date
    Jan 2002
    Posts
    4,205
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,630
    Level
    25
    vBActivity - Bars
    Lv. Percent
    2.86%

    Re: Multiblock Trigger

    Quote Originally Posted by _L_ View Post
    This doesn't seem to do anything that can't already be done using the current secret tile system. See room [9,33] in NeoFirst for an example that not only uses four blocks, but also requires that they be pushed in a certain order.
    The script is more versitile than tiered secrets. Using the script, you don't have to require that the player push the blocks in a particular order, you can allow the player to push blocks over triggers to reach other triggers (ala soboken puzzles) and the door opens only as long as all blocks are in position.

    Unless I'm missing something about singular flags and their uses, this script is necessary to create certain kinds of block puzzles.

  4. #4
    Developer
    ZC Developer

    Join Date
    Aug 2006
    Location
    Australia
    Age
    37
    Posts
    2,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,869
    Level
    25
    vBActivity - Bars
    Lv. Percent
    40.66%

    Re: Multiblock Trigger

    Very well then. I suppose I'll endorse it. (Though I'm not entirely unsure that unordered four-block gates are possible with secrets.)

  5. #5
    Wizrobe C-Dawg's Avatar
    Join Date
    Jan 2002
    Posts
    4,205
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,630
    Level
    25
    vBActivity - Bars
    Lv. Percent
    2.86%

    Re: Multiblock Trigger

    Additionally, L, once they get multiple FFC + scripts working together instead of going apeshit, you can set different blocks to different doors. For instance, you push the block onto the blue trigger, the blue blocks go down. On the red trigger, red blocks go down. I can imagine puzzles having to do with switching the block back and forth like this, or getting two blocks so they can both get down. Ya dig?

  6. #6
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,451
    Level
    24
    vBActivity - Bars
    Lv. Percent
    73.19%

    Re: Multiblock Trigger

    Something I just realized: the canMove function is a bit out of date. It would be more versatile like this:
    Code:
    bool canMove(int x, int y)
    {
    	if(x<0 || x>240 || y<0 || y>160)
    		return false;
    	
    	return Screen->ComboS[ComboAt(x, y)]==0;
    }
    You'd have to import std.zh, but it should fix the problem of having to specify the top-left corner.


    Nice work, by the way. Should be quite useful.

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