Save-Point
EKuipSwitch XP - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: EKuipSwitch XP (/thread-8691.html)



EKuipSwitch XP - kyonides - 02-25-2023

EKuipSwitch XP

by Kyonides


Introduction

Are you in desperate need to turn on a switch whenever a hero equips a specific weapon or armor and vice versa?
Well, now you can do it! Grinning

RMXP's Setup

Either set the key value pairs of the WEAPON_IDS or ARMOR_IDS constants like this:

Code:
ARMOR_IDS = { 33 => 10 }

Where 33 stands for the Armor ID and 10 is the Switch ID.


Terms & Conditions

Free as in Beer beer.
Include my nickname in your game credits! Winking
Do not repost it anywhere! Happy with a sweat


RE: EKuipSwitch - kyonides - 02-27-2023

Your Usual Update Announcement

Just keep in mind guys that this script has been ported to RMXP and RMVX as well! Grinning

VX's version works the same way as VX Ace's, but the XP port needs to use 2 CONSTANTS to achieve the same effect on its own terms. Winking If you have worked with Hashes before, it will be a piece of cake.


RE: EKuipSwitch - kyonides - 04-26-2023

Official Add-On for EkuipSwitch XP

Available Now!

Due to a strange help request thread I had read some time ago, I came up with this add-on to allow the game developers predefine the game variables that will be used by your game any time a hero equips or unequips any weapon or piece of armor.

I hope this will help anyone already using my EkuipSwitch XP script a lot. Winking 

Code:
# * EkuipVar XP -- EkuipSwitch XP Add-On * #
#   Scripter : Kyonides Arkanthes
#   2023-04-26

# This script works pretty much the same way EkuipSwitch XP script does.
# The only difference is that you must assign some unique Game Variable ID
# for every Equip Slot currently available in your game project.
# Setup the VARS_4_EQUIP_IDS Constant accordingly.
# 1st Slot stands for the weapon, the 2nd Slot for the 1st piece of armor, etc.

#   ACTOR_EQUIP_VARS = { ActorID1 => [Slot1Var, etc.], etc. }

# If you equip or unequip a weapon or armor included in one of the constants:
#   VAR_WEAPON_VALUES = { WeaponID1 => Value, etc. }
#   VAR_ARMOR_VALUES  = { ArmorID1 => Value, etc. }

module EKuipSwitch
  ACTOR_EQUIP_VARS = { 1 => [1, 2, 3, 4, 5] }
  VARS_4_EQUIP_IDS.default = [0, 0, 0, 0, 0]
  VAR_WEAPON_VALUES = {}
  VAR_ARMOR_VALUES = {}
  def self.var_value(type, item_id, equipped)
    return 0 unless equipped
    type == 0 ? VAR_WEAPON_VALUES[item_id] : VAR_ARMOR_VALUES[item_id]
  end
end

class Game_Actor
  def turn_equip_var(equip_type, equip_id, in_use)
    var = EKuipSwitch::ACTOR_EQUIP_VARS[@actor_id][type]
    $game_variables[var] = EKuipSwitch.var_value(equip_type, equip_id, in_use)
  end

  def update_equip_switches(equip_type, old_id, new_id)
    return if @is_temp_actor or old_id == new_id
    equip_type = 0 if equip_type == 1 and @dual_wield
    turn_equip_switch(equip_type, old_id, false)
    turn_equip_switch(equip_type, new_id, true)
    turn_equip_var(equip_type, old_id, false)
    turn_equip_var(equip_type, new_id, true)
    true
  end
end