Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # * [ACE] Event Command Corrector
- #===============================================================================
- # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
- # * Version: 1.0
- # * Updated: 06/12/2016
- # * Requires: --------
- #-------------------------------------------------------------------------------
- # * < Change Log >
- #-------------------------------------------------------------------------------
- # * Version 1.0 (06/12/2016)
- # - Initial release.
- #-------------------------------------------------------------------------------
- # * < Description >
- #-------------------------------------------------------------------------------
- # * First thing first, this is NOT an eventing tool!
- # This script can NOT be used in published games, only in unencrypted
- # projects, and only for development corrections!
- # Now that this is out of the way...
- # * Ever got into a situation when you needed to change a face graphic,
- # switch ID, BGM name, or anthing else in tons of event commands?
- # If you have, you certainly know how time consuming and tedious can that be.
- # * This is a developer's tool to ease the amount of tediousness if you need
- # to adjust some very common event commands in case you changed your mind
- # about something or got new resources to implement, for example.
- # With this script you can modify any event commands in any events on any maps
- # you want based on your conditions with a single script call.
- # Your changes will be saved in your physical map files, so you won't need to
- # worry about them ever again after the change (unless you want to change
- # them again, of course).
- # * Map and event filters available in case you kinda know where are the event
- # commands you want to modify located or where they aren't.
- # * The console will show which event commands are changed with very precise
- # information (map ID, event ID, page number, command line, parameter index,
- # old and new values).
- # * Note that this can NOT re-structure your events, it can only modify
- # existing commands without deleting them or adding new ones. For example,
- # you can not remove a choice from a Show Choices command, but you can change
- # it's text.
- # * As a bonus, this script will fix a bug in the default Game_Interpreter
- # class. The "Shake Screen" event command reads the wrong parameters for the
- # wait flag and it's duration, so that part of the command is not functional
- # without a fix.
- #-------------------------------------------------------------------------------
- # * < Script Calls >
- #-------------------------------------------------------------------------------
- # * To modify your event commands, use this script call:
- #
- # EvEdit.modify(setting_key,reload_flag)
- #
- # The setting_key is a valid key you use in the script settings below.
- # Based on your settings, the event commands matching your criterias will be
- # changed according to your settings.
- #
- # The reload_flag can be used to reload the current map in the game if any
- # event on it has been modified.
- # Set it to true, and it will reload the map if needed.
- # Set it to false, and map will not be reloaded.
- # Even if you set this to false, if the current map has been modified and
- # the player leaves and re-enters the map, the changes made will be loaded.
- # The default value for this is false.
- #
- # NOTE:
- # After running this script call, if any changes has been made, you will have
- # to restart the opened project in order to see your changes in the editor!
- #
- # Examples:
- #
- # EvEdit.modify(:bgm_change1)
- # Will load the settings named :bgm_change1. The events modified and the new
- # values will be based on those settings.
- #
- # EvEdit.modify(:face2,true)
- # Will load the settings named :face2. The events modified and the new
- # values will be based on those settings.
- # The current map will be immediately reloaded if any changes were made to any
- # event on it.
- #-------------------------------------------------------------------------------
- # * < Installation >
- #-------------------------------------------------------------------------------
- # * Place this script between Materials and Main!
- #-------------------------------------------------------------------------------
- # * < Compatibility Info >
- #-------------------------------------------------------------------------------
- # * No known incompatibilities.
- #-------------------------------------------------------------------------------
- # * < Known Issues >
- #-------------------------------------------------------------------------------
- # * No known issues.
- #-------------------------------------------------------------------------------
- # * < Terms of Use >
- #-------------------------------------------------------------------------------
- # * Free to use for whatever purposes you want.
- # * Credit me (Sixth) in your game, pretty please! :P
- # * Posting modified versions of this script is allowed as long as you notice me
- # about it with a link to it!
- #===============================================================================
- $imported = {} if $imported.nil?
- $imported["SixthEvCorrector"] = true
- #===============================================================================
- # Settings:
- #===============================================================================
- module EvEdit
- #-----------------------------------------------------------------------------
- # Corrector Settings:
- #-----------------------------------------------------------------------------
- # This is where you set up the conditions and new values for the event
- # commands you want to change.
- #
- # Format:
- #
- # setting_key => {
- # :inc_maps => [map_id1, map_id2, ...],
- # :exc_maps => [map_id1, map_id2, ...],
- # :inc_evs => [ev_id1, ev_id2, ...],
- # :exc_evs => [ev_id1, ev_id2, ...],
- # :command => command_code,
- # :params => {
- # param_index => { :current => current_data, :new => new_data },
- # [param_indexes] => {:current => [current_data], :new => [new_data]},
- # ...
- # },
- # },
- #
- # Details:
- #
- # setting_key => {
- # This is the identifier for the setting.
- # You can use anything you want here, strings, symbols, integers, and so on.
- # This is the key you will use in your script calls to trigger the check and
- # modification of the specified event commands.
- #
- # :inc_maps => [map_id1, map_id2, ...],
- # This is the inclusive filter for maps.
- # If you want to check and modify the events on specific maps only, you can
- # use this setting to specify these maps.
- # If you use this setting, only the events on the maps included in the array
- # will be checked and modified, the rest of them will be skipped!
- # This setting is optional, you can omit it if you want.
- #
- # :exc_maps => [map_id1, map_id2, ...],
- # This is the exclusive filter for maps.
- # If you want to exclude some specific maps from the check, you can use this
- # setting to specify these maps.
- # If you use this setting, the events on the maps included in the array will
- # not be checked/modified at all.
- # This setting is optional, you can omit it if you want.
- #
- # :inc_evs => [ev_id1, ev_id2, ...],
- # This is the inclusive filter for events.
- # Works the same way as the inclusive map filter, but for events instead.
- # This setting is optional, you can omit it if you want.
- #
- # :exc_evs => [ev_id1, ev_id2, ...],
- # This is the exclusive filter for events.
- # Works the same way as the exclusive map filter, but for events instead.
- # This setting is optional, you can omit it if you want.
- #
- # :command => command_code,
- # This is the command code for the event command.
- # You must know the command code for the specific event command you want to
- # modify. That code is a 3-digit integer. You can get the correct command
- # codes from that very long documentation I made named
- # "Event Command Structure". You might as well get familiar with that
- # documentation, because you will use it a lot for this script.
- # There is a table of contents chapter there, and each event command's code
- # is shown there on the right side of each section name.
- #
- # :params => {
- # param_index => { :current => current_value, :new => new_value },
- # [param_indexes] => {:current => [current_values], :new => [new_values]},
- # ...
- # },
- # This is where you select which parameters of the event command you want to
- # change, as well as the current and new values of these parameters.
- # You may notice the difference between the two sample lines I made, and
- # there is a reason for that.
- # The first type will check for one parameter only, and will modify that
- # single parameter accordingly if the condition is met.
- # The second type will check for multiple parameters, and will modify those
- # parameters accordingly if the conditions are met.
- # The number of parameters and their value type vary for each event commands.
- # You can check the structure of them in my "Event Command Structure"
- # documentation.
- # You should only set the correct value type for a parameter or bad things
- # may happen! Very, very bad things! Almost evil! Or something... :P
- # If you use the multi type setting here, you must use an array of parameter
- # indexes for the key (the thing leftmost from the 1st => sign), and an array
- # of parameter values for the :current and :new settings.
- # The :current setting will be the condition check. If the specified
- # parameter's current value is the same as that setting, it will be changed to
- # the value you have set in the :new setting.
- # In the case of multi type setting, the values in the :current and :new
- # arrays must match with the parameter indexes used in the setting key!
- # I can't really explain this well, instead of that, check the sample
- # settings. I added notes for each of them explaining what they would do if
- # you would use them with the script call.
- #
- # NOTE 1:
- # In the case of parameters which use audio files (BGM, BGS, ME or SE
- # objects), you should use an array containing the audio file's name, volume
- # and pitch (in this order) instead of directly using an audio object.
- # This is because audio objects can not be compared with each other directly,
- # so I converted them to arrays before comparing them, and converted these
- # arrays into audio files before setting the new parameter.
- # You can set nil for the name, volume and/or pitch in the :current settings
- # if you want to skip the check on these audio properties.
- # You can do the same for the :new settings if you want to keep an audio
- # property from the current audio file.
- #
- # NOTE 2:
- # You can use Regexp to check for string parameters.
- # If you use Regexp for a :current setting, only the matching part from the
- # text will be replaced by the text you specify in the :new setting!
- # This is true for all parameters which use string for their value (note that
- # a parameter that uses an array of strings can NOT use this feature!).
- # If you use a regular string for the :current setting, the whole text will
- # be replaced with the one in your :new setting!
- #
- # NOTE 3:
- # Set Move Route commands are NOT supported at the moment!
- # I will try to find a way to change these too, but doing this is not a high
- # priority thing on my list right now.
- #
- # And that's it, in short.
- # Remember that if you run the script call, and if there were changes made to
- # any events, the changes will be saved immediately in your physical map files
- # found in the Data folder of your project (by default).
- # It might be a good idea to backup your map files before you try to change
- # anything, so if you managed to make an invalid setting, you can just restore
- # the files from your backups.
- #
- # Check the sample setting explanations to get some insight on how these
- # settings work.
- #-----------------------------------------------------------------------------
- Mods = {
- :msg_face1 => { # This will modify a face image used in Show Text commands.
- :inc_maps => [3], # Will only execute on events found on Map 3.
- #:exc_maps => [], # Excluded maps - not used.
- #:inc_evs => [], # Included events - not used.
- #:exc_evs => [], # Excluded events - not used.
- :command => 101, # This is the (1st) command code for Show Text commands.
- :params => { # Parameters to check and replace:
- # Parameter 0 for the Show Text commands stores the face graphic used.
- # The face graphic parameter's value must be a string, the image filename.
- # This setting will check for any Show Text commands which use the
- # "ActorPrison1" face graphic, and will replace those with the "Actor2"
- # graphic.
- # index => { current_data => new_data },
- 0 => { :current => "ActorPrison1", :new => "Actor2" },
- },
- },
- :msg_face2 => { # This will modify a face image and it's index used in Show Text commands.
- #:inc_maps => [], # Included maps - not used.
- :exc_maps => [1,2,4,8,10], # Will skip the included maps from the change.
- :inc_evs => [*6..45], # Will only make changes in the included events. (From Event 6 to 45 here.)
- #:exc_evs => [], # Excluded events - not used.
- :command => 101, # This is the (1st) command code for Show Text commands.
- :params => { # Parameters to check and replace:
- # Parameter 0 for the Show Text commands stores the face graphic used.
- # Parameter 1 for the Show Text commands stores the face index used.
- # The face graphic parameter's value must be a string, the image filename.
- # The face index parameter's value must be an integer, the spritesheet index.
- # This setting will check for any Show Text commands which use the
- # "Actor2" face graphic AND their face index is set to 0. Any matching
- # commands will get their face graphic changed to "ActorPrison1" AND
- # their face index will be set to 5 as well.
- # index => { current_data => new_data },
- [0,1] => { :current => ["Actor2",0], :new => ["ActorPrison1",5] },
- },
- },
- :choice1 => { # This will modify choice texts used in Show Choice commands.
- # No optional settings were used, all maps and all events will be checked.
- :command => 102, # This is the command code used for Show Choices commands.
- :params => { # Parameters to check and modify:
- # Parameter 0 for the Show Choices commands stores the choice texts in an array.
- # So, this parameter must be an array containing strings only.
- # This setting will search for any Show Choices commands which got the
- # included choice options, and will change the text used for them to the
- # specified choice texts.
- # Note that if your Show Choices command got 3 choices, you also must set
- # 3 choices in the :new setting! You can NOT enter more or less!
- 0 => {
- :current => ["Enhance","Bind","Cancel"],
- :new => ["Upgrade","Seal","Cancel"]
- },
- },
- },
- :battle_bgm1 => { # This will modify the BGM for Change Battle BGM command.
- # No optional settings were used, all maps and all events will be checked.
- :command => 132, # This is the command code for Change Battle BGM commands.
- :params => { # Parameters to check and modify:
- # Parameter 0 for the Change Battle BGM commands stores a BGM object.
- # However, these objects can't be compared with each other directly, so
- # instead of using a real BGM object, you should use an array with the
- # BGM's name, volume and pitch (in this order).
- # This setting will search for any Change Battle BGM commands which got
- # the specified BGM from the :current setting, and will set their BGM to
- # the specified one in the :new setting.
- 0 => {
- # Checks for: RPG::BGM.new("Battle4",any_volume,any_pitch),
- :current => ["Battle4",nil,nil],
- # Sets matches to: RPG::BGM.new("EpicBattleTheme12",old_volume,old_pitch)
- :new => ["EpicBattleTheme12",nil,nil]
- },
- },
- },
- :msg_text1 => { # This will modify the text of the Show Text commands.
- :command => 401, # This is the command code for Show Text (text data) commands.
- :params => { # Parameters to check and modify:
- # Parameter 0 for this command is a string.
- # As such, we can use a Regexp to search for specific words or phrases,
- # and replace only those in these strings.
- # Regexp looks like a string, but instead of double quotes, you put the
- # text between / signs.
- # In this example, any "Forest of Pain" text (case insensitive because of
- # the "i" used at the end of the Regexp) will get replaced by the
- # "Towwer of Struggle" text.
- # Note that if you got a lot of Show Text commands (and you most probably
- # have), it can take a while to finish the check and modification!
- 0 => {:current => /Forest of Pain/i, :new => "Tower of Struggle"},
- },
- }
- # <-- Add more settings here!
- }
- #===============================================================================
- # End of Settings! Editing anything below may lead to... you know it, right?
- #===============================================================================
- def self.modify(data,reload=false)
- return unless $TEST
- changed = false
- inc_maps = Mods[data][:inc_maps]
- exc_maps = Mods[data][:exc_maps]
- inc_evs = Mods[data][:inc_evs]
- exc_evs = Mods[data][:exc_evs]
- mcmd = Mods[data][:command]
- mparams = Mods[data][:params]
- display_cmd(mcmd)
- files = Dir.glob('Data/Map*.rvdata2')
- files.each do |file|
- next if file.include?("Infos")
- if file =~ /Map(\d+).rvdata2/i
- changed = false # Determines if something has been changed on the map or not
- mid = $1.to_i
- next if inc_maps && !inc_maps.include?(mid) # Included maps check
- next if exc_maps && exc_maps.include?(mid) # Excluded maps check
- map = load_data(file)
- map.events.each do |eid,ev|
- next if inc_evs && !inc_evs.include?(eid) # Included events check
- next if exc_evs && exc_evs.include?(eid) # Excluded events check
- ev.pages.each_with_index do |page,pnum|
- page.list.each_with_index do |command,cnum|
- next if command.code != mcmd # Command code check
- cprms = command.parameters
- mparams.each do |pid,data|
- # For multi-conditions
- if pid.is_a?(Array)
- # Change only if there is a match
- if pid.all? {|piid| check_equal(cprms[piid],data[:current][piid]) }
- pid.each do |piid|
- # Change only if the param is not the same
- next if check_equal(cprms[piid],data[:new][piid])
- case cprms[piid]
- when RPG::AudioFile # Separate method for audio files!
- old = cprms[piid].to_ary
- new = []
- old.each_with_index do |prop,i|
- new[i] = data[:new][piid][i] || prop
- end
- audio = convert_audio(cprms[piid],new)
- display_data(mid,eid,pnum,cnum,piid,old,new)
- cprms[piid] = audio
- else
- if cprms[piid].is_a?(String) && data[:current][piid].is_a?(Regexp)
- new = cprms[piid].gsub(data[:current][piid],data[:new][piid])
- display_data(mid,eid,pnum,cnum,piid,cprms[piid],new)
- cprms[piid] = new
- else
- display_data(mid,eid,pnum,cnum,piid,cprms[piid],data[:new][piid])
- cprms[piid] = data[:new][piid]
- end
- end # Audio check end
- changed = true
- end # Param index iter end
- end # Param condition check end
- else
- # Change only if there is a match which is not the same
- if check_equal(cprms[pid],data[:current]) && !check_equal(cprms[pid],data[:new])
- case cprms[pid]
- when RPG::AudioFile # Separate method for audio files!
- old = cprms[pid].to_ary
- new = []
- old.each_with_index do |prop,i|
- new[i] = data[:new][i] || prop
- end
- audio = convert_audio(cprms[pid],new)
- display_data(mid,eid,pnum,cnum,pid,old,new)
- cprms[pid] = audio
- else
- if cprms[pid].is_a?(String) && data[:current].is_a?(Regexp)
- new = cprms[pid].gsub(data[:current],data[:new])
- display_data(mid,eid,pnum,cnum,pid,cprms[pid],new)
- cprms[pid] = new
- else
- display_data(mid,eid,pnum,cnum,pid,cprms[pid],data[:new])
- cprms[pid] = data[:new]
- end
- end # Audio check end
- changed = true
- end # Param condition check end
- end # Array check end
- end # Param iter end
- end # page line iter close
- end # event page iter close
- end # event iter close
- if changed # Save only if there were changes made
- save_data(map, sprintf("Data/Map%03d.rvdata2", mid))
- # Reload map if requested and if it is the current map
- if reload && $game_map && $game_map.map_id == mid
- old_pos = [$game_map.display_x,$game_map.display_y]
- $game_map.setup(mid)
- $game_map.set_display_pos(*old_pos)
- end
- end
- end # file name check close
- end # file iter close
- end
- def self.check_equal(current,check)
- case current
- when RPG::AudioFile # Separate method for audio files!
- old = current.to_ary
- check.each_with_index do |prop,i|
- return false if prop && prop != old[i]
- end
- return true
- when RPG::MoveRoute # Set Move Route commands are not supported yet!
- return false
- else
- if current.is_a?(String) && check.is_a?(Regexp)
- return current =~ check
- else
- return current == check
- end
- end
- end
- def self.convert_audio(old,ary)
- case old
- when RPG::BGM; return RPG::BGM.new(*ary)
- when RPG::BGS; return RPG::BGS.new(*ary)
- when RPG::SE; return RPG::SE.new(*ary)
- when RPG::ME; return RPG::ME.new(*ary)
- end
- end
- def self.display_cmd(code)
- cname = cmd_name(code)
- txt = "--> Looking up '#{cname}' commands..."
- puts txt
- end
- def self.display_data(mid,eid,pgid,cmindex,pid,oprm,nprm)
- mtxt = sprintf("Map: %03d, ", mid)
- etxt = sprintf("Ev: %03d, ", eid)
- pgtxt = sprintf("Page: %03d, ", pgid)
- itxt = sprintf("Line: %03d, ", cmindex)
- ptxt = "Param #{pid}: #{oprm} → #{nprm}"
- txt = mtxt + etxt + pgtxt + itxt + ptxt
- puts txt
- end
- def self.cmd_name(code)
- case code
- when 101; return "Show Text"
- when 401; return "Show Text - Message Text Data"
- when 102; return "Show Choices"
- when 402; return "Show Choices - Choice Branches"
- when 403; return "Show Choices - Cancel Branch"
- when 103; return "Input Number"
- when 104; return "Select Key Item"
- when 105; return "Show Scrolling Text"
- when 405; return "Show Scrolling Text - Message Text Data"
- when 108; return "Comment"
- when 408; return "Comment - Continual"
- when 111; return "Conditional Branch"
- when 411; return "Conditional Branch - Else Branch"
- when 112; return "Loop"
- when 413; return "Repeat Above"
- when 113; return "Break Loop"
- when 115; return "Exit Event Processing"
- when 117; return "Common Event"
- when 118; return "Label"
- when 119; return "Jump to Label"
- when 121; return "Control Switches"
- when 122; return "Control Variables"
- when 123; return "Control Self-Switches"
- when 124; return "Control Timer"
- when 125; return "Change Gold"
- when 126; return "Change Items"
- when 127; return "Change Weapons"
- when 128; return "Change Armors"
- when 129; return "Change Party Member"
- when 132; return "Change Battle BGM"
- when 133; return "Change Battle End ME"
- when 134; return "Change Save Access"
- when 135; return "Change Menu Access"
- when 136; return "Change Encounter Disable"
- when 137; return "Change Formation Access"
- when 138; return "Change Window Color"
- when 201; return "Transfer Player"
- when 202; return "Set Vehicle Location"
- when 203; return "Set Event Location"
- when 204; return "Scroll Map"
- when 205; return "Set Mouve Route"
- when 206; return "Get ON/OFF Vehicle"
- when 211; return "Change Transparency"
- when 212; return "Show Animation"
- when 213; return "Show Balloon"
- when 214; return "Erase Event"
- when 216; return "Change Player Followers"
- when 217; return "Gather Followers"
- when 221; return "Fadeout Screen"
- when 222; return "Fadein Screen"
- when 223; return "Tint Screen"
- when 224; return "Flash Screen"
- when 225; return "Shake Screen"
- when 230; return "Wait"
- when 231; return "Show Picture"
- when 232; return "Move Picture"
- when 233; return "Rotate Picture"
- when 234; return "Tint Picture"
- when 235; return "Erase Picture"
- when 236; return "Set Weather"
- when 241; return "Play BGM"
- when 242; return "Fadeout BGM"
- when 243; return "Save BGM"
- when 244; return "Resume BGM"
- when 245; return "Play BGS"
- when 246; return "Fadeout BGS"
- when 249; return "Play ME"
- when 250; return "Play SE"
- when 251; return "Stop SE"
- when 261; return "Play Movie"
- when 281; return "Change Map Name Display"
- when 282; return "Change Tileset"
- when 283; return "Change Battleback"
- when 284; return "Change Parallax Background"
- when 285; return "Get Location Info"
- when 301; return "Battle Processing"
- when 601; return "Battle Processing - Win Branch"
- when 602; return "Battle Processing - Escape Branch"
- when 603; return "Battle Processing - Lose Branch"
- when 302; return "Shop Processing"
- when 605; return "Shop Processing - Rest of the Items"
- when 303; return "Name Input Processing"
- when 311; return "Change HP"
- when 312; return "Change MP"
- when 313; return "Change State"
- when 314; return "Recover All"
- when 315; return "Change EXP"
- when 316; return "Change Level"
- when 317; return "Change Parameters"
- when 318; return "Change Skills"
- when 319; return "Change Equipment"
- when 320; return "Change Name"
- when 321; return "Change Class"
- when 322; return "Change Actor Graphic"
- when 323; return "Change Vehicle Graphic"
- when 324; return "Change Nickname"
- when 331; return "Change Enemy HP"
- when 332; return "Change Enemy MP"
- when 333; return "Change Enemy State"
- when 334; return "Enemy Recover All"
- when 335; return "Enemy Appear"
- when 336; return "Enemy Transform"
- when 337; return "Show Battle Animation"
- when 339; return "Force Action"
- when 340; return "Abort Battle"
- when 351; return "Open Menu Screen"
- when 352; return "Open Save Screen"
- when 353; return "Game Over"
- when 354; return "Return to Title Screen"
- when 355; return "Script"
- when 655; return "Script - Continued"
- else; return "Wrong Command Code!" # This should never come up anyway...
- end
- end
- end
- class RPG::AudioFile
- def to_ary
- return [@name,@volume,@pitch]
- end
- end
- class Game_Map
- attr_accessor :display_x, :display_y
- end
- class Game_Interpreter
- def command_225 # Fixes the Screen Shake event command bug
- screen.start_shake(@params[0], @params[1], @params[2])
- wait(@params[2]) if @params[3] # Bug here by default, wrong params used!
- end
- end
- #==============================================================================
- # !!END OF SCRIPT - OHH, NOES!!
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement