Galv's Magic Shards - Force Equip Script Call

Discussion in 'RGSS3 Script Requests' started by Vis_Mage, Jan 17, 2019.

  1. Vis_Mage

    Vis_Mage Novice Magician Veteran

    Messages:
    402
    Likes Received:
    142
    Location:
    Ridge Island
    First Language:
    English
    Primarily Uses:
    RMVXA
    Hey! :kaohi:

    I was wondering if someone could help me create a script call add on for Galv's Magic Shards script.

    What I'm hoping to have is a script call that can automatically equip an actor with a specific shard. Something along the lines of

    Code:
    shard_equip(x,y,z)
    Where X is the actor ID, Y is the item type (item/weapon/armor), and Z is the item ID.

    Thank you!
     
    #1
  2. A-Moonless-Night

    A-Moonless-Night WINTER IS COMING Veteran

    Messages:
    519
    Likes Received:
    369
    Location:
    New Zealand
    First Language:
    English
    Primarily Uses:
    RMVXA
    This should work fine:
    Code:
    class Game_Actor < Game_Battler
     
      def add_shard(item, index = 0)
        return if @shards.empty?
        if @shards[index].is_a?(RPG::BaseItem)
          $game_party.gain_item(@shards[index], 1)
        end
        @shards.delete_at(index)
        @shards.insert(index, item)
      end
        
    end
    
    class Game_Interpreter
     
      def shard_equip(actor_id, type, item_id, index = 0)
        case type
        when :item; item = $data_items[item_id]
        when :weapon; item = $data_weapons[item_id]
        when :armor; item = $data_armors[item_id]
        end
        return unless item && item.shard
        $game_actors[actor_id].add_shard(item, index)
      end
        
    end

    Use the following:
    Code:
    shard_equip(actor_id, type, item_id, index)
    # actor_id is the ID of the actor
    # type is either :item, :armor or :weapon
    # item_id is the ID of the item
    # index is the index you want to equip the shard to (starting from 0, so the first slot would be 0)
    
    # You can also do:
    shard_equip(actor_id, type, item_id)
    # and it will use the first shard slot index
    Hope this helps. Of course, it doesn't take into account whether the item is in your inventory. If there's already a shard equipped in the slot index you choose, then it will swap it out.
     
    #2
    Vis_Mage likes this.
  3. Vis_Mage

    Vis_Mage Novice Magician Veteran

    Messages:
    402
    Likes Received:
    142
    Location:
    Ridge Island
    First Language:
    English
    Primarily Uses:
    RMVXA
    Works beautifully! The fact that it doesn't check the inventory shouldn't be any issue, but thanks for letting me know.

    Thank you again! :kaothx:
     
    #3

Share This Page