じ☆ve冰风 发表于 2026-7-26 13:19:36

Party's equipped weapons/armour

Sel Feena's Party Equipment Monitor V 1.0



 

Introduction

This script allows users to automatically keep tabs on if specific weapons or armour are equipped by the current members of their party. This is done by creating a checklist inside the script; if the weapon/armour is equipped by one or all members of the party (you can choose which), a switch is flipped ON. If not, it is OFF. There are no script calls to make, just some setup within the script.

 

Features

- Monitor if any members in your party have a specific weapon/armour equipped.

- Choose if the ALL party members are required to have an item equipped or not (could be good for infiltration subgame?)

 

 

Screenshots

N/A

 

How to Use

You build a checklist of weapons and armour to check by editing the CHECKLIST array inside the script. Let's say that:

- If any member of my party has weapon 1 equipped, I want to flip switch 10 ON

- If all members of my party have armour 4 equipped, I want to flip switch 11 ON

Then my CHECKLIST would look like this:

 

  CHECKLIST = [

  # [ equip type ("a" = armour, "w" = weapon), DB ID, all party equipped?, switch ID ]

    [ "w",                                     1,     false,               10 ],

    [ "a",                                     4,      true,               11 ]

  ]

 

Demo

N/A

 

Script

 

                Code:       
#==============================================================================
# Equipment Checks V 1.0 by Sel Feena
#
# A simple script that will flick switches on/off if it is equipped.
# You can check weapons/armour, and specify if all members have to have this
# equipped to work.
#
# Credits go to NeonBlack for his Equipment and Skill Check Ace Scriptlet,
# for showing me how to access the data needed. :3
#
# This script will run through the checklist whenever new armour/weapons
# are equipped, and also when party members are added or removed.
#
# INSTRUCTIONS
#
#  You build a checklist of weapons and armour to check by editing the CHECKLIST
#  array below. Let's say that:
#  - If member of my party has weapon 1 equipped, I want to flip switch 10 ON
#  - If all members of my party have armour 4 equipped, I want to flip switch 11 ON
#  Then my CHECKLIST would look like this:
#
#  CHECKLIST = [
#  # [ equip type ("a" = armour, "w" = weapon), DB ID, all party equipped?, switch ID ]
#    [ "w",                                     1,     false,               10 ],
#    [ "a",                                     4,      true,               11 ]
#  ]

#
#==============================================================================
 
module SLF_EquipCheck
  CHECKLIST = [
  # [ equip type ("a" = armour, "w" = weapon), DB ID, all party?, switch ID ]
  ]
  
  def self.update
    CHECKLIST.each { |monitor|
      case monitor
      when "w"
        check_weapons_equipped(monitor, monitor, monitor)
      when "a"
        check_armour_equipped(monitor, monitor, monitor)
      end
    }
  end
 
  def self.check_weapons_equipped(weapon_id, all_members, switch_id)
    result = false
    $game_party.members.each { |party_member|
      result = party_member.weapons.include?($data_weapons)
      break if result == true unless all_members
      break if result == false if all_members    
    }
    #Endeach.
    $game_switches = result
  end
  
  def self.check_armour_equipped(armour_id, all_members, switch_id)
    result = false
    $game_party.members.each { |party_member|
      result = party_member.armors.include?($data_armors)
      break if result == true unless all_members
      break if result == false if all_members    
    }
    #Endeach.
    $game_switches = result
  end
end # SLF_EquipCheck
 
#==============================================================================
# Aliasing Game_Party to run checks on party change
#==============================================================================
class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * Add an Actor
  #--------------------------------------------------------------------------
  alias slf_add_actor add_actor
  def add_actor(actor_id)
    slf_add_actor(actor_id)
    SLF_EquipCheck.update
  end
  #--------------------------------------------------------------------------
  # * Remove Actor
  #--------------------------------------------------------------------------
  alias slf_remove_actor remove_actor
  def remove_actor(actor_id)
    slf_remove_actor(actor_id)
    SLF_EquipCheck.update
  end
end # Game_Interpreter
 
#==============================================================================
# Aliasing Game_Actor.change_equip to run checks on equipment change
#==============================================================================
class Game_Actor < Game_Battler  
  #--------------------------------------------------------------------------
  # * Change equipment
  #--------------------------------------------------------------------------
  alias slf_change_equip change_equip
  def change_equip(slot_id, item)
    slf_change_equip(slot_id, item)
    SLF_EquipCheck.update
  end  
end #Game_Actor


 

FAQ

Q: Where do I put this?

A: Above Main, below Materials

 

Q: Where are the script calls needed?

A: None are necessary. When you change equipment in for your characters, or change party members (through either an event call or by using script calls), this script should detect it.

 

Q: What about custom weapon/armour setups?

A: I've tested this out briefly with Yanfly's scripts and there doesn't seem to be an issue.

 

Credit and Thanks

- Sel Feena

- Shaz & Tsukihime for clearing up my confusion regarding aliases

- Neon Black's very clear script highlighting where the weapon and armour info can be accessed.

 

Author's Notes

For the next version it could be nice to:

- Specify a specific actor that must have the item equipped

- Monitor the count of specified items, using a variable to update it


本贴来自国际rpgmaker官方论坛作者:Sel Feena处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/partys-equipped-weapons-armour.17085/
页: [1]
查看完整版本: Party&#039;s equipped weapons/armour