Cant figure out what's wrong with my script call.

I'm trying to create a common event for one of my skills which gives the player another action if their attack misses. I've tried YEP's Battle plugins, but figured they were too complicated at the moment. After a while of testing different methods I found another forum post that talks about the Game_ActionResult.missed script call, so I tried it (see screenshot). It doesn't work. I've assigned the common event to my attack skill and tested it out with other event commands and those events will trigger, so Its gotta be the script call. I've marked out my plugins being the problem. I think my problem is formatting the call, like I'm missing something that goes before or after Game_ActionResult.missed. I've been cracking at this for hours to no avail, im not JavaScript literate in the slightest which is why ive looked for help with this command but nothing comes up. Very frustrated with this, any help would be appreciated. Thanks.
image_2024-05-01_215055047.png
As a tip, when you're referring to things you've read in other threads, please provide links to them. It will help us to clarify anything when we have the correct context.

Game_ActionResult.missed is not a valid script call. Game_ActionResult is a data type, not something that has innate/generic meaning. The target of your skill will have a property of the type Game_ActionResult attached to them.

You can try BattleManager._targets[0].result().missed

I also don't think that adding a state (which presumably has Action Times+ on it) at that point in battle will give the actor another turn. It's been a while since I looked, but I believe the number of actions is calculated at the beginning of the round, so adding the state at this time won't have any effect. But you can try it.

Things are always complicated when you try to mess with extra actions/turns, but using plugins would definitely be a much easier way to approach it, even if you have to ask for help getting the correct code.
Sorry to ask, I don't mean to hijack this thread, but I'm very curious to know more about getting extra actions/turns, and why it is so difficult. I'm having a hard time giving extra turns to my battlers under specific conditions as well, so I'm really interested in knowing more.
I don't mean to hijack this thread
Well, then you could just have easily asked in a new thread 😉 But since we're here:
I'm very curious to know more about getting extra actions/turns, and why it is so difficult.
Simply because the engine is not designed to do that.

It has the Action Times+ trait, and that's it. There's no provision in the code for you to tell it "go back and give this battler another turn," so you have to find the specific states of various properties of the battle manager.

Then you try to manipulate them to let the player go back to choosing an action for a battler without disrupting the rest of the turn that's already in process.

It's a bit like trying to insert extra pages into a book that's already been printed.
Sounds awful, indeed lol...

Thank you for the explanation. I was planning on working on a script to give bonus turns instead of bonus actions, but reading this kind of killed my expectations. Perhaps I should make a thread for this, I don't know.

Best of luck JoeBumpster, I hope you can achieve what you have in mind.

​

As a tip, when you're referring to things you've read in other threads, please provide links to them. It will help us to clarify anything when we have the correct context.

Game_ActionResult.missed is not a valid script call. Game_ActionResult is a data type, not something that has innate/generic meaning. The target of your skill will have a property of the type Game_ActionResult attached to them.

You can try BattleManager._targets[0].result().missed

I also don't think that adding a state (which presumably has Action Times+ on it) at that point in battle will give the actor another turn. It's been a while since I looked, but I believe the number of actions is calculated at the beginning of the round, so adding the state at this time won't have any effect. But you can try it.

Things are always complicated when you try to mess with extra actions/turns, but using plugins would definitely be a much easier way to approach it, even if you have to ask for help getting the correct code.
Sorry about not posting the OG thread. will do in the future: https://forums.rpgmakerweb.com/index.php?threads/state-applying-on-missed-attack.147266/

I changed the script call to what you typed, and it still wont run. I swapped out the state change call for decreasing the hp of the user so it'd be easier to differentiate. You're right though, this would be way easier to do with a plugin which is probably what I'm going to have to do. I looked for about an hour or so before I posted this thread for any info on YEP's battlecore that could help me and didn't find anything too useful (that I know of at least). Would you or anyone know of any good guides for YEP's battlecore/ YEP's action sequence packs that dumbs it down for a normie like me? Thank you guys for the replies.
image_2024-05-01_233447951.png
Is that common event even called?
Please post a screenshot of either the skill or the event that is calling it.
and one more tip: in such cases where you don't know if an event works, include a test message with show text to find out where the problem may be.
posting the OG thread
It really isn't of consequence, but I don't see the syntax you tried to use anywhere in that thread. The closest I see is Kenen's post #3, where he says "Game_Action has result.missed and result.evaded," but again - he's talking about properties of a data type, that isn't code syntax you can take and use in any given context.

