I wondered about that, but wouldn't it need to be a default bomb item to set off bomb triggers?
item script beep{
void run(int sound){
Game->PlaySound(sound);
lweapon bomb = Screen->CreateLWeapon(BombID);
if(Link->Dir==0){ bomb->X = Link->X; bomb->Y = Link->Y-16;
else if(Link->Dir==1){ bomb->X = Link->X; bomb->Y = Link->Y+16;
else if(Link->Dir==2){ bomb->X = Link->X-16; bomb->Y = Link->Y;
else { bomb->X = Link->X+16; bomb->Y = Link->Y;
}
}
Stick in the appropriate ID for a bomb-type LWeapon (you can find it in Zscript.txt and you're done.
Something I noticed, this script plays the sound effect every time I press the button, which means that if I press the button rapidly 5 times, I will be hearing the sound between item uses. Can this be adjusted?
Yes, but you will need to do a little more work. Item scripts do not allow loops, (they terminate after one clock tic) so you need to use the item script to interact with something that will persist over more than one frame. You could either:
1. Declare a global variable that the global script decrements each frame, and then have your bomb script only function (and set the variable to a high number) when that variable is at 0.
2. Have your item script go get a blank FFC and assign it an FFC script, which can run loops and persist. Then, the bomb script would check and see if that script is already running on an FFC before actually doing anything.
Either way is fine.
Edited by C-Dawg, 30 March 2016 - 03:40 PM.