[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,952
Reaction score
11,892
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,932
Reaction score
983
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

Should first boss be easy or maybe little medium, I don't want to be overwhelmingly hard
Proper localization into several languages on a commercial rpg project might be one of the best signs that the developer is super invested into making the game something high effort, because it ain't cheap to hire good translators.
6 hour drive back from Florida and I was able to plan out 6 mini game Common Events for my Game Jam entry, including a new one I hadn't thought of before. Also had some new ideas to improve what I already have and the post game options to continuing playing the mini games that you liked or didn't get to try. Pretty productive drive.
Christmas decorations! !! :kaojoy:
20231209_114754.jpg
Sophie is already helping dismantle the tree...a month early, of course. Such a helpful kitten!
making horse character for game :D at the end it will have 8 directions puling wagon

2p8jdax

Forum statistics

Threads
136,880
Messages
1,270,985
Members
180,653
Latest member
Pirate_Legend
Top