Does initialization not count any method that comes below initialize? When I tried it on Game_Enemy, it seems viable and working. Here's what I mean:
class Game_Actor < Game_Battler alias milena_init initialize # alias the method def initialize(actor_id) milena_init(actor_id) # call original method xstate = [10, 6] # array of states to add xstate.each{|state| add_state(state)} # extract and add endendWhy doesn't the array of state (ids) not added to the actor during the start of battle? Shouldn't add_state method already initialized when Game_Actor is created in the data?
in my own experience this never a good idea to call such method into the initialize why? I don't know but in the past I expected weird glitch
so i advise you why not try with a "states_setup" method?
def states_setupxstate = [10,6]xtate.each{|state| add_state(state)}end but I am not actually sure I am currently really tired so maybe my logic was not right on this c: !
Tried it and the states still doesn't apply. :\
If you want those states to be like permanent then you'll also have to add some sort of exception for those states inside the method clear_states in Game_BattlerBase. This might also be why those states aren't sticking, they might be getting cleared sometime after the initialization.
By exception, you mean erasing them or? What I did was since they're taken from Game_Battler and Game_BattlerBase, I added the method clear_states to the Game_Actor (as it was in Game_BattlerBase) and it works alright, but how does exception be done?
By exception I just meant like removing every state except the ones you want to keep. So instead of @states = [] inside the clear_states method you would have done something like @states = [10, 6] you could also do a @states.keep_if {|state| some condition in here } or @states.delete_if {|state| some condition in here } but it's probably better to just set it equal to the states you want to keep.
Ahh, that works somehow. By pushing the states when I extract the value of each actor's states, I've got it to work. One problem though is it doesn't recognize this:
def update_state_turns states.each do |state| @state_turns[state.id] -= 1 if @state_turns[state.id] > 0 end end It says '>' is undefined in nil NilClass.
hum I for what I say this maybe because it not recognize states did you redefine the states or you just use the rtp definition?
also did you have the other snipset you modify so we can see if the culprit is somewhere else in your script 🙂 ?
Unlike enemies, actors can be reset up after their creation (there is an option for it when you add them to the party for example). This is done by calling the actors setup method. Therefore, if you want to initialize actors with custom stuff, you should add it to the setup method instead of initialize in this case.
States are meant to be added via the add_state method. If you just add the state ids to the @states array, you leave the number of remaining turns/steps uninitialized (you can just initialize these values manually as well of course, if you don't use scripts that rely on the default way of adding states).