Would you or anyone know of any good guides for YEP's battlecore/ YEP's action sequence packs that dumbs it down for a normie like me?
I really don't know of a good way to do what you want using any of these plugins.

It's easy to apply a state to an actor if their attack misses, but as I said above I strongly suspect that won't do anything.

You'd install Yanfly's Buffs & States Core and Yanfly's Auto Passive States. Follow the instructions to create a state and put it on your actor as a passive state.

Give it the notetag:
Code:
<Custom Conclude Effect>
if (target.result().missed)
    user.addState(42);
</Custom Conclude Effect>
where 42 is the ID of the state you want to add.

You might try doing this backwards...give the actor two actions by default (give it the Action Times+ trait), then when something hits you apply a state for one turn that has the Cannot Move restriction.
Is that common event even called?
Please post a screenshot of either the skill or the event that is calling it.
and one more tip: in such cases where you don't know if an event works, include a test message with show text to find out where the problem may be.
I currently have it set to trigger after an attack (which I'm pretty sure is making it do nothing) and in the troop fight itself scanning from moment over the entire battle. I've posted those triggers plus the skill itself and the common event. Thank you for the tip, I am now using that as the test indicator!
1714630797644.png
1714630833826.png
image_2024-05-02_022116785.png
image_2024-05-02_021902085.png


It really isn't of consequence, but I don't see the syntax you tried to use anywhere in that thread. The closest I see is Kenen's post #3, where he says "Game_Action has result.missed and result.evaded," but again - he's talking about properties of a data type, that isn't code syntax you can take and use in any given context.
That's partially why I didn't really think to post it in the OG, but you are right; That post Kenen made was the one I was going off of. I tried that one until I realized it didnt work then consulted a script call spreadsheet: and figured "Game_ActionResult.missed" would fit it better. I must've missed the mention of it referring to data type, so I apologies for that.

I think there is a possible way to acheive what I want with YEP's Action sequence, but I also dont know what im talking about. I found a reddit thread about something similar to mine using YEP's Actioncore/sequences: But when I tried recreating it with the proper plugins installed, I couldn't get any results. I tinkered with that for around 2 hours until I put it on hold to try and recreate it using base RPG maker.
You might try doing this backwards...give the actor two actions by default (give it the Action Times+ trait), then when something hits you apply a state for one turn that has the Cannot Move restriction.
This is a very clever way of doing this and one I may try, though I'm reconsidering if its even worth it for 1 skill. I might just want to meet halfway and do something else if the player misses. Do you know of a way to maybe buff the player the following round after the player misses? Just something to benefit the player after a miss would be nice until a breakthrough occurs. If not, I will try and recreate what you suggested once my time frees up again. I didn't realize this was such a rock-hard place situation lol. Thank you for the speedy replies!
You really should take the time and read through the help file to know what each option in the editor means.
Your troop event does nothing until turn 100, then it will trigger that common event cntinuously until turn 101, at which time it stops doing anything again until turn 200 when it works again.
since battles rarely last one hundred turns it will likely never have its condition true.

Explanation: the turn condition on troop events is a mathematical formula thatcalculates on which turns the condition is true by replacing the x with 0, 1, 2, 3 and so on.
so condition turn : 100*x is true on turn 0 (before battle), turn 100, turn 200, turn 300 and so on.


The attachment to the attack skill should work, but there are a few things that should be checked:
what is the actor's HIT%? By default its 95% and most JRPGs have high hit values as well, but that means that the actor rarely misses and as a result the effect is rarely triggered - you can easily make 30 attacks before missing once with those values.

Does the common event even trigger when the skill misses? It should trigger, but I can easily see some battlesystem plugins where the programmer decided if the skill misses then the effect should not happen.
please test with a show text before the first condition, just to make sure the common event is triggered.
Just as a tip - I don't know how you were making those quotes, but you weren't using the Quote or Reply button (see how my name isn't there?) so I didn't get any notifications about it.

I think there is a possible way to acheive what I want with YEP's Action sequence, but I also dont know what im talking about. I found a reddit thread about something similar to mine using YEP's Actioncore/sequences:
You seem to have very flexible standards for "achieving what you want" 😛 (which makes it hard for us to understand what you want)

If all you want to do is apply a state, the code I gave you in my previous post will do that. The action sequence commands you linked to are a more complicated way to do that.

The point I keep bringing up is that applying a state will not take you back to the point in the turn to select another action for the actor (which is what you originally said you want).

I might just want to meet halfway and do something else if the player misses. Do you know of a way to maybe buff the player the following round after the player misses?
Again, the code I gave you will apply a state when the player misses. You can make that state have a duration of 1 action and have a Trait that increases a parameter.

Or you can look up the script call for applying a buff and put that in there instead of applying a state.
You really should take the time and read through the help file to know what each option in the editor means.
Your troop event does nothing until turn 100, then it will trigger that common event cntinuously until turn 101, at which time it stops doing anything again until turn 200 when it works again.
since battles rarely last one hundred turns it will likely never have its condition true.

Explanation: the turn condition on troop events is a mathematical formula thatcalculates on which turns the condition is true by replacing the x with 0, 1, 2, 3 and so on.
so condition turn : 100*x is true on turn 0 (before battle), turn 100, turn 200, turn 300 and so on.


The attachment to the attack skill should work, but there are a few things that should be checked:
what is the actor's HIT%? By default its 95% and most JRPGs have high hit values as well, but that means that the actor rarely misses and as a result the effect is rarely triggered - you can easily make 30 attacks before missing once with those values.

Does the common event even trigger when the skill misses? It should trigger, but I can easily see some battlesystem plugins where the programmer decided if the skill misses then the effect should not happen.
please test with a show text before the first condition, just to make sure the common event is triggered.
Your troop event does nothing until turn 100, then it will trigger that common event cntinuously until turn 101, at which time it stops doing anything again until turn 200 when it works again.
since battles rarely last one hundred turns it will likely never have its condition true.

Explanation: the turn condition on troop events is a mathematical formula thatcalculates on which turns the condition is true by replacing the x with 0, 1, 2, 3 and so on.
so condition turn : 100*x is true on turn 0 (before battle), turn 100, turn 200, turn 300 and so on.
Sorry about that, the video I used as a guide for troops never really mentioned that. I tried changing the condition to 0 to 0, which did trigger the event. However, it crashed since 'result' is undefined in the script call:

BattleManager._targets[0].result().missed

From the little I know, I think this means that I cant use this script call since its not defined anywhere. I don't know of a way/don't know if there is a way to define 'result' without extensive JavaScript knowledge.

The attachment to the attack skill should work, but there are a few things that should be checked:
what is the actor's HIT%? By default its 95% and most JRPGs have high hit values as well, but that means that the actor rarely misses and as a result the effect is rarely triggered - you can easily make 30 attacks before missing once with those values.
I swear I looked online for what determines hit% and found nothing lol. You are right, I completely missed that in the class sheet. I used to just painstakingly play the battle out until I eventually missed. I temporarily removed the script which was crashing the game and it does trigger after every attack like it should, so no plugin shenanigan's.

I think this all just comes down to the script call itself. Either there's a base script which you can call to determine if an attack has missed, or there's a plugin that can help. I'm gonna try to look a bit more into it and try and find something. If I do I'll post it here for future reference. Until then, anything would help. Thank you.
1714663598028.png

1714662715948.png
perhaps you should come from the other direction instead of searching for the script that stored the miss. Especially as I don't know how long it is stored before the next action overwrites it.

The damage formula is only executed on hit. so include script code there to turn a switch ON.

In the common event you then check that switch.
If it is on, a hit was processed and you turn it off for the next check.
If it is still off, then you know the attack missed and can react to that.

Problem here is that it might require a bit of additional logic to handle multiple battler and prevent enemies form using the same skill and so on
But it would be a valid approach.
Part of the reason why a miss never registers is because it pretty much resets after the apply() function completes. Calling for the BattleManager._targets during the common event is also too late and will give you an undefined/error.

If you have plugins that can allow you to slip code into the apply() function then you can get the results there. If not, you have to work around it.

The damage eval occurs later and is unable to get the info because it happens after the apply() function (and if the action has already be deemed as a miss,the formula never gets evaluated).

Using a "switch" or "state" that turns on when an attack is applied is a way to circumvent this issue by checking if the attack actually connected (checking for damage, etc).

Here is the one of the codes responsible for clearing results for the battler:
JavaScript:
Game_Battler.prototype.onAllActionsEnd = function() {
    this.clearResult();
    this.removeStatesAuto(1);
    this.removeBuffsAuto();
};

And it looks like any time an action/turn/battle begins or ends, the results are cleared on every one of those instances (there are way more functions in the Game_Battler and BattleManager that handles all the clearing of the results).

Or, pushing the information from the apply() function to a game variable or game temp is another way of doing it (activate this code as a plugin):
JavaScript:
_alias_Game_Action_prototype_apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
    _alias_Game_Action_prototype_apply.call(this, target);
    $gameTemp._targetResult = {target: target, result: target.result().missed};
};
With a common event, or anywhere else you may need this info, you can reference $gameTemp._missedResult and it will give you that object of target and its result - keeping the info temporarily at least until you can reference it. Do keep in mind that unless you update this information, it will remain on the last target along with its result.

You should also be able to do $gameTemp._targetResult.target to just get the target or $gameTemp._targetResult.result to just get the result.

Again, this is just one way of doing it and it may not be the best way - I had issues with this a while back and it was frustrating, but this was what I was able to come up with to work within my own prototypes/testing.
Part of the reason why a miss never registers is because it pretty much resets after the apply() function completes. Calling for the BattleManager._targets during the common event is also too late and will give you an undefined/error.

If you have plugins that can allow you to slip code into the apply() function then you can get the results there. If not, you have to work around it.

The damage eval occurs later and is unable to get the info because it happens after the apply() function (and if the action has already be deemed as a miss,the formula never gets evaluated).

Using a "switch" or "state" that turns on when an attack is applied is a way to circumvent this issue by checking if the attack actually connected (checking for damage, etc).

Here is the one of the codes responsible for clearing results for the battler:
JavaScript:
Game_Battler.prototype.onAllActionsEnd = function() {
    this.clearResult();
    this.removeStatesAuto(1);
    this.removeBuffsAuto();
};

And it looks like any time an action/turn/battle begins or ends, the results are cleared on every one of those instances (there are way more functions in the Game_Battler and BattleManager that handles all the clearing of the results).

Or, pushing the information from the apply() function to a game variable or game temp is another way of doing it (activate this code as a plugin):
JavaScript:
_alias_Game_Action_prototype_apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
    _alias_Game_Action_prototype_apply.call(this, target);
    $gameTemp._targetResult = {target: target, result: target.result().missed};
};
With a common event, or anywhere else you may need this info, you can reference $gameTemp._missedResult and it will give you that object of target and its result - keeping the info temporarily at least until you can reference it. Do keep in mind that unless you update this information, it will remain on the last target along with its result.

