StripelessTiger 4 Posted January 2, 2015 Sorry for necro-posting, but I have checked everywhere and there is nothing like this script anywhere else. This is the only script I have found of this type and it has been instrumental in setting up the very unusual system I have in place. Â Basically, I have multiple MP bars in my game (when you use one type is raises another), and a Fatigue bar (think Xenosaga 2 break gauge), all which show up in combat. Â Since I am using TP for an Action Point system, this script is invaluable and I hope it is still being updated or has people supporting because I have some issues and questions. Â First, I am getting weird percentage points being added as decimals, which is not hard to fix, but I thought you should be aware that the regen doesn't round for some reason. Â Second, can we modify these stats or base other factors off of them in combat? Such as when a gauge hits full, it applies a state? Or better yet, can we set it so that skills can add/subtract differing values independently? Â Third, where does the script store these values and how can I reference them in a script? Can I check if Actor 1 has a Fatigue over 50% in a conditional branch event? Share this post Link to post Share on other sites
tiagoms 2 Posted March 5, 2015       #======================#                                # 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", "Energy"],        11 => ["Mana", "Energy"],        12 => ["Heat", "Rage"],        13 => ["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 1 Share this post Link to post Share on other sites
RaZzi 20 Posted March 5, 2015 (edited) @tiagoms: Can you be more specific about the script version you posted, what does it change / fix? I can atleast spot Invert there. Edited March 5, 2015 by RaZzi Share this post Link to post Share on other sites
tiagoms 2 Posted March 6, 2015 In fact, I found this script and I was hoping that someone comment on it. Share this post Link to post Share on other sites
Murd 4 Posted March 6, 2015 (edited) Just wonder if we can make resource regenerate by using a varible rather than fixed amount.. Â For example, Eric has Rage resource which can be regenerated equal to 10% of damage inflicting to enemy. Then Eric equips with Great Sword which increases Rage regeneration by 5%. How can I set it up? Â Thanks! Edited March 6, 2015 by Murd Share this post Link to post Share on other sites
dgrayman123 1 Posted March 6, 2015 (edited) There's an error I'm getting. Line 312: can't define. Help plz, love the concept of this script. Â Edit: Right, I get the error starting a fresh project, meaning there is no other script. I start the game, and then get the error. I mean, I literally start by pressing the F12, and then get the error, if that helps. The error says, "undefined method 'make_obj_damage_value' for class 'Game_Battler" if that helps. Edited March 7, 2015 by dgrayman123 1 Share this post Link to post Share on other sites
RaZzi 20 Posted March 6, 2015 There's an error I'm getting. Line 315: can't define. Help plz, love the concept of this script. Â Sighs. Be a little more specific. When do you get the error? What other scripts do you have? Share this post Link to post Share on other sites
tiagoms 2 Posted March 7, 2015 I understand that the actual value of the change can be made by:$game_actor[x].resoucer[y].valuebut and change the maximum value of an actor? Share this post Link to post Share on other sites
SamHain 0 Posted March 7, 2015 (edited) @tiagoms: Can you be more specific about the script version you posted, what does it change / fix? I can atleast spot Invert there. From the look of it, in addition to :invert now now being fixed, it looks like you can assign resources by class or by actor through the use of BIND_TO_CLASS = true/false and the RESBYCLASS = array.  Though also from the look of it, it isn't complete. I'd stick with 1.05 for now.  Just wonder if we can make resource regenerate by using a varible rather than fixed amount..  For example, Eric has Rage resource which can be regenerated equal to 10% of damage inflicting to enemy. Then Eric equips with Great Sword which increases Rage regeneration by 5%. How can I set it up?  Thanks! Not sure about a variable. But to do what you've said in your example you would give the weapon a 100% chance to give its user a state when equipped. You would then make that state have the regen mana parameter set to regen 5% mp. Then you would add the notetage <AMPX REGEN: RAGE> into the state's note box. Edited March 7, 2015 by SamHain Share this post Link to post Share on other sites
Widen612 14 Posted April 24, 2015 I get a error Line 315 of Alternate MP X v3.01 Â Â Â Share this post Link to post Share on other sites
SamHain 0 Posted May 20, 2015 Necro, I know, but: Does anyone know how I would go about drawing the MP and AMPX so that they offset vertically rather than horizontally? Share this post Link to post Share on other sites
RupamOntherocks 11 Posted August 8, 2016 (edited) What do I need to do, if I want these alternative mp's max value be increased when level up? Edited August 8, 2016 by RupamOntherocks Share this post Link to post Share on other sites
roninator2 257 Posted November 3, 2020 https://pastebin.com/raw/rcfvmRCh  Share this post Link to post Share on other sites