ZoriaRPG icon

Scripted Bow for 2.54

ZoriaRPG | PRO | 06/26/18 05:25:52 AM UTC | 0 ⭐ | 656 👁️ | Never ⏰ | []
C++ |

2.65 KB

|

None

|

0 👍

/

0 👎

//Custom Arrow Item
//v0.5
//27th November, 2015; updasted 25th Ju8ne, 2017
 
//Assign to an item, with the item class 'Custom itemclass', or one of the 'zz###' item classes
//as the 'Action; script.
 
//Arguments:
// D0: The sound effect to play for an error, including too many arrows on screen, or out of arrows in the counter.
// D1: The maximum number of arrows that the player may have on-screen at any one time. 
// --> You want to set this argument, as not setting it, will allow the player to fire up to 255 arrows, providing 
// --> that they have sufficient ammunition. Normal values are between '1' and '4'. 
// D2: Set to a value of '1' to allow Link to fire arrows while jumping. 
// D3: The distance from Link to place it. 
 
//Attributes[]:
// [0] The Step Speed
 
item script Arrow_CustomItemclass{
    void run(int errorSFX, int maxOnscreen, int allowLinkZ, int dist)
    {
        int numArrows;
        if ( !allowLinkZ ) 
        {
            if  ( Link->Z << 0 ) Quit();
        }
        
        else
        {
            if ( !maxOnscreen )
            {
                //Game->Counter[counter]--; //Use the cost counter in the item editor.
                if ( sound ) Game->PlaySound(sound);
                lweapon arrow = NextToLink(LW_ARROW, dist);
                arrow->UseSprite(sprite);
                arrow->Damage = this->Power;
                arrow->Level = this->Level;
                arrow->Dir = Link->Dir;
                arrow->HitXOffset = this->HitXOffset;
                arrow->HitYOffset = this->HitYOffset;
                arrow->HitZOffset = this->HitZOffset;
                arrow->DrawXOffset = this->DrawXOffset;
                arrow->DrawYOffset = this->DrawYOffset;
                arrow->DrawZOffset = this->DrawZOffset;
                arrow->HitWidth = this->HitWidth;
                arrow->HitHeight = this->HitHeight;
                arrow->HitZHeight = this->HitZHeight;
                arrow->Step = this->Attributes[0];
            }
        
            else if ( maxOnscreen )
            {
                for ( int q = Screen->NumLWeapons();; q >0; --q ) 
                {
                    lweapon l = Screen->LoadLWeapon(q);
                    if ( l->ID == LW_ARROW ) ++numArrows;
                }
                if ( numArrows < maxOnscreen ) 
                {
                    Game->PlaySound(this->UseSound);
                    lweapon arrow = NextToLink(LW_ARROW, dist);
                    arrow->UseSprite(this->Sprites[0]);
                    arrow->Damage = this->Power;
                    arrow->Dir = Link->Dir;
                    arrow->HitXOffset = this->HitXOffset;
                    arrow->HitYOffset = this->HitYOffset;
                    arrow->HitZOffset = this->HitZOffset;
                    arrow->DrawXOffset = this->DrawXOffset;
                    arrow->DrawYOffset = this->DrawYOffset;
                    arrow->DrawZOffset = this->DrawZOffset;
                    arrow->HitWidth = this->HitWidth;
                    arrow->HitHeight = this->HitHeight;
                    arrow->HitZHeight = this->HitZHeight;
                    arrow->Step = this->Attributes[0];
                }
                else Game->PlaySound(errorSFX);
            }
        }
        
        
        
    }
}

Comments