Jump to content

Photo

Pushing Pillars and Logs etc

FFC

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

#1 Mr. Z

Mr. Z

    Old Bastard is back!

  • Members
  • Real Name:Erik
  • Gender:Male
  • Location:The Netherlands

Posted 10 May 2013 - 11:10 AM

Pushable Pillars

Description

This script is an edit of Colossal's Ice Push Block script.

It lets you make wide pushable blocks up to 4 combos big, such as seen in the Gameboy games (see screenshot)
The push distance can be adjusted, so these can be used as ice blocks as well, although they'll be either vertical or horizontal.

These blocks stop when they hit a solid combo or a no-push flag. They'll move over any combo that is not solid, including water and pits.

Screenshots and Demo

Attached File  pillars.png   4.42KB   105 downloads

http://www.mediafire...3f692hqpqz27zza

Code
 

import "std.zh"

const int PILLAR_SENSITIVITY=8; //Number of frames the block needs to be pushed before it starts moving

ffc script PushablePillars{
    void run(int orientation, int distance){ //Horizontal/Vertical pushing
    distance=distance*16;
    int undercombo;
    int framecounter=0;
    int pushcounter=0;
    int anicounter=0;
    int anitile=0;
    int originaltile=this->Data;
    int pushspeed=1;
    int width=this->TileWidth;
    int height=this->TileHeight;

        Waitframe();
        undercombo=GetLayerComboD(1,this->Y+(this->X>>4));
        if(orientation==1){ SetSolidCombo(3,this->X,this->Y,width,height,this->Data); } //Horizontally
        if(orientation==2){ SetSolidCombo(1,this->X,this->Y,width,height,this->Data); } //Vertically

        while(true){
            if((Link->X==this->X-16 && (Link->Y<this->Y+4+((height-1)*16) && Link->Y>this->Y-4)
            && Link->InputRight && Link->Dir==DIR_RIGHT && orientation==1) || // Right

            (Link->X==this->X+16 && (Link->Y<this->Y+4+((height-1)*16) && Link->Y>this->Y-4)
            && Link->InputLeft && Link->Dir==DIR_LEFT && orientation==1) || // Left

            (Link->Y==this->Y-16 && (Link->X<this->X+4+((width-1)*16) && Link->X>this->X-4)
            && Link->InputDown && Link->Dir==DIR_DOWN && orientation==2) || // Down

            (Link->Y==this->Y+8 && (Link->X<this->X+4+((width-1)*16) && Link->X>this->X-4) //Change the 8 to 16 if you use big Link
            && Link->InputUp && Link->Dir==DIR_UP && orientation==2)
            ){ // Up
        framecounter++;
        }
        else{ framecounter=0; }

        if(framecounter>=PILLAR_SENSITIVITY){

            if(Link->Dir==DIR_RIGHT){
                while(
                this->X<240 &&
                !ComboFI(this->X+16,this->Y,CF_NOBLOCKS) &&
                NoSolidBlocks(4,this->X,this->Y,width,height)==true &&
                pushcounter<distance
                ){
                    if(pushcounter==0){ Game->PlaySound(SFX_PUSHBLOCK); }
                    if(pushcounter<distance/2){ NoAction(); }
                    if(pushcounter%4==0 && pushcounter!=0){ anitile+=1; }
                    if(anitile>3){ anitile=0; }
                    SetSolidCombo(4,this->X,this->Y,width,height,undercombo);
                    this->Vx=pushspeed;
                    this->Data=originaltile+anitile;
                    pushcounter+=pushspeed;
                    Waitframe();
                    if(pushcounter%16==0){ SetUnderCombo(4,this->X-16,this->Y,width,height); }
                }
            this->Vx=0;
            this->Data=originaltile;
            pushcounter=0;
            anitile=0;
            SetSolidCombo(4,this->X,this->Y,width,height,this->Data);
            }

            else if(Link->Dir==DIR_LEFT){
                while(
                this->X>0 &&
                !ComboFI(this->X-1,this->Y,CF_NOBLOCKS) &&
                NoSolidBlocks(3,this->X,this->Y,width,height)==true &&
                pushcounter<distance
                ){
                    if(pushcounter==0){ Game->PlaySound(SFX_PUSHBLOCK); }
                    if(pushcounter<distance/2){ NoAction(); }
                    if(pushcounter%4==0 && pushcounter!=0){ anitile-=1; }
                    if(anitile<0){ anitile=3; }
                    SetSolidCombo(3,this->X,this->Y,width,height,undercombo);
                    this->Vx=-pushspeed;
                    this->Data=originaltile+anitile;
                    pushcounter+=pushspeed;
                    Waitframe();
                    if(pushcounter%16==0){ SetUnderCombo(3,this->X+16,this->Y,width,height); }
                }
            this->Vx=0;
            this->Data=originaltile;
            pushcounter=0;
            anitile=0;
            SetSolidCombo(3,this->X,this->Y,width,height,this->Data);
            }

            else if(Link->Dir==DIR_DOWN){
                while(
                this->Y<160 &&
                !ComboFI(this->X, this->Y+16, CF_NOBLOCKS) &&
                NoSolidBlocks(2,this->X,this->Y,width,height)==true &&
                pushcounter<distance
                ){
                    if(pushcounter==0){ Game->PlaySound(SFX_PUSHBLOCK); }
                    if(pushcounter<distance/2){ NoAction(); }
                    if(pushcounter%4==0 && pushcounter!=0){ anitile+=4; }
                    if(anitile>12){ anitile=0; }
                    SetSolidCombo(2,this->X,this->Y,width,height,undercombo);
                    this->Vy=pushspeed;
                    this->Data=originaltile+anitile;
                    pushcounter+=pushspeed;
                    Waitframe();
                    if(pushcounter%16==0){ SetUnderCombo(2,this->X,this->Y-16,width,height); }
                }
            this->Vy=0;
            this->Data=originaltile;
            pushcounter=0;
            anitile=0;
            SetSolidCombo(2,this->X,this->Y,width,height,this->Data);
            }

            else if(Link->Dir==DIR_UP){
                while(
                this->Y>0 &&
                !ComboFI(this->X, this->Y-1, CF_NOBLOCKS) &&
                NoSolidBlocks(1,this->X,this->Y,width,height)==true &&
                pushcounter<distance
                ){
                    if(pushcounter==0){ Game->PlaySound(SFX_PUSHBLOCK); }
                    if(pushcounter<distance/2){ NoAction(); }
                    if(pushcounter%4==0 && pushcounter!=0){ anitile-=4; }
                    if(anitile<0){ anitile=12; }
                    SetSolidCombo(1,this->X,this->Y,width,height,undercombo);
                    this->Vy=-pushspeed;
                    this->Data=originaltile+anitile;
                    pushcounter+=pushspeed;
                    Waitframe();
                    if(pushcounter%16==0){ SetUnderCombo(1,this->X,this->Y+16,width,height); }
                }
            this->Vy=0;
            this->Data=originaltile;
            pushcounter=0;
            anitile=0;
            SetSolidCombo(1,this->X,this->Y,width,height,this->Data);
            }

         framecounter=0;
         }

         Waitframe();
      }
   }
}


