Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script typedef ffc namespace;
- typedef const int define;
- typedef const int config;
- namespace script blocks
- {
- define MAX = 32;
- define X = 0;
- define Y = 1;
- define COMBO = 3;
- define CSET = 4;
- define OPACITY = 5;
- define DIR = 6;
- define LAST = 7;
- define CurNum = LAST*MAX; //EXTRA 1
- define PushClock = CurNum+1; //EXTRA 2
- define LastLinkX = CurNum+2; //EXTRA 2
- define LastLinkY = CurNum+3; //EXTRA 2
- define LAYER = 4;
- define EXTRA = 2; //
- define ABOVE = -1;
- define BELOW = 1;
- define LEFT = 0.1;
- define RIGHT = -0.1;
- //call at the end of every frame
- void storeLink()
- {
- positions[LastLinkX] = Link->X;
- positions[LastLinkY] = Link->Y;
- }
- int positions[MAX*LAST+EXTRA];
- void run(){} //automatic
- int create(int x, int y, int cmb, int cset)
- {
- int id = ++positions[CurNum];
- if ( id >= MAX ) return -1;
- positions[id*LAST] = x;
- positions[id*LAST+Y] = y;
- positions[id*LAST+DIR] = -1;
- positions[id*LAST+COMBO] = combo;
- positions[id*LAST+CSET] = cset;
- positions[id*LAST+OPACITY] = 128;
- return id;
- }
- void draw()
- {
- int pos[MAX*5]; int w;
- for ( int q = 0; q < CurNum; += LAST ) //load combo information to an array
- {
- pos[w] = positions[q];
- pos[w+1] = positions[q+1];
- pos[w+2] = positions[q+2];
- pos[w+3] = positions[q+3];
- pos[w+4] = positions[q+4];
- w += 5;
- }
- Screen->DrawCombos(LAYER, pos);
- }
- //0 not touchimg, otherwise, return id +1
- int touching()
- {
- for ( int q = 0; q < positions[CurNum]; q += LAST )
- {
- //check relative Link coordinates
- switch(Link->Dir)
- {
- case DIR_UP:
- {
- if ( Below(positions[id*LAST+Y]) )
- {
- if ( DistY(positions[id*LAST+Y]) <= 8 ) //overlap
- {
- if ( DistX(positions[id*LAST] <= 16 )
- {
- return ((q/LAST)+1)*BELOW;
- }
- return 0;
- }
- return 0;
- }
- return 0;
- }
- case DIR_DOWN:
- {
- if ( Above(positions[id*LAST+Y]) )
- {
- if ( DistY(positions[id*LAST+Y]) <= 16 ) //overlap
- {
- if ( DistX(positions[id*LAST] <= 16 )
- {
- ((q/LAST)+1)*ABOVE;
- }
- return 0;
- }
- return 0;
- }
- return 0;
- }
- case DIR_LEFT:
- {
- if ( LeftOf(positions[id*LAST]) )
- {
- if ( DistY(positions[id*LAST+Y]) <= 16 ) //overlap
- {
- if ( DistX(positions[id*LAST] <= 16 )
- {
- ((q/LAST)+1)*LEFT;
- }
- return 0;
- }
- return 0;
- }
- return 0;
- }
- case DIR_RIGHT:
- {
- if ( RightOf(positions[id*LAST]) )
- {
- if ( DistY(positions[id*LAST+Y]) <= 8 ) //overlap
- {
- if ( DistX(positions[id*LAST] <= 16 )
- {
- ((q/LAST)+1)*RIGHT;
- }
- return 0;
- }
- return 0;
- }
- return 0;
- }
- default: return 0;
- }
- }
- dwfine PushTHRESHOLD = 28; //frames
- bool pushing()
- {
- int id = touching();
- if (!id) return false; //abort
- int pushdir;
- if ( id < 0 )
- {
- if ( !(id << 0) ) //decimal
- {
- pushdir = DIR_LEFT;
- }
- else pushdir = DIR_DOWN;
- }
- else
- {
- if ( !(id << 0) ) //decimal
- {
- pushdir = DIR_RIGHT;
- }
- else pushdir = DIR_UP;
- }
- switch(pushdir)
- {
- case DIR_LEFT:
- {
- if ( Input->Hold[CB_LEFT] )
- {
- positions[id*LAST+DIR] = pushdir;
- ++positions[PushClock];
- Link->X = positions[LastLinkX]; //Hold Link in place
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_LEFT )
- {
- Link->HitDir = -1;
- }
- break;
- }
- else if ( Input->Press[CB_LEFT] )
- {
- Link->X = positions[LastLinkX]; //Hold Link in place
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_LEFT )
- {
- Link->HitDir = -1;
- }
- break;
- }
- else
- {
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_LEFT )
- {
- Link->HitDir = -1;
- }
- positions[id*LAST+DIR] = -1;
- positions[PushClock] = 0;
- break;
- }
- }
- case DIR_RIGHT:
- {
- if ( Input->Hold[CB_RIGHT] )
- {
- positions[id*LAST+DIR] = pushdir;
- ++positions[PushClock];
- Link->X = positions[LastLinkX]; //Hold Link in place
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_RIGHT )
- {
- Link->HitDir = -1;
- }
- break;
- }
- else if ( Input->Press[CB_RIGHT] )
- {
- Link->X = positions[LastLinkX]; //Hold Link in place
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_RIGHT )
- {
- Link->HitDir = -1;
- }
- break;
- }
- else
- {
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_RIGHT )
- {
- Link->HitDir = -1;
- }
- positions[id*LAST+DIR] = -1;
- positions[PushClock] = 0;
- break;
- }
- }
- case DIR_DOWN:
- {
- if ( Input->Hold[CB_DOWN] )
- {
- positions[id*LAST+DIR] = pushdir;
- ++positions[PushClock];
- Link->X = positions[LastLinkX]; //Hold Link in place
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_DOWN )
- {
- Link->HitDir = -1;
- }
- break;
- }
- else if ( Input->Press[CB_DOWN] )
- {
- Link->X = positions[LastLinkX]; //Hold Link in place
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_DOWN )
- {
- Link->HitDir = -1;
- }
- break;
- }
- else
- {
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_DOWN )
- {
- Link->HitDir = -1;
- }
- positions[id*LAST+DIR] = -1;
- positions[PushClock] = 0;
- break;
- }
- }
- case DIR_UP:
- {
- if ( Input->Hold[CB_UP] )
- {
- positions[id*LAST+DIR] = pushdir;
- ++positions[PushClock];
- Link->X = positions[LastLinkX]; //Hold Link in place
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_UP )
- {
- Link->HitDir = -1;
- }
- break;
- }
- else if ( Input->Press[CB_UP] )
- {
- Link->X = positions[LastLinkX]; //Hold Link in place
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_UP )
- {
- Link->HitDir = -1;
- }
- break;
- }
- else
- {
- //Don't allow knockback through a block
- if ( Link->HitDir == DIR_UP )
- {
- Link->HitDir = -1;
- }
- positions[id*LAST+DIR] = -1;
- positions[PushClock] = 0;
- break;
- }
- }
- }
- if ( positions[PushClock] > 0 )
- {
- if ( positions[PushClock] > PushTHRESHOLD )
- {
- return push(id); //we push the block
- }
- else
- {
- return linkpush(); //we do the pushing anim
- }
- }
- else return false; //no
- }
- config TRIGGER = CT_SCRIPT_10;
- config TRIGGER_SENS = 6;
- //pixel-precise triggers with very flexible sensitivity
- bool on_trigger(int id)
- {
- int cx = positions[id*LAST];
- int cy = positions[id*LAST+Y];
- for ( int q = TRIGGER_SENS*-1; q <= TRIGGER_SENS; ++q ) //13*13 checks? Bleah.
- {
- for ( int w = TRIGGER_SENS*-1; w <= TRIGGER_SENS; ++w )
- {
- if ( Screen->ComboT[ComboAt((cx+8-q), (cy-8+w))] == TRIGGER ) return true;
- }
- }
- return false;
- }
- config PushSFX = 63;
- config PushPixels = 8; //half tghe size of PushBlockAnimDur
- config PushBlockAnimDur = 16; //frames during which the block and Link move forward
- //movement of the block
- bool push(id)
- {
- //determine block direction
- int timer = 0;
- if (!timer) ////play the push sound
- //while(timer)
- //change to apecial Link sprite using ScriptTile
- //every 2 frames, move the block forward one pixel until it has moved PushPixels pixels
- //waitframe
- return true; //when done
- }
- bool linkpush()
- {
- //while positions[PushClock] < PushTHRESHOLD
- //hold Link in place
- //use Link->\scriptTile to create a custom sprite inside
- //switch(Link->Dir)
- return true; //when done
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement