Window Extra Functions
Authors: Wecoc
Version: 1.0
Type: Window AddOn
Key Term: Misc Add-on
IntroductionRPG::Sprite functions on Window_Base, so basically you can use windows as battlers
Inspired on the Wolf RPG Editor window options
On this video you can see some of the functionalities this script takes:
https://www.youtube.com/watch?v=Md7yT7fl86c
You can recreate the blink effect on 0:25, damage effects on 2:02 or the paralysis color effect on 4:10
Features
- Use Window as a RPG::Sprite (see Instructions)
ScreenshotsI took none because it's unnecessary for this type of script.
ScriptInsert over main:
#==============================================================================
# ** Window Extra Functions 1.0
#------------------------------------------------------------------------------
# Author: Wecoc (no credits needed)
#------------------------------------------------------------------------------
# RPG::Sprite functions on Window_Base
# Inspired on the Wolf RPG Editor window options
# https://www.youtube.com/watch?v=Md7yT7fl86c
#------------------------------------------------------------------------------
# self.flash(color, duration)
# self.color.set(red, green, blue, [alpha])
# self.displace(x, y, duration)
# self.whiten([color])
# self.appear
# self.escape
# self.collapse
# self.blink_on
# self.blink_off
# self.blink?
# self.effect?
#==============================================================================
class Window_Base < Window
attr_accessor :viewport
alias viewport_settings_ini initialize unless $@
def initialize(x, y, width, height)
viewport_settings_ini(x, y, width, height)
refresh_viewport
@_whiten_duration = 0
@_appear_duration = 0
@_escape_duration = 0
@_collapse_duration = 0
@_displace_duration = 0
@_blink = false
@_x = self.x
@_y = self.y
end
def refresh_viewport
self.viewport = Viewport.new(self.x, self.y, self.width, self.height)
self.viewport.z = self.z + 1
end
def x=(value)
super(value)
refresh_viewport
end
def y=(value)
super(value)
refresh_viewport
end
def width=(value)
super(value)
refresh_viewport
end
def height=(value)
super(value)
refresh_viewport
end
def visible=(value)
super(value)
self.viewport.visible = value
end
def flash(color,duration)
self.viewport.flash(color,duration)
end
def color
return self.viewport.color
end
def displace(x, y, duration)
@_x = x
@_y = y
@_displace_duration = duration
end
def whiten(color=Color.new(255, 255, 255))
self.color.set(color.red, color.green, color.blue, 128)
self.opacity = 255
@_whiten_duration = 16
@_appear_duration = 0
@_escape_duration = 0
@_collapse_duration = 0
end
def appear
self.color.set(0, 0, 0, 0)
self.opacity = 0
@_appear_duration = 16
@_whiten_duration = 0
@_escape_duration = 0
@_collapse_duration = 0
end
def escape
self.color.set(0, 0, 0, 0)
self.opacity = 255
@_escape_duration = 32
@_whiten_duration = 0
@_appear_duration = 0
@_collapse_duration = 0
end
def collapse
self.flash(Color.new(255, 64, 64, 255), 48)
@_collapse_duration = 48
end
def blink_on
unless @_blink
@_blink = true
@_blink_count = 0
end
return true
end
def blink_off
if @_blink
@_blink = false
self.color.set(0, 0, 0, 0)
end
return true
end
def blink?
@_blink
end
def effect?
@_whiten_duration > 0 or
@_appear_duration > 0 or
@_escape_duration > 0 or
@_collapse_duration > 0
end
def update
super
self.viewport.update
if $game_system.windowskin_name != @windowskin_name
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
end
if @_whiten_duration > 0
@_whiten_duration -= 1
self.color.alpha = 128 - (16 - @_whiten_duration) * 10
end
if @_appear_duration > 0
@_appear_duration -= 1
self.opacity = (16 - @_appear_duration) * 16
end
if @_escape_duration > 0
@_escape_duration -= 1
self.opacity = 256 - (32 - @_escape_duration) * 10
end
if @_collapse_duration > 0
@_collapse_duration -= 1
self.opacity = 256 - (32 - @_collapse_duration) * 10
end
if @_displace_duration > 1
@_displace_duration -= 1
self.x += (@_x - self.x) / @_displace_duration
self.y += (@_y - self.y) / @_displace_duration
end
if @_blink
@_blink_count = (@_blink_count + 1) % 32
if @_blink_count < 16
alpha = (16 - @_blink_count) * 6
else
alpha = (@_blink_count - 16) * 6
end
self.color.set(255, 255, 255, alpha)
end
return true
end
end
Instructionsflash(color, duration)
Makes a flash effect on the window
color.set(red, green, blue, [alpha])
Changes the window color
displace(x, y, duration)
Moves the window to the specified point
whiten
Applies a white flash similar to the RPG::Sprite
whiten(color)
Applies a flash with the specified color on the window
appear
The window appears smoothly
escape
The window disappears smoothly
collapse
Applies a red flash similar to the RPG::Sprite
blink_on
The window starts blinking
blink_off
The window stops blinking
blink?
Checks if window is blinking
effect?
Checks if some effect is activated on the window
Author's NotesNo credits needed, so enjoy it for free!