Код:
%Q(
╔════╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═════╗
║ ╔══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╗ ║
╠─╣ Effectus. Performance Enhancer. LOOP MAP VERSION. ╠─╣
╠─╣ by RPG Maker Source. ╠─╣
╠─╣ www.rpgmakersource.com ╠─╣
║ ╚══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╝ ║
╠════╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═════╣
║ ┌────┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴─────┐ ║
╠─┤ Version 1.1.6 09/12/14 DD/MM/YY ├─╣
║ └────┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬─────┘ ║
╠══════╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══════╣
║ ║
║ This work is protected by the following license: ║
║ ╔══════════════════════════════════════════════════════════════════╗ ║
║ │ │ ║
║ │ "Effectus. Performance Enhancer" END USER LICENSE AGREEMENT │ ║
║ │ │ ║
║ │ IMPORTANT, READ CAREFULLY. │ ║
║ │ │ ║
║ │ PLEASE READ THIS END USER LICENSE AGREEMENT (THE "AGREEMENT") │ ║
║ │ CAREFULLY BEFORE USING THIS SOFTWARE. IF YOU (THE "USER") DO NOT │ ║
║ │ AGREE TO THE TERMS, CONDITIONS AND LIMITATIONS OF THIS │ ║
║ │ AGREEMENT, PROMPTLY DELETE THE DIGITAL CONTENT FROM YOUR │ ║
║ │ COMPUTER. │ ║
║ │ │ ║
║ │ 1. Copyright, trademark and other intellectual property rights │ ║
║ │ of "Effectus. Performance Enhancer" (the "Product") are │ ║
║ │ property of Maker Systems (the "Author") found at │ ║
║ │ www.rpgmakersource.com and third party allowed by the Author. │ ║
║ │ │ ║
║ │ 2. The Ruby code included in the Product (the "Product") may be │ ║
║ │ used with ENTERBRAIN's RPG Maker VX ACE. User can create, │ ║
║ │ distribute, or sell their original game made using the │ ║
║ │ Product only if they meet all the following conditions: │ ║
║ │ │ ║
║ │ 2.1 You must be a legitimate user of RPG Maker VX ACE. │ ║
║ │ │ ║
║ │ 2.2 You shall produce a game using RPG MAKER VX ACE only. │ ║
║ │ │ ║
║ │ 2.3 You must be a legitimate user of our products. │ ║
║ │ │ ║
║ │ 2.4 Solely for the creation of your game, you can edit, │ ║
║ │ process, and modify the Ruby code contained in the │ ║
║ │ Product. │ ║
║ │ │ ║
║ │ 2.5 Your game must include additional documentation that │ ║
║ │ clearly indicates the use of the Product and the │ ║
║ │ following copy: "Effectus. Performance Enhancer. │ ║
║ │ Copyright © 2014 Maker Systems - RPG Maker Source." │ ║
║ │ │ ║
║ │ 2.6 You cannot sell, distribute, lease, or transfer the │ ║
║ │ Product itself nor any portions of it (even if the │ ║
║ │ materials were edited, processed, or modified by the │ ║
║ │ User). │ ║
║ │ │ ║
║ │ 3. The Author will bear no responsibility for any damages to the │ ║
║ │ User's computer, data, assets, media, or other │ ║
║ │ products/scripts caused by use or misuse of this Product. │ ║
║ │ │ ║
║ │ 4. By using the Product, the User accepts the full terms and │ ║
║ │ takes sole responsibility for use of the Product. │ ║
║ │ │ ║
║ │ 5. The Author will bear no responsibility for any issues and/or │ ║
║ │ disputes between third parties, regardless of the content, │ ║
║ │ that occur as a result of the creation, distribution, and │ ║
║ │ release of the User's game made with the Product. │ ║
║ │ │ ║
║ ╚══════════════════════════════════════════════════════════════════╝ ║
║ ║
║ ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ 1. VERSION HISTORY. ▼ ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ • Version 1.0.0, 24/11/14 - (DD/MM/YY). ║
║ ║
║ • Version 1.1.0, 30/11/14 - (DD/MM/YY). ║
║ - Added performance improvement measures for parallel processing events ║
║ and some event commands. ║
║ ║
║ • Version 1.1.1, 01/12/14 - (DD/MM/YY). ║
║ ║
║ • Version 1.1.2, 03/12/14 - (DD/MM/YY). ║
║ ║
║ • Version 1.1.3, 05/12/14 - (DD/MM/YY). ║
║ ║
║ • Version 1.1.4, 07/12/14 - (DD/MM/YY). ║
║ ║
║ • Version 1.1.5, 08/12/14 - (DD/MM/YY). ║
║ ║
║ • Version 1.1.6, 09/12/14 - (DD/MM/YY). ║
║ ║
╠══════════════════════════════════════════════════════════════════════════════╣
╠══════════════════════════════════════════════════════════════════════════════╣
║ 2. USER MANUAL. ▼ ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ ┌──────────────────────────────────────────────────────────────────────────┐ ║
║ │ ■ Introduction. │ ║
║ └┬┬┬┬──────────────────────────────────────────────────────────────────┬┬┬┬┘ ║
║ ║
║ Thank you for your purchase of "Effectus. Performance Enhancer"! ║
║ ║
║ We, at RPG Maker Source, hope that it helps you create amazing games with ║
║ outstanding gameplay elements. ║
║ ║
║ This is the user manual. Important information about Effectus use is ║
║ detailed here, but remember that you can always contact us through our ║
║ website if you have any questions or if you need any kind of support. ║
║ ║
║ NOTE: Effectus is designed to work in the full version of RPG Maker VX ║
║ Ace. ║
║ ║
║ We hope you enjoy it. ║
║ ║
║ Thanks for choosing our products. ║
║ ║
║ ┌──────────────────────────────────────────────────────────────────────────┐ ║
║ │ ■ Installation. │ ║
║ └┬┬┬┬──────────────────────────────────────────────────────────────────┬┬┬┬┘ ║
║ ║
║ To install Effectus into your game: ║
║ ║
║ 1. Open your game project in RPG Maker VX ACE. ║
║ ║
║ 2. Open RPG Maker VX ACE's script editor by either pressing F11 key on ║
║ your keyboard or by clicking on its icon in the task bar. ║
║ ║
║ 3. You will see two main parts in the editor, the left part, which ║
║ contains the script list, and the right part, that shows the contents ║
║ of each entry of that list. The right part contents are the actual ║
║ scripts. ║
║ ║
║ 4. Scroll the left part down until you see the entry named as "▼ Materials" ║
║ (without quotation marks). Right click on it and select "Insert", the ║
║ first option of the dropdown menu. This will create a new slot above ║
║ Main and right below the default scripts. ║
║ Anything under Main won't be executed and would be as if it is not even ║
║ there, so beware to put things you want into your project always above ║
║ it. Effectus must be above all other custom scripts. ║
║ ║
║ 5. Name the new entry however you want, we recommend "<< Effectus ║
║ Performance >>" or any other name that allows you to easily identify ║
║ Effectus later. The name of the entry on the left part of the script ║
║ editor doesn't interfere with the functioning of the script it contains ║
║ on the right side, so you could even leave it blank. But it is not ║
║ recommended. ║
║ ║
║ 6. Paste all contents of the Effectus.txt file included in your download ║
║ of Effectus in the right part of the new entry, which should no longer ║
║ be empty by now. ║
║ ║
║ Congratulations! Effectus is now fully integrated into your project! ║
║ ║
║ ┌──────────────────────────────────────────────────────────────────────────┐ ║
║ │ ■ Using Effectus. │ ║
║ └┬┬┬┬──────────────────────────────────────────────────────────────────┬┬┬┬┘ ║
║ ║
║ Although Effectus is plug and play, there are two parameters that you can ║
║ change for it to better suit your needs under special scenarios. ║
║ ║
║ RPG Maker Ace executes the update method for each event on the map one ║
║ time per update cycle, this is not needed for events that are only ║
║ triggered by player interactions, and the player can't trigger what is ║
║ not visible on screen, thus the most used technique for battling event ║
║ related lag being to avoid "updating" them (calling the update method) if ║
║ they are not visible. ║
║ ║
║ This is an effective way to reduce event related lag and poses no threat ║
║ to the game's logic or execution... unless some scripted system that your ║
║ game uses bases its functions on the constant execution of the update ║
║ method of the events involved. This is a rare case but given the vast ║
║ number of scripts available for RPG Maker Ace, it could exist, so we took ║
║ the time to implement two ways that you, as a developer, can use to make ║
║ any system depending on vanilla-event-update-mode work. ║
║ ║
║ (1) PATTERNS. ║
║ ║
║ This constant acts as a container where you can add text patterns. What ║
║ are this patterns for? They are there to let Effectus know that any event ║
║ containing that pattern in any of its active page's comments, needs to be ║
║ always updated. ║
║ ║
║ Imagine the following scenario: ║
║ ║
║ Your game uses an action battle system whose functioning relies on the ║
║ update method of the events being called every frame. That system uses ║
║ comments to define enemies or events that are used by the battle system. ║
║ It can be something like "ABS_ENEMY" or even "<abs_enemy :id=20 ║
║ :respawn=true>", anything that you put in a comment, really. So, you ║
║ include an important part of that common to every event in the pattern ║
║ container, like: ║
║ ║
║ PATTERNS = ['always', '<abs_enemy', 'light_effect', 'SOUND_EMITTER'] ║
║ ║
║ Keep in mind that you must stick to the following rules when adding ║
║ patterns: ║
║ ║
║ 1. Patterns must be inside either single quotation marks ('') or normal ║
║ ones (""), we recommend single ones (''). ║
║ 2. Before the first pattern, a nopening square bracket ([) must be used. ║
║ This is what tells that the "pattern container" starts there. ║
║ 3. The comma is only used to separate patterns, and goes after the ║
║ quotation mark that ended the pattern. ║
║ 4. Last pattern (in the example above, 'SOUND_EMITTER') is not followed up ║
║ by a comma, but followed up by a closing square bracket (]). This is ║
║ what tells that the "pattern container" ends there. ║
║ ║
║ You can also invent your own pattern to let Effectus know that you want ║
║ that event to always update. The default pattern for that is 'always', ║
║ but you can change it to whatever you like or add whatever you want to ║
║ use instead. ║
║ ║
║ (2) PREVENT_OFFSCREEN_UPDATES. ║
║ ║
║ This constant acts as a "master key", if it is set to true, events ║
║ outside the screen won't be updated and you will enjoy a major ║
║ performance improvement. But, if you set it to false, Effectus will ║
║ update events that are outside the screen area like vanilla Ace does. ║
║ ║
║ Imagine the following scenario: ║
║ ║
║ You either paid a lot of money for a custom system or it is essential to ║
║ your game, like an action battle system or anything that you can imagine ║
║ that involves map events, and for some reason that system doesn't use any ║
║ type of comment tag to determine which events it involves. So if any ║
║ event is involved in it without you having to actually TELL it which ones ║
║ you want and that system also needs events to be always updated, then ║
║ this option is the easy way to go. Set it to false and enjoy the other ║
║ improvements that Effectus provides. ║
║ ║
║ You won't receive the full effect of Effectus, while using this mode, but ║
║ you will still receive a great perfomance increase. ║
║ ║
║ TLDR: Use #1 for events that need to always be updated and share a pattern ║
║ Use #2 if an important system doesn't work without constant event ║
║ update and events involved in it doesn't share a text pattern in ║
║ their comments. ║
║ ║
║ ║
╠══════════════════════════════════════════════════════════════════════════════╣
╠══════════════════════════════════════════════════════════════════════════════╣
║ 3. NOTES. ▼ ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ If the division of your game's screen width or height divided by 32 has a ║
║ division remainder, set SCREEN_TILE_DIVMOD to true to avoid events ║
║ appearing "out of nowhere" in the right and bottom borders of the screen. ║
║ ║
║ Have fun and enjoy! ║
║ ║
╠══════════════════════════════════════════════════════════════════════════════╣
╠══════════════════════════════════════════════════════════════════════════════╣
║ 4. CONTACT. ▼ ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ Keep in touch with us and be the first to know about new releases: ║
║ ║
║ www.rpgmakersource.com ║
║ www.facebook.com/RPGMakerSource ║
║ www.twitter.com/RPGMakerSource ║
║ www.youtube.com/user/RPGMakerSource ║
║ ║
║ Get involved! Have an idea for a system? Let us know. ║
║ ║
║ Spread the word and help us reach more people so we can continue creating ║
║ awesome resources for you! ║
║ ║
╚══════════════════════════════════════════════════════════════════════════════╝)
#==============================================================================
# ** MakerSystems
#------------------------------------------------------------------------------
# Module four our Systems.
#==============================================================================
module MakerSystems
#============================================================================
# ** Effectus
#----------------------------------------------------------------------------
# This module contains variables that you can edit to make Effectus work
# in whatever way you may need.
#============================================================================
module Effectus
#------------------------------------------------------------------------
# * Always Update Patterns. [OPT]
#------------------------------------------------------------------------
# This are the patterns that Effectus will look for to know if it needs
# to always update the event. The search is performed through all comments
# in the current page of the event, so the order of the event commands
# doesn't matter.
# You don't have to use this feature if you set PREVENT_OFFSCREEN_UPDATES
# to false.
#------------------------------------------------------------------------
PATTERNS = ['always']
#------------------------------------------------------------------------
# * Prevent Offscreen Updates. [OPT]
#------------------------------------------------------------------------
# Common technique against event lag.
# If true, events that are not inside the screen area won't be updated.
# If false, events will be normally updated as in vanilla Ace.
# but you will still enjoy an enhanced experience thanks to
# the system's clever improvements.
#------------------------------------------------------------------------
PREVENT_OFFSCREEN_UPDATES = true
#------------------------------------------------------------------------
# * Screen Tile Division Modulo. [OPT]
#------------------------------------------------------------------------
# Set this to true if either screen width or height divided by 32 (pixels
# in a tile) has a division remainder.
# If true, an additional tile is considered as "near the visible area".
# Tiny (really tiny) performance loss.
# If false, screen size must be evenly divisible by 32 to avoid errors.
#------------------------------------------------------------------------
SCREEN_TILE_DIVMOD = false
end
end
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# The instance of this class is referenced by $game_temp.
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables. [NEW]
#--------------------------------------------------------------------------
attr_accessor :ms_effectus_sprites
#--------------------------------------------------------------------------
# * Initialize. [REP]
#--------------------------------------------------------------------------
def initialize
@common_event_id = 0
@fade_type = 0
@ms_effectus_sprites = {}
end
end
#==============================================================================
# ** Game_Switches
#------------------------------------------------------------------------------
# This class handles switches. It's a wrapper for the built-in class "Array."
# The instance of this class is referenced by $game_switches.
#==============================================================================
class Game_Switches
#--------------------------------------------------------------------------
# * Set Switch. [REP]
#--------------------------------------------------------------------------
def []=(switch_id, value)
@data[switch_id] = value
unless $BTEST
$game_map.ms_effectus_etriggers[switch_id].each { |event| event.refresh }
$game_map.ms_effectus_refresh_tile_events
end
on_change
end
#--------------------------------------------------------------------------
# * On Change. [REP]
#--------------------------------------------------------------------------
def on_change
# Kept for compatibility purposes.
end
end
#==============================================================================
# ** Game_Variables
#------------------------------------------------------------------------------
# This class handles variables. It's a wrapper for the built-in class "Array."
# The instance of this class is referenced by $game_variables.
#==============================================================================
class Game_Variables
#--------------------------------------------------------------------------
# * Set Variable. [REP]
#--------------------------------------------------------------------------
def []=(variable_id, value)
@data[variable_id] = value
unless $BTEST
$game_map.ms_effectus_etriggers[variable_id].each { |event| event.refresh }
$game_map.ms_effectus_refresh_tile_events
end
on_change
end
#--------------------------------------------------------------------------
# * On Change. [REP]
#--------------------------------------------------------------------------
def on_change
# Kept for compatibility purposes.
end
end
#==============================================================================
# ** Game_SelfSwitches
#------------------------------------------------------------------------------
# This class handles self switches. It's a wrapper for the built-in class
# "Hash." The instance of this class is referenced by $game_self_switches.
#==============================================================================
class Game_SelfSwitches
#--------------------------------------------------------------------------
# * Set SelfSwitch. [REP]
#--------------------------------------------------------------------------
def []=(key, value)
@data[key] = value
unless $BTEST
$game_map.ms_effectus_etriggers[key].each { |event| event.refresh }
$game_map.ms_effectus_refresh_tile_events
end
on_change
end
#--------------------------------------------------------------------------
# * On Change. [REP]
#--------------------------------------------------------------------------
def on_change
# Kept for compatibility purposes.
end
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles parties. Information such as gold and items is included.
# Instances of this class are referenced by $game_party.
#==============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# * Add an Actor. [REP]
#--------------------------------------------------------------------------
def add_actor(actor_id)
@actors.push(actor_id) unless @actors.include?(actor_id)
$game_player.refresh
return if $BTEST
$game_map.ms_effectus_etriggers[actor_id].each { |event| event.refresh }
$game_map.ms_effectus_refresh_tile_events
end
#--------------------------------------------------------------------------
# * Remove Actor. [REP]
#--------------------------------------------------------------------------
def remove_actor(actor_id)
@actors.delete(actor_id)
$game_player.refresh
return if $BTEST
$game_map.ms_effectus_etriggers[actor_id].each { |event| event.refresh }
$game_map.ms_effectus_refresh_tile_events
end
#--------------------------------------------------------------------------
# * Increase/Decrease Items. [REP]
#--------------------------------------------------------------------------
def gain_item(item, amount, include_equip = false)
container = item_container(item.class)
return unless container
last_number = item_number(item)
new_number = last_number + amount
container[item.id] = [[new_number, 0].max, max_item_number(item)].min
container.delete(item.id) if container[item.id] == 0
if include_equip && new_number < 0
discard_members_equip(item, -new_number)
end
return if $BTEST
$game_map.ms_effectus_etriggers[item.id].each { |event| event.refresh }
$game_map.ms_effectus_refresh_tile_events
end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Public Instance Variables. [NEW]
#--------------------------------------------------------------------------
attr_accessor :ms_effectus_event_pos, :ms_effectus_party_pos,
:ms_effectus_etile_pos, :ms_effectus_hard_events,
:ms_effectus_events_to_update, :ms_effectus_pass_table,
:ms_effectus_event_starting, :ms_effectus_etriggers,
:ms_effectus_tile_events
#--------------------------------------------------------------------------
# * Setup. [REP]
#--------------------------------------------------------------------------
def setup(map_id)
@ms_effectus_event_starting = nil
@ms_effectus_events_to_update = []
@ms_effectus_hard_events = []
@ms_effectus_tile_events = []
@ms_effectus_initial_run = nil
@ms_effectus_ody = nil
@ms_effectus_odx = nil
@ms_effectus_party_pos = Hash.new { |hash, key| hash[key] = [] }
@ms_effectus_event_pos = Hash.new { |hash, key| hash[key] = [] }
@ms_effectus_etile_pos = Hash.new { |hash, key| hash[key] = [] }
@ms_effectus_etriggers = Hash.new { |hash, key| hash[key] = [] }
@map_id = map_id
@map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
@tileset_id = @map.tileset_id
@display_x = 0
@display_y = 0
referesh_vehicles
setup_events
setup_scroll
setup_parallax
setup_battleback
@need_refresh = false
@ms_effectus_pass_table = Table.new($game_map.width, $game_map.height, 4)
$game_player.followers.each do |follower|
follower.ms_effectus_position_registered = false
end
end
#--------------------------------------------------------------------------
# * Refresh Tile Events. [REP]
#--------------------------------------------------------------------------
def ms_effectus_refresh_tile_events
@tile_events = []
@ms_effectus_tile_events.each { |e| e.tile? && @tile_events << e }
end
#--------------------------------------------------------------------------
# * Refresh. [REP]
#--------------------------------------------------------------------------
def refresh
@tile_events = []
@events.each_value do |event|
event.refresh
event.tile? && @tile_events << event
end
@common_events.each { |event| event.refresh }
@need_refresh = false
end
#--------------------------------------------------------------------------
# * Update. [REP]
#--------------------------------------------------------------------------
def update(main = false)
refresh if @need_refresh
if main
update_interpreter
else
update_events
update_vehicles
end
update_scroll
update_parallax
@screen.update
end
#--------------------------------------------------------------------------
# * Update Events. [REP]
#--------------------------------------------------------------------------
if MakerSystems::Effectus::SCREEN_TILE_DIVMOD
def update_events
if @events.size > 999 && MakerSystems::Effectus::PREVENT_OFFSCREEN_UPDATES
unless @ms_effectus_initial_run
@events.each_value { |event| event.update }
@common_events.each { |event| event.update }
@ms_effectus_initial_run = true
return
end
adx = @display_x.to_i
ady = @display_y.to_i
if adx != @ms_effectus_odx || ady != @ms_effectus_ody
@ms_effectus_odx = adx
@ms_effectus_ody = ady
@ms_effectus_events_to_update = []
x1 = adx - 3
x2 = adx + screen_tile_x + 2
y1 = ady - 3
y2 = ady + screen_tile_y + 2
unless loop_horizontal?
x1 = 0 if x1 < 0
x2 = width if x2 > width
end
unless loop_vertical?
y1 = 0 if y1 < 0
y2 = height if y2 > height
end
(x1..x2).each do |xx|
(y1..y2).each do |yy|
xx %= width if loop_horizontal?
yy %= height if loop_vertical?
@ms_effectus_event_pos[yy * width + xx].each do |event|
@ms_effectus_events_to_update << event
event.update
end
end
end
return
end
(@ms_effectus_events_to_update | @ms_effectus_hard_events).each do |e|
e.update
end
else
@events.each_value { |event| event.update }
end
@common_events.each { |event| event.update }
end
else
def update_events
if @events.size > 999 && MakerSystems::Effectus::PREVENT_OFFSCREEN_UPDATES
unless @ms_effectus_initial_run
@events.each_value { |event| event.update }
@common_events.each { |event| event.update }
@ms_effectus_initial_run = true
return
end
adx = @display_x.to_i
ady = @display_y.to_i
if adx != @ms_effectus_odx || ady != @ms_effectus_ody
@ms_effectus_odx = adx
@ms_effectus_ody = ady
@ms_effectus_events_to_update = []
x1 = adx - 3
x2 = adx + screen_tile_x + 2
y1 = ady - 3
y2 = ady + screen_tile_y + 2
unless loop_horizontal?
x1 = 0 if x1 < 0
x2 = width if x2 > width
end
unless loop_vertical?
y1 = 0 if y1 < 0
y2 = height if y2 > height
end
(x1..x2).each do |xx|
(y1..y2).each do |yy|
xx %= width if loop_horizontal?
yy %= height if loop_vertical?
@ms_effectus_event_pos[yy * width + xx].each do |event|
@ms_effectus_events_to_update << event
event.update
end
end
end
return
end
(@ms_effectus_events_to_update | @ms_effectus_hard_events).each do |e|
e.update
end
else
@events.each_value { |event| event.update }
end
@common_events.each { |event| event.update }
end
end
#--------------------------------------------------------------------------
# * Set Display Position. [REP]
#--------------------------------------------------------------------------
def set_display_pos(x, y)
to_update_events = $game_map.ms_effectus_events_to_update
x = [0, [x, width - screen_tile_x].min].max unless loop_horizontal?
y = [0, [y, height - screen_tile_y].min].max unless loop_vertical?
@display_x = (x + width) % width
@display_y = (y + height) % height
@parallax_x = x
@parallax_y = y
to_update_events.each { |event| event.update }
end
#--------------------------------------------------------------------------
# * Tile Events XY. [REP]
#--------------------------------------------------------------------------
def tile_events_xy(x, y)
@ms_effectus_etile_pos[y * width + x]
end
#--------------------------------------------------------------------------
# * All Tiles. [REP]
#--------------------------------------------------------------------------
def all_tiles(x, y)
@ms_effectus_etile_pos[y * width + x].collect { |event| event.tile_id } +
layered_tiles(x, y)
end
#--------------------------------------------------------------------------
# * Alias Passable? [NEW]
#--------------------------------------------------------------------------
alias_method(:ms_effectus_original_passable?, :passable?)
#--------------------------------------------------------------------------
# * Passable? [REP]
#--------------------------------------------------------------------------
def passable?(x, y, d)
if (ms_effectus_loop_vertical? || ms_effectus_loop_horizontal?) &&
(x < 2 || y < 2 || x > width - 2 || y > height - 2)
return ms_effectus_original_passable?(x, y, d)
else
if @ms_effectus_pass_table[x, y, (d / 2) - 1] == 0
cd = 10 - d
cx = d == 4 ? x - 1 : d == 6 ? x + 1 : x
cy = d == 2 ? y + 1 : d == 8 ? y - 1 : y
if ms_effectus_original_passable?(x, y, d) &&
ms_effectus_original_passable?(cx, cy, cd)
@ms_effectus_pass_table[x, y, (d / 2) - 1] = 1
@ms_effectus_pass_table[cx, cy, (cd / 2) - 1] = 1
return true
else
@ms_effectus_pass_table[x, y, (d / 2) - 1] = 2
return false
end
end
@ms_effectus_pass_table[x, y, (d / 2) - 1] == 1
end
end
#--------------------------------------------------------------------------
# * MS Effectus Release. [NEW]
#--------------------------------------------------------------------------
def ms_effectus_release(x, y)
@ms_effectus_pass_table[x, y, 0] = 0
@ms_effectus_pass_table[x, y, 1] = 0
@ms_effectus_pass_table[x, y, 2] = 0
@ms_effectus_pass_table[x, y, 3] = 0
@ms_effectus_pass_table[x - 1, y, 0] = 0
@ms_effectus_pass_table[x - 1, y, 1] = 0
@ms_effectus_pass_table[x - 1, y, 2] = 0
@ms_effectus_pass_table[x - 1, y, 3] = 0
@ms_effectus_pass_table[x + 1, y, 0] = 0
@ms_effectus_pass_table[x + 1, y, 1] = 0
@ms_effectus_pass_table[x + 1, y, 2] = 0
@ms_effectus_pass_table[x + 1, y, 3] = 0
@ms_effectus_pass_table[x, y - 1, 0] = 0
@ms_effectus_pass_table[x, y - 1, 1] = 0
@ms_effectus_pass_table[x, y - 1, 2] = 0
@ms_effectus_pass_table[x, y - 1, 3] = 0
@ms_effectus_pass_table[x, y + 1, 0] = 0
@ms_effectus_pass_table[x, y + 1, 1] = 0
@ms_effectus_pass_table[x, y + 1, 2] = 0
@ms_effectus_pass_table[x, y + 1, 3] = 0
end
#--------------------------------------------------------------------------
# * Setup Starting Map Event. [REP]
#--------------------------------------------------------------------------
def setup_starting_map_event
return nil unless @ms_effectus_event_starting
event = @ms_effectus_event_starting
event.clear_starting_flag
@interpreter.setup(event.list, event.id)
@ms_effectus_event_starting = nil
event
end
#--------------------------------------------------------------------------
# * Any Event Starting? [REP]
#--------------------------------------------------------------------------
def any_event_starting?
@ms_effectus_event_starting
end
#--------------------------------------------------------------------------
# * Loop Horizontally? [NEW]
#--------------------------------------------------------------------------
def ms_effectus_loop_horizontal?
@display_x > width - screen_tile_x &&
(@map.scroll_type == 2 || @map.scroll_type == 3)
end
#--------------------------------------------------------------------------
# * Loop Vertically? [NEW]
#--------------------------------------------------------------------------
def ms_effectus_loop_vertical?
@display_y > height - screen_tile_y &&
(@map.scroll_type == 1 || @map.scroll_type == 3)
end
end
#==============================================================================
# ** Game_CommonEvent
#------------------------------------------------------------------------------
# This class handles common events. It includes functionality for execution of
# parallel process events. It's used within the Game_Map class ($game_map).
#==============================================================================
class Game_CommonEvent
#--------------------------------------------------------------------------
# * Initialize. [REP]
#--------------------------------------------------------------------------
def initialize(common_event_id)
@event = $data_common_events[common_event_id]
refresh
if @event.parallel?
$game_map.ms_effectus_etriggers[@event.switch_id] << self
end
end
end
#==============================================================================
# ** Game_CharacterBase
#------------------------------------------------------------------------------
# This base class handles characters. It retains basic information, such as
# coordinates and graphics, shared by all characters.
#==============================================================================
class Game_CharacterBase
#--------------------------------------------------------------------------
# * Alias Passable? [NEW]
#--------------------------------------------------------------------------
alias_method(:ms_effectus_original_passable?, :passable?)
#--------------------------------------------------------------------------
# * Passable? [REP]
#--------------------------------------------------------------------------
def passable?(x, y, d)
if ($game_map.ms_effectus_loop_vertical? ||
$game_map.ms_effectus_loop_horizontal?) &&
(x < 2 || y < 2 || x > $game_map.width - 2 || y > $game_map.height - 2)
return ms_effectus_original_passable?(x, y, d)
else
ox = d == 4 ? -1 : d == 6 ? 1 : 0
oy = d == 8 ? -1 : d == 2 ? 1 : 0
return false unless $game_map.valid?(x + ox, y + oy)
return true if @through || debug_through?
return false unless $game_map.passable?(x, y, d)
return false if collide_with_characters?(x + ox, y + oy)
return true
end
end
#--------------------------------------------------------------------------
# * Collide with Events? [REP]
#--------------------------------------------------------------------------
def collide_with_events?(x, y)
$game_map.ms_effectus_event_pos[y * $game_map.width + x].each do |event|
if (event.normal_priority? || self.is_a?(Game_Event)) && !event.through
return true
end
end
false
end
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles the player. It includes event starting determinants and
# map scrolling functions. The instance of this class is referenced by
# $game_player.
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * Collide? [REP]
#--------------------------------------------------------------------------
def collide?(x, y)
!@through && (pos?(x, y) ||
!$game_map.ms_effectus_party_pos[y * $game_map.width + x].empty?)
end
#--------------------------------------------------------------------------
# * Start Map Event. [REP]
#--------------------------------------------------------------------------
def start_map_event(x, y, triggers, normal)
return if $game_map.interpreter.running?
$game_map.ms_effectus_event_pos[y * $game_map.width + x].each do |event|
if event.trigger_in?(triggers) && event.normal_priority? == normal
event.start
end
end
end
end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class handles events. Functions include event page switching via
# condition determinants and running parallel process events. Used within the
# Game_Map class.
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# * Initialize. [REP]
#--------------------------------------------------------------------------
def initialize(map_id, event)
super()
@map_id = map_id
@event = event
@id = @event.id
moveto(@event.x, @event.y)
refresh
triggers = $game_map.ms_effectus_etriggers
tile_events = $game_map.ms_effectus_tile_events
@event.pages.each do |page|
condition = page.condition
if condition.switch1_valid
unless triggers[condition.switch1_id].include?(self)
triggers[condition.switch1_id] << self
end
end
if condition.switch2_valid
unless triggers[condition.switch2_id].include?(self)
triggers[condition.switch2_id] << self
end
end
if condition.variable_valid
unless triggers[condition.variable_id].include?(self)
triggers[condition.variable_id] << self
end
end
if condition.self_switch_valid
key = [@map_id, @event.id, condition.self_switch_ch]
unless triggers[key].include?(self)
triggers[key] << self
end
end
if condition.item_valid
unless triggers[condition.item_id].include?(self)
triggers[condition.item_id] << self
end
end
if condition.actor_valid
unless triggers[condition.actor_id].include?(self)
triggers[condition.actor_id] << self
end
end
if page.graphic.tile_id > 0 && page.priority_type == 0
unless tile_events.include?(self)
tile_events << self
end
end
end
end
#--------------------------------------------------------------------------
# * Init Public Members. [REP]
#--------------------------------------------------------------------------
def init_public_members
super
@trigger = 0
@list = nil
@starting = false
if $game_map.ms_effectus_event_starting == self
$game_map.ms_effectus_event_starting = nil
end
end
#--------------------------------------------------------------------------
# * Clear Starting Flag. [REP]
#--------------------------------------------------------------------------
def clear_starting_flag
@starting = false
if $game_map.ms_effectus_event_starting == self
$game_map.ms_effectus_event_starting = nil
end
end
#--------------------------------------------------------------------------
# * Detect Collision with Character. [REP]
#--------------------------------------------------------------------------
def collide_with_characters?(x, y)
super || (normal_priority? && $game_player.collide?(x, y))
end
#--------------------------------------------------------------------------
# * Start. [REP]
#--------------------------------------------------------------------------
def start
return if empty?
@starting = true
lock if trigger_in?([0,1,2])
$game_map.ms_effectus_event_starting = self
end
#--------------------------------------------------------------------------
# * Refresh. [REP]
#--------------------------------------------------------------------------
def refresh
new_page = @erased ? nil : find_proper_page
setup_page(new_page) if !new_page || new_page != @page
@ms_effectus_always_update = false
if @page && @page.list
@page.list.each do |command|
next unless command.code == 108
MakerSystems::Effectus::PATTERNS.each do |string|
next unless command.parameters[0].include?(string)
@ms_effectus_always_update = true
break
end
break if @ms_effectus_always_update
end
end
@ms_effectus_always_update = true if trigger == 3 || trigger == 4
if $game_map.ms_effectus_hard_events.include?(self)
unless @ms_effectus_always_update
$game_map.ms_effectus_hard_events.delete(self)
end
else
if @ms_effectus_always_update
$game_map.ms_effectus_hard_events << self
end
end
if tile? || @ms_effectus_tile
if $game_map.ms_effectus_pass_table
unless @ms_effectus_tile && tile?
$game_map.ms_effectus_release(@x, @y)
end
end
end
@ms_effectus_tile = tile?
if @ms_effectus_tile
unless @ms_effectus_tile_registered
@ms_effectus_tile_registered = true
$game_map.ms_effectus_etile_pos[@y * $game_map.width + @x] << self
end
else
if @ms_effectus_tile_registered
$game_map.ms_effectus_etile_pos[@y * $game_map.width + @x].delete(self)
@ms_effectus_tile_registered = nil
end
end
unless @ms_effectus_position_registered
$game_map.ms_effectus_event_pos[@y * $game_map.width + @x] << self
@ms_effectus_last_x = @x
@ms_effectus_last_y = @y
@ms_effectus_position_registered = true
end
unless @character_name == @ms_effectus_last_character_name
bitmap = Cache.character(@character_name)
string = @character_name[/^[\!\$]./]
if string && string.include?('$')
@ms_effectus_bw = bitmap.width / 3
@ms_effectus_bh = bitmap.height / 4
else
@ms_effectus_bw = bitmap.width / 12
@ms_effectus_bh = bitmap.height / 8
end
@ms_effectus_last_character_name = @character_name
@ms_effectus_special_calculus = @ms_effectus_bw > 32 ||
@ms_effectus_bh > 32
end
end
#--------------------------------------------------------------------------
# * Near the Screen? [NEW]
#--------------------------------------------------------------------------
if MakerSystems::Effectus::SCREEN_TILE_DIVMOD
def ms_effectus_near_the_screen?
if @ms_effectus_special_calculus ||
$game_map.ms_effectus_loop_vertical? ||
$game_map.ms_effectus_loop_horizontal?
screen_x + @ms_effectus_bw > 0 &&
screen_x - @ms_effectus_bw < Graphics.width &&
screen_y + @ms_effectus_bh > 0 &&
screen_y - @ms_effectus_bh < Graphics.height
else
@real_x > $game_map.display_x - 1 &&
@real_x < $game_map.display_x + Graphics.width / 32 + 1 &&
@real_y > $game_map.display_y - 1 &&
@real_y < $game_map.display_y + Graphics.height / 32 + 1
end
end
else
def ms_effectus_near_the_screen?
if @ms_effectus_special_calculus ||
$game_map.ms_effectus_loop_vertical? ||
$game_map.ms_effectus_loop_horizontal?
screen_x + @ms_effectus_bw > 0 &&
screen_x - @ms_effectus_bw < Graphics.width &&
screen_y + @ms_effectus_bh > 0 &&
screen_y - @ms_effectus_bh < Graphics.height
else
@real_x > $game_map.display_x - 1 &&
@real_x < $game_map.display_x + Graphics.width / 32 &&
@real_y > $game_map.display_y - 1 &&
@real_y < $game_map.display_y + Graphics.height / 32
end
end
end
#--------------------------------------------------------------------------
# * Update During Autonomous Movement. [REP]
#--------------------------------------------------------------------------
def update_self_movement
if MakerSystems::Effectus::PREVENT_OFFSCREEN_UPDATES
if @stop_count > 30 * (5 - @move_frequency)
case @move_type
when 1
move_type_random
when 2
move_type_toward_player
when 3
move_type_custom
end
end
else
if near_the_screen? && @stop_count > stop_count_threshold
case @move_type
when 1
move_type_random
when 2
move_type_toward_player
when 3
move_type_custom
end
end
end
end
#--------------------------------------------------------------------------
# * Alias Update. [NEW]
#--------------------------------------------------------------------------
alias_method(:ms_effectus_original_update, :update)
#--------------------------------------------------------------------------
# * Update. [MOD]
#--------------------------------------------------------------------------
def update
active = MakerSystems::Effectus::PREVENT_OFFSCREEN_UPDATES
ms_effectus_original_update unless active
if ms_effectus_near_the_screen? || @ms_effectus_wait_for_animation
ms_effectus_original_update if active
unless $game_temp.ms_effectus_sprites[@id]
$game_temp.ms_effectus_sprites[@id] =
Sprite_Character.new(SceneManager.scene.spriteset.viewport1, self)
end
$game_temp.ms_effectus_sprites[@id].update
if $game_temp.ms_effectus_sprites[@id].animation?
@ms_effectus_wait_for_animation = true
unless $game_map.ms_effectus_hard_events.include?(self)
$game_map.ms_effectus_hard_events << self
end
else
if @ms_effectus_wait_for_animation
@ms_effectus_wait_for_animation = nil
unless @ms_effectus_always_update
if $game_map.ms_effectus_hard_events.include?(self)
$game_map.ms_effectus_hard_events.delete(self)
end
end
end
end
else
ms_effectus_original_update if (@ms_effectus_always_update && active) ||
@move_route_forcing
unless @ms_effectus_always_update
if @move_route_forcing
unless @ms_effectus_wait_for_move_route_forcing
@ms_effectus_wait_for_move_route_forcing = true
unless $game_map.ms_effectus_hard_events.include?(self)
$game_map.ms_effectus_hard_events << self
end
end
else
if @ms_effectus_wait_for_move_route_forcing
@ms_effectus_wait_for_move_route_forcing = nil
if $game_map.ms_effectus_hard_events.include?(self)
$game_map.ms_effectus_hard_events.delete(self)
end
end
end
end
if $game_temp.ms_effectus_sprites[@id]
$game_temp.ms_effectus_sprites[@id].dispose
$game_temp.ms_effectus_sprites.delete(@id)
end
end
unless @ms_effectus_position_registered
$game_map.ms_effectus_event_pos[@y * $game_map.width + @x] << self
@ms_effectus_last_x = @x
@ms_effectus_last_y = @y
@ms_effectus_position_registered = true
end
if @x != @ms_effectus_last_x || @y != @ms_effectus_last_y
events = $game_map.ms_effectus_event_pos
width = $game_map.width
events[@y * width + @x] <<
events[@ms_effectus_last_y * width + @ms_effectus_last_x].delete(self)
if @ms_effectus_tile
tiles = $game_map.ms_effectus_etile_pos
tiles[@y * width + @x] <<
tiles[@ms_effectus_last_y * width + @ms_effectus_last_x].delete(self)
end
@ms_effectus_last_x = @x
@ms_effectus_last_y = @y
end
end
end
#==============================================================================
# ** Game_Follower
#------------------------------------------------------------------------------
# This class handles followers. A follower is an allied character, other than
# the front character, displayed in the party. It is referenced within the
# Game_Followers class.
#==============================================================================
class Game_Follower < Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables. [NEW]
#--------------------------------------------------------------------------
attr_accessor :ms_effectus_position_registered
#--------------------------------------------------------------------------
# * Update. [REP]
#--------------------------------------------------------------------------
def update
@move_speed = $game_player.real_move_speed
@transparent = $game_player.transparent
@walk_anime = $game_player.walk_anime
@step_anime = $game_player.step_anime
@direction_fix = $game_player.direction_fix
@opacity = $game_player.opacity
@blend_type = $game_player.blend_type
super
if visible?
events = $game_map.ms_effectus_party_pos
width = $game_map.width
unless @ms_effectus_position_registered
events[@y * width + @x] << self
@ms_effectus_last_x = @x
@ms_effectus_last_y = @y
@ms_effectus_position_registered = true
end
if @x != @ms_effectus_last_x || @y != @ms_effectus_last_y
events[@y * width + @x] <<
events[@ms_effectus_last_y * width + @ms_effectus_last_x].delete(self)
@ms_effectus_last_x = @x
@ms_effectus_last_y = @y
end
else
if @ms_effectus_position_registered
@ms_effectus_position_registered = nil
$game_map.ms_effectus_party_pos[@ms_effectus_last_y *
$game_map.width + @ms_effectus_last_x].delete(self)
end
end
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Public Instance Variables. [NEW]
#--------------------------------------------------------------------------
attr_accessor :viewport1
#--------------------------------------------------------------------------
# * Create Characters. [REP]
#--------------------------------------------------------------------------
def create_characters
@character_sprites = []
$game_map.events.values.each do |event|
next unless event.ms_effectus_near_the_screen?
$game_temp.ms_effectus_sprites[event.id] =
Sprite_Character.new(@viewport1, event)
end
$game_map.vehicles.each do |vehicle|
@character_sprites << Sprite_Character.new(@viewport1, vehicle)
end
$game_player.followers.reverse_each do |follower|
@character_sprites << Sprite_Character.new(@viewport1, follower)
end
@character_sprites << Sprite_Character.new(@viewport1, $game_player)
@map_id = $game_map.map_id
end
#--------------------------------------------------------------------------
# * Dispose Characters. [REP]
#--------------------------------------------------------------------------
def dispose_characters
@character_sprites.each { |sprite| sprite.dispose }
$game_temp.ms_effectus_sprites.each_value { |sprite| sprite.dispose }
$game_temp.ms_effectus_sprites.clear
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the map screen processing.
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# * Public Instance Variables. [NEW]
#--------------------------------------------------------------------------
attr_accessor :spriteset
#--------------------------------------------------------------------------
# * Update. [REP]
#--------------------------------------------------------------------------
def update
super
$game_map.update(true)
$game_player.update
$game_timer.update
@spriteset.update
update_scene if scene_change_ok?
$game_map.update_events
$game_map.update_vehicles
end
end
#==============================================================================
# ** DataManager
#------------------------------------------------------------------------------
# This module manages the database and game objects. Almost all of the
# global variables used by the game are initialized by this module.
#==============================================================================
module DataManager
class << self
#------------------------------------------------------------------------
# * Create Save Contents. [REP]
#------------------------------------------------------------------------
def save_game_without_rescue(index)
$game_map.ms_effectus_party_pos.default = nil
$game_map.ms_effectus_event_pos.default = nil
$game_map.ms_effectus_etile_pos.default = nil
$game_map.ms_effectus_etriggers.default = nil
File.open(make_filename(index), "wb") do |file|
$game_system.on_before_save
Marshal.dump(make_save_header, file)
Marshal.dump(make_save_contents, file)
@last_savefile_index = index
end
$game_map.ms_effectus_party_pos.default_proc = proc { |h, k| h[k] = [] }
$game_map.ms_effectus_event_pos.default_proc = proc { |h, k| h[k] = [] }
$game_map.ms_effectus_etile_pos.default_proc = proc { |h, k| h[k] = [] }
$game_map.ms_effectus_etriggers.default_proc = proc { |h, k| h[k] = [] }
true
end
#------------------------------------------------------------------------
# * Extract Save Contents. [REP]
#------------------------------------------------------------------------
def extract_save_contents(contents)
$game_system = contents[:system]
$game_timer = contents[:timer]
$game_message = contents[:message]
$game_switches = contents[:switches]
$game_variables = contents[:variables]
$game_self_switches = contents[:self_switches]
$game_actors = contents[:actors]
$game_party = contents[:party]
$game_troop = contents[:troop]
$game_map = contents[:map]
$game_player = contents[:player]
return unless $game_map.ms_effectus_party_pos
$game_map.ms_effectus_party_pos.default_proc = proc { |h, k| h[k] = [] }
$game_map.ms_effectus_event_pos.default_proc = proc { |h, k| h[k] = [] }
$game_map.ms_effectus_etile_pos.default_proc = proc { |h, k| h[k] = [] }
$game_map.ms_effectus_etriggers.default_proc = proc { |h, k| h[k] = [] }
end
end
end
#==============================================================================
# ** Sprite_Base
#------------------------------------------------------------------------------
# A sprite class with animation display processing added.
#==============================================================================
class Sprite_Base < Sprite
#--------------------------------------------------------------------------
# * Frame Update. [REP]
#--------------------------------------------------------------------------
def update
super
update_animation if animation?
@@ani_checker.clear
@@ani_spr_checker.clear
end
#--------------------------------------------------------------------------
# * Update Animation. [REP]
#--------------------------------------------------------------------------
def update_animation
@ani_duration -= 1
if @ani_duration % @ani_rate == 0
if @ani_duration > 0
frame_index = @animation.frame_max
frame_index -= (@ani_duration + @ani_rate - 1) / @ani_rate
animation_set_sprites(@animation.frames[frame_index])
@animation.timings.each do |timing|
animation_process_timing(timing) if timing.frame == frame_index
end
else
end_animation
end
end
end
end
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# This sprite is used to display characters. It observes an instance of the
# Game_Character class and automatically changes sprite state.
#==============================================================================
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# * Frame Update. [REP]
#--------------------------------------------------------------------------
def update
super
update_bitmap if graphic_changed?
update_src_rect if @tile_id == 0 && (@character.pattern != @old_pattern ||
@character.direction != @old_dir)
update_position
update_other
update_balloon if @balloon_duration > 0
setup_new_effect
end
#--------------------------------------------------------------------------
# * Update Transfer Origin Bitmap. [REP]
#--------------------------------------------------------------------------
def update_bitmap
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_index = @character.character_index
if @tile_id > 0
set_tile_bitmap
else
set_character_bitmap
end
@old_pattern = nil
end
#--------------------------------------------------------------------------
# * Update Transfer Origin Rectangle. [REP]
#--------------------------------------------------------------------------
def update_src_rect
@old_pattern = @character.pattern
@old_dir = @character.direction
index = @character.character_index
pattern = @character.pattern < 3 ? @character.pattern : 1
sx = (index % 4 * 3 + pattern) * @cw
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
#--------------------------------------------------------------------------
# * Update Position. [REP]
#--------------------------------------------------------------------------
def update_position
if @animation && @animation.position != 3
move_animation(@character.screen_x - x, @character.screen_y - y)
end
sx = @character.screen_x
if sx != @old_sx
@old_sx = sx
self.x = sx
end
sy = @character.screen_y
if sy != @old_sy
@old_sy = sy
self.y = sy
end
self.z = @character.screen_z
end
#--------------------------------------------------------------------------
# * Move Animation. [REP]
#--------------------------------------------------------------------------
def move_animation(dx, dy)
@ani_ox += dx
@ani_oy += dy
@ani_sprites.each do |sprite|
sprite.x += dx
sprite.y += dy
end
end
#--------------------------------------------------------------------------
# * Update Balloon Icon. [REP]
#--------------------------------------------------------------------------
def update_balloon
@balloon_duration -= 1
if @balloon_duration > 0
@balloon_sprite.x = x
@balloon_sprite.y = y - height
@balloon_sprite.z = z + 200
sx = balloon_frame_index * 32
sy = (@balloon_id - 1) * 32
@balloon_sprite.src_rect.set(sx, sy, 32, 32)
else
end_balloon
end
end
end
Социальные закладки