How to check if an @ has changed? (RGSS1)

Cinnamon

Veteran
Veteran
Joined
Jun 20, 2014
Messages
605
Reaction score
209
First Language
English
Primarily Uses
Hey guys,

I'm having an odd problem. When I add states to an actor, they get applied but immediately removed again right after. And I can't figure out where or why the states are getting removed.

How can I write a small method that prints a message each time @states is changed? For example, in Game_Battler I tried:

def self.states

p @states

return @states

end

But that does nothing.

Trying to track down where on earth @states is getting cleared... Because if I do a "p @states" at the end of def add_state, it shows me just fine that they were added. But somehow they're gone again right after.

Thanks in advance. :)
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Something like that is just going to tell you that the state was changed. You already know that. What you want to know is what's causing the state to be changed. Something that tells you it's changed won't tell you WHAT changed it. You could put p @states in def remove_state, but that will only tell you it's being removed, not what's triggering it.


Sounds like you have a script that is updating your states.


What do you mean by "removed again right after"? Are they being added and removed straight away, or are you only noticing after a battle action happens?


Do a global search (Control+Shift+F) for remove_state and see what comes up.
 

Heretic86

Veteran
Veteran
Joined
Nov 30, 2014
Messages
240
Reaction score
167
First Language
Engrish
Primarily Uses
You could do it like this:

class Game_Event

  alias :my_script_update :update unless $@

  def update

    # Store current value for later comparison

    value = @value

    # Call original or alias of other Update methods

    my_script_update

    # Check for a changed value

    if value != @value

      # Do your changes here

      my_method

    end

  end

  def my_method

    # Do your changes n stuff here

    @value = (modify value)

  end

end
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Are you using remove by restriction by chance? Whenever I use remove by restriction that is exactly what RPGMaker does in my game. I'm not sure if either the documentation on how remove by restriction works is misleading, but that is what happens when I use remove by restriction.

And yes, I tested that on the default confusion state in a clean project, so it is not a script conflict (before anyone asks).
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
The OP is asking about RMXP (RGSS1 mentioned). Do you think they would work the same way (assuming your test was done in Ace)
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
The OP is asking about RMXP (RGSS1 mentioned). Do you think they would work the same way (assuming your test was done in Ace)
I *knew* needed more caffeine in me! :p

Still, if said feature exists in XP (I don't know if it does), might be worth investigating.
 

Cinnamon

Veteran
Veteran
Joined
Jun 20, 2014
Messages
605
Reaction score
209
First Language
English
Primarily Uses
Something like that is just going to tell you that the state was changed. You already know that. What you want to know is what's causing the state to be changed. Something that tells you it's changed won't tell you WHAT changed it. You could put p @states in def remove_state, but that will only tell you it's being removed, not what's triggering it.

Sounds like you have a script that is updating your states.

What do you mean by "removed again right after"? Are they being added and removed straight away, or are you only noticing after a battle action happens?

Do a global search (Control+Shift+F) for remove_state and see what comes up.
Yeah, I did. def remove_state is not what is causing it, strangely. That method is not called after the states are added with def add_state.

Basically in Turn 0 I run a Common Event that adds some states on actor 1 manually. I run a "p $game_party.actors[0].states" immediately after that, and the states are gone. So something happens immediately after running def add_state that removes the states again, apparently. This only happens when restarting a battle (I wrote a script that allows you to retry the battle if you lose):

def retry_battle Audio.me_fade(10) $scene.load_battle_stats $game_system.se_play($data_system.battle_start_se) $game_system.bgm_stop $game_system.bgm_play($game_system.battle_bgm) $scene = Scene_Battle.new end def load_battle_stats filename = $appPath + "/" + "BattleProcess.rxdata" unless FileTest.exist?(filename) return end file = File.open(filename, "rb") $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) $game_player = Marshal.load(file) file.close endStates otherwise added work fine. It's just the Turn 0 thing that goes wrong.

Of course this happens before applying the states and before the battle starts again. :)

Let me try that script you gave me...
 
Last edited by a moderator:

Cinnamon

Veteran
Veteran
Joined
Jun 20, 2014
Messages
605
Reaction score
209
First Language
English
Primarily Uses
Nope, that script doesn't help.

Okay, this fixed it. Instead of using the "Change State" command, I made states an attr_accessor instead of attr_reader and simply used this code:

$game_party.actors[0].states = [2,3]

Now that works fine. Anyone have an idea why the Change State code didn't work but this does? xD Going to see if any other problems arise...

EDIT

Okay, this is weird... I think there's some deeper issue going on...

After this change, the states don't seem to disappear over time. If I print @states_turn in def remove_states_auto, it appears empty after retrying the battle. Maybe there's a different set of battlers being created? So confused. s__s *researches*

EDIT

Fixed it. Had to define "@states_turn" separately, of course. Yeuy. :3
 
Last edited by a moderator:

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
564
Reaction score
275
First Language
German
Primarily Uses
[...] def load_battle_stats filename = $appPath + "/" + "BattleProcess.rxdata" unless FileTest.exist?(filename) return end file = File.open(filename, "rb") $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) $game_player = Marshal.load(file) file.close end
When you load $game_party / $game_actors in the RPG Maker XP you also have to call $game_party.refresh to synchronize your party members with the actor list. Otherwise your party members become separate actor objects.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Cinnamon, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


Just edit your post and add the extra information.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,574
Latest member
nikisknight
Top