How to change target for items during the game

Does anybody knows how to change items characteristics during the game? I've set up a target for an item (use on ally) and I want to change the target during the game (use on enemy). Thanks!
Moved to: VX Ace Support

Create two items in your database. At the point when you want to change the target, use Control Variables to determine how many of that item (use on ally) are in inventory. Then use Change Items once to remove that many of the (use on ally) item, and again to add that many of the (use on enemy) item.
Moved to: VX Ace Support

Create two items in your database. At the point when you want to change the target, use Control Variables to determine how many of that item (use on ally) are in inventory. Then use Change Items once to remove that many of the (use on ally) item, and again to add that many of the (use on enemy) item.
Thank you for your answer and for post moving, I'm new here, sorry for the misplace.
I'm not good enough in Variables using, could you show me what you mean with a script ora an image? Thans!
1678536765671.png


1678536790900.png


Items 17 and 18 are exactly the same, except the first one works on an ally and the second one on an enemy (in your database, the names would be exactly the same as well).

Now that you know how many of the first one are in inventory, you can remove them and add that number of the second one.

1678536886663.png

1678536906958.png


And this is what your event looks like:
1678536929874.png
Thank you very much!!
This is an option if you want to go the script method.
Take note that this is not fully tested.
Spoiler: Change item scope
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Change Item/Skill Scope      ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║                                     ╠════════════════════╣
# ║  Alter Item and Skill Scopes        ║    11 Mar 2023     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║                                                          ║
# ║    Use script command to change the skill scope          ║
# ║      change_skill_scope(skill_id, scope)                 ║
# ║      e.g.                                                ║
# ║      change_skill_scope(14,3)                            ║
# ║                                                          ║
# ║    Use script command to change the item scope           ║
# ║      change_item_scope(item_id, scope)                   ║
# ║      change_item_scope(1,3)                              ║
# ║                                                          ║
# ║    List of scopes:                                       ║
# ║      0 = none                                            ║
# ║      1 = one enemy                                       ║
# ║      2 = all enemies                                     ║
# ║      3 = 1 random enemy                                  ║
# ║      4 = 2 random enemies                                ║
# ║      5 = 3 random enemies                                ║
# ║      6 = 4 random enemies                                ║
# ║      7 = 1 ally                                          ║
# ║      8 = all allies                                      ║
# ║      9 = 1 ally (dead?)                                  ║
# ║      10 = all allies (dead?)                             ║
# ║      11 = the user                                       ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║   2023-Mar-11 - Initial publish                          ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Terms of use:                                            ║
# ║ Free for all uses in RPG Maker VX Ace - except nudity    ║
# ╚══════════════════════════════════════════════════════════╝

#==============================================================================
# ** DataManager
#==============================================================================
module DataManager
  #--------------------------------------------------------------------------
  # * Create Save Contents
  #--------------------------------------------------------------------------
  class <<self; alias make_database_save_skill_item make_save_contents; end
  def self.make_save_contents
    $game_player.load_data = true
    contents = make_database_save_skill_item
    contents
  end
end # DataManager

#==============================================================================
# ** Game_Temp
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :skill_scope
  attr_accessor :item_scope
  attr_accessor :load_data
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias r2_temp_item_skill_scope_init  initialize
  def initialize
    r2_temp_item_skill_scope_init
    @skill_scope = []
    @item_scope = []
    @load_data = false
  end
  #--------------------------------------------------------------------------
  # common cache: load_scope_for_item
  #--------------------------------------------------------------------------
  def load_scope_for_item
    @item_scope.each do |i|
      $data_items[i[0]].scope =
      $data_items[i[1]]
      $game_party.items.each do |h|
        if h.id == i[0]
          h.scope = i[1]
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # common cache: load_scope_for_skill
  #--------------------------------------------------------------------------
  def load_scope_for_skill
    @skill_scope.each do |i|
      $data_skills[i[0]].scope =
      $data_skills[i[1]]
      $game_party.members.each do |a|
        a.skills.each do |s|
          if s.id == i[0]
            s.scope = i[1]
          end
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias r2_skill_item_scope_update  update
  def update
    r2_skill_item_scope_update
    if @load_data == true
      load_scope_for_item
      load_scope_for_skill
      @load_data = false
    end
  end
  #--------------------------------------------------------------------------
  # common cache: set_scope_for_skill
  #--------------------------------------------------------------------------
  def set_scope_for_skill(skill_id, scope)
    found = false
    id = nil
    for i in 0..@skill_scope.size - 1
      if @skill_scope[i][0] == skill_id
        found = true
        id = i
      end
    end
    if found == true
      @skill_scope[id][1] = scope
    else
      @skill_scope << [skill_id, scope]
    end
  end
  #--------------------------------------------------------------------------
  # common cache: set_scope_for_item
  #--------------------------------------------------------------------------
  def set_scope_for_item(item_id, scope)
    found = false
    id = nil
    for i in 0..@item_scope.size - 1
      if @item_scope[i][0] == item_id
        found = true
        id = i
      end
    end
    if found == true
      @item_scope[id][1] = scope
    else
      @item_scope << [item_id, scope]
    end
  end
end

#==============================================================================
# ■ Game Interpreter
#==============================================================================
class Game_Interpreter
  def change_skill_scope(skill_id, scope)
    $data_skills[skill_id].scope = scope
    $game_player.set_scope_for_skill(skill_id, scope)
  end
  def change_item_scope(item_id, scope)
    $data_items[item_id].scope = scope
    $game_player.set_scope_for_item(item_id, scope)
  end
end
First of all, there's no skill ID 0 so that's a real issue there. Plus, why do you want the player to keep loading the skill scope data every time the Game_Player update method is called?
First of all, there's no skill ID 0 so that's a real issue there. Plus, why do you want the player to keep loading the skill scope data every time the Game_Player update method is called?
If someone was to use the script call to load skill 0 into the array then sure it could have a problem.
So I suppose adding a line to check for 0 could be done, but at the same time if you tried adding skill 1983893 to the array it would also fail. So this is a user error not the script.
I went through a few places to attempt to get this to work and ended up on game player when I finally discovered the things I was doing wrong. So I basically left it there. As game player is one of the groups that get saved automatically it seemed a good enough place. But then I needed a way to load the data and change the scope when loading a save game. So update it is. But as you suggested without understanding (I'm guessing) game player update is run a lot, which is why I added the check to only do it when the value is true. Which it is as it is set to true when saving the game, otherwise it is false and will never load the data.
So is it a problem to have game player update check for one extra value every time and never process the rest of the script ever while playing? Unless the dev adds in a new value and saves the game.
So maybe I can set the value to false after saving the game. Have to think on that one.
Thanks to everybody for answers, I followed Shaz's advice and it works for me. I just wanted a very simple and quick trick to block the access to items, so I made two identical items but the player can use only one of them.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-change-target-for-items-during-the-game.155685/