Equipment Licences

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
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


Code: [Select]
#==============================================================================
#    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


  • modern algebra

Thanks

  • dragon3025

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.

**
Rep: +0/-0Level 73
Robot Unicorns ATTACK!!!!
This sounds a lot like the FFXII Licensing system. God job!
YOU LOST THE GAME
 
Projects & Recruitment
Spoiler for:
Recruitment:

Current Project:


ONLY AT RRR!
Userbars
Spoiler for:


**
Rep:
Level 83
プログラマです
Hey man, nice script.

I think it has compatibility issues wth YEM Equipment Overhaul (sounds obvious enough why :P).

When I use your script to allow new equipment to be equipped it will not allow me to equip it in the equip scene, yet when I check the weapon in the inventory screen my character is lit up (meaning he is allowed to equip the weapon).

I took out the Equipment Overhaul script and your licence system worked perfect.
I pasted the licence above and below the Equipment overhaul script just to see but both produced the same result.

Is there any chance you'd have the time to write up some kinda fix for this?


Thanks for reading :)


EDIT: Just clicked "optimize equipment" from the equip scene and it equipped the weapons that I had allowed through the licence script. Yet, when I remove them and try to manually equip them it won't show them in "equipment you can equip" box.
« Last Edit: June 30, 2011, 07:24:13 AM by SeMcDun »

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Well, it looks like the problem is that Yanfly alters the function of the equippable? method in Game_Actor to allow for level requirements, but I suppose still wanted to show them (but disabled) in the Equip scene. This is untested, but I think the following patch, placed under YEM Equipment Overhaul, should fix it:

Code: [Select]
class Game_Actor
  def ma_yemeqp_licence_check (equip)
    return false if equip.nil?
    # Check if explicitly unlicenced
    ary = equip.is_a? (RPG::Weapon) ? @unlicenced_weapons : @unlicenced_armors
    return false if ary.include? (equip.id)
    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
end

class Window_Equip_Item
  #--------------------------------------------------------------------------
  # class_equippable?
  #--------------------------------------------------------------------------
  alias modrna_equiplicence_yem_equippable class_equippable?
  def class_equippable? (item, *args)
    return (modrna_equiplicence_yem_equippable (item, *args) || @actor.ma_yemeqp_licence_check (item))
  end
end

**
Rep:
Level 83
プログラマです
Hey man :) Really appreciate you spending time to help me.

I put the patch under equipment overhaul, but over Licence and as I ran my game I got a syntax error;
"????? Modern Algebra' ? 21 ??? Syntax Error ????????"

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Change it to this I guess:

Code: [Select]
class Game_Actor
  def ma_yemeqp_licence_check (equip)
    return false if equip.nil?
    # Check if explicitly unlicenced
    ary = equip.is_a? (RPG::Weapon) ? @unlicenced_weapons : @unlicenced_armors
    return false if ary.include? (equip.id)
    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
end

class Window_Equip_Item
  #--------------------------------------------------------------------------
  # class_equippable?
  #--------------------------------------------------------------------------
  alias modrna_equiplicence_yem_equippable class_equippable?
  def class_equippable? (item, *args)
    result = modrna_equiplicence_yem_equippable (item, *args)
    return (result || @actor.ma_yemeqp_licence_check (item))
  end
end

**
Rep:
Level 83
プログラマです
Aw it works! :D Thank you very very much.

**
Rep: +0/-0Level 85
This sounds a lot like the FFXII Licensing system. God job!

This is from MDark FF12 License Board Version Project.

**
Rep: +0/-0Level 81
Could you post a class-based version of this Licence system? I ask because I event job system and I'd prefer to have each class has their own licences rather then buying licences from various jobs just to add it to actor.