item falls into pit
#1
Posted 08 April 2019 - 02:26 PM
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
Posted 08 April 2019 - 02:50 PM
I am also very interested in this as well sounds like a lot can be done with this.
#3
Posted 08 April 2019 - 03: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
Posted 09 April 2019 - 05:26 PM
Honestly i was thinking the same thing but i guess i have the anwser
#5
Posted 09 April 2019 - 05: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.
#6
Posted 10 April 2019 - 07:42 AM
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 - 12:00 PM.
#7
Posted 10 April 2019 - 08: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
Posted 11 April 2019 - 02: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
Posted 12 April 2019 - 08: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
Posted 15 April 2019 - 09:39 AM
Are there any arguements to set?
#11
Posted 16 April 2019 - 10: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.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users