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.

Actor Damage Sounds- Further assistance needed.

Ahoy there, Im not too sure if this belongs in this part or the general support, but I'll start it here..

I want my characters to make a certain sound when attacked, like a sort of "ow" sound when they get hit [I can do the sounds myself anyway] and I just dont know how to make it that when a certain actor gets hit it plays a different sound.. [hard to understand? Ill try again]

So lets say this is what Happens
Tea gets hit by Goblin, then a SE is played when the goblin hits then the damage appears.

Now I could just set the attack function to play a normal sound, but Id rather it change for each of my 4 characters, Tea, Tix, Tor and Tam so that each of them has their own damage voice.

Can someone help me out in figuring out how to do this.

ON another note, I have minimal scripting skill... and I can't seem to locate a script for this.
 
Try this...    paste in a new script above 'main'

You'll need a sound effect file in the Audio\SE folder with the name: <actor_name>.ogg

Code:
class Scene_Battle
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 5 : damage display)
  # BREW - Customized to play an actor specific 'Hit' sound
  #--------------------------------------------------------------------------
  def update_phase4_step5
    # Hide help window
    @help_window.visible = false
    # Refresh status window
    @status_window.refresh
    # Display damage
    for target in @target_battlers
      if target.damage != nil
        target.damage_pop = true
        # if actor, look for custom 'ouch' sound
        if target.damage != "Miss" and target.damage > 0
          if target.is_a?(Game_Actor)
            # check for custom sound effect
            filename = "Audio\\SE\\" + target.name + ".ogg"
            if FileTest.exist?(filename)
              Audio.se_play(filename)
            else
              print "File: " + filename + " not found."
            end
          end
        end
      end
    end
    # Shift to step 6
    @phase4_step = 6
  end
end

Be Well
 
replace it with "if target.damage != "Miss" AND target.damage > 0",
or just add the "AND target.damage > 0"  on the end.

I just showed the old statement commented for clarity. I usually do this in scripts I modify so I can find the
modifications easily.

The "AND target.damage > 0" part will only allow the SE if the damage is positive. (negative damage = healing).
We have to leave the 'if target.damage != "Miss"', since "Miss" is > 0.

Be Well
 

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