Force action using current character

So I originally wanted to have an item that does a skill when used. I had a look at the forums and realized that force action is the way to go. Unfortunately, you can't target the current character so it looks like i'll have to use a script. I have no script experience nor do I know how to use ruby so I looked online and tried to learn to come up with a script that would work which obviously didn't, hence why I made the post. So if anyone could be kind enough to help I'd be very appreciative.
you can't target the current character so it looks like i'll have to use a script.
What do you mean? Because there are various way to do this. You could, for example, use a dummy skill that stores both caster and target in variables using the skill formula and then forces the action based on those variables. It is completely possible without using a script. If you mean something different then you have to add more details.
Thanks for the reply. I think i like that dummy skill idea tho.

If its not too much trouble, could you show how that method is done. Mainly asking because I'm not sure how to use the force action command using variables.
Storing user and target information in variables using skill formula can be done this way:
Code:
$game_variables[USER] = a; $game_variables[TARGET] = [] unless $game_variables[TARGET].is_a?(Array); $game_variables[TARGET] << b; 0
The 0 in the end is to ensure that your dummy skill deals no damage/healing.

In your event you should use the following script call:
Code:
$game_variables[TARGET].length.times do
  b = $game_variables[TARGET].pop
  next if (b.dead?) # skip if target is already dead
  i = 0
  # I am not too sure about this part
  SceneManager.scene.all_battle_members.each.with_index do |battler, index|
    if battler == b
      i = index
      break
    end
  end
  $game_variables[USER].force_action(skill_id, i) # see note
end

NOTE:
I am not too sure about the part that gets the target index because I do not remember if you have to pass a target index or a target to the force_action method. If you have to pass an index, it should work that way. I am not too sure if you need the enemy index in the troop array or if you need its index in the all_battle_members array, but that should be changed easily and it is easy to verify. If you have to pass the target instead of its index, you can just change the line with the "see note" comment into this:
Code:
$game_variables[USER].force_action(skill_id, b)
If this is the case you can completely remove everything from i = 0 to that line (except for that line, of course).

I would check this myself, but I am currently unable to access the engine and I have to rely on my memory. I hope this helps you.
a more easier to learn method is using a dummy state instead of variables to store data. It requires a lot more eventing, but is easier to learn and can be applied to other options.

the item is set to affect the user, and places an invisible state on that actor (no icon, no texts, just a statename that you can identify "usedpotionx")
then it calls a common event.

on the common event you check every actor by conditional branch if it has that state applied - if yes then you have found the user and can give a force action with that actor as user.
Don't forget to remove the invisible state
Thanks to the both of you. I'll give the code a try first thing tomorrow and if that doesn't work I'll use the invisible state.

Really appreciate the quick replies. 🙂
So I thought about using the code but I'm not gonna lie, it looks pretty daunting to me. I'm assuming that this dummy skill essentially forces a character to use another skill by storing the skill user as a variable and utilizing 'force action' to trigger another skill. But I'm not sure how I would trigger the dummy skill using an item, seems like I end up back where I started. Apologies if I've misunderstood the code.

But the dummy status works like a charm. Thanks to both for your ideas. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/force-action-using-current-character.110378/