Trying to apply permanent statuses

● ARCHIVED · READ-ONLY
Started by HeroicJay 5 posts View original ↗
  1. I'm trying to apply permanent statuses to both actors and enemies alike. Think like in Final Fantasy VI, where Interceptor was a permanent "status" applied to Shadow. These statuses should be applied to nearly all units, with a bit of randomness on the part of the enemies.

    I can get the initial application down, but the trick is preventing the game from automatically removing them when hit with a cureall or something. I'm trying this:

      alias :old_clear_states :clear_states
      def clear_states
        if @states.nil?
          old_clear_states
          return
        end
        
        alignment = -1
        if @states.include?(42)
          alignment = 42
        elsif @states.include?(43)
          alignment = 43
        elsif @states.include?(44)
          alignment = 44
        elsif @states.include?(45)
          alignment = 45
        elsif @states.include?(46)
          alignment = 46
        elsif @states.include?(47)
          alignment = 47
        elsif @states.include?(48)
          alignment = 48
        elsif @states.include?(49)
          alignment = 49
        end
        old_clear_states
        unless alignment == -1 then
          self.add_state(alignment)
        end
      end

    Works fine at first. I've tested against a "Recover All Heroes" event. And then I get into battle. Round 1: everything goes smoothly. Round 2: The game crashes upon the first move used. Excuse given? "SystemStackError occurred. stack level too deep"

    I have no idea what would be causing this; the error makes me think "infinite loop", but what loop? I don't even know why this would be getting called on the second round of battle!

    I know it must be that part of the code, because disabling it causes everything to work fine (except, of course, for curealls wiping the statuses.)

    (BTW, I'm very well aware that the above code wouldn't work unless the statuses are mutually exclusive. That's deliberate. They are mutually exclusive.)

    EDIT: I realize that I could just write my own custom cureall that would ignore those statuses every time - wouldn't even need to script for it - but dangit, sometimes you just want to be lazy and hit "Recover all: Entire Party".
  2. HeroicJay said:
    Round 2: The game crashes upon the first move used. Excuse given? "SystemStackError occurred. stack level too deep"
    In 99% of all cases, that error happens if a script is copied into the script manager twice - the rare other option is that you've created an iteration where the script calls itself.
    I suggest checking the unnamed slots in your script editor to see if you've placed it somewhere else and forgot to name the slot, then placed it twice because you didn't see its name in the list.


    If that is not the case, then check your script - especially why do you call the "old_clear_states" twice?
  3. Andar said:
    In 99% of all cases, that error happens if a script is copied into the script manager twice - the rare other option is that you've created an iteration where the script calls itself.

    I suggest checking the unnamed slots in your script editor to see if you've placed it somewhere else and forgot to name the slot, then placed it twice because you didn't see its name in the list.

    If that is not the case, then check your script - especially why do you call the "old_clear_states" twice?
    Twice? I mean, yes, it's in the code twice, but it should never call old_clear_states twice in a single run of the method. The first one has a "return" immediately after it, after all. I could rework the code to remove that, but I must profess my doubts on that fixing it.

    This project is relatively clean, and this wasn't copy/pasted or anything until I created this topic, so it's very unlikely this exists elsewhere. I'll check anyway...

    EDIT: Removing one instance of old_clear_states did a whopping nothing, so that wasn't it.
  4. I have a lead: turns out Battler has its own version of clear_states. It does call BattleBase's (which I'm overriding) but then calls @result.clear_status_effects. That could be causing the error. Come to think of it, in my test battle, I'm doing the same actions every time, and round 2 should be killing the monster, which would wipe status effects...

    EDIT: Yup. All I had to do was apply an @HP == 0 check.
  5. HeroicJay, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


    That doesn't sound quite right, but as long as you've got it working the way you want it, who am I to argue? ;)


    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.