Page 1 of 1

Weapons

PostPosted: Thu Apr 06, 2006 4:02 pm
by Phil
OK I want to make a 2 handed sword!How can I

PostPosted: Fri Apr 07, 2006 12:34 am
by DilloDude
Making swords is fairly simple, but not easy to do well. First, a simple function; add this in global code:
Code: Select all
void ASBS(char *ANAME, int animation_direction)
{
    if (animindex != getAnimIndex(ANAME))
    {
        ChangeAnimation("Event Actor", ANAME, animation_direction);
    }
}

ASBS stands for animation should be string. All it does is change animation, but only if that animation is not already playing.
You'll want two actors, a 'player' and a 'sword'. Make two variables: 'swing' and 'dir'. Add keydown events on your player to move him and change dir to the direction of his movement. Add on keydown->sword: swing = 1; Your sword should have animations for being still in all directions and swinging in all directions. For this example, lets just use 1 for right and -1 for left. So your sword has 4 animations: left, right, swingleft, swingright. On draw actor->sword:
Code: Select all
x=Player.x;
y=Player.y;
if (dir==1)
{
    if (swing==0)
    {
        ASBS("right", FORWARD);
    }
    else
    {
        ASBS("swingright", FORWARD);
    }
}
else
{
    if (swing==0)
    {
        ASBS("left", FORWARD);
    }
    else
    {
        ASBS("swingleft", FORWARD);
    }
}

on animation finish-> sword, swing = 0;

on collision->enemy->any side of sword
Code: Select all
if (swing)
{
    DestroyActor("Event Actor");
}

To make the animations better, Have player animations for swinging to make it look like he is swinging the sword.