Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #======================#
- # Z-Systems by: Zetu #
- #===========================#======================#===========================#
- # * * * Alternate MP X v1.10 * * * #
- #------------------------------------------------------------------------------#
- # Will Overwrite Draw Functions for MP. #
- #------------------------------------------------------------------------------#
- # Known Compatable Battle Systems: #
- # • Tankentai #
- #------------------------------------------------------------------------------#
- # Version History #
- # 1.01 ALPHA #
- # 1.02 #
- # * Added Customization (allowing you to easly create your own resources #
- # without programming knowledge.) #
- # * Added Changes to Resource color (for draw_actor_mp). #
- # 1.03 #
- # * Corrected on damage Percent algorithum. #
- # 1.04 #
- # * Updated to define resource by Class (not individual Actor) #
- # 1.05-1.06 #
- # * Using module instead of global variables. #
- # * Now allowing floats for further customization. #
- # * Since floats are now allowed, no longer a constant divider on base #
- # values. #
- # * Corrected end_turn, since Tankentai uses end_turn(actor). #
- # * Allowing case insensitivity in DEF. #
- # 1.07-1.09 #
- # * Fixed Refresh (or lack of) glitch (so that the proper values are #
- # displayed.) #
- # * Fixed healing items and added notetags. #
- # * Fixed degen when healed. #
- # * Fixed regen when dead. #
- # * Fixed display on MP damage/Healing (to show custom resource) #
- # 1.10 #
- # * OVERHAUL #
- # * Multi Resource Types #
- #=#==========================================================================#=#
- # DEF[type] = [0, 1, 2, ..., 8] #
- # 0 = Defines amount of resource out of battle. #
- # 0 = Default (Keep same amount) #
- # 1 = Set to 0 #
- # 2 = Set to Full #
- # 1 = Defines base resource Regeneration (Float allowed) #
- # 2 = Regen Type #
- # "Normal" = Multiply base equal to damage * Recomended for max 100 * #
- # "Atk"/"Def"/"HP"/"MaxHP"/"MP"/"MaxMP"/"Agi"/"Spi" = Multiply equal to #
- # respective user's stat. #
- # 3 = On Damage change to resource (Multiplier / float allowed) #
- # 4 = On Damage change to resource (Type) #
- # "Normal" = Gain [3]*Damage MP. #
- # "Percent" = Gain [3]*(Ratio of damage to MaxMP) as percent to MP #
- # 5 = Max Resource Value #
- # 0 = Default (Defined by Database, increases with level) #
- # 1 = 100 #
- #--------------------------------------------------------------------------#
- # SPEC[type] #
- # 0 = Vocab of Resource #
- # 1 = Letter to abbreviate Resource #
- # 2 and 3 = System Color to define resource bar color (as gradient) #
- # 4 = System Color to define text for particular resource.
- #--------------------------------------------------------------------------#
- # For mp recovery items, use <regen: TYPE> to force the item to only #
- # regenerate that particular mp resource. #
- #==========================================================================#
- module Z
- module AMPX
- DEF = {#
- :mana => [0, 0.05, "MaxMP", 0, "Normal", 0, "M", 22, 23],
- :rage => [1, 0, "Normal", 2, "Percent", 1, "R", 10, 2],
- :energy => [2, 20, "Normal", 0, "Normal", 1, "E", 14, 6],
- :focus => [2, 30, "Normal", -1.5, "Percent", 1, "F", 11, 3]}
- SPEC = {
- :mana => ["Mana", "M", 22, 23, 22],
- :rage => ["Rage", "R", 10, 2, 10],
- :energy => ["Energy", "E", 14, 6, 14],
- :focus => ["Focus", "F", 11, 3, 11]}
- # Customize Char Res types by Class ID
- CLASS = {#It is recommended to have 2 at MOST!
- 2 => [:mana, :rage],
- 3 => [:energy],
- 4 => [:energy, :focus]
- } # DO NOT REMOVE! (If class is not defined, will return [DEF_RES]
- DEF_RES = :mana
- RECOLOR_SINGLE = true # If false, actors with only one resource will not
- # recolor MP cost to match the resource type.
- #==========================================================================#
- # In Skill Notes #
- # <ampx: *> => Skill uses * resource (refer to SPEC[resource][0]) #
- # <regen: *> => MP healing is done to * resource. (Also works in Item) #
- #=#======#======================#====#================================#======#=#
- #--------# #----# DO NOT EDIT PAST THIS POINT!!! #--------#
- #--------# End of Customization #----# Editing will cause death by #--------#
- #--------# #----# brain asplosions. #--------#
- #========#======================#====#================================#========#
- def self.symbol(type)
- for resource in Z::resources
- return resource if SPEC[resource][0].upcase == type[0].upcase
- end
- return DEF_RES
- end
- end
- def self.resources
- return AMPX::DEF.keys
- end
- end
- $zsys = {} if $zsys.nil?
- $zsys["AltRes"] = true
- class RPG::Skill
- def resource(default = Z::AMPX::DEF_RES)
- self.note.scan(/<ampx[:][ ](.*)>/i){|type| return Z::AMPX::symbol(type)}
- return default
- end
- end
- class Game_Actor < Game_Battler
- alias ampx_setup setup
- def setup(actor_id)
- ampx_setup(actor_id)
- @ampx = {}
- for resource in self.resources
- @ampx[resource] = Game_Resources.new(resource, self)
- end
- end
- def resources
- result = Z::AMPX::CLASS[self.class_id]
- return result.nil? ? [Z::AMPX::DEF_RES] : result
- end
- def ampx(resource = Z::AMPX::DEF_RES)
- return 0 if @ampx[resource].nil?
- return @ampx[resource].value
- end
- def set_ampx(value, resource = Z::AMPX::DEF_RES)
- return if @ampx[resource].nil?
- @ampx[resource].value = value
- end
- def var_ampx(value, resource = Z::AMPX::DEF_RES)
- return if @ampx[resource].nil?
- @ampx[resource].value += value
- end
- def maxampx(resource = Z::AMPX::DEF_RES)
- case Z::AMPX::DEF[resource][5]
- when 0
- return maxmp
- when 1
- return 100
- end
- end
- def ampx_on_hit(damage)
- return unless damage > 0
- for resource in self.resources
- base = Z::AMPX::DEF[resource][3]
- case Z::AMPX::DEF[resource][4].upcase
- when "PERCENT"
- ratio = (100*damage)/self.maxhp
- self.var_ampx((100 * (ratio * base) / self.maxampx(resource)).to_i, resource)
- when "NORMAL"
- self.var_ampx((damage*base).to_i, resource)
- end
- end
- end
- alias old_execute_damage execute_damage
- def execute_damage(user)
- old_execute_damage(user)
- ampx_on_hit(@hp_damage)
- end
- def item_effective?(user, item)
- if item.for_dead_friend? != dead?
- return false
- end
- if not $game_temp.in_battle and item.for_friend?
- return item_test(user, item)
- end
- return true
- end
- def item_test(user, item, resource = Z::AMPX::DEF_RES) #OVERWRITE
- tester = self.clone
- tester.make_obj_damage_value(user, item)
- tester.apply_state_changes(item)
- if tester.hp_damage < 0 or tester.calc_hp_recovery(user, item) > 0
- return true if tester.hp < tester.maxhp
- end
- if tester.mp_damage < 0 or tester.calc_mp_recovery(user, item, tester) > 0
- return true if tester.ampx(resource) < tester.maxampx(resource)
- end
- return true unless tester.added_states.empty?
- return true unless tester.removed_states.empty?
- return true if item.parameter_type > 0
- return false
- end
- def calc_mp_recovery(user, item, target, resource=Z::AMPX::DEF_RES) #OVERWRITE
- result = maxmp * item.mp_recovery_rate / 100 + item.mp_recovery
- result *= 2 if user.pharmacology
- $type = resource
- for line in item.note.split(/[\r\n]+/)
- case line
- when /<regen:[ ](.*)>/i
- $type = Z::AMPX::symbol($1)
- return result
- end
- end
- return result
- end
- def item_effect(user, item) #OVERWRITE
- clear_action_results
- unless item_effective?(user, item)
- @skipped = true
- return
- end
- if rand(100) >= calc_hit(user, item)
- @missed = true
- return
- end
- if rand(100) < calc_eva(user, item)
- @evaded = true
- return
- end
- hp_recovery = calc_hp_recovery(user, item)
- mp_recovery = calc_mp_recovery(user, item, self)
- make_obj_damage_value(user, item)
- @hp_damage -= hp_recovery
- @mp_damage -= mp_recovery
- make_obj_absorb_effect(user, item)
- execute_damage(user)
- item_growth_effect(user, item)
- if item.physical_attack and @hp_damage == 0
- return
- end
- apply_state_changes(item)
- end
- def skill_can_use?(skill)
- return false unless skill.is_a?(RPG::Skill)
- return false unless movable?
- return false if silent? and skill.spi_f > 0
- return false unless self.resources.include?(skill.resource)
- return false if calc_mp_cost(skill) > self.ampx(skill.resource(self.resources[0]))
- if $game_temp.in_battle
- return skill.battle_ok?
- else
- return skill.menu_ok?
- end
- end
- end
- class Game_Resources
- def initialize(resource, actor)
- @actor = actor
- @resource = resource
- @value = Z::AMPX::DEF[resource][0] == 1 ? 0 : @actor.maxampx(resource)
- end
- def value
- return @value
- end
- def value=(new_value)
- @value = [[0, new_value].max, @actor.maxampx(@resource)].min
- end
- def resource
- return @resource
- end
- end
- class Window_Base < Window
- def draw_actor_ampx(actor, x, y, resource, width = 120)
- draw_actor_ampx_gauge(actor, x, y, resource, width)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 30, WLH, Z::AMPX::SPEC[resource][1])
- self.contents.font.color = mp_color(actor)
- last_font_size = self.contents.font.size
- xr = x + width
- if width < 120
- self.contents.draw_text(xr - 44, y, 44, WLH, actor.ampx(resource), 2)
- else
- self.contents.draw_text(xr - 99, y, 44, WLH, actor.ampx(resource), 2)
- self.contents.font.color = normal_color
- self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
- self.contents.draw_text(xr - 44, y, 44, WLH, actor.maxampx(resource), 2)
- end
- end
- def draw_actor_mp(actor, x, y, width = 120)
- size_x = width / actor.resources.size
- offset = size_x
- unless size_x == width
- offset += 1
- size_x -= 1
- end
- for i in 0...actor.resources.size
- draw_actor_ampx(actor, x + offset*i, y, actor.resources[i], size_x)
- end
- end
- def draw_actor_ampx_gauge(actor, x, y, resource, width = 120)
- gw = width * actor.ampx(resource) / [actor.maxampx(resource), 1].max
- gc1 = text_color(Z::AMPX::SPEC[resource][2])
- gc2 = text_color(Z::AMPX::SPEC[resource][3])
- self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
- self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
- end
- end
- class Window_BattleStatus < Window_Selectable
- def draw_item(index)
- rect = item_rect(index)
- rect.x += 4
- rect.width -= 8
- self.contents.clear_rect(rect)
- self.contents.font.color = normal_color
- actor = $game_party.members[index]
- draw_actor_state(actor, 114, rect.y, 48)
- draw_actor_name(actor, 4, rect.y)
- draw_actor_hp(actor, 124, rect.y, 120)
- draw_actor_mp(actor, 260, rect.y, 120)
- end
- end
- class Window_Skill < Window_Selectable
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- skill = @data[index]
- if skill != nil
- rect.width -= 4
- enabled = @actor.skill_can_use?(skill)
- draw_item_name(skill, rect.x, rect.y, enabled)
- resource = skill.resource(@actor.resources[0])
- bool = Z::AMPX::RECOLOR_SINGLE and @actor.resources.size == 1
- color = text_color(Z::AMPX::RECOLOR_SINGLE ? Z::AMPX::SPEC[resource][2] : 0)
- self.contents.font.color = color
- self.contents.draw_text(rect, @actor.calc_mp_cost(skill), 2)
- end
- end
- end
- class Scene_Base
- alias old_main main
- def main
- old_main
- refresh_zsr
- end
- def refresh_zsr
- for actor in $game_party.members
- for resource in actor.resources
- case Z::AMPX::DEF[resource][0]
- when 1
- actor.set_ampx(0, resource)
- when 2
- actor.set_ampx(actor.maxampx(resource), resource)
- end
- end
- end
- end
- end
- class Scene_Battle < Scene_Base
- alias old_battle_end battle_end
- def battle_end(result)
- old_battle_end(result)
- refresh_zsr
- end
- alias res_turn_end turn_end
- def turn_end(actor = nil)
- if actor != nil
- res_turn_end(actor)
- regen_mp(actor)
- else
- res_turn_end
- for actor in $game_party.members
- regen_mp(actor)
- end
- end
- end
- def regen_mp(actor)
- return if actor.dead?
- for resource in actor.resources
- base = Z::DEF[resource][1]
- var = 0
- case Z::DEF[resource][2].upcase
- when "NORMAL"
- value = base.to_i
- when "ATK", "ATTACK"
- value = (base*actor.atk).to_i
- when "DEF", "DEFENSE"
- value = (base*actor.def).to_i
- when "HP", "HIT POINTS"
- value = (base*actor.hp).to_i
- when "MP", "MAGIC POINTS"
- value = (base*actor.mp).to_i
- when "MAXHP"
- value = (base*actor.maxhp).to_i
- when "MAXMP"
- value = (base*actor.maxampx(resource)).to_i
- when "AGI", "AGILITY"
- value = (base*actor.agi).to_i
- when "SPI", "SPIRIT"
- value = (base*actor.spi).to_i
- end
- actor.var_ampx(value, resource) unless var == 0
- end
- end
- def refresh_zsr
- for actor in $game_party.members
- for resource in actor.resources
- case Z::DEF[resource][0]
- when 1
- actor.var_ampx(0, resource)
- when 2
- actor.ampx(actor.maxampx(resource), resource)
- end
- end
- end
- end
- alias zsres_update_actor_command_selection update_actor_command_selection
- def update_actor_command_selection
- zsres_update_actor_command_selection
- @status_window.refresh
- end
- alias zsres_update_party_command_selection update_party_command_selection
- def update_party_command_selection
- zsres_update_party_command_selection
- @status_window.refresh
- end
- def display_mp_damage(target, obj = nil) #OVERWRITE
- return if target.dead?
- return if target.mp_damage == 0
- type = "MP!"
- else
- if target.absorbed # Absorb
- fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
- text = sprintf(fmt, target.name, type, target.mp_damage)
- elsif target.mp_damage > 0 # Damage
- fmt = target.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
- text = sprintf(fmt, target.name, type, target.mp_damage)
- else # Recovery
- fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
- text = sprintf(fmt, target.name, type, -target.mp_damage)
- Sound.play_recovery
- end
- @message_window.add_instant_text(text)
- wait(30)
- end
- def execute_action_skill
- skill = @active_battler.action.skill
- resource = @skill.resource(@active_battler.resources[0])
- text = @active_battler.name + skill.message1
- @message_window.add_instant_text(text)
- unless skill.message2.empty?
- wait(10)
- @message_window.add_instant_text(skill.message2)
- end
- targets = @active_battler.action.make_targets
- display_animation(targets, skill.animation_id)
- @active_battler.ampx_var(-@active_battler.calc_mp_cost(skill), resource)
- $game_temp.common_event_id = skill.common_event_id
- for target in targets
- target.skill_effect(@active_battler, skill)
- display_action_effects(target, skill)
- end
- end
- end
- class Scene_Skill < Scene_Base
- def use_skill_nontarget
- Sound.play_use_skill
- resource = @skill.resource(@actor.resources[0])
- @actor.var_ampx(-@actor.calc_mp_cost(@skill), resource)
- @status_window.refresh
- @skill_window.refresh
- @target_window.refresh
- if $game_party.all_dead?
- $scene = Scene_Gameover.new
- elsif @skill.common_event_id > 0
- $game_temp.common_event_id = @skill.common_event_id
- $scene = Scene_Map.new
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement