fix issue with map renderer after battles ( commit 2c65a9de7d )

This commit is contained in:
infinitefusion
2022-06-03 15:38:38 -04:00
parent cc200ac0ed
commit 6ecdd9575f
10 changed files with 503 additions and 509 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -2,18 +2,12 @@
# Battle intro animation # Battle intro animation
#=============================================================================== #===============================================================================
def pbSceneStandby def pbSceneStandby
$scene.disposeSpritesets if $scene && $scene.is_a?(Scene_Map)
if RPG::Cache.need_clearing
RPG::Cache.clear
end
Graphics.frame_reset
yield yield
$scene.createSpritesets if $scene && $scene.is_a?(Scene_Map)
end end
def pbBattleAnimation(bgm=nil,battletype=0,foe=nil) def pbBattleAnimation(bgm=nil,battletype=0,foe=nil)
$game_temp.in_battle = true $game_temp.in_battle = true
viewport = Viewport.new(0,0,Graphics.width,Graphics.height) viewport = Viewport.new(0,0,Graphicsc.width,Graphics.height)
viewport.z = 99999 viewport.z = 99999
# Set up audio # Set up audio
playingBGS = nil playingBGS = nil

View File

@@ -572,7 +572,7 @@ def pbLoadRpgxpScene(scene)
oldscene = $scene oldscene = $scene
$scene = scene $scene = scene
Graphics.freeze Graphics.freeze
oldscene.disposeSpritesets #oldscene.disposeSpritesets
visibleObjects = pbHideVisibleObjects visibleObjects = pbHideVisibleObjects
Graphics.transition(20) Graphics.transition(20)
Graphics.freeze Graphics.freeze
@@ -582,7 +582,7 @@ def pbLoadRpgxpScene(scene)
Graphics.transition(20) Graphics.transition(20)
Graphics.freeze Graphics.freeze
$scene = oldscene $scene = oldscene
$scene.createSpritesets #$scene.createSpritesets
pbShowObjects(visibleObjects) pbShowObjects(visibleObjects)
Graphics.transition(20) Graphics.transition(20)
end end

View File

