Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #======================#
- # Z-Systems by: Zetu #
- #===========================#======================#===========================#
- # * * * Alternate MP X v3.01 * * * #
- #------------------------------------------------------------------------------#
- # Will Overwrite Draw Functions for MP. #
- #------------------------------------------------------------------------------#
- # Known Compatable Battle Systems: #
- # • Tankentai #
- #------------------------------------------------------------------------------#
- # Version History #
- # 3.01 ALPHA #
- #=#==========================================================================#=#
- # You may need slight scripting knowledge of working with arrays (but #
- # not a whole lot!). #
- #--------------------------------------------------------------------------#
- # * * Anything in "< >" means replace with the described contents. * * #
- # REQUIRED PARAMETERS (Any resource without it will cause an error) #
- # :name, <name of resource> #
- # :abbv, <1 or 2 character abbv. of resource> #
- # :color, <color 1>, <color 2> #
- # * These color attributes are indexes of the window skin #
- # OPTIONAL PARAMETERS #
- # Resource Regen for each turn: #
- # :regen, <type>, <base> #
- # type can be :maxmp, :atk, :def, :spi, :agi, :set #
- # base is number multiplied by type (:set is considered 1) #
- # Resource Regen on Damage #
- # :regenondamage, <type>, <base> #
- # type can be :damage, :maxmp, :set, :percentdmg #
- # base in number multipled by type (:set is considered 1) #
- # (:percentdmg is ratio of maxmp and damage) #
- # :regenelemental, <element_id>, <type>, <base> #
- # same as :regenondamage, except on elemental damage (of #
- # element_ids) (may place more than 1 id) #
- # Resource Change Out of Battle: #
- # :depleteoob (Set to 0) #
- # :regenoob (Set to Max) #
- # Resource Inversion #
- # :invert #
- # this allows the resource to Add instead of Subtract for its cost #
- # and disallows skill use if cost will exceed the maxmp #
- #==========================================================================#
- module Z11
- RESOURCES = [
- :regen, :maxmp, 0.05,
- :name, "Mana",
- :abbv, "M",
- :color, 23, 22
- ],[
- :depleteoob,
- :regenondamage, :percentdmg, 1.2,
- :max, 100,
- :name, "Rage",
- :abbv, "R",
- :color, 10, 2
- ],[
- :regenoob,
- :regen, :set, 20,
- :max, 100,
- :name, "Energy",
- :abbv, "E",
- :color, 6, 14
- ],[
- :regenoob,
- :regen, :set, 30,
- :regenondamage, :percent, -1.5,
- :max, 100,
- :name, "Focus",
- :abbv, "F",
- :color, 3, 11
- ],[
- :invert,
- :depleteoob,
- :regenelemental, 9, :percent, 2,
- :regenelemental, 10, 12, :percent, -1,
- :regen, :set, -30,
- :max, 150,
- :name, "Heat",
- :abbv, "H",
- :color, 2, 10
- ]
- # If set to false, use RESBYCLASS's indexes as Actor IDs instead of Class IDs
- BIND_TO_CLASS = true
- # <Class ID> => <Array of Resources by :name parameter>
- # Recommended max is 2
- RESBYCLASS = {
- 1 => ["Mana", "Rage"],
- 2 => ["Mana", "Energy"],
- 3 => ["Heat", "Rage"],
- 4 => ["Rage"]
- }
- # Default value if not in RESBYCLASS hash.
- DEF_RES = "Mana"
- #=========================================================================#
- # Note Tags: To be used in notebox #
- #=========================================================================#
- #Skill Notes
- #States what Resource Skill uses. Use :name parameter (case insensitive)
- #If tag does not exist, will default to actor's primary resource
- RESOURCECOSTTYPE = /<ampx[: ]+(.*)>/i
- #========#======================#====#================================#========#
- #--------# #----# DO NOT EDIT PAST THIS POINT!!! #--------#
- #--------# End of Customization #----# Editing will cause death by #--------#
- #--------# #----# brain asplosions. #--------#
- #========#======================#====#================================#========#
- def self.get_resource_index(type)
- for array in RESOURCES
- if array[array.index(:name)+1].upcase == type.upcase
- return RESOURCES.index(array)
- end
- end
- return -1
- end
- end
- class Game_Resources
- attr_reader :name, :abbv, :color1, :color2, :value, :regenelemental,
- :regentype, :regenbase, :regenodtype, :regenodbase, :tags
- attr_accessor :max
- def initialize(type, actor)
- @index = Z11::get_resource_index(type)
- @actor = actor
- scan_object_variables(type)
- end
- def scan_object_variables(type)
- i = 0
- array=Z11::RESOURCES[@index]
- @tags = []
- @max = @actor.maxmp
- @value = @max
- @maxdefault = true
- @regenelemental = {}
- while (i < array.size)
- case array[i]
- when :name; @name = array[i+1]; i+=1
- when :abbv; @abbv = array[i+1]; i+=1
- when :color; @color1 = array[i+1]; @color2 = array[i+2]; i+=2
- when :regen; @regentype = array[i+1]; @regenbase = array[i+2]; i+=2
- when :regenondamage
- @regenodtype = array[i+1]
- @regenodbase = array[i+2]
- i+=2
- when :regenelemental
- i+=1
- id = []
- while (array[i].is_a?(Integer))
- id.push(array[i])
- i+=1
- end
- for n in id
- @regenelemental[n]= array[i], array[i+1]
- end
- i+=1
- when :max
- @max = array[i+1]
- i+=1
- @value = [@max, @value].min
- @maxdefault = false
- when :depleteoob; @tags.push(:depleteoob); @value = 0
- when :regenoob; @tags.push(:regenoob)
- when :invert; @tags.push(:invert)
- end
- i+=1
- end
- end
- def value=(new_value)
- @value = [[new_value, 0].max, @max].min
- 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.push(Game_Resources.new(resource,self))
- end
- end
- def resources
- if Z11::BIND_TO_CLASS
- result = Z11::RESBYCLASS[self.class_id]
- else
- result = Z11::RESBYCLASS[self.actor_id]
- end
- return result.nil? ? [Z11::DEF_RES] : result
- end
- alias z11ed execute_damage unless $@
- def execute_damage(user)
- z11ed(user)
- ampx_on_hit(@hp_damage)
- self.mp -= @mp_damage####
- if @absorbed
- user.mp += @mp_damage####
- end
- end
- def resourcenameof(skill)
- skill.note.scan(Z11::RESOURCECOSTTYPE){
- return $1.upcase
- }
- return self.ampx[0].name.upcase
- end
- end
- class Game_Enemy < Game_Battler####
- alias ampx_initialize initialize
- def initialize(index, enemy_id)
- ampx_initialize(index, enemy_id)
- @ampx = [Game_Resources.new(Z11::DEF_RES,self)]
- end
- def resources
- return [Z11::DEF_RES]
- end
- def resourcenameof(skill)
- return Z11::DEF_RES
- end
- end
- class Game_Battler
- attr_reader :ampx
- 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
- resource = skill.resourceof(self)
- return false unless self.ampx.include?(resource)
- if resource.tags.include?(:invert)
- return false if calc_mp_cost(skill) + resource.value > resource.max
- else
- return false if calc_mp_cost(skill) > resource.value
- end
- if $game_temp.in_battle
- return skill.battle_ok?
- else
- return skill.menu_ok?
- end
- end
- alias z11ed execute_damage unless $@
- def execute_damage(user)
- z11ed(user)
- ampx_on_hit(@hp_damage)
- self.mp -= @mp_damage####
- if @absorbed
- user.mp += @mp_damage####
- end
- end
- def ampx_on_hit(damage)
- return unless damage > 0
- for resource in @ampx
- next if resource.regenodtype.nil?
- value = resource.regenodbase
- case resource.regenodtype
- when :damage
- value *= damage
- when :maxmp
- value *= resource.max
- when :percentdmg
- value *= 100*damage/resource.max
- end
- resource.value += value.to_i
- next if @obj.nil?
- total = 0
- value = 0
- for i in @obj.element_set
- if resource.regenelemental.key?(i)
- value = resource.regenelemental[i][1]
- case resource.regenelemental[i][0]
- when :damage; value *= damage
- when :maxmp; value *= resource.max
- when :percentdmg; value *= 100*damage/resource.max
- end
- total+=1
- end
- end
- resource.value += (value/total).to_i if total != 0
- end
- end
- def recover_all
- @hp = maxhp
- return if @ampx.nil?
- for resource in @ampx
- unless resource.tags.include?(:depleteoob)
- resource.value = resource.max
- end
- end
- for i in @states.clone
- remove_state(i)
- end
- end
- alias z11modv make_obj_damage_value unless $@
- def make_obj_damage_value(user, obj)
- @obj = obj
- z11modv(user,obj)
- end
- alias z11madv make_attack_damage_value
- def make_attack_damage_value(attacker)
- @obj = nil
- z11madv(attacker)
- end
- end
- class Scene_Base
- alias old_main main unless $@
- def main
- old_main
- refresh_zsr
- end
- def refresh_zsr
- for actor in $game_party.members
- for resource in actor.ampx
- if resource.tags.include?(:regenoob)
- resource.value=resource.max
- elsif resource.tags.include?(:depleteoob)
- resource.value=0
- end
- end
- end
- end
- end
- class Scene_Battle < Scene_Base
- def regen_ampx(actor)
- return if actor.dead?
- for resource in actor.ampx
- next if resource.regentype.nil?
- value = resource.regenbase
- case resource.regentype
- when :maxmp; value *= resource.max
- when :atk; value *= actor.atk
- when :def; value *= actor.def
- when :spi; value *= actor.spi
- when :agi; value *= actor.agi
- end
- resource.value += value.to_i
- end
- @status_window.refresh
- end
- def refresh_zsr
- for actor in $game_party.members
- for resource in actor.ampx
- if resource.tags.include?(:regenoob)
- resource.value = resource.max
- elsif resource.tags.include?(:depleteoob)
- resource.value = 0
- end
- end
- end
- end
- end
- class Scene_Skill < Scene_Base
- def use_skill_nontarget # OVERWRITE
- Sound.play_use_skill
- resource = @skill.resourceof(@actor)
- if resource.tags.include?(:invert)
- resource.value += @actor.calc_mp_cost(@skill)
- else
- resource.value -= @actor.calc_mp_cost(@skill)
- end
- @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
- class Scene_Item < Scene_Base
- def use_item_nontarget # OVERWRITE
- Sound.play_use_item
- $game_party.consume_item(@item)
- @item_window.draw_item(@item_window.index)
- @target_window.refresh
- if $game_party.all_dead?
- $scene = Scene_Gameover.new
- elsif @item.common_event_id > 0
- $game_temp.common_event_id = @item.common_event_id
- $scene = Scene_Map.new
- end
- end
- end
- class RPG::Skill < RPG::UsableItem
- def resourceof(actor)
- unless actor.actor?
- return actor.ampx[0]
- end
- name = actor.resourcenameof(self)
- for resource in actor.ampx
- if resource.name.upcase==name
- return resource
- end
- end
- print "Error: def resourceof(#{actor.name}) for skill #{self.name} returned nil, type #{name}"
- end
- end
- class Window_Base < Window
- def draw_actor_mp(actor, x, y, width = 120) # OVERWRITE
- width = width/actor.ampx.size
- offset = width
- if actor.ampx.size != 1
- offset += 1
- width -= 1
- end
- for i in 0...actor.ampx.size
- draw_actor_ampx(actor.ampx[i], x+i*offset,y,width)
- end
- end
- def draw_actor_ampx(resource, x, y, width = 120)
- draw_actor_ampx_gauge(resource, x, y, width)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 30, WLH, resource.abbv)
- self.contents.font.color = text_color(resource.color1)
- last_font_size = self.contents.font.size
- xr = x + width
- if width < 120
- self.contents.draw_text(xr - 44, y, 44, WLH, resource.value, 2)
- else
- self.contents.draw_text(xr - 99, y, 44, WLH, resource.value, 2)
- self.contents.font.color = normal_color
- self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
- self.contents.font.color = text_color(resource.color1)
- self.contents.draw_text(xr - 44, y, 44, WLH, resource.max, 2)
- end
- end
- def draw_actor_ampx_gauge(resource, x, y, width = 120)
- gw = width * resource.value / [resource.max, 1].max
- gc1 = text_color(resource.color1)
- gc2 = text_color(resource.color2)
- 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
- #BS
- class Scene_Battle < Scene_Base
- def display_mp_damage(target, obj = nil) #OVERWRITE
- return if target.dead?
- return if target.mp_damage == 0
- type = obj.regresource.name
- if target.absorbed
- fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
- text = sprintf(fmt, target.name, type, target.mp_damage)
- elsif target.mp_damage > 0
- fmt = target.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
- text = sprintf(fmt, target.name, type, target.mp_damage)
- else
- 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 #OVERWRITE
- skill = @active_battler.action.skill
- text = @active_battler.name + skill.message1
- resource = skill.resourceof(@active_battler)
- @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)
- if resource.tags.include?(:invert)
- resource.value += @active_battler.calc_mp_cost(skill)
- else
- resource.value -= @active_battler.calc_mp_cost(skill)
- end
- $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
- alias old_battle_end battle_end unless $@
- def battle_end(result)
- old_battle_end(result)
- refresh_zsr
- end
- alias res_turn_end turn_end unless $@
- def turn_end(actor = nil)
- if actor.nil?
- res_turn_end
- for actor in $game_party.members
- regen_ampx(actor)
- end
- else
- res_turn_end(actor)
- regen_ampx(actor)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement