ACE Equip Add-on: Level Based Equipment Slots

Discussion in 'RGSS3 Script Requests' started by Panda_Artist, Aug 14, 2019 at 12:58 AM.

  1. Panda_Artist

    Panda_Artist Humble RPG Fan Member

    Messages:
    27
    Likes Received:
    3
    First Language:
    Portuguese
    Primarily Uses:
    RMVXA
    Good Morning / Day / Afternoon / Evening everyone.

    I have a request for a certain kind of script modification.

    I have Tsukihime's Core Equip along with Dynamic Equip slots

    The script give you the option to create your own custom equipment types and slots

    However, I would like to implement an add on that for example. I have a custom equip type in which an actor starts with 1 slot of at level 1 but grows to 3 slots of the same at level 20 for example.

    Is there any easy way to implement these?
     
    Last edited: Aug 14, 2019 at 10:00 PM
    #1
  2. GGZiron

    GGZiron Veteran Veteran

    Messages:
    68
    Likes Received:
    16
    Location:
    Bulgaria
    First Language:
    Bulgarian
    Primarily Uses:
    RMVXA
    One very easy way that to happen is via this script call:
    Code:
    $game_actors[actor_id].actor.base_equip_slots.push(equip_type_id)
    You replace the actor_id with the coresponding actor id number, and the equip_type_id with the coresponding equip type id number set in yanfly's script. Not too heavely tested though.

    That script call does not work on actors that would use default equip slots. Or, it rather do work, but once you push any equip slot, the default ones would not load for the given actor. As that script call is something that could help you, it might not in the example you give.
    To work for the example you give, the level up method could be modified, so it pushes more slots when certain conditions are met. But you need to provide more data how exactly that should happen. That happens for all actors, or only for certain? Different actors have different levels when they would recieve new slot, and different slot type to recieve on criteria met? Or it works same for all actors? Same level criteria, same slot type added?

    Edit: Only the script call by itself won't help you, as that won't remain in the save file.
    The equip slot data should be stored in save data, and extracted from there loading new game, if you add this snippet at the end of the Yanfly Equip Engine:
    Code:
    #Add-on for Ace Equip Engine
    #Purpose: Save and loads the actors equip slots.
    
    module DataManager
     
      class << self
        alias_method :ggz_yee_make_save_contents_old,    :make_save_contents
        alias_method :ggz_yee_extract_save_contents_old, :extract_save_contents
      end
     
       def self.make_save_contents(*args)
        contents = ggz_yee_make_save_contents_old(*args)
        equip_slot_save = Array.new
        $data_actors.each_with_index do |actor, i|
          next unless actor
          equip_slot_save[i] = actor.base_equip_slots
        end
        contents[:ynf_base_equip_slots] = equip_slot_save
        contents
      end
      #--------------------------------------------------------------------------
      # * Extract Save Contents
      #--------------------------------------------------------------------------
      def self.extract_save_contents(contents)
        ggz_yee_extract_save_contents_old(contents)
         equip_slot_load = contents[:ynf_base_equip_slots]
         if equip_slot_load
           $data_actors.each_with_index do |actor, i|
             next unless actor
             actor.base_equip_slots = equip_slot_load[i]
           end
         end
      end
     
    end  
    You should add that snippet at the end of "Ace Equip Engine" script, after everything else there.
    That snippet only makes it so whatever changes you make, to be stored in the save.
    It would not add any equip slots on level up. For that, you need to provide more info how you want it to happen.
     
    Last edited: Aug 16, 2019 at 3:30 AM
    #2
  3. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,582
    Likes Received:
    345
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    Not the best, but it works.
    Code:
    =begin
    #=====================================================================
    #   HIME's Dynamic Equip Slots - Add-on
    #   Version 1.0.01
    #   Author: Roninator2
    #   Date: 18 Aug 2019
    #   Latest: 19Aug 2019
    #=====================================================================#
    #   UPDATE LOG
    #---------------------------------------------------------------------#
    # 18 Aug 2019 - Created notetag to add slots by level
    #=====================================================================#
    #       NOTETAGS
    #=====================================================================#
    
    Notetag actors as many times as you require with the following:
    
        * <add slot: Level, etype_id>
        * e.g. <add slot: 5, 4>
     Where `etype_id` is the equip type ID. By default, they are as follows:
       0 - weapon
       1 - shield
       2 - headgear
       3 - bodygear
       4 - accessory
     
    =end
    
    module TH
      module Dynamic_Equip_Slots
        Regexlevel = /<add[-_ ]slot:[-_ ](\d+*)\,*.*?(\d+*)>/i
      end
    end
    
    module RPG
      class Actor
        attr_reader :level
        def load_notetag_level_equip_slots
          results = self.note.scan(TH::Dynamic_Equip_Slots::Regexlevel)
          results.each do |res|
            if $game_actors[@id].level == res[0].to_i
              $game_actors[@id].add_equip_slot(res[1].to_i)
            end
          end
        end
      end
    end
    
    class Game_Actor < Game_Battler
      alias :r2_level_up_97bfu  :level_up
      def level_up
        r2_level_up_97bfu
        actor.load_notetag_level_equip_slots
      end
    end
    
    
    Fix the code.
    For the life of me I could not get this to work without a global variable. Perhaps someone can assist with that.
     
    Last edited: Aug 20, 2019 at 8:48 AM
    #3
  4. Panda_Artist

    Panda_Artist Humble RPG Fan Member

    Messages:
    27
    Likes Received:
    3
    First Language:
    Portuguese
    Primarily Uses:
    RMVXA

    It worked just fine without it, I leveled up my character and his slots increased, even with characters with a lower level on the party, I was able to accomplish just what I wanted.

    Thank you so much, you will definitely be credited.
     
    #4
  5. GGZiron

    GGZiron Veteran Veteran

    Messages:
    68
    Likes Received:
    16
    Location:
    Bulgaria
    First Language:
    Bulgarian
    Primarily Uses:
    RMVXA
    Hey, just to apologise. I for some reason believed you used Yanfly equip engine, although you certainly said Tsukihime. Sometimes my short term memory play me such tricks. Is not my practice when someone ask help for one script, I to go for another. Anyway, I see Roninator2 helped you :).
     
    #5

Share This Page