Equipment Licences
Version: 1.0
Author: modern algebra
Date: December 14, 2010
Version History
- <Version 1.0> 12.14.2010 - Original Release
Description
This script allows you to set it up so that an actor will be able to equip weapons and armors not normally assigned to his or her class. It can be useful if you want to create a licensing system, if you want the actor to have to purchase training before being able to use a certain type of weapon, etc...
However, it has no graphical or system component. It is meant to be used only through events within some system that you create yourself. If you'd like a full system, I'm open to suggestions.
Features
- Allows you to modify, in-game, what weapons and armors a particular actor can use
- Allows you to do it by actor, rather than class, thus allowing you to create a licencing system
- Very simple and intuitive to use
Instructions
Place this script in its own slot above Main and below other custom scripts in the Script Editor (F11).
For instructions on use, see the header of the script.
Script
#==============================================================================
# Equipment Licences
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: December 14, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script allows you to set it up so that an actor will be able to
# equip weapons and armors not normally assigned to his or her class. It can
# be useful for a licensing system, if you want the actor to have to purchase
# training before being able to use a certain type of weapon, etc...
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Place this script in its own slot above Main and below other custom
# scripts in the Script Editor (F11).
#
# To make a weapon or armor equippable, all you need to do is use one of the
# following codes in a Script command:
#
# licence_weapon (actor_id, w1_id, w2_id, ..., wn_id)
# licence_armor (actor_id, a1_id, a2_id, ..., an_id)
#
# where:
# actor_id : the ID of the actor who you want to licence
# w1_id ... wn_id : the IDs of the weapons that you want to unlock. Just
# put as many as you want to unlock at the time and follow.
# a1_id ... an_id : the IDs of the armors that you want to unlock. Same
# thing as w1_id ... wn_id except for armors.
#
# Examples:
# 1. licence_weapon (5, 2, 7, 23)
# That would unlock weapon 2 (Long Sword), weapon 7 (Iron Claw) and
# weapon 23 (Great Axe) for Actor 5 (Lawrence). This means that Actor 5
# would now be able to equip those weapons.
# 2. licence_armor (2, 1, 2, 7)
# That would unlock armor 1 (Leather Shield), armor 2 (Scale Shield)
# and armor 7 (Feathered Hat) for Actor 2 (Ulrika). This means that
# Actor 2 would now be able to equip those armors.
#
# Similarly, you can unlicence weapons and armors with the following codes:
#
# unlicence_weapon (actor_id, w1_id, w2_id, ..., wn_id)
# unlicence_armor (actor_id, a1_id, a2_id, ..., an_id)
#
# The variables mean the same thing as with the other codes.
#==============================================================================
#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased methods - setup; equippable?
# new method - licence_equip
#==============================================================================
class Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Actor Setup
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malgb_licnc_setup_7uj3 setup
def setup (*args)
@licenced_weapons, @licenced_armors = [], []
# Also set up arrays for unlicenced weapons and armors in order to
# allow override of class defaults
@unlicenced_weapons, @unlicenced_armors = [], []
malgb_licnc_setup_7uj3 (*args) # Run Original Method
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Equippable?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mara_licenc_equipbl_5to0 equippable?
def equippable? (equip, *args)
# Check if explicitly unlicenced
ary = equip.is_a? (RPG::Weapon) ? @unlicenced_weapons : @unlicenced_armors
return false if ary.include? (equip.id)
# Run Original Method
result = mara_licenc_equipbl_5to0 (equip, *args)
if !result # If unequippable by default, check if licenced
if equip.is_a? (RPG::Weapon)
return @licenced_weapons.include? (equip.id)
else
return @licenced_armors.include? (equip.id) && !(two_swords_style && equip.kind == 0)
end
end
return result
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Licence Equip
# type : 0 => Licence Weapon; 1 => Licence Armor; 2 => Unlicence Weapon
# 3 => Unlicence Armor
# ids : array of IDs to operate on
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def licence_equip (type, ids)
case type
when 0 # Licence Weapon
@licenced_weapons |= ids
@unlicenced_weapons -= ids
when 1 # Licence Armor
@licenced_armors |= ids
@unlicenced_armors -= ids
when 2 # Unlicence Weapon
@unlicenced_weapons |= ids
@licenced_weapons -= ids
# Unequip equipped weapon if one of they impugned kinds
for i in 0...weapons.size
next if weapons[i].nil?
change_equip (i, nil) if ids.include? (weapons[i].id)
end
when 3 # Unlicence Armor
@unlicenced_armors |= ids
@licenced_armors -= ids
# Unequip equipped armor if one of they impugned kinds
for i in 0...armors.size
next if armors[i].nil?
change_equip (i + weapons.size, nil) if ids.include? (armors[i].id)
end
end
end
end
#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new methods - licence_equip; licence_weapon; licence_armor;
# unlicence_weapon; unlicence_armor
#==============================================================================
class Game_Interpreter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Licence Weapon
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def licence_weapon (actor_id, *w_ids)
$game_actors[actor_id].licence_equip (0, w_ids)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Licence Armor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def licence_armor (actor_id, *a_ids)
$game_actors[actor_id].licence_equip (1, a_ids)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Unlicence Weapon
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def unlicence_weapon (actor_id, *w_ids)
$game_actors[actor_id].licence_equip (2, w_ids)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Unlicence Armor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def unlicence_armor (actor_id, *a_ids)
$game_actors[actor_id].licence_equip (3, a_ids)
end
end
Credit
Thanks
Support
Please post in this topic if you are reporting a bug or have a suggestion. Do so no matter how old the topic is; do not PM me.
Known Compatibility Issues
There might be some issues with scripts that create new equipment types or extend previous ones. It probably won't be anything too dramatic, but it may not work exactly as it should with those scripts. Put this script below them in any case, but still above Main.