Jump to content

Photo

How do I code if R button is pressed B button item is something?


  • Please log in to reply
1 reply to this topic

#1 LikeLike888

LikeLike888

    Spicy food lover!!

  • Members
  • Real Name:Jason
  • Location:North America

Posted 01 April 2020 - 01:41 PM

Item number (#) 48 is Bomb (Super)

would

if (Link->PressR)
{
  Link->BButtonItem[48];
]

make Link's treat as B button item be Bomb (Super) or no?

 

 

 

If no how do I correct up above code to properly make Link's treated as B button item is Bomb (Super) please? Thank you.



#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 April 2020 - 05:19 PM

You have two options:
 
1. Use 2.55, and itemdata scripts.
 
 
if ( Hero->PressR )
{
    itemdata id = Game->LoadItemData[itemnumber];
    id->RunScript(); //Run any arbitrary item script based on the button press
}

itemdata script sbomb
{
    void run()
    {
        //Check that there are no super bombs on screen
        for ( int q = Screen->NumLWeapons(); --q )
        {
            lweapon l = Screen->LoadLWeapon(q);
            if ( l->ID == LW_SBOMB ) Quit();
        }
        
        unless ( Game->Counter[CR_SBOMB] ) return; //Check if Link has ammo
        
        --Game->Counter[CR_SBOMB]; //Reduce the counter
        
        //Create the weapon, and position it properly.
        lweapon sb = Screen->CreateLWeapon(LW_SBOMB);
        sb->Dir = Hero->Dir;
        switch(Hero->Dir)
        {
            case DIR_UP:
            {
                sb->X = Hero->X;
                sb->Y = Hero->Y - 16;
                break;
            }
            case DIR_DOWN:
            {
                sb->X = Hero->X;
                sb->Y = Hero->Y + 16;
                break;
            }
            case DIR_LEFT:
            {
                sb->X = Hero->X-16;
                sb->Y = Hero->Y;
                break;
            }
            case DIR_RIGHT:
            {
                sb->X = Hero->X+16;
                sb->Y = Hero->Y;
                break;
            }
        }
    }
}
 
In 2.53.x, you'd need to code a global function for R:
 
void RButton()
{
    if ( Link->PressR )
    {
        //Check that there are no super bombs on screen
        for ( int q = Screen->NumLWeapons(); --q )
        {
            lweapon l = Screen->LoadLWeapon(q);
            if ( l->ID == LW_SBOMB ) return;
        }
        if ( !Game->Counter[CR_SBOMB] ) return; //Check if Link has ammo
        
        --Game->Counter[CR_SBOMB]; //Reduce the counter
        
        //Create the weapon, and position it properly.
        lweapon sb = Screen->CreateLWeapon(LW_SBOMB);
        sb->Dir = Link->Dir;
        if ( Link->Dir == DIR_UP )
        {
            sb->X = Hero->X;
            sb->Y = Hero->Y - 16;
            break;
        }
        else if ( Link->Dir == DIR_DOWN )
        {
            sb->X = Hero->X;
            sb->Y = Hero->Y + 16;
            break;
        }
        else if ( Link->Dir == DIR_LEFT )
        {
            sb->X = Hero->X-16;
            sb->Y = Hero->Y;
            break;
        }
        else
        {
            sb->X = Hero->X+16;
            sb->Y = Hero->Y;
            break;
        }
    }
}

  • ShadowTiger and Aquamentus (Facing Right) like this


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users