You should also be able to do $gameTemp._targetResult.target to just get the target or $gameTemp._targetResult.result to just get the result.

Again, this is just one way of doing it and it may not be the best way - I had issues with this a while back and it was frustrating, but this was what I was able to come up with to work within my own prototypes/testing.
I think I'm just going to work backwards like Andar said. It seems to be the best way to determine if an attack misses. Ill try it and update if it works.

perhaps you should come from the other direction instead of searching for the script that stored the miss. Especially as I don't know how long it is stored before the next action overwrites it.

The damage formula is only executed on hit. so include script code there to turn a switch ON.

In the common event you then check that switch.
If it is on, a hit was processed and you turn it off for the next check.
If it is still off, then you know the attack missed and can react to that.

Problem here is that it might require a bit of additional logic to handle multiple battler and prevent enemies form using the same skill and so on
But it would be a valid approach.
I've tried what you said, and I've ran into some problems. Like you said, if the Attack hits, then the switch turns on, then immediately turns off. But this has created a bit of a paradox. Since its ON, it will turn OFF / and since its OFF, the skill will run. We don't want that since we've basically moved to the other side of the spectrum; Once never triggering to now triggering constantly. Seeing how the switch being OFF would trigger the check to run constantly, one might think to trigger the check if the switch is ON, but we cant do that since the only time a switch turns ON is if the attack hits, and we want this check to register as a miss. Its a bit of a puzzle. Also, the switch is default set to OFF, so the check will trigger at the beginning of the round, which isn't good since the player hasn't even done anything yet. I thought maybe setting the switch to ON at the beginning (through either an autorun event or troop event), but all this does is essentially circumvent the need for an attack/miss to trigger the event.

