Jump to content

Photo

help with link pushing animation script?


  • Please log in to reply
10 replies to this topic

#1 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 18 October 2016 - 02:53 PM

can someone tell me how to go about drawing a custom link animation?

 

this is the code I currently have

const int PushUpTile = 0 // just a place holder not actully set
const int PushUpTileFrames = 2;
const int PushDownTile = 0 // just a place holder not actully set
const int PushDownTileFrames = 2;
const int PushLeftTile = 0 // just a place holder not actully set
const int PushLeftTileFrames = 2;
const int PushRightTile = 0 // just a place holder not actully set
const int PushRightTileFrames = 2;

global script link_push {
	void run() {
	    int PushDir = Link_Pushing();
        if (PushDir != -1)
        {
            if (PushDir == 0) {  }
            if (PushDir == 1) {  }
            if (PushDir == 2) {  }
            if (PushDir == 3) {  }
        }
	}
}

int Link_Pushing()
{
    int CheckX = 0
    int CheckY = 0 
    if ((Link->InputAxisUp)     && (Link->Dir == 0)) { CheckY = Link->Y-8; }
    if ((Link->InputAxisDown)   && (Link->Dir == 1)) { CheckY = Link->Y+8; }
    if ((Link->InputAxisLeft)   && (Link->Dir == 2)) { CheckX = Link->X-8; }
    if ((Link->InputAxisRight)  && (Link->Dir == 3)) { CheckX = Link->X+8; }
    
    if ((CheckX != 0) && (CheckY != 0)) 
    {
        if (Screen->IsSolid(CheckX, CheckY)) 
        { 
            return Link->Dir; 
        }
    }
    return -1;
}


#2 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 20 October 2016 - 01:03 PM

bump: does anybody know how to stop drawing link's animations for a specific number of frames and draw a alternate animation over link?



#3 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 20 October 2016 - 01:42 PM

Set Link->Invisible to true for however long you need it. But Link->Tile won't be readable during that time, because ZC is dumb.

#4 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 25 October 2016 - 12:17 AM

@Lejes whats the best way to draw a animated tile over link?

I was going to use FastTile() but I don't know the best way to make him animate  



#5 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 25 October 2016 - 02:25 AM

There isn't a great way to do it, honestly. It all depends on what you want the animation itself to do. If it mirrors his default animations exactly, you can read Link->Tile and use an offset based on that. If you go with this approach, there's something very important to remember: Setting Link->Invisible renders Link->Tile useless. It no longer equals what Link's tile ought to be. If you want to get Link's real sprite out the way and draw matching tiles over it, you have to place the draw offsets offscreen instead. If your custom animation doesn't depend on Link->Tile, you won't have that problem and can just set/unset Link->Invisible.

Going off that custom Link Action system you came up with in that other thread, you could have the global script make Link invisible and draw the proper tiles for as long as the proper action state lasts. Link->Invisible vs. draw offsets, the tiles themselves and their speed/order, etc. depends on how you want it to look. I will say that FastCombo() is flat out the easiest way to animate something. But it has its limitations.

Edited by Lejes, 25 October 2016 - 02:26 AM.


#6 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 28 October 2016 - 07:03 PM

@Lejes so I got it working kinda the only problems are..

-it looks like are that its not draw on the layer Link is drawn on

-link's hitbox is still too big sideways

whats the best way to fix these with scripting that doesn't break the game?



#7 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 28 October 2016 - 07:26 PM

I forget which layer Link is drawn on. Somewhere between layer 3 and 4? You probably won't be able to replicate it exactly. I have no idea what you mean about the hitbox.

#8 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 28 October 2016 - 09:20 PM

@Lejes

hmm weird ok I'll try to draw it on layer 4 then

 

also the hitbox is about 4 pixels too big on the left and right side


Edited by Shadowblitz16, 28 October 2016 - 09:20 PM.


#9 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 28 October 2016 - 09:31 PM

You're going to have to explain what you mean. Link does have hitbox size variables, but changing them won't affect his hitbox because they don't work. If you mean the tile you're drawing for the animation is too big or positioned incorrectly...well, that's an easy fix, isn't it?

#10 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 28 October 2016 - 09:57 PM

I'm not talking about variable I'm taking about where he collides with solids in general,

since I'm drawing the combo at Link's X and Y when he goes into his push animation via drawing a combo he is not positioned like he would be in the GB games because his

hitbox(I'm talking about the one programmed into Zelda Classic) is too big on the left and right side

 

Edit: here is a script I'm working on to correct the issue

//import "std.zh"
//import "stdExtra.zh"
//import "ffcscript.zh"
//import "string.zh"
 
bool Collision = 0;
int LastColX = 0;
int LastColY = 0;
 
bool LinkCollision(int step)
{
    if (Link->InputUp || Link->InputDown || Link->InputLeft || Link->InputRight)
    {
        if (!CanWalk(Link->X, Link->Y, Link->Dir, step, false))
        {
            return 1;
        }
    }
    return 0;
}
 
void LinkCollisionOffset(int step, int top, int bottom, int left, int right)
{
    if(CanWalk(Link->X, Link->Y, Link->Dir, step, 0))
    {
        LastColX = Link->X;
        LastColY = Link->Y;   
    }
    
    if (LinkCollision(step))
    {
        if (Link->InputUp && Link->Y - LastColY > top )
            Link->Y -= 1;
        if (Link->InputDown && Link->Y - LastColY < bottom )
            Link->Y += 1;
        if (Link->InputLeft && Link->X - LastColX > left )
            Link->X -= 1;
        if (Link->InputRight && Link->X - LastColX < right )
            Link->X += 1; 
    }
    
    int testx = Link->X - LastColX;
    int testy = Link->Y - LastColY;
    Screen->DrawInteger(6, 0, 0, FONT_Z1, 0x01, 0x07, 0, 0, testx, 0, OP_OPAQUE);
    Screen->DrawInteger(6, 0, 16, FONT_Z1, 0x01, 0x07, 0, 0, testy, 0, OP_OPAQUE);
}
 

Edited by Shadowblitz16, 28 October 2016 - 10:23 PM.


#11 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 29 October 2016 - 09:42 AM

An alternative to Link->Invisible would be to use Link->DrawXOffset to make Link's sprite be drawn offscreen.

 

But I think you already solved that problem.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users