Need enemy sprite to be flipped horizontally as long as a specified state is applied to it
Flip Enemy Sprite With A State
RGSS3 Script Requeststry this, place above main.
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Mirror sprite ║ Version: 1.01 ║
# ║ Author: Roninator2 ║ ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function: ║ Date Created ║
# ║ Flip battler image is inflicted ╠════════════════════╣
# ║ with a specific state ║ 26 Nov 2021 ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Flip battler sprite while inflicted with a state ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions: ║
# ║ Add the states that will flip the battler image ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates: ║
# ║ 1.01 -> Added check for multiple states ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use: ║
# ║ Free for all uses in RPG Maker ║
# ╚═════════════════════════════════════╝
module R2_Mirror_State
# enter the states that will cause the battler image to reverse
# can be multiple [5,9,14]
STATES = [5,9]
end
class Game_Battler < Game_BattlerBase
attr_accessor :mirror # flip horizontal flag
#--------------------------------------------------------------------------
# * Alias Add State
#--------------------------------------------------------------------------
alias r2_state_mirror_add add_state
def add_state(state_id)
r2_state_mirror_add(state_id)
if state_addable?(state_id)
if R2_Mirror_State::STATES.include?(state_id)
@mirror = true
end
end
end
#--------------------------------------------------------------------------
# * alias Remove State
#--------------------------------------------------------------------------
alias r2_remove_mirror_state remove_state
def remove_state(state_id)
if state?(state_id)
if R2_Mirror_State::STATES.include?(state_id)
clear = true
@states.each do |st|
next if st == state_id
if R2_Mirror_State::STATES.include?(st)
clear = false
end
end
@mirror = false if clear == true
end
end
r2_remove_mirror_state(state_id)
end
end
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# * alias Start Effect
#--------------------------------------------------------------------------
alias r2_start_effect_mirror start_effect
def start_effect(effect_type)
update_mirror
r2_start_effect_mirror(effect_type)
end
#--------------------------------------------------------------------------
# * Update Effect
#--------------------------------------------------------------------------
alias r2_update_mirror_effect update_effect
def update_effect
update_mirror
r2_update_mirror_effect
end
#--------------------------------------------------------------------------
# * Update Mirror
#--------------------------------------------------------------------------
def update_mirror
if @battler.mirror == true
self.mirror = true
else
self.mirror = false
end
end
end
works great, thank you
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
Original thread: https://forums.rpgmakerweb.com/threads/flip-enemy-sprite-with-a-state.142475/