Use an item once per battle

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
I am trying make an item that can only be used once per battle, and I'm hitting a brick wall.

One option:
Switch turned on turn 0 of each battle. Item calls common event which checks if a particular switch is ON. If it is, does forced action on a skill, and turns that switch OFF. The problem is that Forced Action requires that I specify a particular actor to use the skill, but I cannot know which actor the player has chosen.

Another option:
Use the damage formula of the item itself. No problem about which actor it is - but I can see no way of preventing it being used again that battle.

Does anyone have any insight into how this might be done?

Thanks.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,370
Reaction score
7,678
First Language
German
Primarily Uses
RMMV
make the item set a state on the user, and have that state invisible (no message, no icon, no effect).
then in the common event, check which actor has that state and use a force action on that actor, remove the state after that.

you'll need one conditional branch for each actor in your game in the common event, but it will work without problems if you go that route - as long as you don't have too many actors.
 
  • Like
Reactions: Kes

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
You could use script and do a .select on the party members to filter out which one has the state and that will save you needing a conditional branch for every actor.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@Trihan Could you spell that out in baby steps? My head doesn't seem to be working well today, and I don't understand clearly what you mean.
 

Tiamat-86

old jrpg gamer
Veteran
Joined
Dec 5, 2017
Messages
555
Reaction score
230
First Language
english
Primarily Uses
RMMV
item restriction scripts using !states.
use item normally but then common event adds state to all actors which blocks using that item
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
@Trihan Could you spell that out in baby steps? My head doesn't seem to be working well today, and I don't understand clearly what you mean.
$game_party.alive_members.select { |member| member.has_state?(id of state)}[0]
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@Trihan Told you my head is not working - I didn't explain myself well.
I know about the .select script call, but what I can't work out is how to use that to inform the Force Action command which one it is. There is no option in that command except a named actor.
Sorry for being so slow on the uptake. Maybe I need more caffeine.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
Oh, I was suggesting that you use the script call for forcing action rather than the event command.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@Trihan I think you are about to tear your hair out, because I still don't understand what you are saying.

The item inflicts state 155 on the user. In the common event which the item calls up I have the script call with that state id. (Not sure what the 0 at the end does, but still). How does that script call force the actor to use skill 110?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
.select gives you an array of elements that meet the criteria. [0] gets the first element in that array.

You'd then store that in a variable and have the battler call the force action method:

Code:
actor =  $game_party.alive_members.select { |member| member.has_state?(155)}[0]
actor.force_action(110, target id here)
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@Trihan Light is slowly dawning.
One last question. You have target id. How do I know which enemy the actor has chosen to target? I suppose it would be the equivalent of 'Last target' in the event command version, but I don't know the script call equivalent.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
actor.last_target_index, or just enter -2 and the method will use the last target index itself.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@Trihan
So I did the script call like this (copy/pasting from your posts):
Code:
$game_party.alive_members.select { |member| member.has_state?(155)}[0]
actor.force_action(110, actor.last_target_index)
Which gives this error message

1598899994771.png
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
Sorry, I got the method wrong. It's just state?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
You didn't put actor = at the beginning of the select line.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@Trihan And finally, gasping and panting, I stagger over the finishing line.

Thank you so much for all your help. You've shown the patience of a saint.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
It's born of many long years of helping Kes with VX Ace queries. ;)
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,960
First Language
English
Primarily Uses
RMMV
I didn't mean that in a disparaging way at all, but I do tend to jump in immediately whenever you ask a question. :p
 

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

Latest Threads

Latest Profile Posts

I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:
attack on titan final season is airing tomorrow, I'm excited and scared at the same time!

Forum statistics

Threads
105,882
Messages
1,017,230
Members
137,607
Latest member
Maddo
Top