Party's equipped weapons/armour

● ARCHIVED · READ-ONLY
Started by Sel Feena 1 posts View original ↗
  1. 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[0]
          when "w"
            check_weapons_equipped(monitor[1], monitor[2], monitor[3])
          when "a"
            check_armour_equipped(monitor[1], monitor[2], monitor[3])
          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[weapon_id])
          break if result == true unless all_members
          break if result == false if all_members    
        }
        #Endeach.
        $game_switches[switch_id] = 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[armour_id])
          break if result == true unless all_members
          break if result == false if all_members    
        }
        #Endeach.
        $game_switches[switch_id] = 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