@@ -1,225 +1,225 @@
#=============================================================================== # #===============================================================================
# Klein Footprints / WolfPP for Pokémon Essentials # # Klein Footprints / WolfPP for Pokémon Essentials
# Give credits if you're using this! # # Give credits if you're using this!
# http://kleinstudio.deviantart.com # # http://kleinstudio.deviantart.com
# #
# # bo4p5687 update (v.19)
# #===============================================================================
# #
# bo4p5687 update (v.19) # # Fix event comment
#=============================================================================== # def pbEventCommentInput(*args)
# parameters = []
# Fix event comment # list = *args[0].list # Event or event page
def pbEventCommentInput(*args) # elements = *args[1] # Number of elements
parameters = [] # trigger = *args[2] # Trigger
list = *args[0].list # Event or event page # return nil if list == nil
elements = *args[1] # Number of elements # return nil unless list.is_a?(Array)
trigger = *args[2] # Trigger # for item in list
return nil if list == nil # next unless item.code == 108 || item.code == 408
return nil unless list.is_a?(Array) # if item.parameters[0] == trigger[0]
for item in list # start = list.index(item) + 1
next unless item.code == 108 || item.code == 408 # finish = start + elements[0]
if item.parameters[0] == trigger[0] # for id in start...finish
start = list.index(item) + 1 # next if !list[id]
finish = start + elements[0] # parameters.push(list[id].parameters[0])
for id in start...finish # end
next if !list[id] # return parameters
parameters.push(list[id].parameters[0]) # end
end # end
return parameters # return nil
end # end
end #
return nil # module FootprintVariables
end # # If you set pokemon here, they doesn't have footprints
# FOLLOWING_DONT_WALK = [
module FootprintVariables # # Example:
# If you set pokemon here, they doesn't have footprints # # 12,15,17
FOLLOWING_DONT_WALK = [ # ]
# Example: #
# 12,15,17 # # Set here the terrain tag for footprints, 3 is sand
] # TERRAIN_FOOT = 3
#
# Set here the terrain tag for footprints, 3 is sand # # Initial opacity for footprints
TERRAIN_FOOT = 3 # FOOT_OPACITY = 62
#
# Initial opacity for footprints # # Delay velocity
FOOT_OPACITY = 62 # FOOT_DELAY = 1.1
#
# Delay velocity # def self.get_new_id
FOOT_DELAY = 1.1 # newId = 1
# while !$game_map.events[newId].nil? do
def self.get_new_id # break if $game_map.events[newId].erased
newId = 1 # newId += 1
while !$game_map.events[newId].nil? do # end
break if $game_map.events[newId].erased # return newId
newId += 1 # end
end #
return newId # def self.show(event, position)
end # if event != $game_player
# return if event.character_name == "" || event.character_name == "nil" || event.name.include?("/nofoot/")
def self.show(event, position) # return if pbEventCommentInput(event, 0, "NoFoot")
if event != $game_player # if $Trainer.party.length > 0
return if event.character_name == "" || event.character_name == "nil" || event.name.include?("/nofoot/") # return if (!($game_map.events[event] && $game_map.events[event].name == "Dependent") &&
return if pbEventCommentInput(event, 0, "NoFoot") # (FOLLOWING_DONT_WALK.include?($Trainer.party[0].species) || $PokemonGlobal.bicycle))
if $Trainer.party.length > 0 # end
return if (!($game_map.events[event] && $game_map.events[event].name == "Dependent") && # end
(FOLLOWING_DONT_WALK.include?($Trainer.party[0].species) || $PokemonGlobal.bicycle)) # character_sprites = $scene.spriteset.character_sprites
end # viewport = $scene.spriteset.viewport1
end # footsprites = $scene.spriteset.footsprites
character_sprites = $scene.spriteset.character_sprites # nid = self.get_new_id
viewport = $scene.spriteset.viewport1 # rpgEvent = RPG::Event.new(position[0], position[1])
footsprites = $scene.spriteset.footsprites # rpgEvent.id = nid
nid = self.get_new_id # fev = Game_Event.new($game_map.map_id, rpgEvent, $game_map)
rpgEvent = RPG::Event.new(position[0], position[1]) # eventsprite = Sprite_Character.new(viewport, fev)
rpgEvent.id = nid # character_sprites.push(eventsprite)
fev = Game_Event.new($game_map.map_id, rpgEvent, $game_map) # footsprites.push(Footsprite.new(eventsprite, fev, viewport, $game_map, position[2], nid, character_sprites, (event==$game_player)))
eventsprite = Sprite_Character.new(viewport, fev) # end
character_sprites.push(eventsprite) #
footsprites.push(Footsprite.new(eventsprite, fev, viewport, $game_map, position[2], nid, character_sprites, (event==$game_player))) # end
end #
# class Game_Event < Game_Character
end # attr_reader :erased
# end
class Game_Event < Game_Character #
attr_reader :erased # class Sprite_Character
end # alias old_initialize_foot initialize
# def initialize(viewport, character=nil)
class Sprite_Character # old_initialize_foot(viewport, character)
alias old_initialize_foot initialize # @disposed = false
def initialize(viewport, character=nil) # end
old_initialize_foot(viewport, character) #
@disposed = false # alias old_update_foot update
end # def update
# return if @disposed
alias old_update_foot update # old_update_foot
def update # end
return if @disposed #
old_update_foot # alias old_dispose_foot dispose
end # def dispose
# old_dispose_foot
alias old_dispose_foot dispose # @disposed = true
def dispose # end
old_dispose_foot # end
@disposed = true #
end # class Spriteset_Map
end # attr_accessor :character_sprites
# attr_accessor :footsprites
class Spriteset_Map #
attr_accessor :character_sprites # alias old_initialize initialize
attr_accessor :footsprites # def initialize(map=nil)
# old_initialize(map)
alias old_initialize initialize # @footsprites = []
def initialize(map=nil) # end
old_initialize(map) #
@footsprites = [] # def viewport1
end # return @@viewport1
# end
def viewport1 #
return @@viewport1 # def putFootprint(event, pos)
end # return FootprintVariables.show(event, pos)
# end
def putFootprint(event, pos) #
return FootprintVariables.show(event, pos) # alias old_dispose dispose
end # def dispose
# old_dispose
alias old_dispose dispose # @footsprites.each { |sprite| sprite.dispose } if !@footsprites.nil?
def dispose # @footsprites.clear
old_dispose # end
@footsprites.each { |sprite| sprite.dispose } if !@footsprites.nil? #
@footsprites.clear # alias old_update update
end # def update
# old_update
alias old_update update # return if @footsprites.nil?
def update # @footsprites.each { |sprite| sprite.update }
old_update # end
return if @footsprites.nil? # end
@footsprites.each { |sprite| sprite.update } #
end # class Scene_Map
end # def spriteset?
# return !@spritesets.nil?
class Scene_Map # end
def spriteset? # end
return !@spritesets.nil? #
end # class Game_Character
end #
# def get_last_pos
class Game_Character # case direction
# when 2 then return [@x, @y-1, direction] # Move down
def get_last_pos # when 4 then return [@x+1, @y, direction] # Move left
case direction # when 6 then return [@x-1, @y, direction] # Move right
when 2 then return [@x, @y-1, direction] # Move down # when 8 then return [@x, @y+1, direction] # Move up
when 4 then return [@x+1, @y, direction] # Move left # end
when 6 then return [@x-1, @y, direction] # Move right # return false
when 8 then return [@x, @y+1, direction] # Move up # end
end #
return false # def foot_prints?
end # return $game_map.terrain_tag(get_last_pos[0], get_last_pos[1]) == FootprintVariables::TERRAIN_FOOT && $scene.is_a?(Scene_Map) && $scene.spriteset?
# end
def foot_prints? #
return $game_map.terrain_tag(get_last_pos[0], get_last_pos[1]) == FootprintVariables::TERRAIN_FOOT && $scene.is_a?(Scene_Map) && $scene.spriteset? # alias leave_tile_footprints triggerLeaveTile
end # def triggerLeaveTile
# leave_tile_footprints
alias leave_tile_footprints triggerLeaveTile # $scene.spriteset.putFootprint(self, get_last_pos) if foot_prints?
def triggerLeaveTile # end
leave_tile_footprints #
$scene.spriteset.putFootprint(self, get_last_pos) if foot_prints? # end
end #
# class Footsprite
end # def initialize(sprite,event,viewport,map,direction,nid,chardata,player)
# @rsprite = sprite
class Footsprite # # Sprite
def initialize(sprite,event,viewport,map,direction,nid,chardata,player) # @sprite = Sprite.new(viewport)
@rsprite = sprite # file = player && $PokemonGlobal.bicycle ? "footsetbike.png" : "footset.png"
# Sprite # @sprite.bitmap = RPG::Cache.load_bitmap("Graphics/Pictures/", file)
@sprite = Sprite.new(viewport) # # Set position
file = player && $PokemonGlobal.bicycle ? "footsetbike.png" : "footset.png" # @realwidth = @sprite.bitmap.width/4
@sprite.bitmap = RPG::Cache.load_bitmap("Graphics/Pictures/", file) # @sprite.src_rect.width = @realwidth
# Set position # @opacity = FootprintVariables::FOOT_OPACITY
@realwidth = @sprite.bitmap.width/4 # setFootset(direction)
@sprite.src_rect.width = @realwidth # # Values
@opacity = FootprintVariables::FOOT_OPACITY # @map = map
setFootset(direction) # @event = event
# Values # @disposed = false
@map = map # @eventid = nid
@event = event # @viewport = viewport
@disposed = false # @chardata = chardata
@eventid = nid # update
@viewport = viewport # end
@chardata = chardata #
update # def setFootset(direction)
end # @sprite.src_rect.x =
# case direction
def setFootset(direction) # when 2 then 0 # Move down
@sprite.src_rect.x = # when 4 then @realwidth * 3 # Move left
case direction # when 6 then @realwidth * 2 # Move right
when 2 then 0 # Move down # when 8 then @realwidth # Move up
when 4 then @realwidth * 3 # Move left # end
when 6 then @realwidth * 2 # Move right # @sprite.opacity = @opacity
when 8 then @realwidth # Move up # end
end #
@sprite.opacity = @opacity # def dispose
end # return if @disposed
# @disposed = true
def dispose # @event.erase
return if @disposed # (0...@chardata.length).each { |i| @chardata.delete_at(i) if @chardata[i] == @rsprite }
@disposed = true # @rsprite.dispose
@event.erase # @sprite.dispose
(0...@chardata.length).each { |i| @chardata.delete_at(i) if @chardata[i] == @rsprite } # @sprite = nil
@rsprite.dispose # end
@sprite.dispose #
@sprite = nil # def update
end # return if @disposed
# x = @rsprite.x - @rsprite.ox
def update # y = @rsprite.y - @rsprite.oy
return if @disposed # width = @rsprite.src_rect.width
x = @rsprite.x - @rsprite.ox # height = @rsprite.src_rect.height
y = @rsprite.y - @rsprite.oy # @sprite.x = x + width / 2
width = @rsprite.src_rect.width # @sprite.y = y + height
height = @rsprite.src_rect.height # @sprite.ox = @realwidth / 2
@sprite.x = x + width / 2 # @sprite.oy = @sprite.bitmap.height
@sprite.y = y + height # @sprite.z = @rsprite.z - 2
@sprite.ox = @realwidth / 2 # @opacity -= FootprintVariables::FOOT_DELAY
@sprite.oy = @sprite.bitmap.height # @sprite.opacity = @opacity
@sprite.z = @rsprite.z - 2 # dispose if @sprite.opacity <= 0
@opacity -= FootprintVariables::FOOT_DELAY # end
@sprite.opacity = @opacity # end
dispose if @sprite.opacity <= 0
end
end