There's a lot of problems and possible solutions that come with this method, but I think assigning this check only 2 values (ON/OFF) isn't really going to work. Through the use of variables however, this may be possible. I'm going to work on this some more and edit this post with an update.

UPDATE: I finally got it to work! for future reference there IS A WAY TO TRACK A MISS USING BASE RPGMAKER MV (though it takes a bit for it to work). This is what I did: I created 2 variables, and before any battles began, I set those 2 variables to be 2 numbers off from each other (VAR1 = 2 and VAR2 = 0). Using the troop menu, I've set a troop event to check every turn, from turn 1 to 1, for my 2 common events and to increase VAR2 by 1. Also, I've set my basic attack to trigger my switch to ON for every attack. Once the battle begins, VAR1 = 2 and VAR2 = 1. This ensures that the event you want to trigger for a miss wont trigger automatically.

Now, if your first attack misses, VAR1 = 2 and VAR2 = 2, which will trigger the first common event. In this common event your going to want to first set a 'conditional branch' to check if VAR1 is EQUAL to VAR2. Then, simply input what you want to happen if you 'miss' (for me, your actor acquires a state). Lastly, you're going to want to put a 'control variable' and SUBTRACT 1 from VAR2 so that they're 1 apart again.

Now we need to maintain this imbalance. Create another common event that starts with a 'conditional branch' that only triggers if our switch (that we got from attacking something) is ON. Then, simply 'control variable' and ADD 1 to VAR1. Then, lastly, turn the switch back OFF. This will ensure that the imbalance is continuous and not getting held up by either side.

BOOM! you did it! Now, your going to need to set an event in your troop that resets VAR1 and VAR2 back to their original state once the battle ends. (VAR1 = 2 and VAR2 = 0). You should be good from here! just copy and paste the troop events to every troop if you want your 'miss' event to trigger for every battle!
1714793321824.png

1714793298434.png

1714793269616.png
then immediately turns off.
that should not happen, not if done correctly.

either you have a different event turning the switch off or thee same switch is used for two different things

Please show screenshots of your current skill and events
that should not happen, not if done correctly.

either you have a different event turning the switch off or thee same switch is used for two different things

Please show screenshots of your current skill and events
I had the event to immediately turn off the switch if it was on so it could reset. probably did it wrong lol. Thank you for your responses and understanding!
I had the event to immediately turn off the switch if it was on so it could reset.
yes, that was the error
you should simply have activated the else branch of the conditional branch (checkbox in the window) and then switch off the switch only if it is ON, and in the else branch do what should happen on miss.

Original thread: https://forums.rpgmakerweb.com/threads/cant-figure-out-whats-wrong-with-my-script-call.168249/