Save-Point
Remaining turns of states - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: Remaining turns of states (/thread-7302.html)



Remaining turns of states - Melana - 07-31-2018

Today I coded a window which shows all states that are currently added to the actor.
It's also possible to show this window in battle so now I'm wondering how I can show the remaining turns of each state.
I can show the total amount of lasting turns for each state with $data_states[i].hold_turn but not the remaining amount.

Example: Actor A gets the venom state which lasts for 5 turns. After 2 turns there are 3 turns left and I want to show that number in my window.

I guess it's something with @states_turn{} from Game_Battler but I'm not sure how use that.
Does anyone has any ideas how achieve that?^^

Edit: It looks like this. The "R." stands for "Runden" which means "turns"

[Image: n1bwLwh.png]

(Yes that guy is suffering. I wanted to test how many states the window is able  to display)


RE: Remaining turns of states - BeJeremiah - 08-01-2018

(07-31-2018, 11:16 PM)Melana Wrote: Today I coded a window which shows all states that are currently added to the actor.
It's also possible to show this window in battle so now I'm wondering how I can show the remaining turns of each state.
I can show the total amount of lasting turns for each state with $data_states[i].hold_turn but not the remaining amount.

Example: Actor A gets the venom state which lasts for 5 turns. After 2 turns there are 3 turns left and I want to show that number in my window.

I guess it's something with @states_turn{} from Game_Battler but I'm not sure how use that.
Does anyone has any ideas how achieve that?^^

Edit: It looks like this. The "R." stands for "Runden" which means "turns"

[Image: n1bwLwh.png]

(Yes that guy is suffering. I wanted to test how many states the window is able  to display)

At the beginning of Game_Battler class add the following
Code:
attr_accessor :states_turn


This gives you access to the variable @states_turn which is created whenever you add a state. See Line 39 of Game Battler 2.

For easy access create a method to control its access since it is a Hash based on the state ID.

Some like ...

Code:
# Return the Number of state turns remaining.
def state_turns(state_id)
   if @states_turn[state_id] != nil
    return @states_turn[state_id]
   end
end

I hope this is what you are referring to. (The "if" statement was added to the method to prevent a error in the event your state has nil turns for whatever reason, it would usually be -1 turns if not 0 or more but.. meh)


RE: Remaining turns of states - Melana - 08-01-2018

Thank you very much!
This helped me alot.


RE: Remaining turns of states - kyonides - 08-01-2018

I wonder if something like @states_turn[state_id] || 0 wouldn't do the job there... Confused