KagggZu

Villager
Member
Joined
Sep 18, 2021
Messages
9
Reaction score
0
First Language
English
Primarily Uses
RMVXA
Hi everyone! Does anyone know a script to have some combination of armor be equipped by default instead of the equipment slot being empty? Another scenario of this script would be that unequipping a different armor would automatically equip the specified default armor back on.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,879
Reaction score
8,587
First Language
German
Primarily Uses
RMMV
the first thing doesn't need a script as you can set the default equipment in the daatabase. you just have to make sure that the actor can equip the part before it appears in the default lists.

the other part is probably best done by a script that calls a common event on unequip or equip because I don't remember any script with that direct functionality. So you'll have to write a common event that on equipment change checks all slots and if neccessary equips the default.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,283
Reaction score
758
First Language
English
Primarily Uses
RMVXA
Interesting concept. Haven't thought about that before.
Wasn't too hard. Try this out.
Let me know if it works for you
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Actor Default Equipment      ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║                                     ╠════════════════════╣
# ║ Equip basic equipment on actor      ║    18 Sep 2021     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ When an actor has a slot unequipped, this will           ║
# ║ automatically equip a base item for that slot.           ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   Specify the equipment for each actor                   ║
# ║      {  # actor 1                                        ║
# ║    :slot1 => [1,1],   # short sword                      ║
# ║  0 = items, 1 = weapons, 2 = armour : item number        ║
# ║  items are included in case you have items equippable    ║
# ║    :slot2 => [2,46],  # wood shield                      ║
# ║    :slot3 => [2,6],   # Bandana                          ║
# ║    :slot4 => [2,1],   # casual clothes                   ║
# ║    :slot5 => [2,51],  # amulet                           ║
# ║  },                                                      ║
# ║                                                          ║
# ║  Add or remove slots to accomdate your game.             ║
# ║  Add or remove sections to accomdate your game.          ║
# ║                                                          ║
# ║  Always remember the comma after each closing            ║
# ║  curly bracket                                           ║
# ║                                                          ║
# ║  You are responsible for making sure the actor can equip ║
# ║  the item, otherwise the slot will be blank when         ║
# ║  removing the item in the current slot.                  ║
# ║                                                          ║
# ║  Due to the nature of equipping items, it is recommended ║
# ║  that you use items the player cannot sell, and cannot   ║
# ║  obtain anywhere. That way the default items are not     ║
# ║  saved in the inventory.                                 ║
# ║                                                          ║
# ║  This script will delete items from the party inventory  ║
# ║  if the player tries to remove the item intended to be   ║
# ║  a base item. This is to prevent someone from simply     ║
# ║  trying to remove the item to an empty slot and gaining  ║
# ║  the base items for free, since this script does not     ║
# ║  check party inventory.                                  ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝
module R2_Equip_defaults
  # actors 1-10 included here
       ACTORS = [
      { # actor 0 - not used - example
    :slot0 => [1,1],   # short sword
    :slot1 => [2,46],  # wood shield
    :slot2 => [2,6],   # bandana
    :slot3 => [2,1],   # casual clothes
    :slot4 => [2,51],  # amulet
    },
      { # actor 1
    :slot0 => [1,1],
    :slot1 => [2,46],
    :slot2 => [2,6],
    :slot3 => [2,1],
    :slot4 => [2,51],
    },
      { # actor 2
    :slot0 => [1,1],
    :slot1 => [2,46],
    :slot2 => [2,6],
    :slot3 => [2,1],
    :slot4 => [2,51],
    },
      {
    :slot0 => [1,1],
    :slot1 => [2,46],
    :slot2 => [2,6],
    :slot3 => [2,1],
    :slot4 => [2,51],
    },
      {
    :slot0 => [1,1],
    :slot1 => [2,46],
    :slot2 => [2,6],
    :slot3 => [2,1],
    :slot4 => [2,51],
    },
      {
    :slot0 => [1,1],
    :slot1 => [2,46],
    :slot2 => [2,6],
    :slot3 => [2,1],
    :slot4 => [2,51],
    },
      {
    :slot0 => [1,1],
    :slot1 => [2,46],
    :slot2 => [2,6],
    :slot3 => [2,1],
    :slot4 => [2,51],
    },
      {
    :slot0 => [1,1],
    :slot1 => [2,46],
    :slot2 => [2,6],
    :slot3 => [2,1],
    :slot4 => [2,51],
    },
      {
    :slot0 => [1,1],
    :slot1 => [2,46],
    :slot2 => [2,6],
    :slot3 => [2,1],
    :slot4 => [2,51],
    },
      {
    :slot0 => [1,1],
    :slot1 => [2,46],
    :slot2 => [2,6],
    :slot3 => [2,1],
    :slot4 => [2,51],
    },
    ]
