VX/VXA Delayed/Charged actions over multiple turns

Hello. First post and new to RPGM.

Trying to make an actor cast a skill -> cannot move/act for X amount of turns -> Spell comes out.
Note: I don't want the actor actionable at all, so I don't want to treat it the same way as "learn skill when under state"

What I did: made the skill to add a State to User, State is unable to move for X turns. I thought of then making a call with "Force action" on actor through common event or something. But I can't figure out what or how to do it. Having a loop conditional branch freezes the game, as I am not sure how to make it trigger after the condition is met (no longer under state).

Also tried Yanfly's Lunatic States script. Seems exactly what I am looking for (and need for the future). But I don't understand how to use it, so guidance there is also very appreciated.

Thanks for reading
Hime's Casting Time script does what you need. The link from Hime's site doesn't work any more (at least for me), but I saved it when it was still available. I'll attach it, since I'll assume that while there is the link on her site, Hime is fine with people sharing it (and I guess it could be retrievable through wayback machine).
Thank you. That works great.

I should close the thread somehow (if I can), but if possible I want to ask for another thing.

I have an issue with having a skill both deal damage to enemy(s), and simultaneously heal the actor. With trial and error I could only heal the party leader actor, or a specific index? (instead of the actor that used the skill), through calling a common event with a script.

That said, do you have any tips for figuring things out? I don't want to make a thread every time I'm stuck because I don't know whether it's a basic eventing thing, or a more complex/scripting thing. I have the time but I need some direction. Thanks again
Should the damage to the enemy be the same as the heal to the user? I think this could be done in the damage formula, I just need to know the details to tell you exactly what to do. So step by step what should be happening when the skill is used.
Should the damage to the enemy be the same as the heal to the user? I think this could be done in the damage formula, I just need to know the details to tell you exactly what to do. So step by step what should be happening when the skill is used.
Right. I want the skill to do damage to enemy (say, atk * 4 in damage formula), and heal the actor by 25% of their max hp.

My attempts at doing so in formula would heal the enemy instead of the actor.

Instead I set it to trigger a common event with a script (that I seemingly deleted) because it only healed the party leader, or whatever was in index 0, Instead of the actor. I hope this answers you

====

For my original post issue (delayed/charged attacks), I set it up to work by using:
Skill (no damage, assigns variable1 to skill ID in the damage formula & adds a state to actor) -> state expire calls common event -> common event conditionally triggers different force actions based on variable1 == constant(Skill ID, inputted manually) in conditional branches.
I'm trying not to rely on scripting alone, so I try to do it natively while slowly learning scripts/ruby

Why does the damage formula accept ruby code? How does notebox accept code/script-call with some scripts? A lot of things that may seem easy but I'm quite lost as a newbie. Especially when I mix up what is native to the engine, and what actually comes from a script I installed without properly understanding it.

I also tried looking for script call to do Force action (actor using skill) but I couldn't find an answer online. Where do I even start with figuring it out on my own? Hopefully with time as I learn ruby and read everything under "Game Objects" in scripts tab.
So for the skill that should do damage to enemy and heal actor, you can put something like this in the damage formula (having set HP damage in the Damage type window):

a.hp+=a.mhp/4 ; a.atk*4

In the damage formula, a is the user, and b is the target - so you have for example a.atk*4 - b.def*2, user's attack stat times 4 minus target's defence stat times 2. So in the above, a.hp is the user's HP, += means adding, a.mhp is user's maximum HP, and a.mhp/4 will be the 25% of user's max HP that you want to add. The last value in the formula window is always the damage to be done. So you first write out everything you want to happen (divided by ; ) and as the last you put the damage.

For example, I have a skill that deals damage to enemy and then heals the actor by part of that damage. My formula for that looks like this:

v[13]=a.atk * 4 - b.def * 2; a.hp=a.hp+(v[13]/2); v[13]

First the damage is calculated and put in a variable; then the user is healed by half of that damage (I see that I complicated things, could have done just a.hp+=(v[13]/2), but it works like this, too); and then the damage happens (only denoted by the variable).

If you want to link common events to skills, and you need to know who is the user, or who is the target, you can store these in variables in the damage formula, too, for example like this:

v[105]=b.index() ; v[106]=a.id ; a.atk * 5 - b.def * 2

Variable 105 is the target's index (its position in the troop). Variable 106 is the user's (actor's in this case) ID. Then there's the damage. You can use these variables in your common event to identify the user/target.

For example, you can do this in the common event:

$game_actors[$game_variables[106]].force_action(267, $game_variables[105]);
BattleManager.force_action($game_actors[$game_variables[106]])

which would make the user perform skill 267 on enemy index stored in variable 105. The second line executes the command. (This also answers your question about how to do Force action.)

To be honest, I don't really understand the workings of the engine, so I can't answer those questions for you. But maybe you can look at some tutorials for VX Ace on this forum. There's also a thread about script calls here. It is overwhelming for a new user for sure, but take it step by step and you'll master it in no time :LZSwink:


Edited to add: For the delayed action, I'm afraid you'd need one script or another anyway. For example one that allows you to add commands when a state is added or removed. Do you still want to do it on your own, or will you use Hime's script?
v[13]=a.atk * 4 - b.def * 2; a.hp=a.hp+(v[13]/2); v[13]

I feel dumb. I was already using variables in damage formula but didn't occur to me at all to use them like that outside of damage calculation. Works great. Solved multiple issues I had

For example one that allows you to add commands when a state is added or removed.
Hime did work but I want more freedom/understanding. I have switched to Yanfly's Lunatic states

```<leave effect> $game_temp.reserve_common_event(12) </leave effect>```

With that triggering a common event and uses the force action script you sent. Thank you.
Similarly I just assign skill ID to a variable in the formula so that I only need a single common event for all charged skills.

After annoying trial and error I noticed that I couldn't use double digits in the script call
$game_actors[$game_variables[10]].force_action($game_variables[11],$game_variables[9]);
BattleManager.force_action($game_actors[$game_variables[10]])

using bigger variable numbers led it to wrap to the line below (in common event -> script), and even if I delete the extra hidden spaces, it would give an error and crash on execute. How do I deal with this?

And if possible, similarly to how you grabbed actor id and enemy index with "v[105]=b.index() ; v[106]=a.id" Could you tell me how can I look for skill ID in the same way? That way it's assigned to a variable like the other two. How do I know where something like that myself? Am I expected to search google/threads or can I find them easily through default engine scripts?
=================
Since then I've read a little on the game's default scripts, and with help of AI I got a tiny script running that lets me grab the turns left on a state. And use that in damage formula for some of the spicy skill ideas I had. text & eval type notetags, etc. fun stuff, but super ing confusing lol. Thanks as always
I think that if you put it like this

$game_actors[$game_variables[10]].force_action($game_variables[11],
$game_variables[9]);
BattleManager.force_action($game_actors[$game_variables[10]])

then it should work, but I'm not 100% sure. It should be possible to go to a new line after commas and such (places where a space can be inserted).

What exactly do you need with the skill ID? I know how to check if an actor knows a skill, but not much else.

The script calls thread that I linked in my previous post is really useful, although there are some things missing. I also used to search for script calls a lot, and copied everything I found into a text file, so now I search that :LZSproud: But I often have to go back to it because I tend to forget how I did things before, while you seem to be absorbing it all much better.

Original thread: https://forums.rpgmakerweb.com/threads/delayed-charged-actions-over-multiple-turns.182047/