Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// v5
- /// Functions to grab, or drag keys, or items in lists back to Link; or give instantly to Link,
- /// when touched by a hookshot, or boomerang:
- /// Default function uses only keys, and level keys as objects to collect with these weapons.
- /// Other versions accept args to do any of the following:
- /// Return the item matching coordinates of lweapon each frame.
- /// ( May be unsafe? Will item return to its position if Link doesn;t take it? it ...should. )
- /// Give the item directly to Link (instantaneous)
- /// Hold the item overhead (bool holdUpItem).
- /// Accept an array (int list) listing other itemd to give when a brang or hookshot touches them; obeys the same physics defined by bool instantaneous, and bool holdUpItem.
- const int SFX_HOLDTOHAND = 20;
- //Drags keys back to Link, if touched by a boomerang, or hookshot. Call every frame before Waitdraw();
- void BrangKey_Drag(int holdUpItem)
- {
- holdUpItem = Clamp(holdUpItem,0,2);
- for ( int q = Screen->NumLWeapons(); q > 0; --q )
- {
- lweapon w = Screen->LoadLWeapon(q);
- if ( w->ID == LW_BRANG || w->ID == LW_HOOKSHOT )
- {
- for ( int e = Screen->NumItems(); e > 0; --e )
- {
- item a = Screen->LoadItem(e);
- if ( Collision (w,a) )
- {
- if ( a->ID == I_KEY || a->ID == I_LEVELKEY)
- {
- w->DeadState = WDS_BOUNCE; //Starts return anim for boomerang, or hookshot.
- //Bouncing must precede item movement.
- if ( a->isValid() )
- {
- a->Z = 0;
- a->X = w->X;
- a->Y = w->Y; //Drag the item back to Link.
- if ( holdUpItem )
- {
- if ( a->Y == Link->Y )
- {
- if ( a->X == Link->X )
- {
- Link->Action = LA_HOLD1LAND+(holdUpItem-1); //Hold item over head.
- Game->PlaySound(SFX_HOLDTOHAND);
- Link->HeldItem = a->ID;
- }
- }
- }
- }
- }
- else continue;
- }
- }
- }
- }
- }
- //instantly gives Link the item.
- void BrangKey_Instant(int holdUpItem)
- {
- holdUpItem = Clamp(holdUpItem,0,2);
- for ( int q = Screen->NumLWeapons(); q > 0; --q )
- {
- lweapon w = Screen->LoadLWeapon(q);
- if ( w->ID == LW_BRANG || w->ID == LW_HOOKSHOT )
- {
- for ( int e = Screen->NumItems(); e > 0; --e )
- {
- item a = Screen->LoadItem(e);
- if ( Collision (w,a) )
- {
- if ( a->ID == I_KEY || a->ID == I_LEVELKEY )
- {
- w->DeadState = WDS_BOUNCE; //Starts return anim for boomerang, or hookshot.
- //Bouncing must precede item movement.
- if ( a->isValid() )
- {
- a->Z = Link->Z;
- a->X = Link->X;
- a->Y = Link->Y; //Drag the item back to Link.
- if ( holdUpItem )
- {
- Link->Action = LA_HOLD1LAND+(holdUpItem-1); //Hold item over head.
- Game->PlaySound(SFX_HOLDTOHAND);
- Link->HeldItem = a->ID;
- }
- }
- }
- else continue;
- }
- }
- }
- }
- }
- //Drags keys, or anything on specified array of items back to link if touched by a boomerang, or hookshot.
- void BrangPickup_Drag(int list, int holdUpItem)
- {
- holdUpItem = Clamp(holdUpItem,0,2);
- for ( int q = Screen->NumLWeapons(); q > 0; --q )
- {
- lweapon w = Screen->LoadLWeapon(q);
- if ( w->ID == LW_BRANG || w->ID == LW_HOOKSHOT )
- {
- for ( int e = Screen->NumItems(); e > 0; --e )
- {
- item a = Screen->LoadItem(e);
- if ( Collision (w,a) )
- {
- for ( int r = SizeOfArray(list); r >=0; --r )
- {
- if ( a->ID == list[r] )
- {
- w->DeadState = WDS_BOUNCE; //Starts return anim for boomerang, or hookshot.
- //Bouncing must precede item movement.
- if ( a->isValid() )
- {
- a->Z = 0;
- a->X = w->X;
- a->Y = w->Y;
- if ( holdUpItem )
- {
- if ( a->Y == Link->Y )
- {
- if ( a->X == Link->X )
- {
- Link->Action = LA_HOLD1LAND+(holdUpItem-1); //Hold item over head.
- Game->PlaySound(SFX_HOLDTOHAND);
- Link->HeldItem = a->ID;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- //Drags keys, or anything on specified array of items back to link if touched by a boomerang, or hookshot.
- void BrangPickup_Instant(int list, int holdUpItem)
- {
- holdUpItem = Clamp(holdUpItem,0,2);
- for ( int q = Screen->NumLWeapons(); q > 0; --q )
- {
- lweapon w = Screen->LoadLWeapon(q);
- if ( w->ID == LW_BRANG || w->ID == LW_HOOKSHOT )
- {
- for ( int e = Screen->NumItems(); e > 0; --e )
- {
- item a = Screen->LoadItem(e);
- if ( Collision (w,a) )
- {
- for ( int r = SizeOfArray(list); r >= 0; --r )
- {
- if ( a->ID == list[r] )
- {
- w->DeadState = WDS_BOUNCE; //Starts return anim for boomerang, or hookshot.
- //Bouncing must precede item movement.
- if ( a->isValid() )
- {
- a->Z = 0;
- a->X = Link->X;
- a->Y = Link->Y; //Give the item directly to Link
- if ( holdUpItem )
- {
- Link->Action = LA_HOLD1LAND+(holdUpItem-1); //Hold item over head.
- Game->PlaySound(SFX_HOLDTOHAND);
- Link->HeldItem = a->ID;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- //! TEST GLOBAL ACTIVE
- global script test_brangkey5
- {
- void run()
- {
- while(1)
- {
- BrangKey_Instant(1);
- Waitdraw();
- Waitframe();
- }
- }
- }
- // SCREEN SPECIFIC FFCs
- ffc script test_brangkey5_ffc
- {
- void run()
- {
- while(1)
- {
- BrangKey_Instant(1);
- Waitframe();
- }
- }
- }
- ////////////////////
- /// Item Pick-Up ///
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /// This script creates an FFC, that gives Link a key, and clears the FFC if the FFC is touched by the ///
- /// boomerang, or the hookshot. This is useful if you want the boomerang/hookshot to pick up keys as in Z3, ///
- /// without also allowing them to pick up other special items (per quest rules for Z3 boomerang. ///
- /// ///
- /// Note: The pick-up is instantaneous, and does not need to wait for Link to touch the item. ///
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /// RUN ON SCREEN INIT! ///
- /// D0: Set to 0 to give a normal key, or 1 to give a key specific to the level that the player is inside. ///
- /// Set to a negative number to give specific item, OTHER THAN a key. ///
- /// D1: Set this to the Sound Effect to play on giving the player the item, from Quest->Audio->SFX Data. ///
- /// D2: Set this to the 1 to hold the item with one hand, 2 to hold with 2 hands. ///
- /// D3: Screen->D[register] to use. ///
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ffc script Z3_Key_Pickup
- {
- void run(int level, int SFX, int holdUpItem, int reg)
- {
- holdUpItem = Clamp(holdUpItem,0,2);
- reg = Clamp(reg,0,7);
- bool waiting = true;
- while(waiting)
- {
- if ( Screen->D[reg] )
- { // If the FFC has already run on the screen
- this->Data = 0; //Remove sprite
- return; //Quit
- }
- else
- {
- for (int q = Screen->NumLWeapons(); q > 0; --q )
- { // Loop through all LWeapons on screen.
- lweapon lw = Screen->LoadLWeapon(q);
- if ( lw->ID == LW_BRANG || lw->ID == LW_HOOKSHOT )
- {
- if (lw->CollDetection && Collision(this, lw)) // If the LWeapon is touching us.
- {
- waiting = false;
- if ( !level )
- {
- ++Game->Counter[CR_KEYS];
- Game->PlaySound(SFX);
- Screen->D[reg] = 1;
- if ( holdUpItem )
- {
- Link->Action = LA_HOLD1LAND+(holdUpItem-1); //Hold item over head.
- Game->PlaySound(SFX_HOLDTOHAND);
- Link->HeldItem = I_KEY;
- }
- this->Data = 0; //Remove sprite
- return; //Quit
- }
- else if ( level > 0 )
- {
- item levelKeyGiven = Screen->CreateItem(I_LEVELKEY);
- levelKeyGiven->X = Link->X;
- levelKeyGiven->Y = Link->Y;
- levelKeyGiven->Z = Link->Z;
- Game->PlaySound(SFX);
- Screen->D[reg] = 1;
- if ( holdUpItem )
- {
- Link->Action = LA_HOLD1LAND+(holdUpItem-1); //Hold item over head.
- Game->PlaySound(SFX_HOLDTOHAND);
- Link->HeldItem = I_LEVELKEY;
- }
- this->Data = 0; //Remove sprite
- return; //Quit
- }
- else if ( level < 0 )
- {
- item levelKeyGiven = Screen->CreateItem(-level);
- if ( holdUpItem )
- {
- levelKeyGiven->Pickup |= IP_HOLDUP;
- }
- levelKeyGiven->X = Link->X;
- levelKeyGiven->Y = Link->Y;
- levelKeyGiven->Z = Link->Z;
- Game->PlaySound(SFX);
- Screen->D[reg] = 1;
- this->Data = 0; //Remove sprite
- return; //Quit
- }
- }
- }
- }
- Waitframe();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment