Item user PHA

Discussion in 'RGSSx Script Support' started by Topdod, Jan 1, 2019.

  1. Topdod

    Topdod Villager Member

    Messages:
    8
    Likes Received:
    0
    Not sure if I'm missing something obvious here or not but when from the item menu NOT in battle, using an item uses whoever has the highest PHA stat or leader.

    I'm using Hime's Custom Use Conditions script which allows me to have requirements to use an item which in this case is a state but here is the problem as whoever is in front of the party will only ever use the item on the rest of the party and the item's condition isn't used for anybody but the first actor.
    If actor 1 uses the item on themselves it locks out the entire party from using this item but if the item is used on anybody but the first it can be used until there is no more of the item left.

    I guess like the target of the item would use the item on themselves instead of whoever had the highest PHA.
    This would let me give a buff, make the party member wait X amount of battles for it to wear off and then they can use the item again.

    Edit:
    Ah, sorry about posting in the wrong place.
    Hime script
    http://himeworks.com/2013/11/custom-use-conditions/
     
    Last edited: Jan 1, 2019
    #1
  2. Kes

    Kes Global Moderators Global Mod

    Messages:
    19,891
    Likes Received:
    10,197
    First Language:
    English
    Primarily Uses:
    RMVXA

    I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


    Would you please edit your post to include a link to the web page where you got that script. That way if anyone needs to check something before making a suggestion, they won't have to go hunting.
    Thanks
     
    #2
  3. Another Fen

    Another Fen Veteran Veteran

    Messages:
    501
    Likes Received:
    222
    First Language:
    German
    Hey there,

    Haven't tested it yet or anything (again), but you could try to use this as an additional script:
    Code:
    # ============================================================================
    #  * Menu Item User Fix
    #    Version 1.0 (January 4th, 2019)
    #    by Another Fen <forums.rpgmakerweb.com>
    # ----------------------------------------------------------------------------
    #  This script attempts to change the "user" for items used from the menu, so...
    #  ...items with self-scope should now be used by the target.
    #  ...items are used by a party member that can actually use the item
    #     (e.g. if item usablility is restricted through other scripts).
    #  ...reusing an item after immobilizing the party with it does not cause an
    #     error.
    # ----------------------------------------------------------------------------
    #  Place this script within the "▼ Materials" section of the script editor.
    #  The script overwrites  Scene_ItemBase#user  and should be placed above
    #  other scripts that alias this method.
    # ============================================================================
    
    class Scene_ItemBase
      # Scene_ItemBase#user  (Redefined)
      # Try to find a user that can actually use the item, and fix self-scope
      def user
        users = (item && item.for_user?) ? item_target_actors : $game_party.members
        return users.select { |a| a.usable?(item) }.max_by { |a| a.pha } || users[0]
      end
    end
    
     
    #3

Share This Page