[XP] Making the 'Change Enemy State' event account for enemy state resistances

level2janitor

Regular
Regular
Joined
Feb 8, 2018
Messages
68
Reaction score
15
First Language
English
Primarily Uses
RMMV
I'm using this event for some combat gimmicks in my game, but it's turning into a real hassle that it just bypasses resistances completely when I'd really rather it not. Is there any script or anything else I could use to change this?
 

Andar

Regular
Regular
Joined
Mar 5, 2013
Messages
39,922
Reaction score
11,871
First Language
German
Primarily Uses
RMMV
event commands like that are supposed to bypass all resistances in order to make story elements guaranteed. changing that might have consequences elsewhere.

why don't you simply use a force-action command with a skill that applies the state? that should have the skill working normally even if the force action overrides all skill requirements.
 

level2janitor

Regular
Regular
Joined
Feb 8, 2018
Messages
68
Reaction score
15
First Language
English
Primarily Uses
RMMV
I also tried using the 'Force Action' command, but that one has other issues - namely that it doesn't work before the first turn of combat, and there's no option to have it force an action without using up the actor's turn.
 

level2janitor

Regular
Regular
Joined
Feb 8, 2018
Messages
68
Reaction score
15
First Language
English
Primarily Uses
RMMV
Currently I've been trying to edit the 'Change Enemy State' script in Interpreter 7 and I'm stuck. I mostly don't know how scripting works, but I've added a bit from Game_Battler 2 that references enemy state effectiveness.

Ruby:
  #--------------------------------------------------------------------------
  # * Change Enemy State
  #--------------------------------------------------------------------------
  def command_333
    # Process with iterator
    iterate_enemy(@parameters[0]) do |enemy|
      # If [regard HP 0] state option is valid
      if $data_states[@parameters[2]].zero_hp
        # Clear immortal flag
        enemy.immortal = false
      end
      # Change
      if @parameters[1] == 0 and rand(100) < [0,100,80,60,40,20,0][enemy.state_ranks[i]]
        enemy.add_state(@parameters[2])
      else
        enemy.remove_state(@parameters[2])
      end
    end
    # Continue
    return true
  end

Unfortunately the little "i" in there should reference which state is being applied, but doesn't (it does do that in Game_Battler 2, but I can't figure out which part of the code makes it do that or how I'd bring it over to Interpreter 7). If I change to a specific number, it actually works just fine, but only with that specific state (i.e. changing it to [3] references the 3rd listed state).

All I need to figure out is how to make "i" reference the state being applied and the script will work just fine, so if anyone could help me with that I'd really appreciate it.
 

kyonides

Reforged is laughable
Regular
Joined
Nov 17, 2019
Messages
1,904
Reaction score
971
First Language
English
Primarily Uses
RMXP
Ruby:
# * Enemies, Resist State Changes! XP
#   Overwritten Method: Interpreter#command_333

# * Toggle a given Game Switch to activate / deactivate this feature in game.

class Interpreter
  USE_ENEMY_STATE_RANKS_SWID = 1 # You can change the Switch ID!
  # * Change Enemy State
  def command_333
    iterate_enemy(@parameters[0]) do |enemy|
      state_id = @parameters[2]
      enemy.immortal = false if $data_states[state_id].zero_hp
      # Add State to Enemy
      if @parameters[1] == 0
        if $game_switches[USE_ENEMY_STATE_RANKS_SWID]
          pos = enemy.state_ranks[state_id]
          percent = [0,100,80,60,40,20,0][pos]
          return true if rand(100) >= percent
        end
        enemy.add_state(state_id)
      else
        enemy.remove_state(state_id)
      end
    end
    return true
  end
end

I just improved the code posted above to allow people use a game switch to enable or disable the feature at any moment during gameplay.
 

level2janitor

Regular
Regular
Joined
Feb 8, 2018
Messages
68
Reaction score
15
First Language
English
Primarily Uses
RMMV
This is fantastic, thank you so much!
 

Latest Threads

Latest Profile Posts

How it feels right now with Advent resources and Sleigh the Competition event screenshots coming in.
WindRyder_ChristmasIncoming.png
So, apparently, Glow-in-the-Dark cats exist.

Are Sir Oinkers and the fairy responsible for all those dead uhm sleeping monsters?
Well, they now can be in your game, thanks to Day 4's content!
1701691228682.png
Stealing.
1701688258164287088.gif

Forum statistics

Threads
136,736
Messages
1,269,332
Members
180,455
Latest member
Razuk
Top