View File

@@ -1,278 +1,278 @@
#=============================================================================== # #===============================================================================
# * Unreal Time System - by FL (Credits will be apreciated) # # * Unreal Time System - by FL (Credits will be apreciated)
#=============================================================================== # #===============================================================================
# #
# # This script is for Pokémon Essentials. It makes the time in game uses its
# # own clock that only pass when you are in game instead of using real time
# # (like Minecraft and Zelda: Ocarina of Time).
# #
# #== INSTALLATION ===============================================================
# #
# # To this script works, put it above main OR convert into a plugin.
# #
# #== HOW TO USE =================================================================
# #
# # This script automatic works after installed.
# #
# # If you wish to add/reduce time, there are 3 ways:
# #
# # 1. EXTRA_SECONDS/EXTRA_DAYS are variables numbers that hold time passage;
# # The time in these variable isn't affected by PROPORTION.
# # Example: When the player sleeps you wish to the time in game advance
# # 8 hours, so put in EXTRA_SECONDS a game variable number and sum
# # 28800 (60*60*8) in this variable every time that the players sleeps.
# #
# # 2. 'UnrealTime.add_seconds(seconds)' and 'UnrealTime.add_days(days)' does the
# # same thing, in fact, EXTRA_SECONDS/EXTRA_DAYS call these methods.
# #
# # 3. 'UnrealTime.advance_to(16,17,18)' advance the time to a fixed time of day,
# # 16:17:18 on this example.
# #
# #== NOTES ======================================================================
# #
# # If you wish to some parts still use real time like the Trainer Card start time
# # and Pokémon Trainer Memo, just change 'pbGetTimeNow' to 'Time.now' in their
# # scripts.
# #
# # This script uses the Ruby Time class. Before Essentials version 19 (who came
# # with 64-bit ruby) it can only have 1901-2038 range.
# #
# # Some time methods:
# # 'pbGetTimeNow.year', 'pbGetTimeNow.mon' (the numbers from 1-12),
# # 'pbGetTimeNow.day','pbGetTimeNow.hour', 'pbGetTimeNow.min',
# # 'pbGetTimeNow.sec', 'pbGetAbbrevMonthName(pbGetTimeNow.mon)',
# # 'pbGetTimeNow.strftime("%A")' (displays weekday name),
# # 'pbGetTimeNow.strftime("%I:%M %p")' (displays Hours:Minutes pm/am)
# #
# #===============================================================================
# #
# This script is for Pokémon Essentials. It makes the time in game uses its # if defined?(PluginManager) && !PluginManager.installed?("Unreal Time System")
# own clock that only pass when you are in game instead of using real time # PluginManager.register({
# (like Minecraft and Zelda: Ocarina of Time). # :name => "Unreal Time System",
# :version => "1.1",
# :link => "https://www.pokecommunity.com/showthread.php?t=285831",
# :credits => "FL"
# })
# end
# #
#== INSTALLATION =============================================================== # module UnrealTime
# # Set false to disable this system (returns Time.now)
# ENABLED=true
# #
# To this script works, put it above main OR convert into a plugin. # # Time proportion here.
# # So if it is 100, one second in real time will be 100 seconds in game.
# # If it is 60, one second in real time will be one minute in game.
# PROPORTION=60
# #
#== HOW TO USE ================================================================= # # Starting on Essentials v17, the map tone only try to refresh tone each 30
# # real time seconds.
# # If this variable number isn't -1, the game use this number instead of 30.
# # When time is changed with advance_to or add_seconds, the tone refreshes.
# TONE_CHECK_INTERVAL = 10.0
# #
# This script automatic works after installed. # # Make this true to time only pass at field (Scene_Map)
# # A note to scripters: To make time pass on other scenes, put line
# # '$PokemonGlobal.addNewFrameCount' near to line 'Graphics.update'
# TIME_STOPS=true
# #
# If you wish to add/reduce time, there are 3 ways: # # Make this true to time pass in battle, during turns and command selection.
# # This won't affect the Pokémon and Bag submenus.
# # Only works if TIME_STOPS=true.
# BATTLE_PASS=true
# #
# 1. EXTRA_SECONDS/EXTRA_DAYS are variables numbers that hold time passage; # # Make this true to time pass when the Dialog box or the main menu are open.
# The time in these variable isn't affected by PROPORTION. # # This won't affect the submenus like Pokémon and Bag.
# Example: When the player sleeps you wish to the time in game advance # # Only works if TIME_STOPS=true.
# 8 hours, so put in EXTRA_SECONDS a game variable number and sum # TALK_PASS=true
# 28800 (60*60*8) in this variable every time that the players sleeps.
# #
# 2. 'UnrealTime.add_seconds(seconds)' and 'UnrealTime.add_days(days)' does the # # Choose switch number that when true the time won't pass (or -1 to cancel).
# same thing, in fact, EXTRA_SECONDS/EXTRA_DAYS call these methods. # # Only works if TIME_STOPS=true.
# SWITCH_STOPS=-1
# #
# 3. 'UnrealTime.advance_to(16,17,18)' advance the time to a fixed time of day, # # Choose variable(s) number(s) that can hold time passage (or -1 to cancel).
# 16:17:18 on this example. # # Look at description for more details.
# EXTRA_SECONDS=79
# EXTRA_DAYS=-1
# #
#== NOTES ====================================================================== # # Initial date. In sequence: Year, month, day, hour and minutes.
# # Method UnrealTime.reset resets time back to this time.
# def self.initial_date
# return Time.local(2000,1,1, 12,0)
# end
# #
# If you wish to some parts still use real time like the Trainer Card start time # # Advance to next time. If time already passed, advance
# and Pokémon Trainer Memo, just change 'pbGetTimeNow' to 'Time.now' in their # # into the time on the next day.
# scripts. # # Hour is 0..23
# def self.advance_to(hour,min=0,sec=0)
# if hour < 0 || hour > 23
# raise RangeError, "hour is #{hour}, should be 0..23"
# end
# day_seconds = 60*60*24
# seconds_now = pbGetTimeNow.hour*60*60+pbGetTimeNow.min*60+pbGetTimeNow.sec
# target_seconds = hour*60*60+min*60+sec
# seconds_added = target_seconds-seconds_now
# seconds_added += day_seconds if seconds_added<0
# $PokemonGlobal.newFrameCount+=seconds_added
# PBDayNight.sheduleToneRefresh
# end
# #
# This script uses the Ruby Time class. Before Essentials version 19 (who came # # Resets time to initial_date.
# with 64-bit ruby) it can only have 1901-2038 range. # def self.reset
# raise "Method doesn't work when TIME_STOPS is false!" if !TIME_STOPS
# $game_variables[EXTRA_SECONDS]=0 if EXTRA_DAYS>0
# $game_variables[EXTRA_DAYS]=0 if EXTRA_DAYS>0
# $PokemonGlobal.newFrameCount=0
# $PokemonGlobal.extraYears=0
# PBDayNight.sheduleToneRefresh
# end
# #
# Some time methods: # # Does the same thing as EXTRA_SECONDS variable.
# 'pbGetTimeNow.year', 'pbGetTimeNow.mon' (the numbers from 1-12), # def self.add_seconds(seconds)
# 'pbGetTimeNow.day','pbGetTimeNow.hour', 'pbGetTimeNow.min', # raise "Method doesn't work when TIME_STOPS is false!" if !TIME_STOPS
# 'pbGetTimeNow.sec', 'pbGetAbbrevMonthName(pbGetTimeNow.mon)', # $PokemonGlobal.newFrameCount+=(seconds*Graphics.frame_rate)/PROPORTION.to_f
# 'pbGetTimeNow.strftime("%A")' (displays weekday name), # PBDayNight.sheduleToneRefresh
# 'pbGetTimeNow.strftime("%I:%M %p")' (displays Hours:Minutes pm/am) # end
# #
#=============================================================================== # def self.add_days(days)
# add_seconds(60*60*24*days)
if defined?(PluginManager) && !PluginManager.installed?("Unreal Time System") # end
PluginManager.register({ #
:name => "Unreal Time System", # NEED_32_BIT_FIX = [''].pack('p').size <= 4
:version => "1.1", # end
:link => "https://www.pokecommunity.com/showthread.php?t=285831", #
:credits => "FL" # # Essentials V18 and lower compatibility
}) # module Settings
end # TIME_SHADING = defined?(ENABLESHADING) ? ENABLESHADING : ::TIME_SHADING
# end if defined?(TIME_SHADING) || defined?(ENABLESHADING)
module UnrealTime #
# Set false to disable this system (returns Time.now) # module PBDayNight
ENABLED=true # class << self
# if method_defined?(:getTone) && UnrealTime::TONE_CHECK_INTERVAL > 0
# Time proportion here. # def getTone
# So if it is 100, one second in real time will be 100 seconds in game. # @cachedTone = Tone.new(0,0,0) if !@cachedTone
# If it is 60, one second in real time will be one minute in game. # return @cachedTone if !Settings::TIME_SHADING
PROPORTION=60 # toneNeedUpdate = (!@dayNightToneLastUpdate ||
# Graphics.frame_count-@dayNightToneLastUpdate >=
# Starting on Essentials v17, the map tone only try to refresh tone each 30 # Graphics.frame_rate*UnrealTime::TONE_CHECK_INTERVAL
# real time seconds. # )
# If this variable number isn't -1, the game use this number instead of 30. # if toneNeedUpdate
# When time is changed with advance_to or add_seconds, the tone refreshes. # getToneInternal
TONE_CHECK_INTERVAL = 10.0 # @dayNightToneLastUpdate = Graphics.frame_count
# end
# Make this true to time only pass at field (Scene_Map) # return @cachedTone
# A note to scripters: To make time pass on other scenes, put line # end
# '$PokemonGlobal.addNewFrameCount' near to line 'Graphics.update' # end
TIME_STOPS=true #
# # Shedule a tone refresh on the next try (probably next frame)
# Make this true to time pass in battle, during turns and command selection. # def sheduleToneRefresh
# This won't affect the Pokémon and Bag submenus. # @dayNightToneLastUpdate = nil
# Only works if TIME_STOPS=true. # end
BATTLE_PASS=true # end
# end
# Make this true to time pass when the Dialog box or the main menu are open. #
# This won't affect the submenus like Pokémon and Bag. # def pbGetTimeNow
# Only works if TIME_STOPS=true. # return Time.now if !$PokemonGlobal || !UnrealTime::ENABLED
TALK_PASS=true # day_seconds = 60*60*24
# if UnrealTime::TIME_STOPS
# Choose switch number that when true the time won't pass (or -1 to cancel). # # Sum the extra values to newFrameCount
# Only works if TIME_STOPS=true. # if UnrealTime::EXTRA_SECONDS>0
SWITCH_STOPS=-1 # UnrealTime.add_seconds(pbGet(UnrealTime::EXTRA_SECONDS))
# $game_variables[UnrealTime::EXTRA_SECONDS]=0
# Choose variable(s) number(s) that can hold time passage (or -1 to cancel). # end
# Look at description for more details. # if UnrealTime::EXTRA_DAYS>0
EXTRA_SECONDS=79 # UnrealTime.add_seconds(day_seconds*pbGet(UnrealTime::EXTRA_DAYS))
EXTRA_DAYS=-1 # $game_variables[UnrealTime::EXTRA_DAYS]=0
# end
# Initial date. In sequence: Year, month, day, hour and minutes. # elsif UnrealTime::EXTRA_SECONDS>0 && UnrealTime::EXTRA_DAYS>0
# Method UnrealTime.reset resets time back to this time. # # Checks to regulate the max/min values at UnrealTime::EXTRA_SECONDS
def self.initial_date # while pbGet(UnrealTime::EXTRA_SECONDS)>=day_seconds
return Time.local(2000,1,1, 12,0) # $game_variables[UnrealTime::EXTRA_SECONDS]-=day_seconds
end # $game_variables[UnrealTime::EXTRA_DAYS]+=1
# end
# Advance to next time. If time already passed, advance # while pbGet(UnrealTime::EXTRA_SECONDS)<=-day_seconds
# into the time on the next day. # $game_variables[UnrealTime::EXTRA_SECONDS]+=day_seconds
# Hour is 0..23 # $game_variables[UnrealTime::EXTRA_DAYS]-=1
def self.advance_to(hour,min=0,sec=0) # end
if hour < 0 || hour > 23 # end
raise RangeError, "hour is #{hour}, should be 0..23" # start_time=UnrealTime.initial_date
end # if UnrealTime::TIME_STOPS
day_seconds = 60*60*24 # time_played=$PokemonGlobal.newFrameCount
seconds_now = pbGetTimeNow.hour*60*60+pbGetTimeNow.min*60+pbGetTimeNow.sec # else
target_seconds = hour*60*60+min*60+sec # time_played=Graphics.frame_count
seconds_added = target_seconds-seconds_now # end
seconds_added += day_seconds if seconds_added<0 # time_played=(time_played*UnrealTime::PROPORTION)/Graphics.frame_rate
$PokemonGlobal.newFrameCount+=seconds_added # time_jumped=0
PBDayNight.sheduleToneRefresh # if UnrealTime::EXTRA_SECONDS>-1
end # time_jumped+=pbGet(UnrealTime::EXTRA_SECONDS)
# end
# Resets time to initial_date. # if UnrealTime::EXTRA_DAYS>-1
def self.reset # time_jumped+=pbGet(UnrealTime::EXTRA_DAYS)*day_seconds
raise "Method doesn't work when TIME_STOPS is false!" if !TIME_STOPS # end
$game_variables[EXTRA_SECONDS]=0 if EXTRA_DAYS>0 # time_ret = 0
$game_variables[EXTRA_DAYS]=0 if EXTRA_DAYS>0 # # Before Essentials V19, there is a year limit. To prevent crashes due to this
$PokemonGlobal.newFrameCount=0 # # limit, every time that you reach in year 2036 the system will subtract 6
$PokemonGlobal.extraYears=0 # # years (to works with leap year) from your date and sum in
PBDayNight.sheduleToneRefresh # # $PokemonGlobal.extraYears. You can sum your actual year with this extraYears
end # # when displaying years.
# loop do
# Does the same thing as EXTRA_SECONDS variable. # time_fix=0
def self.add_seconds(seconds) # if $PokemonGlobal.extraYears!=0
raise "Method doesn't work when TIME_STOPS is false!" if !TIME_STOPS # time_fix = $PokemonGlobal.extraYears*day_seconds*(365*6+1)/6
$PokemonGlobal.newFrameCount+=(seconds*Graphics.frame_rate)/PROPORTION.to_f # end
PBDayNight.sheduleToneRefresh # time_ret=start_time+(time_played+time_jumped-time_fix)
end # break if !UnrealTime::NEED_32_BIT_FIX || time_ret.year<2036
# $PokemonGlobal.extraYears+=6
def self.add_days(days) # end
add_seconds(60*60*24*days) # return time_ret
end # end
#
NEED_32_BIT_FIX = [''].pack('p').size <= 4 # if UnrealTime::ENABLED
end # class PokemonGlobalMetadata
# attr_accessor :newFrameCount # Became float when using extra values
# Essentials V18 and lower compatibility # attr_accessor :extraYears
module Settings #
TIME_SHADING = defined?(ENABLESHADING) ? ENABLESHADING : ::TIME_SHADING # def addNewFrameCount
end if defined?(TIME_SHADING) || defined?(ENABLESHADING) # return if (UnrealTime::SWITCH_STOPS>0 &&
# $game_switches[UnrealTime::SWITCH_STOPS])
module PBDayNight # self.newFrameCount+=1
class << self # end
if method_defined?(:getTone) && UnrealTime::TONE_CHECK_INTERVAL > 0 #
def getTone # def newFrameCount
@cachedTone = Tone.new(0,0,0) if !@cachedTone # @newFrameCount=0 if !@newFrameCount
return @cachedTone if !Settings::TIME_SHADING # return @newFrameCount
toneNeedUpdate = (!@dayNightToneLastUpdate || # end
Graphics.frame_count-@dayNightToneLastUpdate >= #
Graphics.frame_rate*UnrealTime::TONE_CHECK_INTERVAL # def extraYears
) # @extraYears=0 if !@extraYears
if toneNeedUpdate # return @extraYears
getToneInternal # end
@dayNightToneLastUpdate = Graphics.frame_count # end
end #
return @cachedTone # if UnrealTime::TIME_STOPS
end # class Scene_Map
end # alias :updateold :update
# def update
# Shedule a tone refresh on the next try (probably next frame) # $PokemonGlobal.addNewFrameCount
def sheduleToneRefresh # updateold
@dayNightToneLastUpdate = nil # end
end #
end # if UnrealTime::TALK_PASS
end # alias :miniupdateold :miniupdate
# def miniupdate
def pbGetTimeNow # $PokemonGlobal.addNewFrameCount
return Time.now if !$PokemonGlobal || !UnrealTime::ENABLED # miniupdateold
day_seconds = 60*60*24 # end
if UnrealTime::TIME_STOPS # end
# Sum the extra values to newFrameCount # end
if UnrealTime::EXTRA_SECONDS>0 #
UnrealTime.add_seconds(pbGet(UnrealTime::EXTRA_SECONDS)) # if UnrealTime::BATTLE_PASS
$game_variables[UnrealTime::EXTRA_SECONDS]=0 # class PokeBattle_Scene
end # alias :pbGraphicsUpdateold :pbGraphicsUpdate
if UnrealTime::EXTRA_DAYS>0 # def pbGraphicsUpdate
UnrealTime.add_seconds(day_seconds*pbGet(UnrealTime::EXTRA_DAYS)) # $PokemonGlobal.addNewFrameCount
$game_variables[UnrealTime::EXTRA_DAYS]=0 # pbGraphicsUpdateold
end # end
elsif UnrealTime::EXTRA_SECONDS>0 && UnrealTime::EXTRA_DAYS>0 # end
# Checks to regulate the max/min values at UnrealTime::EXTRA_SECONDS # end
while pbGet(UnrealTime::EXTRA_SECONDS)>=day_seconds # end
$game_variables[UnrealTime::EXTRA_SECONDS]-=day_seconds # end
$game_variables[UnrealTime::EXTRA_DAYS]+=1
end
while pbGet(UnrealTime::EXTRA_SECONDS)<=-day_seconds
$game_variables[UnrealTime::EXTRA_SECONDS]+=day_seconds
$game_variables[UnrealTime::EXTRA_DAYS]-=1
end
end
start_time=UnrealTime.initial_date
if UnrealTime::TIME_STOPS
time_played=$PokemonGlobal.newFrameCount
else
time_played=Graphics.frame_count
end
time_played=(time_played*UnrealTime::PROPORTION)/Graphics.frame_rate
time_jumped=0
if UnrealTime::EXTRA_SECONDS>-1
time_jumped+=pbGet(UnrealTime::EXTRA_SECONDS)
end
if UnrealTime::EXTRA_DAYS>-1
time_jumped+=pbGet(UnrealTime::EXTRA_DAYS)*day_seconds
end
time_ret = 0
# Before Essentials V19, there is a year limit. To prevent crashes due to this
# limit, every time that you reach in year 2036 the system will subtract 6
# years (to works with leap year) from your date and sum in
# $PokemonGlobal.extraYears. You can sum your actual year with this extraYears
# when displaying years.
loop do
time_fix=0
if $PokemonGlobal.extraYears!=0
time_fix = $PokemonGlobal.extraYears*day_seconds*(365*6+1)/6
end
time_ret=start_time+(time_played+time_jumped-time_fix)
break if !UnrealTime::NEED_32_BIT_FIX || time_ret.year<2036
$PokemonGlobal.extraYears+=6
end
return time_ret
end
if UnrealTime::ENABLED
class PokemonGlobalMetadata
attr_accessor :newFrameCount # Became float when using extra values
attr_accessor :extraYears
def addNewFrameCount
return if (UnrealTime::SWITCH_STOPS>0 &&
$game_switches[UnrealTime::SWITCH_STOPS])
self.newFrameCount+=1
end
def newFrameCount
@newFrameCount=0 if !@newFrameCount
return @newFrameCount
end
def extraYears
@extraYears=0 if !@extraYears
return @extraYears
end
end
if UnrealTime::TIME_STOPS
class Scene_Map
alias :updateold :update
def update
$PokemonGlobal.addNewFrameCount
updateold
end
if UnrealTime::TALK_PASS
alias :miniupdateold :miniupdate
def miniupdate
$PokemonGlobal.addNewFrameCount
miniupdateold
end
end
end
if UnrealTime::BATTLE_PASS
class PokeBattle_Scene
alias :pbGraphicsUpdateold :pbGraphicsUpdate
def pbGraphicsUpdate
$PokemonGlobal.addNewFrameCount
pbGraphicsUpdateold
end
end
end
end
end

Binary file not shown.