Jump to content

Photo

If Sound3 is playing reduce Bat health by 1


  • Please log in to reply
5 replies to this topic

#1 LikeLike888

LikeLike888

    Spicy food lover!!

  • Members
  • Real Name:Jason
  • Location:North America

Posted 12 September 2016 - 09:34 PM

GML stands for Game Maker Language


Here is GML version of what I want:
if (sound_isplaying(sound3))
{
  if (instance_exists(Bat))
  {
    Bat.hp -= 1;
  }
}

How do I properly do ZScript version of what I want please?

#2 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 12 September 2016 - 09:48 PM

You don't. There is no function like sound_isplaying() in ZScript. There is a PlaySound(), so you can put the bat health reduction in the same spot that plays the sound. If it's a non-scripted event, though, you're going to have to hope there's some other proxy for detecting it.
  • LikeLike888 likes this

#3 idontknow8

idontknow8

    Senior

  • Members

Posted 12 September 2016 - 11:23 PM

I think playing a sound is write-only, meaning you can have a script tell the game to play a sound…the script is:  Game->PlaySound(3).  However, I don't think an if statement would work properly, that is:  if(Game->PlaySound(3)){

 

HOWEVER, you could script an event to play sound 3 and then simultaneously if whenever that event is triggered, it also triggers the HP reduction.


  • LikeLike888 likes this

#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 13 September 2016 - 09:59 PM

I can confirm both relies above. There isn't even an easy way that I could add book PlayingSound(it sound) to the language.

I could make something that you could use to check if sounds player by scripts are still playing, but it wouldn't be perfect.

What I would do, is make a function PlaySfx(int sound) that plays the sound, looks up its duration from an array, and starts or resets a timer (also in that array) to that duration.

Tick down all timers above zero every frame, and you can check if a scripted sound is still playing by reading if its timer is valid.

Edited by ZoriaRPG, 14 September 2016 - 04:23 AM.


#5 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 13 September 2016 - 10:20 PM

Out of curiosity, I checked std_constants.zh and found that SFX #3 is a bomb blast. If you're not using a script to play that sound, perhaps you could more easily check to see if there's a bomb blast or super bomb blast on screen?



#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 15 September 2016 - 01:32 PM

Out of curiosity, I checked std_constants.zh and found that SFX #3 is a bomb blast. If you're not using a script to play that sound, perhaps you could more easily check to see if there's a bomb blast or super bomb blast on screen?


There is also that... hahah.

If it's just the explosion sound he's after, then launch an ffc whenever a bombblast occurs, and for x-frames, hurt npcs with a desired ID, where x-seconds is the duration of the explosion sound, then clear and quit the ffc.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users