My game generally pretty heavily uses elemental resistances and vulnerabilities, and I feel like it'd really reduce the amount of trial and error involved in figuring out resistances as a player if the game would just let you know if you've just hit one. Preferably it'd just have a little image pop up alongside the damage number, or let me set it to a specific animation from the animations tab of the database.
Script that visually indicates when you hit an elemental resistance/vulnerability?
RGSS Script RequestsYou might like to try Yanfly's element popups. You can get the script here.
almost not quite. He needs it for XP
This is neat, but... color-coding is actually the one thing that wouldn't work since my game's all in black and white.
also this is for vx ace
Oops! Sorry about that. I missed that it was for XP. My apologies.
I'm not too familiar with any script that does this, so I spent some time trying to come up with one. I'd like to give it a configuration, but I can already imagine the number of possible features one would want and how difficult it would be to cater to, for instance, custom battle systems.
I started going down the route of using Icons to display but decided to just use the RTP windowskin arrow instead. You can see it commented out in the script (icon graphic names would be "weak" and "strong").
Anyways, here's a proof-of-concept script:
Plug-n-play as is. This is the result of Cross Cutting a ghost:
I started going down the route of using Icons to display but decided to just use the RTP windowskin arrow instead. You can see it commented out in the script (icon graphic names would be "weak" and "strong").
Anyways, here's a proof-of-concept script:
Ruby:
class Game_Battler
attr_reader :element_effect
alias set_ee_after_attack_effect attack_effect
def attack_effect(attacker)
effective = set_ee_after_attack_effect(attacker)
@element_effect = nil
if self.damage.is_a?(Numeric) && effective
@element_effect = elements_correct(attacker.element_set)
end
effective
end
alias set_ee_after_skill_effect skill_effect
def skill_effect(user, skill)
effective = set_ee_after_skill_effect(user, skill)
@element_effect = nil
if self.damage.is_a?(Numeric) && effective
@element_effect = elements_correct(skill.element_set)
end
effective
end
alias set_ee_after_item_effect item_effect
def item_effect(item)
effective = set_ee_after_item_effect(item)
@element_effect = nil
if self.damage.is_a?(Numeric) && effective
@element_effect = elements_correct(item.element_set)
end
effective
end
end
class Sprite_Battler < RPG::Sprite
def damage(*args)
element_effect = nil
if @battler.element_effect && @battler.element_effect != 100
element_effect =
if @battler.element_effect > 100
'weak'
elsif @battler.element_effect > 0
'strong'
end
end
super(@battler.damage, @battler.critical, element_effect)
end
end
class RPG::Sprite < ::Sprite
alias dispose_element_effect_after dispose_damage
def dispose_damage
dispose_element_effect_after
if @_element_effect_sprite != nil
@_element_effect_sprite.bitmap.dispose
@_element_effect_sprite.dispose
@_element_effect_sprite = nil
end
end
alias call_original_damage damage
def damage(value, critical, element_effect)
call_original_damage(value, critical)
return if element_effect.nil?
# -- Uses Icon graphics instead of the windowskin arrow
#text_width = @_damage_sprite.bitmap.text_size(value.abs.to_s).width
#@_element_effect_sprite = ::Sprite.new(self.viewport)
#@_element_effect_sprite.bitmap = RPG::Cache.icon(element_effect)
#@_element_effect_sprite.x = self.x - text_width / 2 - 16
#@_element_effect_sprite.y = self.y - self.oy / 2 - 12
#@_element_effect_sprite.z = 2999
text_width = @_damage_sprite.bitmap.text_size(value.abs.to_s).width
@_element_effect_sprite = ::Sprite.new(self.viewport)
@_element_effect_sprite.bitmap = RPG::Cache.windowskin('001-Blue01')
@_element_effect_sprite.src_rect.set(160,96,32,32)
@_element_effect_sprite.angle = 180 if element_effect == 'strong'
@_element_effect_sprite.ox = 16
@_element_effect_sprite.oy = 16
@_element_effect_sprite.x = self.x - text_width / 2
@_element_effect_sprite.y = self.y - self.oy / 2
@_element_effect_sprite.z = 2999
end
alias update_element_effect_sprite_after update
def update
update_element_effect_sprite_after
if @_damage_duration > 0 && @_element_effect_sprite
case @_damage_duration
when 38..39
@_element_effect_sprite.y -= 4
when 36..37
@_element_effect_sprite.y -= 2
when 34..35
@_element_effect_sprite.y += 2
when 28..33
@_element_effect_sprite.y += 4
end
@_element_effect_sprite.opacity = 256 - (12 - @_damage_duration) * 32
end
end
end
This is really good, thank you! Would you be able to change it so I can use Pictures instead of the arrows from the windowskin? Other than that, this is perfect.
Edit: In particular I'd like to be able to display these specific popups.
Edit: Nevermind! I tinkered with the script and got it working the way I'd like it. Here's my current code:
Edit: In particular I'd like to be able to display these specific popups.
Edit: Nevermind! I tinkered with the script and got it working the way I'd like it. Here's my current code:
Ruby:
class Game_Battler
attr_reader :element_effect
alias set_ee_after_attack_effect attack_effect
def attack_effect(attacker)
effective = set_ee_after_attack_effect(attacker)
@element_effect = nil
if self.damage.is_a?(Numeric) && effective
@element_effect = elements_correct(attacker.element_set)
end
effective
end
alias set_ee_after_skill_effect skill_effect
def skill_effect(user, skill)
effective = set_ee_after_skill_effect(user, skill)
@element_effect = nil
if self.damage.is_a?(Numeric) && effective
@element_effect = elements_correct(skill.element_set)
end
effective
end
alias set_ee_after_item_effect item_effect
def item_effect(item)
effective = set_ee_after_item_effect(item)
@element_effect = nil
if self.damage.is_a?(Numeric) && effective
@element_effect = elements_correct(item.element_set)
end
effective
end
end
class Sprite_Battler < RPG::Sprite
def damage(*args)
element_effect = nil
if @battler.element_effect && @battler.element_effect != 100
element_effect =
if @battler.element_effect > 100
'weak'
elsif @battler.element_effect > 0
'strong'
elsif @battler.element_effect < 1
'immune'
end
end
super(@battler.damage, @battler.critical, element_effect)
end
end
class RPG::Sprite < ::Sprite
alias dispose_element_effect_after dispose_damage
def dispose_damage
dispose_element_effect_after
if @_element_effect_sprite != nil
@_element_effect_sprite.bitmap.dispose
@_element_effect_sprite.dispose
@_element_effect_sprite = nil
end
end
alias call_original_damage damage
def damage(value, critical, element_effect)
call_original_damage(value, critical)
return if element_effect.nil?
# -- Uses Icon graphics instead of the windowskin arrow
#text_width = @_damage_sprite.bitmap.text_size(value.abs.to_s).width
#@_element_effect_sprite = ::Sprite.new(self.viewport)
#@_element_effect_sprite.bitmap = RPG::Cache.icon(element_effect)
#@_element_effect_sprite.x = self.x - text_width / 2 - 16
#@_element_effect_sprite.y = self.y - self.oy / 2 - 12
#@_element_effect_sprite.z = 2999
text_width = @_damage_sprite.bitmap.text_size(value.abs.to_s).width
@_element_effect_sprite = ::Sprite.new(self.viewport)
@_element_effect_sprite.bitmap = RPG::Cache.picture('QZ-1-vulnerable') if element_effect == 'weak'
@_element_effect_sprite.bitmap = RPG::Cache.picture('QZ-2-resisted') if element_effect == 'strong'
@_element_effect_sprite.bitmap = RPG::Cache.picture('QZ-3-immune') if element_effect == 'immune'
@_element_effect_sprite.ox = 16
@_element_effect_sprite.oy = 16
@_element_effect_sprite.x = self.x - text_width / 2
@_element_effect_sprite.y = self.y - self.oy / 2
@_element_effect_sprite.z = 2999
end
alias update_element_effect_sprite_after update
def update
update_element_effect_sprite_after
if @_damage_duration > 0 && @_element_effect_sprite
case @_damage_duration
when 38..39
@_element_effect_sprite.y -= 4
when 36..37
@_element_effect_sprite.y -= 2
when 34..35
@_element_effect_sprite.y += 2
when 28..33
@_element_effect_sprite.y += 4
end
@_element_effect_sprite.opacity = 256 - (12 - @_damage_duration) * 32
end
end
end
Hey, nice work finishing the script off for yourself!
As a pro tip, you can just do this instead:
As a pro tip, you can just do this instead:
Code:
if @battler.element_effect > 100
'QZ-1-vulnerable'
elsif @battler.element_effect > 0
'QZ-2-resisted'
elsif @battler.element_effect < 1
'QZ-3-immune'
Code:
@_element_effect_sprite.bitmap = RPG::Cache.picture(element_effect )
The main reason I did that was because I wanted to use an arrow graphic from the RTP. I forgot that RMXP doesn't have any icons like that and spent some time making my own. Then I remembered about the triangle on the windowskin. I just wanted something plug-n-play for easy testing without having to provide any extra files.
Ah, thank you! That would've been smart. I'm not really any sort of actual scripter, I mostly just figure that stuff out through trial & error and context clues; I super appreciate the help!
Original thread: https://forums.rpgmakerweb.com/threads/script-that-visually-indicates-when-you-hit-an-elemental-resistance-vulnerability.149494/