Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

changing enemy collapse sound effect in-battle

Hi all,

Was wondering if someone knew how to alter the enemy collapse se (and other system sounds) in battle. So, for example, a goblin would make a different grunt noise than a human once he collapsed in battle. I'm familiar with scripts such as this: $game_system.enemy_collapse_se = "<filename>", which one could use to enact in an event to change any system sound. How might I set this up so that every monster/actor returns a different sound when they collapse?
 
[rgss]module EnemyCollapse
  # enemy_id => 'Se filename'
  SE = {}
  # Collection - Do not modify
  SE.each {|k, v| SE[k] = RPG::AudioFile.new(v)}
end
 
class Sprite_Battler
  alias_method :seph_enemycollapsese_sprbtlr_update, :update
  def update
    old_collapse = $data_system.enemy_collapse_se.dup
    if @battler != nil && @battler.is_a?(Game_Enemy) && EnemyCollapse::SE.has_key?(@battler.id)
      $data_system.enemy_collapse_se = EnemyCollapse::SE[@battler.id].dup
    end
    seph_enemycollapsese_sprbtlr_update
    $data_system.enemy_collapse_se = old_collapse
  end
end
[/rgss]

Just insert above Main. Add enemy_id=>'se filename' pairs in the SE = {} line.
- Example: Enemy 1-'Collapse01', Enemy 3-'Collapse02'
Code:
SE = {1=>'Collapse01', 3=>'Collapse02'}

Let me know how that works for you.
 
Hmm, thanks for the quick reply, but I couldn't get that to work for me. I typed in SE = {2=>'goblin_die.wav'} under main. Does that line know to specifically replace the system enemy collapse se with a new sound?

I'm using GubiD's tactical battle system, by the way. I can change in battle sounds using conditional options (i.e., if enemy's HP is 1% or below, play "sound.wav."), but this method doesn't return the sound until after the turn is over, resulting in an unrealistic gap between the time the enemy is defeated and the battle grunt. I just want mine to happen instantaneously as with the in-game enemy collapse sound effect.

Thanks!
 
Yeah, I figured I'd have to modify something in the CBS script.

Gubid's tactical battle script: viewtopic.php?t=32656.0 The link to the cbs is under "current releases" at the top. I've emailed the creator of the script several times with this question but haven't gotten a response, so I figured I'd try this forum.

Thanks again SephirothSpawn.
 
The code you sent me works, as long as you have the right sound file in the SE folder.

Code:
class Sprite_Battler

  def collapse

    super

#    if @battler.is_a?(Game_Actor)

      sound = "Audio\\SE\\"

      sound.concat(@battler.name)

      sound.concat(".mp3")

#      print sound

      if FileTest.exist?(sound)

        Audio.se_play(sound)

      end

#    end

  end

end

Your problem might be that you are using the wrong filename? @battler.name is the character's name. (e.g Aluxes) not the battler file name (001-Fighter01). I put a file called "Aluxes.mp3" in the SE folder, and when Aluxes dies, I heard it.

You mentioned wanting a different sound for each character/monster. So change the 2nd concast line to:

sound.concat("_die.mp3")

Then create files for each actor & monster using their name (Aluxes_die.mp3, Goblin_die.mp3, etc...)

Also, to play for monsters, you don't need the "if @battler.is_a?(Game_Actor)" statement. (I commented it out)

The 'print' statement is to check/debug the filename it's looking for.

Be Well
 
Thanks Brewmeister. Actually, the code works fine with the default battle system, but apparently not with Gubid's tactical battle system (and I was never able to get a hold of Gubid).
 
Also, if anyone is interested, I found a way (albeit somewhat complicated) to return character and enemy "hit" as well as "collapse" sound effects through events only. Works very well, though, even with a custom battle system such as Gubid's.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top