Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ################################################################################
- # TARRIS HOLD ANTILAG
- # By: Ixfuru
- # For: Tarris Hold; By: neosky
- ################################################################################
- module IxTh
- module AntiLag
- #===========================================================================
- # THE ISSUES
- #===========================================================================
- # The lag in Tarris Hold is coming from several things. First of all, there
- # are maps with over 60 events. Whenever that occurs, there are more
- # events to update than there are frames per second, and it causes lag.
- # In 'Section 1' below I tackle that issue.
- #
- # Secondly, there is lag because the 'update' method of Scene_Map is just
- # having to do too much. Also, there are some extraordinarily long checks
- # being made that don't really need to be checked all the time. I tackled
- # this issue by consolidating the scripts that were using Scene_Map's update
- # method, or were creating instances that slowed things down. For instance,
- # I found three different call_shop methods, so I turned them all into
- # one method. Another example is the dart throwing and the overlay map
- # scripts, they both had their own Scene_Map update method, so I created
- # a single Scene_Map update method and put what was required of both into one.
- # This should speed the code up a bit, because it won't have to alias
- # all those methods and recheck things it already did the first time through.
- #
- # Lastly, and probably most importantly, there is a tremendous amount of lag
- # coming from the ever-present images that are having to be drawn on to the
- # screen every frame. This is being done with a heavy amount of common events
- # that are set to run via parallel processing. This is still an issue, even
- # after I implemented my work in Section 2.
- #=============================================================================
- #===========================================================================
- # SECTION 1
- #
- # Stifling Events from Updating
- #===========================================================================
- #
- # There are effectively two ways to keep an event from updating using this
- # script. I had to do it this way because there was so much already created.
- # And I wanted to give you a way to go through and fix some of the maps
- # without having to redo all the events on each map.
- #
- # The First Way:
- #
- # In the hash below, called 'MAP_NO_UPDATE_EVENTS', you can make a reference
- # to any map in the project and then link it to all the IDs of the events you
- # don't want to update. This way will be the fastest way to take care of
- # already-existing maps. Here's an entry example:
- #
- # 14 => [65, 68, 73, 90],
- #
- # In the above example, on map number 14, the system would not update events
- # numbered 65, 68, 73, and 90.
- #
- #---------------------------------------------------------------------------
- #
- # The Second Way:
- #
- # The second way requires you to go into the event, and add the following
- # tag in each one that you don't want to update:
- #
- # <X>
- #
- # That's pretty much all you have to do. If the system finds <X> in the name
- # of the event, it will not update it.
- #===========================================================================
- MAP_NO_UPDATE_EVENTS = {
- # mapID => [eventIDs]
- }
- #===========================================================================
- # SECTION 3.
- #
- # Parallel Lag from Common Events
- #===========================================================================
- #
- # In order to fix the heavy lag being caused by parallel operating common
- # events, I tried to make a system that linked each common event to a counter.
- # The counter would count each frame, but would not update until it reached
- # the value it was supposed to. Those values are stored in the hash below
- # called 'PARALLEL COMMON_EVENT_COUNTERS'. In the hash, you reference the
- # common event by ID as the key, and then you link it to the amount of
- # frames that should be allowed to pass prior to calling for that specific
- # event's update method. Take a look at this example hash entry:
- #
- # 71 => 45,
- #
- # In the example above, the number 71 common event would only update every
- # 45 frames. Keep in mind that there are 60 frames per second, so this is still
- # updating in less than a second each time.
- #
- #****************************************************************************
- # NOTE
- #****************************************************************************
- # Neo, I tried to set them up the best I could. You can see that I set the
- # clock HUD to only update every second. Also, the 'lures' event seemed
- # like it wasn't something that was required every second of the game, because
- # it is only accessed when someone goes fishing, so I backed off the update
- # time on that. I didn't playtest enough after implementing this to see if it
- # made a real difference, but try it out, adjust the numbers, and let me
- # know what you think.
- #
- # Ixfuru
- #
- #****************************************************************************
- #=============================================================================
- PARALLEL_COMMON_EVENT_COUNTERS = {
- # common_eventID => frames_between_updates
- # LANTERN EVENT
- 1 => 3,
- # LURES EVENT
- 10 => 90,
- # MINI-MAP
- 12 => 5,
- # HUD GAUGE
- 17 => 7,
- # HUD GAUGE TIME
- 18 => 60,
- # HUD GAUGE GEMS
- 19 => 2,
- # HUD G EVENTS
- 42 => 12,
- }
- end
- end
- #===============================================================================
- # GAME MAP
- #===============================================================================
- class Game_Map
- NO_UPDATE_MARK = "<X>"
- #-----------------------------------------------------------------------------
- # Initialize * Aliased *
- #-----------------------------------------------------------------------------
- alias thal_gmmp_ini initialize unless $@
- def initialize
- thal_gmmp_ini
- @parallel_ce_counters = {}
- end
- #--------------------------------------------------------------------------
- # * Update Events
- #--------------------------------------------------------------------------
- def update_events
- #~ p "UPDATING EVENTS"
- ale = antilag_events
- if ale.has_key?(@map_id)
- for event in @events.values
- next if event.name.include?(NO_UPDATE_MARK)
- next if ale[@map_id].include?(event.id)
- event.update
- end
- else
- for event in @events.values
- next if event.name.include?(NO_UPDATE_MARK)
- event.update
- end
- end
- @parallel_ce_counters = {} if @parallel_ce_counters.nil?
- for common_event in @common_events.values
- next if common_event.nil?
- ceid = common_event.id
- pcec = parallel_common_event_counters
- if pcec.include?(common_event.id)
- if @parallel_ce_counters.include?(common_event.id)
- @parallel_ce_counters[common_event.id] += 1
- if @parallel_ce_counters[common_event.id] > pcec[common_event.id]
- common_event.update
- @parallel_ce_counters[common_event.id] = 0
- end
- else
- @parallel_ce_counters[common_event.id] = 0
- end
- else
- common_event.update
- end
- end
- end
- #------------------------------------------------------------------------------
- # Parallel Common Event Counters
- #----------------------------------------------------------------------------
- def parallel_common_event_counters
- return IxTh::AntiLag::PARALLEL_COMMON_EVENT_COUNTERS
- end
- #----------------------------------------------------------------------------
- # Antilag Events
- #----------------------------------------------------------------------------
- def antilag_events
- return IxTh::AntiLag::MAP_NO_UPDATE_EVENTS
- end
- end
- #===============================================================================
- # SPRITESET VARPIC
- #===============================================================================
- class Spriteset_VarPic
- #-----------------------------------------------------------------------------
- # Update
- #-----------------------------------------------------------------------------
- alias thal_ssvp_upd update unless $@
- def update
- return if @sprites.empty?
- thal_ssvp_upd
- end
- end
- #===============================================================================
- # SCENE MAP
- #===============================================================================
- class Scene_Map < Scene_Base
- #-----------------------------------------------------------------------------
- # Update
- #-----------------------------------------------------------------------------
- def update
- super
- $game_map.interpreter.update
- $game_map.update
- $game_player.update
- $game_system.update
- @spriteset.update
- @message_window.update
- update_dart_trigger
- if $game_temp.transition_processing
- process_transition
- end
- $OverlayMap.update
- unless $game_message.visible
- update_transfer_player
- update_encounter
- update_call_menu
- update_call_debug
- update_scene_change
- end
- end
- #-----------------------------------------------------------------------------
- # Call Shop
- #-----------------------------------------------------------------------------
- def call_shop
- $game_temp.next_scene = nil
- if $game_switches[YE::SYNTH::SYNTH_SWITCH]
- $game_switches[YE::SYNTH::SYNTH_SWITCH] = false
- $scene = Scene_Synthesis.new
- elsif meet_ceshop_conditions
- $scene = Scene_Common_Event_Shop.new
- else
- $scene = Scene_Shop.new
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment