PDA

View Full Version : Link Turning Animation by Dummy Tile Modifier (Anima) [FFC]



CJC
09-23-2012, 07:40 PM
Successor expressed interested in the script I used to impose turning sprites on Link. However, he declared distaste about the Tile Modifier aspect of the script, preferring DrawTile in its place. Still, I'm sure somebody can modify this into something worth using.


ffc script DiagonalAnima{

void run(){
int TurnGrade;
const int PosSlopeAnima = 16; //Sets the number for the dummy item
//that makes Link animate for up-right and down-left.
//Don't bother changing the slash and action tiles, though,
//just the walking ones.
//Set as Bait for testing
const int NegSlopeAnima = 12; //Sets the number for the dummy item
//that makes Link animate for down-right and up-left.
//Set as Letter for testing

while(true){
if(Link->Dir == 0){ //Facing Up
if(Link->InputRight || Link->InputDown){
Link->InputRight = false; Link->InputDown = false;
TurnGrade++; //Makes the turn more gradual, so you can actually see it.
if(!Link->Item[PosSlopeAnima]){ Link->Item[PosSlopeAnima] = true;}
//Adds the Positive Slope Anima. At this point, Link will
//appear to be facing north by north-east.
if(Link->Item[NegSlopeAnima]){ Link->Item[NegSlopeAnima] = false;}
//Removes the Negative Slope Anima. This is to prevent the player
//from owning both at the same time, which they can achieve by
//mashing the keyboard. The result of owning both is a big ugly mess.
if(TurnGrade >= 6){
Link->Dir = 3;
//Sets Link's official direction to Right. He'll still appear
//to be turning at this point, but the turn will be east by north-east
//instead.
TurnGrade = 5;
}
}
if(Link->InputLeft){
Link->InputLeft = false;
TurnGrade--; //Same as above, but in the opposite direction.
//At this point, Link would be facing north by north-west.
if(!Link->Item[NegSlopeAnima]){ Link->Item[NegSlopeAnima] = true;}
if(Link->Item[PosSlopeAnima]){ Link->Item[PosSlopeAnima] = false;}
if(TurnGrade <= -6){
Link->Dir = 2;
//Sets Link's official direction to Left. He will appear
//to be facing west by north-west.
TurnGrade = -5;
}
}
if(TurnGrade > 0 && Link->InputUp){
Link->InputUp = false;
TurnGrade--;
//Used to revert back to neutral if you decide to
//press up again after the turn right begins.
}
if(TurnGrade < 0 && Link->InputUp){
Link->InputUp = false;
TurnGrade++;
//Used to revert back to neutral if you decide to
//press up again after the turn left begins.
}
if(TurnGrade == 0 && (Link->Item[PosSlopeAnima] || Link->Item[NegSlopeAnima])){
Link->Item[PosSlopeAnima] = false;
Link->Item[NegSlopeAnima] = false;
//Removes the Anima if you are facing the cardinal
//direction... in this case, north.
}
}
if(Link->Dir == 1){ //Facing Down
if(Link->InputRight){
Link->InputRight = false;
TurnGrade--;
if(!Link->Item[NegSlopeAnima]){ Link->Item[NegSlopeAnima] = true;}
if(Link->Item[PosSlopeAnima]){ Link->Item[PosSlopeAnima] = false;}
if(TurnGrade <= -6){
Link->Dir = 3;
TurnGrade = -5;
}
}
if(Link->InputLeft || Link->InputUp){
Link->InputLeft = false; Link->InputUp = false;
TurnGrade++;
if(!Link->Item[PosSlopeAnima]){ Link->Item[PosSlopeAnima] = true;}
if(Link->Item[NegSlopeAnima]){ Link->Item[NegSlopeAnima] = false;}
if(TurnGrade >= 6){
Link->Dir = 2;
TurnGrade = 5;
}
}
if(TurnGrade > 0 && Link->InputDown){
Link->InputDown = false;
TurnGrade--;
}
if(TurnGrade < 0 && Link->InputDown){
Link->InputDown = false;
TurnGrade++;
}
if(TurnGrade == 0 && (Link->Item[PosSlopeAnima] || Link->Item[NegSlopeAnima])){
Link->Item[PosSlopeAnima] = false;
Link->Item[NegSlopeAnima] = false;
}
}
if(Link->Dir == 2){ //Facing Left
if(Link->InputUp || Link->InputRight){
Link->InputUp = false; Link->InputRight = false;
TurnGrade--;
if(!Link->Item[NegSlopeAnima]){ Link->Item[NegSlopeAnima] = true;}
if(Link->Item[PosSlopeAnima]){ Link->Item[PosSlopeAnima] = false;}
if(TurnGrade <= -6){
Link->Dir = 0;
TurnGrade = -5;
}
}
if(Link->InputDown){
Link->InputDown = false;
TurnGrade++;
if(!Link->Item[PosSlopeAnima]){ Link->Item[PosSlopeAnima] = true;}
if(Link->Item[NegSlopeAnima]){ Link->Item[NegSlopeAnima] = false;}
if(TurnGrade >= 6){
Link->Dir = 1;
TurnGrade = 5;
}
}
if(TurnGrade > 0 && Link->InputLeft){
Link->InputLeft = false;
TurnGrade--;
}
if(TurnGrade < 0 && Link->InputLeft){
Link->InputLeft = false;
TurnGrade++;
}
if(TurnGrade == 0 && (Link->Item[PosSlopeAnima] || Link->Item[NegSlopeAnima])){
Link->Item[PosSlopeAnima] = false;
Link->Item[NegSlopeAnima] = false;
}
}
if(Link->Dir == 3){ //Facing Right
if(Link->InputUp){
Link->InputUp = false;
TurnGrade++;
if(!Link->Item[PosSlopeAnima]){ Link->Item[PosSlopeAnima] = true;}
if(Link->Item[NegSlopeAnima]){ Link->Item[NegSlopeAnima] = false;}
if(TurnGrade >= 6){
Link->Dir = 0;
TurnGrade = 5;
}
}
if(Link->InputDown || Link->InputLeft){
Link->InputDown = false; Link->InputLeft = false;
TurnGrade--;
if(!Link->Item[NegSlopeAnima]){ Link->Item[NegSlopeAnima] = true;}
if(Link->Item[PosSlopeAnima]){ Link->Item[PosSlopeAnima] = false;}
if(TurnGrade <= -6){
Link->Dir = 1;
TurnGrade = -5;
}
}
if(TurnGrade > 0 && Link->InputRight){
Link->InputRight = false;
TurnGrade--;
}
if(TurnGrade < 0 && Link->InputRight){
Link->InputLeft = false;
TurnGrade++;
}
if(TurnGrade == 0 && (Link->Item[PosSlopeAnima] || Link->Item[NegSlopeAnima])){
Link->Item[PosSlopeAnima] = false;
Link->Item[NegSlopeAnima] = false;
}
}
Waitframe();
} // end of while loop
} // end of void run
}

I know there is probably a better way to code this, but that's not the point of this thread. Also, this is provided as-is, so you're going to have to play with it if you want to use it (I had never intended to share it outside my quest, but since that quest will likely never be finished, you can poke the dead remains of its script).

SUCCESSOR
09-23-2012, 08:00 PM
I was actually interested in the sprites but it is a very interesting script. I'll have to look at it more closely soon. My distaste for using LTMs is that using them when unnecessary can cause problems when you use LTMs for many things inwhich they are necessary. And LTMs tend to give me a headache in general.