end
# ╔═════════════════════════════════════╗
# ║ Do not edit past here               ║
# ╚═════════════════════════════════════╝
class Game_Actor < Game_Battler
  def change_equip(slot_id, item)
    return unless trade_item_with_party(item, equips[slot_id])
    return if item && equip_slots[slot_id] != item.etype_id
    @equips[slot_id].object = item
      eslot = R2_Equip_defaults::ACTORS[id]
      case slot_id
      when 0
        data = eslot[:slot0]
      when 1
        data = eslot[:slot1]
      when 2
        data = eslot[:slot2]
      when 3
        data = eslot[:slot3]
      when 4
        data = eslot[:slot4]
      end
      slottype = data[0]
      case slottype
      when 0
        item2 = $data_items[data[1]]
      when 1
        item2 = $data_weapons[data[1]]
      when 2
        item2 = $data_armors[data[1]]
      end
    if item == nil
      @equips[slot_id].object = item2
      $game_party.lose_item(item2, 1, false) if $game_party.has_item?(item2, false)
    end
    if $game_party.has_item?(item2, false)
      $game_party.lose_item(item2, 1, false)
    end
    refresh
  end
end
 
Last edited:

KagggZu

Villager
Member
Joined
Sep 18, 2021
Messages
9
Reaction score
0
First Language
English
Primarily Uses
RMVXA
It works perfectly on its own, but with other equip engine scripts, it seems to break. I'm using Yanfly's Ace Equip Engine.

Screenshot 2021-09-18 201608.png

Is the problem that the equip engine has too many equipment slots?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,283
Reaction score
758
First Language
English
Primarily Uses
RMVXA
How many slots do you have?
Line 156 is an end.
If you didn't change anything in the equip engine script from yanfly then you may have a few extra slots. As I said in the instructions you are responsible to change the settings to make it work.
If you use 9 slots then you need 9 entries for each actor.
That being said I can see how it may not work since I only included 5 slots in the code.
 

KagggZu

Villager
Member
Joined
Sep 18, 2021
Messages
9
Reaction score
0
First Language
English
Primarily Uses
RMVXA
Yep you're right. Adding more "slot[number]" lines to actor slots under
module R2_Equip_defaults

and adding more of
when 0
data = eslot[:slot0]

makes the script work with more slots.

Having less equipment slots work just fine too. Just have to remove "slot[number]" lines per actor.

That said, this script works perfectly! Thanks for the quick response!
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,879
Reaction score
8,587
First Language
German
Primarily Uses
RMMV
@KagggZu for the future, please remember to always name the slots you place your scripts into.
see that
script '' line
in your error message? Between the two ' there should be the name of the slot to identify the script where the error happens.
And if you have multiple unnamed scripts you'll never identify which one is causing a more mysterious error message...
 

Latest Threads

Latest Profile Posts

One uncomfortable truth that has withstood the test of time, is how most people will stand by while they see a crime happening, unless it's illegal to stand by. We probably wouldn't have stories about "special heroes" or games about heroes if the "everyday common folk" were largely capable of being heroes. Heroes face dangers that most people are not willing to.
I'm having toooo much fun designing the new MP (Mental Psyche) system. I've only worked it out for enemies so far, but it's fun to stun them, then go after their MP and delete them instead to farm for better item drops.
anyone know of a place I can promote my game? sorta like game awards but for indie devs, like a place where I can drop a trailer and like stir up some hype
Doing RPG Maker News for 17th October 2021

That moment when you came up with a very good game title, but when you searched it, it has already been used... T.T

Forum statistics

Threads
115,880
Messages
1,093,684
Members
151,124
Latest member
jonahcisco
Top