Status
Not open for further replies.
Joined
May 14, 2020
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
I want a state's icon to change to a different one based on how many turns remains of its duration.
Simply adding 1 to index for every 1 turn passed will work, i'll just put the appropriate icons next to each other on the icon sheet.

Tried doing that within draw_actor_icon method, but it changed icon for all states at once, couldn't figure it out
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,392
Reaction score
810
First Language
English
Primarily Uses
RMVXA
Try this
Ruby:
class Game_Actor < Game_Battler
  def state_icons
    ic = 0
    icons = states.collect {|state| 
      @st_turn.each { |st|
        if st[0] == state.id
          a = st[1][state.id]
          tmp = state.icon_index
          if a > 1
            ic = tmp + a.to_i
          else
            ic = state.icon_index
          end
        end
      }
      ic
    }
    icons.delete(0)
    icons
  end
  
  def state_turns_r2(state, turns)
    @st_turn = [] if @st_turn.nil?
    @st_turn.push([state.id, turns])
  end
  
  alias r2_state_reset_count  reset_state_counts
  def reset_state_counts(state_id)
    r2_state_reset_count(state_id)
    state = $data_states[state_id]
    state_turns_r2(state, @state_turns)
  end
end
Never mind. It auto removes after taking one step. need to work on it more.
Hopefully fixed.
 
Last edited:
Joined
May 14, 2020
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
steps, you mean in overworld? in that case, doesn't matter, I only need states in combat

Here's what's happening:
- when state is inflicted, it has the wrong icon already, and not the one in the database
- next turn it switches to an icon way off in the iconset, and it syncs up with other battlers?
im not actually sure

Sorry I think I wasn't clear enough in the OP, so I made this crappy mockup picture to show how I want it to look:
Each turn, every state that is currently on each battler, shifts its icon forward. Individually, since states are applied at different times to different battlers, they must display different icons. The idea is that the icon will function as a turns remaining indicator: so, a Fire state will show the flame progressively petering out, a Bleed state has less and less blood each turn, and so on

That's why I tried messing with draw_actor_icon method, because the index shift must happen independently for each actor.

Also I should've noted right away, but I'm using Yanfly's Battle Engine. no other scripts that mess with icon drawing though

state decay.jpg
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,392
Reaction score
810
First Language
English
Primarily Uses
RMVXA
draw_actor_icon
This is for the window which calls the actor state icons.
My code changes the state icons. I have tested it with and without yanfly battle manager. It works for both. The icons are changed to the icon for the state + the number of turns it lasts.
So if the state lasts 7 turns then it would go to the 7th icon in the iconset past the original icon for that state. I don't know what you are referring to with it going way off the icon set? Unless you have your icon set with the state icons at the left and nothing on the right.
If you want it to be in stages (3 from your example) then please say so. (and it sounds like that's what you want - but you said turns)

Give me some more time to see if I can change it to stages.
 
Joined
May 14, 2020
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
The icons are changed to the icon for the state + the number of turns it lasts.
I see, that's a bit confusing. It'd make more sense for it to keep the database icon on the initial turn.

What I tried is simply adding +1 to index every turn that passes
So, an state with icon 1 gets inflicted and displays icon 1, then on the next turn it changes to icon 2, then icon 3, and so on
My code changes the state icons
does that mean it changes them globally? It should only change for the current battler
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,392
Reaction score
810
First Language
English
Primarily Uses
RMVXA
If the state does not have a turn count then it will be the icon in the database.

What you're suggesting is tracking what turn the actor got inflicted and add one to the icon for each turn up to three and then remove state. That is more complicated in my opinion.

the state icons for the code I wrote will be there for the each actor. If the state is not removed at the end of battle, then it will be in the menu.(if you have states shown in the menu)

By default poison does not get removed at end of battle or by steps or turns etc. So until it is cured it will always be the poison icon.
Sleep and paralysis have turns, so they will have changing icons.
Also note that states do not add on turns. If an actor inflicted with sleep has two turns left and then inflicted with sleep again it will change to 3-5 not 5-7, so it does not add on. Which I think is not your interest anyways.

*Scratch all that

I did a search for scripts in my folder and found one by Grilled Paste (google translate)
I modified it to have a hard limit of 3. So when inflicted it starts at three turns (if the state applies that many.
This also only changes the icon in battle.
You were right about the draw_actor_icons, I just didn't see how, because I was looking at the code and thinking it needs to be changed at the actor level.
Here is the modified script. It starts at icon 3 then goes to 2 then 1. so your icon set will need to have the icons reversed from what you showed.
Ruby:
=begin
#==============================================================================
[Name] Display of remaining turns of state + α
[Author] Grilled paste
[Distributor] Relaxing Maker miscellaneous goods
http://mata-tuku.ldblog.jp/
# ------------------------------------------------- -----------------------------
[Change log]・2012/10/28 public
・2012/12/01 Bug fixes. Added "Hide state icon with display priority 0" function
Moddified by Roninator2 to change icon and not show number
#==============================================================================

#------------------------------------------------------------------------------
[Correspondence]
・ Only RGSS3 is possible
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
[function]
-Only during battle, the number of remaining turns of state and ability change
is displayed on the icon.
-Hide the icon of the state where the display priority is 0.
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
[how to use]
-There is no special operation. Just install this script and it will work.
#------------------------------------------------------------------------------

[Redefined part]
・Window_Base の draw_actor_icons
#------------------------------------------------------------------------------
[○: New definition, ◎: Alias definition, ●: Redefinition]
#------------------------------------------------------------------------------
=end
$YkNr_Scripts ||= {}
$YkNr_Scripts[:ShowStatesTurns] = true
# * If you do not use this script, set ↑ to false.

if $YkNr_Scripts[:ShowStatesTurns]
#==============================================================================
# ■ Game_BattlerBase
#==============================================================================
class Game_BattlerBase
  #--------------------------------------------------------------------------
  # ◎ Get the current state as an array of icon numbers
  #--------------------------------------------------------------------------
  alias yknr_ShowStatesTurnsGame_BattlerBase_state_icons :state_icons
  def state_icons
    states = self.states.select {|state| !state.priority.zero? }
    yknr_ShowStatesTurnsGame_BattlerBase_state_icons
  end
  #--------------------------------------------------------------------------
  # ○ Get the current state as an array of the number of remaining turns
  #--------------------------------------------------------------------------
  def state_turns
    turns = []
    states.each do |s|
      if !s.icon_index.zero?
        is_turn = !s.auto_removal_timing.zero? && !s.priority.zero?
        turn = is_turn ? @state_turns[s.id].truncate : -1
        turns.push(turn)
      end
    end
    turns
  end
  #--------------------------------------------------------------------------
  # ○ Get the current enhancement /
  #   weakness in an array of the number of remaining turns
  #--------------------------------------------------------------------------
  def buff_turns
    turns = []
    @buffs.each_with_index do |lv, i|
      turns.push(@buff_turns[i].truncate) if !lv.zero?
    end
    turns
  end
end

#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● Draw state and enhancement / weakness icons
  #--------------------------------------------------------------------------
  def draw_actor_icons(actor, x, y, width = 96)
    last_font = contents.font.clone
    contents.font.size = 19
    contents.font.bold = true
    contents.font.color = crisis_color
    icons = (actor.state_icons + actor.buff_icons)[0, width / 24]
    turns = (actor.state_turns + actor.buff_turns)[0, width / 24]
    turns.each_with_index do |n, i|
      turns[i] = 2 if n > 2
    end
    icons.each_with_index do |n, i|
      draw_icon(n + turns[i], x + 24 * i, y)
#~       if $game_party.in_battle && turns[i] != -1
#~         draw_text(x + 24 * i, y, 24, line_height, turns[i] + 1, 2)
#~       end
    end
    contents.font = last_font
  end
end
end # $YkNr_Scripts
 
Joined
May 14, 2020
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
When used with a state that lasts 3 turns:
- it starts off at icon 3
- the next turn, it stays at icon 3 and doesn't change
- the next turn it changes to icon 2
- the next turn it runs out of turns and is removed, without ever showing icon 1

I fixed it by changing the limit from 2 to 3. There aren't any states with longer durations anyway, so this will work. Thank you for your help
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,116
Reaction score
5,971
First Language
Dutch
Primarily Uses
RMXP

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.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

aww man, color hex code #C4C4C4 doesn't work for the tint value in this scene I need something darker, which stinks just because I liked that one it was my favorite plastic explosive three times...#696969 (nice) should work better (WHY IS MY BRAIN LIKE THIS)
Tell it to me straight, doc. If I've been trying to piece together a "shorter" game to learn stuff outside of game jams... am I just running away from my WIP? :v
Well, I've got a party tomorrow, and my friends are coming over. I wanted to work a bit on the Fandom Scouts assets so I can be ready when that update arrives... in other news, Pizza Time Horror is getting a second teaser, and it shows Cabaret Helen's last performance before the location closed.
Also who used to be scared of Chuck E as a kid? I was! Now I love him!
The new cards and what they do:

(I am clearly not a youtuber... Haha)

Forum statistics

Threads
117,282
Messages
1,106,098
Members
153,456
Latest member
tomdavies
Top