bool NoSolidBlocks(int direction, int xpos, int ypos, int width, int height){
int size=1;
    if(direction==1 || direction==2){ size=width; } //Vertical pushing
    if(direction==3 || direction==4){ size=height; } //Horizontal pushing

    for(int i=size-1; i>=0; i--){
        if(xpos%16==0 && ypos%16==0){
            if(direction==1){ if(Screen->ComboS[ypos-16+((xpos+(i*16))>>4)]!=0000b){ return(false); } }
            if(direction==2){ if(Screen->ComboS[ypos+16+((xpos+(i*16))>>4)]!=0000b){ return(false); } }
            if(direction==3){ if(Screen->ComboS[ypos+(i*16)+((xpos-16)>>4)]!=0000b){ return(false); } }
            if(direction==4){ if(Screen->ComboS[ypos+(i*16)+((xpos+16)>>4)]!=0000b){ return(false); } }
        }
    }
    return(true);
}

int SetSolidCombo(int direction, int xpos, int ypos, int width, int height, int data){
int size=1;
    if(direction==1 || direction==2){ size=width; } //Vertical pushing
    if(direction==3 || direction==4){ size=height; } //Horizontal pushing

    for(int i=size-1; i>=0; i--){
        if(xpos%16==0 && ypos%16==0){
            if(direction==1){ Screen->ComboD[ypos+((xpos+(i*16))>>4)]=data; }
            if(direction==2){ Screen->ComboD[ypos+((xpos+(i*16))>>4)]=data; }
            if(direction==3){ Screen->ComboD[ypos+(i*16)+(xpos>>4)]=data; }
            if(direction==4){ Screen->ComboD[ypos+(i*16)+(xpos>>4)]=data; }
        }
    }
}

int SetUnderCombo(int direction, int xpos, int ypos, int width, int height){
int size=1;
    if(direction==1 || direction==2){ size=width; } //Vertical pushing
    if(direction==3 || direction==4){ size=height; } //Horizontal pushing

    for(int i=size-1; i>=0; i--){
        if(xpos%16==0 && ypos%16==0){
            if(direction==1){ Screen->ComboD[ypos+((xpos+(i*16))>>4)]=GetLayerComboD(1,ComboAt(xpos+(i*16),ypos)); }
            if(direction==2){ Screen->ComboD[ypos+((xpos+(i*16))>>4)]=GetLayerComboD(1,ComboAt(xpos+(i*16),ypos)); }
            if(direction==3){ Screen->ComboD[ypos+(i*16)+(xpos>>4)]=GetLayerComboD(1,ComboAt(xpos,ypos+(i*16))); }
            if(direction==4){ Screen->ComboD[ypos+(i*16)+(xpos>>4)]=GetLayerComboD(1,ComboAt(xpos,ypos+(i*16))); }
            if(direction==1){ Screen->ComboT[ypos+((xpos+(i*16))>>4)]=GetLayerComboT(1,ComboAt(xpos+(i*16),ypos)); }
            if(direction==2){ Screen->ComboT[ypos+((xpos+(i*16))>>4)]=GetLayerComboT(1,ComboAt(xpos+(i*16),ypos)); }
            if(direction==3){ Screen->ComboT[ypos+(i*16)+(xpos>>4)]=GetLayerComboT(1,ComboAt(xpos,ypos+(i*16))); }
            if(direction==4){ Screen->ComboT[ypos+(i*16)+(xpos>>4)]=GetLayerComboT(1,ComboAt(xpos,ypos+(i*16))); }
        }
    }
}

Setup

It requires some setup:

-First: Import the script to any ffc slot you want.

-Second: Go to Tiles and make two 4 by 4 grids of the tile you want to push. Like this:


For the horizontal pillars:
==== 1
==== 2
==== 3
==== 4

And for the vertical pillars do it like this:
| | | |
| | | |
| | | |
| | | |
1,2,3,4

These numbers are the frames of the graphic as it's standing still (1) or is being pushed (2-4). You need to make all these tiles even if you're not using an animation.

-Third: Turn each tile into a SOLID combo using the same 4 by 4 pattern as the tiles.

-Fourth: Place a FFC on the grid. Use the top-left combo of the graphic you want to push around. Then attach the script.

-Fifth: Now adjust the size.
Set ComboW to 16, 32, 48 or 64 if you're using a horizontal pillar. Use ComboH for vertical pillars.
Set TileH or TileW to 1, 2, 3 or 4 (a 16th of the Combo-W/H)

-Sixth: You have to set 2 Arguments:
*Set D0 to 1 if you're using a vertical pillar, or to 2 if the pillar is horizontal.
*D1 is the amount of tiles the pillar will move when pushed, can be as big as you want, although more than 16 would be pointless. Use at least 1, or the pillar won't move.

-Seventh: Layer 1 is used as the under combo, so any tiles that the pillars may cross over have to be drawn on layer 1. (Just copy the whole screen)

There is 1 constant integer, PILLAR_SENSITIVITY, which is the amount of frames you have to push the block before it starts moving.

Resources

std.zh as usual.



#2 Jamian

Jamian

    ZC enthusiast

  • Members
  • Gender:Unspecified

Posted 10 December 2013 - 04:27 PM

Would it be possible to slightly alter the script so pillars can be pushed BOTH vertically and horizontally, regardless of their orientation? Or would that imply a complete rewrite?



#3 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Gender:Male
  • Location:Massachusetts

Posted 10 December 2013 - 06:03 PM

Does this work for combos on half a layer? I know people have really been wanting that.


  • ShadowTiger and Mero like this

#4 Mr. Z

Mr. Z

    Old Bastard is back!

  • Members
  • Real Name:Erik
  • Gender:Male
  • Location:The Netherlands

Posted 11 December 2013 - 10:31 AM

Would it be possible to slightly alter the script so pillars can be pushed BOTH vertically and horizontally, regardless of their orientation? Or would that imply a complete rewrite?

 

It can't push when there is more than one combo between Link and the direction you want to push, that would require a big rewrite.

 

 

Does this work for combos on half a layer? I know people have really been wanting that.

 

Half a layer?


  • Avataro likes this

#5 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Gender:Female
  • Location:Rainbow Factory

Posted 11 December 2013 - 10:56 AM

It can't push when there is more than one combo between Link and the direction you want to push, that would require a big rewrite.

 

 

 

Half a layer?

 

He means upright pillars



#6 Mr. Z

Mr. Z

    Old Bastard is back!

  • Members
  • Real Name:Erik
  • Gender:Male
  • Location:The Netherlands

Posted 11 December 2013 - 11:06 AM

He means upright pillars

 

That would need such a complicated rewrite that making a new ZC version would almost be easier. @_@



#7 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Gender:Male
  • Location:Massachusetts

Posted 11 December 2013 - 11:13 AM

Why is it so difficult?



#8 Mr. Z

Mr. Z

    Old Bastard is back!

  • Members
  • Real Name:Erik
  • Gender:Male
  • Location:The Netherlands

Posted 11 December 2013 - 11:20 AM

Why is it so difficult?

 

Because making this script nearly cost me my life :3. (I'm actually not that good at scripting, I just get a lot of stuff done because I don't like giving up.)

 

In order to make layer pushing work you'd need to make another ffc that displays above Link, which is tied to the motion and location of the base ffc on the floor.

Plus, if I remember correctly, ffcs can either be under Link or Overhead, so it would look bad when you make Link jump when standing under one.

 

Pushing a larger block around would require even more complicated rewriting and ffc linking, although I'd love to see a script like that if someone else made it.



#9 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Gender:Female
  • Location:Rainbow Factory

Posted 11 December 2013 - 11:20 AM

Actually I might be able to do that Jared for you just PM me the details.



#10 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Gender:Male
  • Location:Massachusetts

Posted 14 December 2013 - 07:08 PM

Well I don't currently need it. I'm sure many, many members would love it though.



#11 TheBlueTophat

TheBlueTophat

    🔸

  • Members
  • Gender:Male
  • Location:USA

Posted 29 March 2014 - 01:12 PM

So to be clear, This script will allow a block to only move up/down or left/right but never both?


Edited by coolgamer012345, 29 March 2014 - 01:12 PM.


#12 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Gender:Female
  • Location:Rainbow Factory

Posted 29 March 2014 - 02:19 PM

Yes





Also tagged with one or more of these keywords: FFC

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users