Jump to content

Photo

Hadoken


  • Please log in to reply
2 replies to this topic

#1 Saffith

Saffith

    IPv7 user

  • Members

Posted 06 December 2008 - 02:45 PM

Down, down-forward, forward, A. But you knew that already, right?
Demo
Demo (alternate location)
Should work as is in build 884+. Change fireball->Step=200; to fireball->Step=2; for older builds.

CODE
import "std.zh"
const int SFX_HADOKEN=60;
const int HADOKEN_TILE_LEFT=300;
const int HADOKEN_TILE_RIGHT=302;
const int HADOKEN_CSET=7;

ffc script Hadoken
{
    void run()
    {
        int step=0;
        int counter=0;
        int direction;
        bool stillHoldingA=false;
        
        while(true)
        {
            // Step 0: Wait for down to be pressed
            if(step==0)
            {
                if(Link->InputDown && !(Link->InputUp || Link->InputLeft || Link->InputRight || Link->InputA))
                {
                    step=1;
                    counter=0;
                }
            }
            // Step 1: Wait for left or right to be pressed in addition to down
            else if(step==1)
            {
                // If down isn't still held, or if another button is pressed, reset.
                // Left and right are okay, as long as it's just one of them.
                if(!Link->InputDown || Link->InputUp || Link->InputA || (Link->InputLeft && Link->InputRight))
                    step=0;
                // Down is still held; check for left
                else if(Link->InputLeft)
                {
                    step=2;
                    counter=0;
                    direction=DIR_LEFT;
                }
                // Check for right
                else if(Link->InputRight)
                {
                    step=2;
                    counter=0;
                    direction=DIR_RIGHT;
                }
                // Nothing new, keep waiting
                else
                {
                    counter++;
                    // Waited too long, reset.
                    if(counter>10)
                        step=0;
                }
            }
            // Step 2: Wait for down to be released
            else if(step==2)
            {
                // Restart if an invalid button is pressed
                if(Link->InputUp || Link->InputA || (Link->InputLeft && direction!=DIR_LEFT) || (Link->InputRight && direction!=DIR_RIGHT))
                    step=0;
                // Move on if down isn't still being held
                else if(!Link->InputDown)
                {
                    step=3;
                    counter=0;
                }
                // Still held, keep waiting
                else
                {
                    counter++;
                    // Enough waiting.
                    if(counter>10)
                        step=0;
                }
            }
            // Step 3: Wait for A to be pressed
            else
            {
                // Restart if an invalid button is pressed, or if left or right aren't held anymore
                if(Link->InputDown || Link->InputUp || !(Link->InputLeft || Link->InputRight) ||
                   (Link->InputLeft && direction!=DIR_LEFT) || (Link->InputRight && direction!=DIR_RIGHT))
                    step=0;
                // Pressed A yet?
                else if(Link->InputA)
                {
                    // Finally!
                    DoHadoken(direction);
                    stillHoldingA=true;
                    step=0;
                }
                // Nope. Just wait.
                else
                {
                    counter++;
                    // Too late.
                    if(counter>10)
                        step=0;
                }
            }
            
            // Without this, Link'll use his sword afterward if A is held.
            if(stillHoldingA)
            {
                if(Link->InputA)
                    Link->InputA=false;
                else
                    stillHoldingA=false;
            }
            Waitframe();
        }
    }
    
    void DoHadoken(int direction)
    {
    
        Game->PlaySound(SFX_HADOKEN);    
        Link->Action=LA_ATTACKING;

        lweapon fireball=Screen->CreateLWeapon(LW_SCRIPT1);
        
        if(direction==DIR_LEFT)
        {
            fireball->OriginalTile=HADOKEN_TILE_LEFT;
            fireball->X=Link->X-8;
        }
        else
        {
            fireball->OriginalTile=HADOKEN_TILE_RIGHT;
            fireball->X=Link->X+8;
        }
        fireball->Y=Link->Y;
        fireball->CSet=HADOKEN_CSET;
        fireball->NumFrames=2;
        fireball->Dir=direction;
        fireball->Step=200;
        fireball->Damage=8;
    }
}


#2 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 06 December 2008 - 03:20 PM

This is extraordinarily leet. Do show it to C-Dawg for his Zodiac Demo. He'll go nuts.

#3 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 06 December 2008 - 06:59 PM

Dont forget gleeok and his grikarugan demo also ^_^ but this is cool saffith. Shouldnt this go on on the database though?


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users