Make an action times "minus" feature

Is there a way, through either scripts or events, to make a feature that reduces the amount of action times + an enemy gets?

In my game, the bosses generally have two turns. I want to make a stun like state that reduces their action times + by 1.

Hypothetically, I could accomplish this through lunatic states but I'm wondering if there's a less roundabout way.
Hey,

Events would probably not qualify as "less roundabout", but if you wanted to go that route you could create a new state that gives the boss an extra action, use battle events to add the state before every turn, and make your "stun" effect state resist the extra action state.
Alternatively you could maybe make the boss unmovable for the rest of the turn after they finished an action while stunned.

Lunatic States would probably allow a more comfortable solution. There may be scripts out there that more directly do what you want, too.
You could also use this script to modify the "make_action_times" method from Game_Battler:
Spoiler
Code:
# Add
#   <action times minus: 1>
# to a note box to make the battler wearing it have 1 fewer actions

class RPG::BaseItem
 
  def action_times_minus
    @action_times_minus ||= note[/<action times minus:(.*?)>/i] ? $1.to_i : 0
  end
end

class Game_Battler
 
  alias_method(:make_action_times_without_action_times_minus, :make_action_times)
  def make_action_times
    result = make_action_times_without_action_times_minus
    result = feature_objects.reduce(result) { |r, o| r - o.action_times_minus }
    return [result, 0].max
  end
end

Edit: Typo
I will try that out.
Before you are wondering: I just realized I made a typo in the script above, but it should work now after the edit.
Also worth noting, since I may have not completely understood what you are aiming for: the number of action times are only calculated once per turn, so reducing an enemies actions would currently not void any actions the enemy has already selected.
how many bosses?
you could set the battle of each boss to add them a state at turn 0 that gives them those extra attacks, without adding them to the battler itself.
if you move that aspect to states, THEN you can work with +/- states through the states system proper.
The issue, I think, with having the state be applied via turn events is that you'd get a situation where a character inflicts the "stun" but then the boss just gains the state to use action times plus right back.

I believe it could work like this.

1. Create a state that gives the action times plus. Let's call it Boss Mode.
2. The stun skill has a 100% chance of removing Boss Mode but also applies a Dummy state for 1 turn
3. Via Lunatic States, the dummy state reapplies Boss Mode when it gets removed.
<leave effect>
a.add_state(id)
</leave effect>
you'd get a situation where a character inflicts the "stun" but then the boss just gains the state to use action times plus right back.
not if you set the stun to 0% land rate of that state.

as long as the target is stunned, it can't get boosted again.
That's what I'm trying now, lol.

The problem is I don't know how to have the Boss Mode state attempt to reapply itself every turn.

Lunatic States Leave effect didn't seem to work. I believe because I have to define it separately within the script
set a troop event to run every turn.
that's why I asked how many bosses... if it's a few, set troop events.
if it's a lot, better use a plugin.
Like this?

Edit: Okay, just had to use another page for the remaining turns.

It works but the enemy only does the single action upon the next turn. Is there a way to fix that? If not, I can just point it out in the skill description
There are several ways to achieve this.
Piling on to what gstv87 wrote, I would probably use the "State Resist" feature instead of "State Rate = 0%" if you want to go that route.
Resisting a state automatically removes the state from the target and prevents it from being readded through any means (including event commands) while the resistance is active, while "State Rate" mainly affects states applied through skills/items.

Your <leave effect> looks fine to me and worked when I tried it in a new project with only Lunatic States.
Although as written above, action times are only applied during action selection, so your boss may still use their two prepared actions before the next turn starts, if that is the issue?

An alternative effect you could try might be
Code:
<while effect>
a.clear_actions
</while effect>
which clears all remaining actions after your boss executed their first action while stunned.


Edit: This post was written in response to Post #7, some of this might be moot now.
Edit2: I cannot recall what I tested there, but no, it does not.
I'll try that one.

Edit: Doesn't work. I have a ton of other scripts, so one of them is likely causing a conflict with a similar method. I may try to figure it out later, but I think it's good for now.

Anyways, thanks to everyone for your help.
Ah, my bad.
I was assuming the lunatic states would execute arbitrary Ruby code, but at least by default they do not. Instead you can add tags you would have to implement in scripts.

You could try to add your effect into the original Lunatic States script under the common sections (and replace a with user) or you can add this as a script:
Code:
# Add
#  <XXX effect: clear actions>
# to a notebox to clear the wearers actions when lunatic state effect XXX occurs.

class Game_BattlerBase
 
  alias_method(:lunatic_state_extension_without_clear_actions,
  :lunatic_state_extension)
  def lunatic_state_extension(effect, state, user, state_origin, log_window)
    case effect.upcase
    when "CLEAR ACTIONS" then user.clear_actions
    end
    lunatic_state_extension_without_clear_actions(effect, state, user, state_origin, log_window)
  end
end

Edit: Forgot to add the alias back in

Original thread: https://forums.rpgmakerweb.com/threads/make-an-action-times-minus-feature.167348/