[SCRIPTING] [RMVX ACE] IS THERE A WAY TO PLAY SOUNDS ON INEFFECTIVE ATTACKS?

Posts

Pages: 1
Is there a way to play a sound when an attack type is resisted by the target?
I can't seem to find a script for it, is it not possible in RPG Maker VX Ace?
I'm guessing you can force it by adding a play command in one of the attack effectivity tests in Game_Battler.

I'm on my phone, so I can't confirm right now though...
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Audio.se_play("Audio/SE/filename")

You can supply volume and pitch as optional parameters after the filename.

Edit: Or are you looking for where in the scripts to put that?
author=Trihan
Audio.se_play("Audio/SE/filename")
You can supply volume and pitch as optional parameters after the filename.

Edit: Or are you looking for where in the scripts to put that?


I'm actually entirely clueless on how to achieve the effect at all.
Whether I'm supposed to put it in notetags in the database somewhere, or find an entire script for it, or to add something within existing scripts...
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Okay, I'll tell you where you need to put it. One sec. Just to clarify, do you only want to play this sound specifically if the target's resistances caused less than 100% of normal damage?
author=Trihan
Okay, I'll tell you where you need to put it. One sec. Just to clarify, do you only want to play this sound specifically if the target's resistances caused less than 100% of normal damage?


Ah, yes!
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Okay, probably the way I would do this would be to add a :resisted attr_accessor property to Game_Battler and alias initialize to set @resisted to false before doing the other initialisation stuff. Then I would alias make_damage_value to look something like this:

def make_damage_value(user, item)
    value = resist_check = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    @resisted = true if value < resist_check
    value *= rec if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
  end

And then in perform_damage_effect of Game_Enemy:

def perform_damage_effect
    @sprite_effect_type = :blink
    if @resisted
      Audio.se_play("Audio/SE/parry")
    else
      Sound.play_enemy_damage
    end
    @resisted = false
  end

And the same sort of thing for perform_damage_effect in Game_Actor.

Obviously you'd have to put together a script that will overwrite those unless you want to edit the defaults (which I wouldn't recommend) and replace 'parry' with whatever SE you want to have on resist (you could even add it to Audio as a method so you can call that instead).
author=Trihan
Okay, probably the way I would do this would be to add a :resisted attr_accessor property to Game_Battler and alias initialize to set @resisted to false before doing the other initialisation stuff. Then I would alias make_damage_value to look something like this:

def make_damage_value(user, item)
    value = resist_check = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    @resisted = true if value < resist_check
    value *= rec if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
  end


And then in perform_damage_effect of Game_Enemy:

def perform_damage_effect
    @sprite_effect_type = :blink
    if @resisted
      Audio.se_play("Audio/SE/parry")
    else
      Sound.play_enemy_damage
    end
    @resisted = false
  end


And the same sort of thing for perform_damage_effect in Game_Actor.

Obviously you'd have to put together a script that will overwrite those unless you want to edit the defaults (which I wouldn't recommend) and replace 'parry' with whatever SE you want to have on resist (you could even add it to Audio as a method so you can call that instead).


It worked!! Thank you Trihan!
Pages: 1