Jump to content

Photo

Item Action Scrtipt Request (SFX)


  • Please log in to reply
79 replies to this topic

#1 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 29 March 2016 - 07:36 PM

Hi, I'm looking for a way to make a sound effect play when Link uses a button item (on the button press). I would like to use it for custom items, but there is also a situation where I want to prevent the default sound effect (for placing a bomb) from playing so that I can replace it with a different sound effect entirely.

 

Can either of these be done?



#2 C-Dawg

C-Dawg

    Magus

  • Members

Posted 29 March 2016 - 07:48 PM

item script beep{
 
void run(int sound){
Game->PlaySound(sound);
}
 
}

Put that on an item and it'll play a sound when the item is used.  Use the Data fields in the item script to tell it which sound to play, or  0 for none.


Edited by C-Dawg, 29 March 2016 - 07:49 PM.

  • Cukeman, Demonlink and Kivitoe like this

#3 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 30 March 2016 - 12:31 AM

item script beep{
 
void run(int sound){
Game->PlaySound(sound);
}
 
}

Put that on an item and it'll play a sound when the item is used.  Use the Data fields in the item script to tell it which sound to play, or  0 for none.

 

 

Thank you, it works great, now if only I could disable the default sound effect for placing a bomb...

 

I mean, I can replace it with a silent sound file, but that would also make the item select confirmation sound silent...



#4 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 30 March 2016 - 10:40 AM

Yeah, I guess you'll have to find a sound effect that sounds good for both item select confirmation and placing a bomb.



#5 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 30 March 2016 - 12:45 PM

Aw. So much for being true to MC



#6 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 30 March 2016 - 12:55 PM

Couldn't you just rescript the bomb item? It seems like they did it in the old version of Echoes of Aurelia. I'm not exactly sure, though.

 

https://www.youtube....h?v=HToXWh3Bceg


  • Avaro likes this

#7 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 30 March 2016 - 02:34 PM

Couldn't you just rescript the bomb item? It seems like they did it in the old version of Echoes of Aurelia. I'm not exactly sure, though.

 

https://www.youtube....h?v=HToXWh3Bceg

 

I wondered about that, but wouldn't it need to be a default bomb item to set off bomb triggers?



#8 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 30 March 2016 - 02:45 PM

No, as long as it creates a bomb explosion lweapon, it'll trigger bomb flags. The actual script would be easy. If item is used, call FFC script. Place FFC at spot, give bomb graphics. Wait x frames. Clear FFC graphical data, make explosion lweapon on the spot. The only potentially tricky part would be if you want the bomb to animate, since relying on default combo animations for these things rarely works, and you'd probably wanna hard code it to advance tile by tile of animation at specific intervals.
  • Jared likes this

#9 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 30 March 2016 - 03:36 PM

item script beep{
 
void run(int sound){
Game->PlaySound(sound);
}
 
}

Put that on an item and it'll play a sound when the item is used.  Use the Data fields in the item script to tell it which sound to play, or  0 for none.

 

 

 

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 so that the sound only plays when I actually use the item? (I'm testing a non-bomb item at the moment)


Edited by Cukeman, 30 March 2016 - 03:40 PM.


#10 C-Dawg

C-Dawg

    Magus

  • Members

Posted 30 March 2016 - 03:37 PM

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.


#11 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 30 March 2016 - 03:48 PM

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.

 


So, if I understand correctly, I can create a custom item, and when I use this script, it will essentially create a bomb using the bomb placement SFX I specify?


Edited by Cukeman, 30 March 2016 - 03:54 PM.


#12 C-Dawg

C-Dawg

    Magus

  • Members

Posted 30 March 2016 - 03:54 PM

Yeah, unless I goofed, it should.  You can spawn an LWeapon of any kind and place it anywhere you want.

 

If you want to do something more creative, instead of spawning the bomb item, find an empty FFC, give it a script, and have that script tell it how to act.  Bombchus or whatever can be made this way.  Then, the FFC script can do whatever kind of animation you like and end by spawning bomb explosion Lweapons.



#13 grayswandir

grayswandir

    semi-genius

  • ZC Developers

Posted 30 March 2016 - 05:00 PM

That doesn't set damage, though? I guess it'll stun.



#14 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 02 April 2016 - 08:03 PM

Stick in the appropriate ID for a bomb-type LWeapon (you can find it in Zscript.txt and you're done.

 

What am I looking for exactly, a number? I'm not seeing a list of numbered IDs.



#15 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 02 April 2016 - 08:09 PM

//LWeapon types. Use with Screen->CreateLWeapon() and Screen->LoadLWeapon().
const int LW_SWORD              = 1; // This cannot be created
const int LW_WAND               = 12; // This cannot be created
const int LW_CANDLE             = 12; // This cannot be created
const int LW_HAMMER             = 19; // This cannot be created
const int LW_HOOKSHOT           = 20; // This cannot be created
const int LW_CANEOFBYRNA        = 27; // This cannot be created
const int LW_ARROW              = 8;
const int LW_BEAM               = 2; // Sword beam
const int LW_BRANG              = 3;
const int LW_BOMB               = 6;
const int LW_BOMBBLAST          = 4; // Bomb explosion
const int LW_SBOMB              = 7;
const int LW_SBOMBBLAST         = 5; // Super Bomb explosion
const int LW_FIRE               = 9;
const int LW_WHISTLE            = 10; // Whistle music - kills Digdogger
const int LW_BAIT               = 11;
const int LW_MAGIC              = 13; // Wand magic
const int LW_WIND               = 15; // Whistle whirlwind
const int LW_REFMAGIC           = 16; // Reflected wand magic
const int LW_REFFIREBALL        = 17; // Reflected fireball
const int LW_REFROCK            = 18; // Reflected rock
const int LW_REFBEAM            = 28; // Reflected sword beam
const int LW_SPARKLE            = 23;
const int LW_FIRESPARKLE        = 24; // Damages enemies
// Dummy weapons, for use with scripts.
const int LW_SCRIPT1            = 31;
const int LW_SCRIPT2            = 32;
const int LW_SCRIPT3            = 33;
const int LW_SCRIPT4            = 34;
const int LW_SCRIPT5            = 35;
const int LW_SCRIPT6            = 36;
const int LW_SCRIPT7            = 37;
const int LW_SCRIPT8            = 38;
const int LW_SCRIPT9            = 39;
const int LW_SCRIPT10           = 40;
These are in std_constants.zh, not zscript.txt.
  • Cukeman likes this


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users