Original Source
- Original title: Hime's Pic Wrap Fix
- Original author: Rutsah
- Original date: June 7, 2021
- Source thread: https://forums.rpgmakerweb.com/threads/himes-pic-wrap-fix.137253/
- Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > RGSSx Script Support
Summary
Hi, because my RPG uses a visual novel style, I often need to display character busts on both ends of the screen, which I have used as common events so I do not have to remember the exact positions and designated pic number each time. To save space for the pics (and not having to include a completely separate pic of character busts with just a horizontal flip), I use Hime's Pic Wrap, only for the "mirror_pic(index)" function. Unfortunately, the script for some reason remembers previous instances of its use,...
Archived First Post
To save space for the pics (and not having to include a completely separate pic of character busts with just a horizontal flip), I use Hime's Pic Wrap, only for the "mirror_pic(index)" function. Unfortunately, the script for some reason remembers previous instances of its use, even from completely different events, maps etc. As a result, the first call of the script works fine, reversing the bust's direction, but the 2nd one reverses the reverse, so my bust ends up looking in the initial direction, and so on. This gets very bizarre very fast, as the various expressions of characters all call the same pic number, so if for example I call the common event for a character to change expressions (aka designated bust pics) twice, the script will also trigger twice.
Is it possible to change the code so that ~at least the mirror_pic command~ only affects the pic called directly below it and nothing else?
Code:
#==============================================================================
# ** Picture Wrapper
# Author: Hime
# Version: 1.4
# Date: Oct 21, 2012
#------------------------------------------------------------------------------
# ** Change log
# Mar 3, 2013
# -fixed bug where `fade` causes picture to move to origin
# Oct 21, 2012
# -added support for fixed images (do not move with the screen)
# May 5, 2012
# -added grayscale toggling
# -added horizontal flip toggling
# -added vertical flip toggling
# -normalized origins during x,y calculation
# May 3, 2012
# -added support for battle scenes
# -added 'wait for completion' functionality
# May 1, 2012
# -added pic shifting
# -added pic spinning around specified origin
# Apr 30, 2012
# -initial release
#------------------------------------------------------------------------------
# Convenience wrappers methods for Game_Picture objects
# No error checking is performed
# Usage: Just call the methods in a script or script box.
#
# make_pic(index, name, opacity, x, y, origin)
# show_pic(index, name) - show or change the picture shown.
# Filename must exist in your Picture folder.
# move_pic(index, x, y, duration, wait) - moves the picture to the given coords
# shift_pic(index, x, y, duration, wait) - move the picture relative to current position
# zoom_pic(index, x, y, duration, wait) - zoom the width and height
# rotate_pic(index, angle, speed, wait) - rotate the picture at that speed
# spin_pic(index, speed) - spin the picture forever
# fade_pic(index, opacity, duration, wait) - fade in, fade out...
# tone_pic(index, r, g, b, a, duration, wait) - change the color
# blend_pic(index, blend) - change the blend type
# origin_pic(index, origin) - change the origin
# erase_pic(index) - erase the picture. Same as Erase Picture command
# grayscale_pic(index) - toggles grayscale
# mirror_pic(index) - toggles horizontal flipping (flip along y-axis)
# flip_pic(index) - toggles vertical flipping (flip along x-axis)
# fix_pic(index, bool) - set whether the image should be fixed to the map
#==============================================================================
module Tsuki
module Picture_Wrapper
end
end
class Sprite_Picture < Sprite
alias tsuki_picture_wrapper_sprite_update update
def update
tsuki_picture_wrapper_sprite_update
update_mirror
update_flip
update_fixed
end
def update_mirror
self.mirror = @picture.mirror
end
def update_flip
self.angle = @picture.angle
end
# Offset the image to the origin
def update_fixed
if @picture.fixed
self.x = 0 - $game_map.display_x * 32 + @picture.x
self.y = 0 - $game_map.display_y * 32 + @picture.y
else
self.x = @picture.x
self.y = @picture.y
end
end
end
class Game_Picture
attr_reader :mirror
attr_reader :grayscale
attr_reader :flip
attr_reader :rot_count
attr_reader :spin
attr_reader :fixed
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
alias tsuki_picture_wrapper_initialize initialize
def initialize(number)
tsuki_picture_wrapper_initialize(number)
@width = 0
@height = 0
end
alias tsuki_picture_wrapper_init_basic init_basic
def init_basic
tsuki_picture_wrapper_init_basic
@mirror = false
@flip = false
@angle = 0
@rot_count = 0
@spin = false
end
alias tsuki_picture_wrapper_init_tone init_tone
def init_tone
tsuki_picture_wrapper_init_tone
@grayscale = false
end
alias tsuki_picture_wrapper_show show
def show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
tsuki_picture_wrapper_show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
end
#--------------------------------------------------------------------------
# * Get the width of the displayed image
#--------------------------------------------------------------------------
def width
@width * (@zoom_x / 100)
end
#--------------------------------------------------------------------------
# * Get the height of the displayed image
#--------------------------------------------------------------------------
def height
@height * (@zoom_y / 100)
end
# Adjust for absolute/relative coords if picture is fixed
def map_x
@fixed ? @x * 32 : @x
end
def map_y
@fixed ? @y * 32 : @y
end
#--------------------------------------------------------------------------
# * Shows a picture at the specified x,y with normal blend type
# If the origin is centered then we need to adjust the image
#--------------------------------------------------------------------------
def create(name, opacity, x, y, origin, fixed)
@name = name
@opacity = opacity
@fixed = fixed
@origin = origin
@x = x
@y = y
if origin == 1
@x = map_x + width / 2
@y = map_y + height / 2
end
@origin = origin
@blend_type = 0
update
end
#--------------------------------------------------------------------------
# * Change the picture to the specified name.
#--------------------------------------------------------------------------
def rename(name)
@name = name
if @origin == 1
@target_x = y + width / 2
@target_y = x + height / 2
end
@origin = 1
end
#--------------------------------------------------------------------------
# * Move the picture to the specified position in duration frames
# specified by absolute x,y coords relative to the game screen
#--------------------------------------------------------------------------
def position(x, y, duration)
@target_x = if origin == 1 then (x.to_f + width / 2) else x.to_f end
@target_y = if origin == 1 then (y.to_f + height / 2) else y.to_f end
@duration = duration
end
#--------------------------------------------------------------------------
# * Move the picture to the specified position in duration frames
# specified by x,y coords relative to the picture's origin
#--------------------------------------------------------------------------
def shift(x, y, duration)
@target_x = @x + x.to_f
@target_y = @y + y.to_f
@duration = duration
end
#--------------------------------------------------------------------------
# * Zoom the picture to the specified scale ratio. 100 is original size
#--------------------------------------------------------------------------
def zoom(x, y, duration)
@target_zoom_x = x.to_f
@target_zoom_y = y.to_f
@duration = duration
end
#--------------------------------------------------------------------------
# * Make the picture spin
#--------------------------------------------------------------------------
def spin(speed, origin)
@origin = origin
if !@spin
rotate(speed)
else
rotate(0)
end
@spin = !@spin
end
#--------------------------------------------------------------------------
# * Rotate the picture by angle degrees
#--------------------------------------------------------------------------
def turn(angle, speed)
@angle = angle
@rotate_speed = speed
@rotate_speed = 0
end
#--------------------------------------------------------------------------
# * Change the blend type
#--------------------------------------------------------------------------
def change_blend(blend)
@blend_type = blend.between?(0,2) ? blend : 0
end
#--------------------------------------------------------------------------
# * Change the opacity over duration frames
#--------------------------------------------------------------------------
def fade(opacity, duration)
@target_x = @x
@target_y = @y
@target_opacity = opacity
@duration = duration
end
#--------------------------------------------------------------------------
# * Change the tone over duration frames
#--------------------------------------------------------------------------
def tone_pic(r, g, b, a, duration)
start_tone_change(Tone.new(r,g,b,a), duration)
end
#--------------------------------------------------------------------------
# * Change the origin. 0 is top-left, anything else is center
#--------------------------------------------------------------------------
def change_origin(origin)
@origin = origin
end
#--------------------------------------------------------------------------
# * Set picture to gray scale
#--------------------------------------------------------------------------
def grayscale(duration=1)
tone = @tone.clone
if !@grayscale
tone.gray = 255
else
tone.gray = 0
end
@grayscale = !@grayscale
start_tone_change(tone, duration)
end
def flip_pic
@angle = @angle + 180
@flip = !@flip
end
def mirror_pic
@mirror = !@mirror
end
def fix_pic(bool)
@fixed = bool
end
end
class Game_Interpreter
def game_screen
return $game_map.screen if SceneManager.scene_is?(Scene_Map)
return $game_troop.screen if SceneManager.scene_is?(Scene_Battle)
end
def make_pic(index, name, opacity=255, x=0, y=0, origin=1, fixed=false)
game_screen.pictures[index].create(name, opacity, x, y, origin, fixed)
end
def show_pic(index, name)
game_screen.pictures[index].rename(name)
end
def move_pic(index, x, y, duration=1, _wait=false)
game_screen.pictures[index].position(x, y, duration)
wait(duration) if _wait
end
def shift_pic(index, x, y, duration=1, _wait=false)
game_screen.pictures[index].shift(x, y, duration)
wait(duration) if _wait
end
def zoom_pic(index, x, y, duration=1, _wait=false)
game_screen.pictures[index].zoom(x, y, duration)
wait(duration) if _wait
end
def rotate_pic(index, angle, speed, _wait=false)
game_screen.pictures[index].turn(angle, speed)
wait(duration) if _wait
end
def spin_pic(index, speed, origin=1)
game_screen.pictures[index].spin(speed, origin)
end
def fade_pic(index, opacity, duration=1, _wait=false)
game_screen.pictures[index].fade(opacity, duration)
wait(duration) if _wait
end
def tone_pic(index, r, g, b, a, duration=1, _wait=false)
game_screen.pictures[index].tone_pic(r,g,b,a, duration)
wait(duration) if _wait
end
def blend_pic(blend, index=1)
game_screen.pictures[index].change_blend(blend)
end
def origin_pic(index, origin)
game_screen.pictures[index].change_origin(origin)
end
def grayscale_pic(index, duration=1)
game_screen.pictures[index].grayscale(duration)
end
def mirror_pic(index=1)
game_screen.pictures[index].mirror_pic
end
def flip_pic(index=1)
game_screen.pictures[index].flip_pic
end
def erase_pic(index=1)
game_screen.pictures[index].erase
end
def fix_pic(index=1, bool=true)
game_screen.pictures[index].fix_pic(bool)
end
end
See the screenshot for how I use it. The number at the end of the name corresponds to the number of the pic called, that way I can have them changing expressions by just calling another common event of their expression without having to erase the previous pic. "R" in the name means they are from the reverse side, aka placed farther on the "X" basis and using Hime's Wrap (by default all the character are staring right, so with Hime's Wrap they stare left).
The goal is to be able to call in an event 2 of a character's "R" common events and have them both staring in the correct direction. Also for the script NOT to record the previous mirror commands once the event is over.
Any help would be greatly appreciated, and used for my Broken Reality RPG (https://lord-rutsah.itch.io/broken-reality-rpg)
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadCreator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...