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,850
Reaction score
8,577
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,278
Reaction score
754
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,278
Reaction score
754
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,850
Reaction score
8,577
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 Posts

Latest Profile Posts

Anyone doing anything for NaNoWriMo this year?
Listening to, "Draum" by Eldrim. If you haven't heard it before, do so. Absolutely lovely, and utterly haunting.
Using Live2D is actually pretty fun once you get familiar with where everything is. :rhappy: And no, I'm not learning because of the Vtuber thing going around, but yes looking at those helps a lot to know what can be done :LZSlol:
[Maybe Sensitive] Personal thoughts on being "cringe".
If I were to say, being a creator also means getting cringe ideas on your project. But why would having one makes the work somehow "being bad"?

Forum statistics

Threads
115,829
Messages
1,093,285
Members
151,019
Latest member
FuchsiaFeline
Top