Jump to content

Photo

item falls into pit


  • Please log in to reply
10 replies to this topic

#1 Rocksfan13

Rocksfan13

    Looks best in Blue

  • Members
  • Real Name:Doug
  • Gender:Male
  • Location:Earth

Posted 08 April 2019 - 01:26 PM

Basically I'm looking for a script that will allow an item to fall into a pit, whether it be from link or just an item on the screen.

I'm trying to have a screen were link needs to get a key before it falls into a hole.

Any help is very appreciated.

#2 Flying Fish

Flying Fish

    King of the Fish

  • Members
  • Real Name:Flying fish
  • Gender:Male
  • Location:Under the sea

Posted 08 April 2019 - 01:50 PM

I am also very interested in this as well sounds like a lot can be done with this.



#3 P-Tux7

P-Tux7

    Doyen(ne)

  • Members

Posted 08 April 2019 - 02:57 PM

This would probably be good for a 2.55 script since that has item scripts. In 2.50 you'd probably have to make the key an FFC that can disappear if it touches a pit (or just make a moving combo and it eventually combo cycles to a blank combo after a certain amount of time that it takes to cross the conveyor), and gives you a key and disappears and sets the "screen item gotten" flag to the screen, and the ffc doesn't appear if the screen's item gotten flag is set.



#4 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Gender:Male
  • Location:Judgement Hall

Posted 09 April 2019 - 04:26 PM

Honestly i was thinking the same thing but i guess i have the anwser :P 



#5 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Gender:Male
  • Location:Washington

Posted 09 April 2019 - 04:50 PM

ffc script FallingKey{
	void run(int itemID, int PitCombo, int FallingCombo, int FallingCSet, int FallingTime){
		Waitframes(8); //I don't think this is actually needed, but just in case items work like enemies, let's put it here
		item FallingKey;
		for(int i = Screen->NumItems(); i>0; i--){ //Loop through all items
			FallingKey = Screen->LoadItem(i);
			if(FallingKey->ID == itemID)	//If the desired item is found, stop looping
				break;
		}
		while(true){ //Now our man loop
			if(Screen->ComboT[ComboAt(FallingKey->X+8, FallingKey->Y+8)] == PitCombo){ //If the middle of the item is touching a pit combo
				this->X = FallingKey->X; //Move this FFC to the right spot.
				this->Y = FallingKey->Y;
				this->Data = FallingCombo;
				this->CSet = FallingCSet;
				Remove(FallingKey);
				Waitframes(FallingTime);
				this->Data = 0;
				this->CSet = 0;
				this->X = 0;
				this->Y = 0;
			}
			Waitframe();
		}
	}
}
D0 = The Item ID of the item to make fall into the pit (For example, a key is 9; checking the item editor).
D1 = The combo type of the pit combo.
D2 = The combo of the animation for the item falling into the pit.
D3 = The CSet of the animation.
D4 = The amount of time it takes for that animation to play, in frames.

It's not the best script in the world, but it should do the trick just fine.

P-Tux, your solution way over complicates things. FFC scripts can track items just fine. :P

#6 Rocksfan13

Rocksfan13

    Looks best in Blue

  • Members
  • Real Name:Doug
  • Gender:Male
  • Location:Earth

Posted 10 April 2019 - 06:42 AM

Russ, genius thank you.
Just one request to add on, is it possible to add a sound effect of the item falling into the pit as an arguement?
Would it also be possible to add one for a combo ID?
That could effectively make it so blocks can be pushed into pits.

Edited by Rocksfan13, 10 April 2019 - 11:00 AM.


#7 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Gender:Male
  • Location:Washington

Posted 10 April 2019 - 07:06 PM

ffc script FallingKey{
	void run(int itemID, int PitCombo, int FallingCombo, int FallingCSet, int FallingTime, iny FallingSFX){
		Waitframes(8); //I don't think this is actually needed, but just in case items work like enemies, let's put it here
		item FallingKey;
		for(int i = Screen->NumItems(); i>0; i--){ //Loop through all items
			FallingKey = Screen->LoadItem(i);
			if(FallingKey->ID == itemID)	//If the desired item is found, stop looping
				break;
		}
		while(true){ //Now our man loop
			if(Screen->ComboT[ComboAt(FallingKey->X+8, FallingKey->Y+8)] == PitCombo){ //If the middle of the item is touching a pit combo
				Game->PlaySound(FallingSFX);
				this->X = FallingKey->X; //Move this FFC to the right spot.
				this->Y = FallingKey->Y;
				this->Data = FallingCombo;
				this->CSet = FallingCSet;
				Remove(FallingKey);
				Waitframes(FallingTime);
				this->Data = 0;
				this->CSet = 0;
				this->X = 0;
				this->Y = 0;
			}
			Waitframe();
		}
	}
}
Same as above, except D5 is now the sound effect to play when it falls into the pit.

