MV Need help with a STATE Notetag

I want to add this to my States:

Yanfly DualCast Tip and Tricks:
Code:
<Custom Action Start Effect>
// If a chained action is stored...
if ($gameTemp._chainAction === undefined) {
  // ...then set the action to the user's current action.
  $gameTemp._chainAction = user.currentAction();
} else {
  // ...then clear the stored action.
  $gameTemp._chainAction = undefined;
}
</Custom Action Start Effect>

<Custom Action End Effect>
// If a chained action is stored...
if ($gameTemp._chainAction) {
  // Set the 'action' variable to the chained action.
  var action = $gameTemp._chainAction;
  // Check if the action exists, is a skill, and is a magical attack.
  if (action && action.isSkill() && action.isMagical()) {
    // Get the skill used for that action.
    var skill = action.item();
    // Check if the user can pay the skill cost.
    if (user.canPaySkillCost(skill)) {
      // Check if the battle system is DTB.
      if (BattleManager.isDTB()) {
        // If it is, add the action to queue.
        user.setAction(0, action);
      // If the battle system isn't DTB...
      } else {
        // ...make it a forced forced.
        BattleManager.queueForceAction(user, skill.id, -2);
      }
    }
  }
}
</Custom Action End Effect>

<Custom Remove Effect>
// Clear the chained action effect.
$gameTemp._chainAction = undefined;
</Custom Remove Effect>

It works great for what is does... But I would like to make so that the second casting of the spell is free [No MP cost] and if possible, make so only certain spells can be cast.

Can anyone help me out with this?
But I would like to make so that the second casting of the spell is free [No MP cost]
i dont think actions called by queueForceAction() actually pay the cost, so you should be able to just remove the check to see if the user can pay the cost and then only run whats in the else block for the DTB check. Otherwise, you could also apply a state to the user with a trait that waives MP costs before they act and have its duration be a turn or an action.

and if possible, make so only certain spells can be cast.
if its a small set list, you can add a list of id's to the "Check if the action exists, is a skill, and is a magical attack." bit

Code:
if (action && action.isSkill() && [1,2,3,4].contains(action.item().id)) {
checks if the action is skill 1,2,3 or 4.

if its a list thatll grow over time and you dont want to keep coming back to the state to add more skills, then you can use a notetag. something like <Dualcast> on the skill and then
Code:
if (action && action.isSkill() && action.item().meta.Dualcast) {
in the state

also...

I've moved this thread to Javascript/Plugin Support. Thank you.

I've moved this thread to Javascript/Plugin Support. Thank you.
Thank you

Otherwise, you could also apply a state to the user with a trait that waives MP costs before they act and have its duration be a turn or an action.
I did this:
Code:
<Custom Action Start Effect>
// If a chained action is stored...
if ($gameTemp._chainAction === undefined) {
  // ...then set the action to the user's current action.
  $gameTemp._chainAction = user.currentAction();
} else {
  // ...then clear the stored action.
  $gameTemp._chainAction = undefined;
}
</Custom Action Start Effect>

<Custom Action End Effect>
// If a chained action is stored...
if ($gameTemp._chainAction) {
  // Set the 'action' variable to the chained action.
  var action = $gameTemp._chainAction;
  // Check if the action exists, is a skill, and is a magical attack.
  if (action && action.isSkill() && action.item().meta.Dualcast) {
    // Get the skill used for that action.
    var skill = action.item();
    user.addState(238);
    // ...make it a forced forced.
        BattleManager.queueForceAction(user, skill.id, -2);
        user.removeState(238);
        user.removeState(239);
  }
}
</Custom Action End Effect>

<Custom Remove Effect>
// Clear the chained action effect.
user.removeState(238);
$gameTemp._chainAction = undefined;
</Custom Remove Effect>

The "No MP" State is applied but the trait in the state doesn't activate... I tried an experiment and the trait does activate if the skill is NOT a Dualcast skill... So, my thought process is the state is being applied, but not activated for the forced action. I think it has to do with the timing... The trait/state needs time to activate and the Dualcast state is not allowing it the time it needs [mainly outside of the state, like how things in the menu only update after you close the menu].
BattleManager.queueForceAction(user, skill.id, -2)
user.removeState(238);
user.removeState(239);
and to be sure, neither of those remove state calls are for the cost reduction state? it had an icon and youre sure it was on the battler when the skill started?
i said to had it be 1 turn because if its being used, it needs to not be removed until the skills fully resolve. queued forced actions dont happen instantly, so those listed states are removed before the skill is executed.
and to be sure, neither of those remove state calls are for the cost reduction state? it had an icon and youre sure it was on the battler when the skill started?
i said to had it be 1 turn because if its being used, it needs to not be removed until the skills fully resolve. queued forced actions dont happen instantly, so those listed states are removed before the skill is executed.
I added an icon to the state JUST to make sure it was being applied...



It applies the state, but the state is quickly removed and then the second skill activates... Even with it being 1 Turn the same thing happens.
and to be sure, neither of those remove state calls are for the cost reduction state?
It applies the state, but the state is quickly removed and then the second skill activates... Even with it being 1 Turn the same thing happens.
right, but i didnt ask to make sure it was being applied. i asked to make sure you werent manually removing it. cause now i can see it is one of the states youre removing manually

i said to had it be 1 turn because if its being used, it needs to not be removed until the skills fully resolve. queued forced actions dont happen instantly, so those listed states are removed before the skill is executed.
you need to try to *not* remove the state in the same place youre using calling for the forced action because the forced action doesnt immediately execute while the state removal does. as already said, try and let it fall off by timing out. see which fits better between action timing and turn timing.
you need to try to *not* remove the state in the same place youre using calling for the forced action because the forced action doesnt immediately execute while the state removal does. as already said, try and let it fall off by timing out. see which fits better between action timing and turn timing.

right, but i didnt ask to make sure it was being applied. i asked to make sure you werent manually removing it. cause now i can see it is one of the states youre removing manually
I removed the manual state removals from the notetag... And turned the "No MP" state to 'Action End' Turn 1. It did the exact same thing. I changed it to Turn End and It seems to have worked better... So... Yay... :blush:

I guess it's solved now, Thank you for putting up with and helping me...

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-a-state-notetag.182678/