Force action using current character

bigboi567

Villager
Member
Joined
Jun 9, 2019
Messages
5
Reaction score
0
First Language
english
Primarily Uses
RMVXA
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.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
594
First Language
Italian
Primarily Uses
RMVXA
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.
 

bigboi567

Villager
Member
Joined
Jun 9, 2019
Messages
5
Reaction score
0
First Language
english
Primarily Uses
RMVXA
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.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
594
First Language
Italian
Primarily Uses
RMVXA
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.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,235
Reaction score
7,617
First Language
German
Primarily Uses
RMMV
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
 

bigboi567

Villager
Member
Joined
Jun 9, 2019
Messages
5
Reaction score
0
First Language
english
Primarily Uses
RMVXA
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. :)
 

bigboi567

Villager
Member
Joined
Jun 9, 2019
Messages
5
Reaction score
0
First Language
english
Primarily Uses
RMVXA
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. :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Profile Posts

Anyone know the best size image to put in signature?
Well, the local collections agency is hiring... bleh. I'm not rude enough for them to hire me. Even the people they collect FOR don't like dealing with them. >.>
EA: "Kids are buying currency, not using money to gamble. It shouldn't be illegal!"
Me: "So... kids should be allowed into casinos to buy poker chips and not spend them at the blackjack table? Pretty sure, even buying currency used to gamble is illegal for children."
Been hard at work in photoshop working with MOG scripts for main menu & victory result screens, might do all my maps and Npc chatter this week too!
rux
The most words I have ever written in an entire document is in my game's script, jeez i have a lot of characters that ramble on

Forum statistics

Threads
105,495
Messages
1,014,189
Members
137,153
Latest member
cottonfrog
Top