Jump to content

Photo

push scripts


  • Please log in to reply
5 replies to this topic

#1 Master Maniac

Master Maniac

    Earth, Wind, Fire, and Water.

  • Members
  • Real Name:kris

Posted 30 June 2010 - 12:03 PM

I need a purely cosmetic script for link pushing blocks etc.

I wasn't exactly sure how to do it myself but here's how I want it to work:

Global script preferrably (but I can work with ffc's)
When link goes to push a block, his tile changes to another (pushing animatiom)
The tile under the block changes to a different tile depending on whether its being pushed horizontally or vertically
When the block stops moving, then link's tile returns to normal.

Basically, I just want link to look like he is pushing a block, and for the block to leave marks on the floor.

I also would love for this to operate with any block combotype.


Thanks icon_smile.gif

#2 Zepinho

Zepinho

    Experienced Forumer

  • Members
  • Location:Trieste, Italy

Posted 01 July 2010 - 02:44 AM

Hi!
I have a script which does the link graphics stuff, but not the floor marks for the blocks.

You have to setup 8 combos, for Link pushing:
two consecutive ones for each direction.
Then just combine this global script (and functions) with other global scripts.
Aslo the script sets a wait-time (default 20 frames) before starting to move the block (like GB-style games).

Anyway, this is the script.

CODE

//id of link pushing combos
const int LINK_PUSHING_UP_ID=3184;
const int LINK_PUSHING_DOWN_ID=3186;
const int LINK_PUSHING_LEFT_ID=3188;
const int LINK_PUSHING_RIGHT_ID=3190;

// global variables
int link_pushing;


// global script
global script Slot_2{
void run(){

  //---to do when the quest starts---

  ffc lnk   = Screen->LoadFFC(31);
  lnk   -> CSet = 6;

  while(true){

   //---to repeat each frame---

   // Push
   if( NoInputCheck() && SameDir() && Screen->isSolid(TouchedX(),TouchedY()) && Link->Z == 0 ) link_pushing++;
   else link_pushing=0;
  
   // FFC for Link doing actions
   LnkFFC(lnk);

   Waitframe();
  }
}
}


// Functions

// LnkFFC - FFC for Link pushing
// (if you are using my Magic Brecelet / Pickup script, you have to combinbe this part)
void LnkFFC(ffc lnk){
if(link_pushing>0){
  Link->Invisible=true;
  if(Floor(link_pushing/10)%2==0) lnk->Data=LinkPushingCombo();
  else if(Floor(link_pushing/10)%2==1) lnk->Data=LinkPushingCombo()+1;
  if(link_pushing<20 && IsPushable(TouchedComboLoc())) NoAction();
  lnk->X=Link->X;
  lnk->Y=Link->Y;
  lnk->Vx=0;
  lnk->Vy=0;
  lnk->Ax=0;
  lnk->Ay=0;
}
else{
  Link->Invisible=false;
  lnk->Data=INV_COMBO_ID;
  lnk->X=0;
  lnk->Y=0;
  lnk->Vx=0;
  lnk->Vy=0;
  lnk->Ax=0;
  lnk->Ay=0;
}
DrawToLayer(lnk,3,128);
}

//function which gives true if Link pushes the same direction of his facing direction
bool SameDir(){
if(Link->InputUp && Link->Dir==DIR_UP) return true;
if(Link->InputDown && Link->Dir==DIR_DOWN) return true;
if(Link->InputLeft && Link->Dir==DIR_LEFT) return true;
if(Link->InputRight && Link->Dir==DIR_RIGHT) return true;
else return false;
}

//function LinkPushingCombo
int LinkPushingCombo(){
int result;
if(Link->Dir==0) result=LINK_PUSHING_UP_ID;
else if(Link->Dir==1) result=LINK_PUSHING_DOWN_ID;
else if(Link->Dir==2) result=LINK_PUSHING_LEFT_ID;
else if(Link->Dir==3) result=LINK_PUSHING_RIGHT_ID;
return result;
}

bool IsPushable(int loc){
bool re = false;
if( Screen->ComboF[loc]==CF_PUSHUPDOWN ||
     Screen->ComboF[loc]==CF_PUSH4WAY ||
     Screen->ComboF[loc]==CF_PUSHLR ||
     Screen->ComboF[loc]==CF_PUSHUP ||
     Screen->ComboF[loc]==CF_PUSHDOWN ||
     Screen->ComboF[loc]==CF_PUSHLEFT ||
     Screen->ComboF[loc]==CF_PUSHRIGHT ||
     Screen->ComboF[loc]==CF_PUSHUPDOWNNS ||
     Screen->ComboF[loc]==CF_PUSHLEFTRIGHTNS ||
     Screen->ComboF[loc]==CF_PUSH4WAYNS ||
     Screen->ComboF[loc]==CF_PUSHUPNS ||
     Screen->ComboF[loc]==CF_PUSHDOWNNS ||
     Screen->ComboF[loc]==CF_PUSHLEFTNS ||
     Screen->ComboF[loc]==CF_PUSHRIGHTNS ||
     Screen->ComboF[loc]==CF_PUSHUPDOWNINS ||
     Screen->ComboF[loc]==CF_PUSHLEFTRIGHTINS ||
     Screen->ComboF[loc]==CF_PUSH4WAYINS ||
     Screen->ComboF[loc]==CF_PUSHUPINS ||
     Screen->ComboF[loc]==CF_PUSHDOWNINS ||
     Screen->ComboF[loc]==CF_PUSHLEFTINS ||
     Screen->ComboF[loc]==CF_PUSHRIGHTINS )
  re = true;
else if( Screen->ComboI[loc]==CF_PUSHUPDOWN ||
     Screen->ComboI[loc]==CF_PUSH4WAY ||
     Screen->ComboI[loc]==CF_PUSHLR ||
     Screen->ComboI[loc]==CF_PUSHUP ||
     Screen->ComboI[loc]==CF_PUSHDOWN ||
     Screen->ComboI[loc]==CF_PUSHLEFT ||
     Screen->ComboI[loc]==CF_PUSHRIGHT ||
     Screen->ComboI[loc]==CF_PUSHUPDOWNNS ||
     Screen->ComboI[loc]==CF_PUSHLEFTRIGHTNS ||
     Screen->ComboI[loc]==CF_PUSH4WAYNS ||
     Screen->ComboI[loc]==CF_PUSHUPNS ||
     Screen->ComboI[loc]==CF_PUSHDOWNNS ||
     Screen->ComboI[loc]==CF_PUSHLEFTNS ||
     Screen->ComboI[loc]==CF_PUSHRIGHTNS ||
     Screen->ComboI[loc]==CF_PUSHUPDOWNINS ||
     Screen->ComboI[loc]==CF_PUSHLEFTRIGHTINS ||
     Screen->ComboI[loc]==CF_PUSH4WAYINS ||
     Screen->ComboI[loc]==CF_PUSHUPINS ||
     Screen->ComboI[loc]==CF_PUSHDOWNINS ||
     Screen->ComboI[loc]==CF_PUSHLEFTINS ||
     Screen->ComboI[loc]==CF_PUSHRIGHTINS )
  re = true;
else if( Screen->ComboT[loc]==CT_PUSHHEAVY ||
          Screen->ComboT[loc]==CT_PUSHHEAVY2 ||
          Screen->ComboT[loc]==CT_PUSHHEAVY2WAIT ||
          Screen->ComboT[loc]==CT_PUSHHEAVYWAIT ||
          Screen->ComboT[loc]==CT_PUSHWAIT )
  re = true;
return re;
}

bool NoInputCheck(){
if(Link->InputA) return false;
if(Link->InputB) return false;
return true;
}

//function TouchedComboLoc
int TouchedComboLoc(){
int loc;
loc = ComboAt( TouchedX(), TouchedY() );
return loc;
}

int TouchedX(){
int x;
if(Link->Dir == 0)      x = Link->X+8; //up
else if(Link->Dir == 1) x = Link->X+8; //down
else if(Link->Dir == 2) x = Link->X-2; //left
else if(Link->Dir == 3) x = Link->X+18; //right
return x;
}

int TouchedY(){
int y;
if(Link->Dir == 0)      y = Link->Y+6;
else if(Link->Dir == 1) y = Link->Y+18;
else if(Link->Dir == 2) y = Link->Y+8;
else if(Link->Dir == 3) y = Link->Y+8;
return y;
}

//Stops all Link's inputs
void NoAction(){
Link->InputUp = false;
Link->InputDown = false;
Link->InputLeft = false;
Link->InputRight = false;
Link->InputR = false;
Link->InputL = false;
Link->InputA = false;
Link->InputB = false;
}


I'm not 100% sure the script I'm giving you will work out of the box, since I'm using it combined with many other ones...

Edited by Zepinho, 02 July 2010 - 02:13 AM.


#3 Joe123

Joe123

    Retired

  • Members

Posted 01 July 2010 - 03:20 AM

You can do the floor marks with the undercombo. They won't point in the right direction though if that's what you're after, but there's a tile in most sets which looks like 'floor with diagonal scrape marks', it looks fairly good underneath blocks that've been pushed.

#4 Master Maniac

Master Maniac

    Earth, Wind, Fire, and Water.

  • Members
  • Real Name:kris

Posted 01 July 2010 - 06:39 PM

Hm... I see. Thanks guys. I'll use that script, and I guess just some clever undercombos icon_razz.gif

I believe the diagonal scrapes will have to do. Thanks a bunch!

#5 Zepinho

Zepinho

    Experienced Forumer

  • Members
  • Location:Trieste, Italy

Posted 02 July 2010 - 02:15 AM

Sorry, I modified the function IsPushable,
since there was some incorrectness with ComboI and ComboT.
Now it should be better and work with any "push" ComboType, ComboFlag and ComboInherentFlag.

#6 Master Maniac

Master Maniac

    Earth, Wind, Fire, and Water.

  • Members
  • Real Name:kris

Posted 02 July 2010 - 07:32 AM

Cool icon_razz.gif thanks. I haven't copied it into my global file yet, so its no biggie lol.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users