#---------------------------------------------------------------------------- # StorymasterQ's MaxHP/MaxMP Offsetting Equipment Script (Skew's MMOES) # Version 1.3 # Released 29 April 2008 #---------------------------------------------------------------------------- # This script adds the ability for weapons and armors to increase or decrease # the maximum HP or MP of the wearer by a certain amount or percentage #---------------------------------------------------------------------------- # Usage: # In the chosen weapon/armor's Note Field, add a tag like this: # # | | | | # | | | > ! for set amount, % for percentage # | | > Offset amount. Can be any number, but see notes below # | > + to increase, - to decrease # > MaxHP to offset MaxHP, MaxMP to offset MaxMP # Remember, the tag must be on its own line (nothing before or after) # You can use any number, but MaxHP/MaxHP upper limit is always 9999, while the # lower limit is 1 for MaxHP and 0 for MaxMP. Also, remember that if you set an # equipment that increases your MaxHP/MaxMP (or unequipping one that decreases # it), your current HP or MP will not be affected by the change. #---------------------------------------------------------------------------- # Compatibility # - Will run smoothly with Multi-Slot Equipment (v1.2) # - Will run smoothly at a glance with KGC's Equipment Extension (v1.3) # - Will need slight tinkering when used with anything that involves the equip # menu. # Compatibility Notes # - To ensure compatibility, put MMOES under the scripts mentioned above in the # Materials list. #---------------------------------------------------------------------------- # Version History # v1.0 - 15 April 2008 # Initial Release # v1.1 - 17 April 2008 # Fixed problem with equipment not resetting their offset when unequipped # !Forced to remove Percentage functionality temporarily # v1.2 - 23 April 2008 # Fixed all problems with Percentage Offset # v1.3 - 29 April 2008 # Streamlined the code using a different technique to test equipped items # Adds rudimentary support for KGC's Equipment Extension, may still be buggy #---------------------------------------------------------------------------- # Known Issues # - Offsetting the same thing with different types won't work. For example, # offsetting MaxHP with +15% and then another +100! will ignore the 15% and # use only the +100! #---------------------------------------------------------------------------- # Future Work # - Find a way to resolve known issues (if the community demands it) # - Extend the percentage functionality to other parameters (unlikely) # - Find a way to become less procrastinating (extremely unlikely) #---------------------------------------------------------------------------- class Game_Battler attr_accessor :skew_moes_hp_offset attr_accessor :skew_moes_mp_offset #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- alias skew_moes_initialize initialize def initialize skew_moes_initialize @skew_moes_hp_offset = Array.new(5, 0) @skew_moes_mp_offset = Array.new(5, 0) end #-------------------------------------------------------------------------- # * Get Maximum HP #-------------------------------------------------------------------------- def maxhp(withOffset = true) offset = 0 offset = sumArray(@skew_moes_hp_offset) if withOffset maxhp = [[base_maxhp + @maxhp_plus + offset, 1].max, maxhp_limit].min return maxhp end #-------------------------------------------------------------------------- # * Get Maximum MP #-------------------------------------------------------------------------- def maxmp(withOffset = true) offset = 0 offset = sumArray(@skew_moes_mp_offset) if withOffset maxmp = [[base_maxmp + @maxmp_plus + offset, 0].max, 9999].min return maxmp end #-------------------------------------------------------------------------- # * An extra function to sum the integer contents of an array #-------------------------------------------------------------------------- def sumArray(ar) result = 0 ar.each { |item| begin result += item.to_i rescue result += 0 end } if !ar.nil? return result end end class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Change Equipment (designate object) # equip_type : Equip region (0..4) # item : Weapon or armor (nil is used to unequip) # test : Test flag (for battle test or temporary equipment) #-------------------------------------------------------------------------- alias skew_moes_change_equip change_equip def change_equip(equip_type, item, test = false) last_item = equips[equip_type] skew_moes_change_equip(equip_type, item, test) determine_tag_offset(equip_type, item, last_item, test) end #-------------------------------------------------------------------------- # * Determine Tag Offset # item : Weapon or armor (nil is used to unequip) # last_item : Previous Weapon or armor #-------------------------------------------------------------------------- def determine_tag_offset(equip_type, item, last_item = nil, test = false) unless last_item.nil? # Unequipping previous weapon/armor updateBase(equip_type, last_item, test, true) end updateBase(equip_type, item, test) end #-------------------------------------------------------------------------- # * Update Base # Integrates the offsetting code into one function #-------------------------------------------------------------------------- def updateBase(equip_type, item, test, unequip = false) item.note.split(/[\r\n]+/).each { |line| if line =~ %r{^\s*<((?:maxhp|maxmp))\s*([+-])(\d+)([!%])>\s*$}i target = $1.downcase # maxhp/maxmp, doesn't care about case isAdd = ($2 == "+") # + or - value = $3.to_i # Offset amount isAbs = ($4 == "!") # Absolute or percentage base = self.maxhp(false) base = self.maxmp(false) if target == "maxmp" offset = value offset *= -1 if !isAdd absoluteOffset = offset absoluteOffset = 0 if unequip percentOffset = offset percentOffset *= -1 if unequip percentOffset = (base * (100 + percentOffset) / 100) - base percentOffset = 0 if unequip if target == "maxhp" offset = self.skew_moes_hp_offset offset[equip_type] = absoluteOffset if isAbs offset[equip_type] = percentOffset if !isAbs self.skew_moes_hp_offset = offset else offset = self.skew_moes_mp_offset offset[equip_type] = absoluteOffset if isAbs offset[equip_type] = percentOffset if !isAbs self.skew_moes_mp_offset = offset end end } unless item.nil? end end # endClass class Scene_Equip < Scene_Base #-------------------------------------------------------------------------- # * Update Status Window #-------------------------------------------------------------------------- def update_status_window if @equip_window.active @status_window.set_new_parameters(nil, nil, nil, nil, nil, nil) elsif @item_window.active temp_actor = Marshal.load(Marshal.dump(@actor)) temp_actor.change_equip(@equip_window.index, @item_window.item, true) new_atk = temp_actor.atk new_def = temp_actor.def new_spi = temp_actor.spi new_agi = temp_actor.agi new_hp = temp_actor.maxhp new_mp = temp_actor.maxmp @status_window.set_new_parameters(new_atk, new_def, new_spi, new_agi, new_hp, new_mp) end @status_window.update end #-------------------------------------------------------------------------- # * Create Item Window #-------------------------------------------------------------------------- def create_item_windows @item_windows = [] for i in 0...EQUIP_TYPE_MAX @item_windows[i] = Window_EquipItem.new(0, 256, 544, 160, @actor, i) @item_windows[i].help_window = @help_window @item_windows[i].visible = (@equip_index == i) @item_windows[i].y = 256 @item_windows[i].height = 160 @item_windows[i].active = false @item_windows[i].index = -1 end end #-------------------------------------------------------------------------- # * Update Equip Region Selection #-------------------------------------------------------------------------- alias skew_moes_update_equip_selection update_equip_selection def update_equip_selection skew_moes_update_equip_selection end end class Window_Equip < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization # x : window X coordinate # y : window Y corrdinate # actor : actor #-------------------------------------------------------------------------- def initialize(x, y, actor) super(x, y, 336, WLH * 7 + 32) # Edited to 7 lines @actor = actor refresh self.index = 0 end end class Window_EquipStatus < Window_Base #-------------------------------------------------------------------------- # * Object Initialization # x : window X coordinate # y : window Y corrdinate # actor : actor #-------------------------------------------------------------------------- def initialize(x, y, actor) super(x, y, 208, WLH * 7 + 32) # Edited to 7 lines @actor = actor refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear draw_actor_name(@actor, 4, 0) draw_parameter(0, WLH * 1, 4) draw_parameter(0, WLH * 2, 5) draw_parameter(0, WLH * 3, 0) draw_parameter(0, WLH * 4, 1) draw_parameter(0, WLH * 5, 2) draw_parameter(0, WLH * 6, 3) if $imported["EquipExtension"] # Using KGC's EquipExtension Script # Show EP if using EP System draw_actor_ep(@actor, 120, 0, 56) if KGC::EquipExtension::USE_EP_SYSTEM end end #-------------------------------------------------------------------------- # * Set Parameters After Equipping # new_atk : attack after equipping # new_def : defense after equipping # new_spi : spirit after equipping # new_agi : agility after equipping # new_hp : hp after equipping # new_mp : mp after equipping #-------------------------------------------------------------------------- def set_new_parameters(new_atk, new_def, new_spi, new_agi, new_hp, new_mp) if @new_atk != new_atk or @new_def != new_def or @new_spi != new_spi or @new_agi != new_agi or @new_hp != new_hp or @new_mp != new_mp @new_atk = new_atk @new_def = new_def @new_spi = new_spi @new_agi = new_agi @new_hp = new_hp @new_mp = new_mp refresh end end #-------------------------------------------------------------------------- # * Draw Parameters # x : draw spot x-coordinate # y : draw spot y-coordinate # type : type of parameter (0 - 5) #-------------------------------------------------------------------------- def draw_parameter(x, y, type) case type when 0 name = Vocab::atk value = @actor.atk new_value = @new_atk # @temp_actor.atk # @new_atk when 1 name = Vocab::def value = @actor.def new_value = @new_def # @temp_actor.def # @new_def when 2 name = Vocab::spi value = @actor.spi new_value = @new_spi # @temp_actor.spi # @new_spi when 3 name = Vocab::agi value = @actor.agi new_value = @new_agi # @temp_actor.agi # @new_agi when 4 name = Vocab::hp value = @actor.maxhp new_value = @new_hp # @temp_actor.maxhp # @new_hp when 5 name = Vocab::mp value = @actor.maxmp new_value = @new_mp # @temp_actor.maxmp # @new_mp end self.contents.font.color = system_color self.contents.draw_text(x + 4, y, 80, WLH, name) self.contents.font.color = normal_color self.contents.draw_text(x + 75, y, 40, WLH, value, 2) self.contents.font.color = system_color self.contents.draw_text(x + 115, y, 20, WLH, ">", 1) if new_value != nil self.contents.font.color = new_parameter_color(value, new_value) self.contents.draw_text(x + 135, y, 40, WLH, new_value, 2) end end end $skew = {} if $skew == nil $skew["MMOES"] = true