State Name Cycling

Discussion in 'RGSS Script Requests' started by Lord Vectra, Jun 9, 2019.

  1. Lord Vectra

    Lord Vectra Master Eventer Veteran

    Messages:
    187
    Likes Received:
    324
    Location:
    The Abyss
    First Language:
    English
    Primarily Uses:
    RMVXA
    So do you know how XP shows only one state on enemies and actors alike? I know the state icons script exist, but I want to keep the [State Name] but have it cycle through all of them. There is this script by Atoa that does something similar but does it for the state animations instead. I would like them to be compatible and ideally in unison so the name and animations changes at the same time.

    Code:
    #==============================================================================
    # Atoa State Cycling
    # by Atoa
    #==============================================================================
    module Atoa
      # Increase the time between the animation change.
      State_Cycle_Time = 4
    end
    
    #==============================================================================
    # Game_Battler
    #==============================================================================
    class Game_Battler
      #--------------------------------------------------------------------------
      include Atoa
      #--------------------------------------------------------------------------
      attr_accessor :state_animation_id
      #--------------------------------------------------------------------------
      alias atoa_state_initialize initialize
      def initialize
        atoa_state_initialize
        @state_frame = @state_animation_id = 0
        @anim_states = []
      end
      #--------------------------------------------------------------------------
      def state_animation_id
        return 0 if @states.empty?
        return 0 if @states.include?(1)
        @state_frame -= 1 if @state_frame > 0
        return @state_animation_id if @state_frame > 0
        if @anim_states.empty?
          for state in @states
            @anim_states << state if $data_states[state].animation_id > 0
          end
        end
        now_state = @anim_states.shift
        return 0 if now_state.nil?
        @state_animation_id = $data_states[now_state].animation_id
        return 0 if $data_animations[@state_animation_id].nil?
        @state_frame = $data_animations[@state_animation_id].frame_max * State_Cycle_Time * 2
        return @state_animation_id
      end
    end
     
    #1
  2. Lord Vectra

    Lord Vectra Master Eventer Veteran

    Messages:
    187
    Likes Received:
    324
    Location:
    The Abyss
    First Language:
    English
    Primarily Uses:
    RMVXA
    bump
     
    #2
  3. Lord Vectra

    Lord Vectra Master Eventer Veteran

    Messages:
    187
    Likes Received:
    324
    Location:
    The Abyss
    First Language:
    English
    Primarily Uses:
    RMVXA
    bump
     
    #3
  4. Lord Vectra

    Lord Vectra Master Eventer Veteran

    Messages:
    187
    Likes Received:
    324
    Location:
    The Abyss
    First Language:
    English
    Primarily Uses:
    RMVXA
    bump :/
     
    #4

Share This Page