Creating a script for pushing blocks into pits would be doable, but also a bit more complicated... but doable. I see a couple of different ways this could work. Undercombos are the big issue here. You could potentially have pushblocks on layer 0 and the ground on -2 or -3. Or, the blocks could go on layer 1 or 2... assuming pushblocks work on those layers. I frankly have no idea; I never use pushblocks. Either way... in theory, you could have a script check every block against every pit, but that could easily cause lag on low end machines. So an easier way would be to make the blocks themselves FFCs. I have a half-scripted pushblock FFC, but it doesn't perfectly emulate built-in pushblocks, nor do I particularly wanna make one that does. I suppose the FFC could be scripted to just stick to the pushblock... but I have no idea how pushblocks work internally. I imagine it could work by just checking if the combo under it is a block still and, if not, checking the adjacent spaces to see where the block moved, but I don't know when the combos actually change internally.

#8 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 11 April 2019 - 01:18 AM

ffc script FallingKey{
	void run(int itemID, int PitCombo, int FallingCombo, int FallingCSet, int FallingTime, iny FallingSFX){
		Waitframes(8); //I don't think this is actually needed, but just in case items work like enemies, let's put it here
		item FallingKey;
		for(int i = Screen->NumItems(); i>0; i--){ //Loop through all items
			FallingKey = Screen->LoadItem(i);
			if(FallingKey->ID == itemID)	//If the desired item is found, stop looping
				break;
		}
		while(true){ //Now our man loop
			if(Screen->ComboT[ComboAt(FallingKey->X+8, FallingKey->Y+8)] == PitCombo){ //If the middle of the item is touching a pit combo
				Game->PlaySound(FallingSFX);
				this->X = FallingKey->X; //Move this FFC to the right spot.
				this->Y = FallingKey->Y;
				this->Data = FallingCombo;
				this->CSet = FallingCSet;
				Remove(FallingKey);
				Waitframes(FallingTime);
				this->Data = 0;
				this->CSet = 0;
				this->X = 0;
				this->Y = 0;
			}
			Waitframe();
		}
	}
}
Same as above, except D5 is now the sound effect to play when it falls into the pit.

Creating a script for pushing blocks into pits would be doable, but also a bit more complicated... but doable. I see a couple of different ways this could work. Undercombos are the big issue here. You could potentially have pushblocks on layer 0 and the ground on -2 or -3. Or, the blocks could go on layer 1 or 2... assuming pushblocks work on those layers. I frankly have no idea; I never use pushblocks. Either way... in theory, you could have a script check every block against every pit, but that could easily cause lag on low end machines. So an easier way would be to make the blocks themselves FFCs. I have a half-scripted pushblock FFC, but it doesn't perfectly emulate built-in pushblocks, nor do I particularly wanna make one that does. I suppose the FFC could be scripted to just stick to the pushblock... but I have no idea how pushblocks work internally. I imagine it could work by just checking if the combo under it is a block still and, if not, checking the adjacent spaces to see where the block moved, but I don't know when the combos actually change internally.

 

 

Push blocks work only on layer 0, so, you would need negative layers to preserve a complex floor.



#9 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 12 April 2019 - 07:05 PM

If anyone cares:

 

itemsprite script fallpit
{
    const float MIN_SCALE = 0.01;
    void run(int fallsfx, int fallclk)
    {
        this->Z = 100; int clk = -1;
        fallclk = ( fallclk > 0 ) ? fallclk : 30;
        int curscale;
        while(this->isValid())
        {
            if ( !this->Z && clk == -1 )
            {
                if ( ComboFI(ComboAt(this->X+8, this->Y+8)) == CT_PIT )
                {
                    this->Pickup = IP_DUMMY;
                    clk = fallclk;
                    Audio->PlaySound(fallsfx);
                }
            }
            
            if ( clk > 0 )
            {
                --clk;
                curscale = (( 100/fallclk ) * clk)/100;
                this->Scale = (curscale != 0) ? (curscale) : MIN_SCALE;
                sprites::rectify(this); //Adjust draw position.v
            }
            else if ( clk == 0 )
            {
                //remove it
                Remove(this); Quit();
            }
            Waitframe();
        }
    }
}
               


#10 Rocksfan13

Rocksfan13

    Looks best in Blue

  • Members
  • Real Name:Doug
  • Gender:Male
  • Location:Earth

Posted 15 April 2019 - 08:39 AM

I certainly care.
Are there any arguements to set?

#11 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 16 April 2019 - 09:52 AM

I certainly care.
Are there any arguements to set?

 

Arg D0 is the falling sound, D1 is the timer. The latter defaults to 30 frames, and the former can be made to have a default if desired.

 

Note that this requires 2.55. Its an item sprite scipt.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users