Problem with scaling of state alterations

CuddleFox

Furry
Veteran
Joined
Feb 18, 2017
Messages
116
Reaction score
40
First Language
French
Primarily Uses
RMVXA
Hi, I have a problem with my state alterations.
I would like to make a system that groups buffs into state alterations, whose icons are modified with each change of alteration. For example, you take a buff one notch in attack, it puts you 110% altered, if you take a buff again it puts you 120%. But if you take a three-step debuff, you go from 120 to 91%. Each time with the corresponding icons.

Why don't I use the basic VX Ace buff system?
  1. Because I want alterations of indefinite duration and buffs are limited
  2. The icon does not change beyond 2 buffs and I have 3 buffs
  3. My buffs do not change a specific parameter, but a xparam so not directly configurable from the software interface, or if it is possible I have not found how to do it.

So each of these buff situations is a state alteration. Here is the list:
7 : 130%
6 : 120%
5 : 110%
4 : 100%
3 : 91%
2 : 83%
1 : 77%

Here's my problem: I want to use a technique that lowers a stat a notch. Here is the content of my damage formula in the database:

!b.states.include?(52) & b.states.include?(51);b.add_state(50) & b.remove_state(51) & b.remove_state(52) & b.remove_state(53) & b.remove_state(54) & b.remove_state(55);nil
b.states.include?(52);b.add_state(51) & b.remove_state(52) & b.remove_state(50) & b.remove_state(53) & b.remove_state(54) & b.remove_state(55);nil
Which means:

If the target does not have ATK +30% and has ATK+20% then the target gains the alteration ATK+10% and loses ATK+20% ATK+30% ATK-23% ATK-17% ATK-9%, if the conditions are not met, nothing happens.
If the target has ATK+30% then it gains ATK+20% and loses ATK+30% ATK+10% ATK-23% ATK-17% ATK-9%, if the conditions are not met, nothing happens.
Logically, if when the effect arrives the target has ATK+30%, it goes to ATK+20%.
Yes, I have tested it and it works.

But normally, if it has ATK + 20%, it should go to ATK + 10%.

And it doesn't work, it stays at ATK+20%, and I don't understand. It drives me crazy. I don't find a solution.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
You are using the wrong syntax. The & operator is the bitwise and, not the logical and (which is && instead). There is no way something works when using the wrong syntax. I would recommend putting everything in a script and then calling it from the damage formula box.

From what I can see you cannot have more than one of those states active at the same time. For this reason you can do it this way:
Code:
class Game_Battler < Game_BattlerBase
  def add_buff(value = 0)
    buff_id = 0
    min_buff_id = 51
    max_buff_id = 56
    (min_buff_id..max_buff_id).each do |id|
      if state?(id)
        buff_id = id
        break
      end
    end
    remove_state(buff_id) unless (buff_id == 0)
    return if (buff_id == (-1 * value) + (min_buff_id + max_buff_id) / 2)
    buff_id = (min_buff_id + max_buff_id) / 2 + (-1 * value) if (buff_id == 0)
    value == -1 ? buff_id -= 1 : buff_id += 1
    add_state(buff_id) if (min_buff_id..max_buff_id).include?(buff_id)
  end
end
You can then use b.add_buff to increase the buff strength, or b.add_buff(-1) to decrease its strength.

Please note that I wrote this from mobile without syntax highlighting, I do not guarantee that there are no mistakes in the code.
 
Last edited:

CuddleFox

Furry
Veteran
Joined
Feb 18, 2017
Messages
116
Reaction score
40
First Language
French
Primarily Uses
RMVXA
Okay, thank you very much for your help. ^^

I just tried your code, and I have another problem. We go from one state to another, but the middle of the scale is an absence of state. There are 6 alterations, not 7. So we jump from 91% to 110% for example. I can solve this by making an invisible alteration for 100%, but how not to make the messages of the alterations appear in the battlelog?
I also encountered another problem with states disappearing,
  1. When I take a debuff at 120% or 83%, the state is removed instead of being replaced by a new state.
  2. When I take a buff at 110%, the alteration is also removed.
  3. Same when I'm at the max buff and I take a buff or at the min buff and I take a debuff.
Thank you again!

Here's my states list if it can help.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
I fixed one mistake in the code, but that is now what is causing your problem as it happens after the line that is supposed to cause the issue. However, the line
Code:
return if (buff_id == (-1 * value) + (min_buff_id + max_buff_id) / 2)
should already prevent new states from being applied if you are in the middle of the scale.
What that line is supposed to do is to stop the method execution if buff ID is equal to
Code:
(-1 * value) + (50 + 55) / 2 = (-1 * value) + 105 / 2 = (-1 * value) + 52
# if it is a buff, value is 0 and you have
-1 * 0 + 52 = 52
# if it is a debuff, value is -1 and you have
-1 * -1 + 52 = 1 + 52 = 53
The code should add nothing if you are applying a de-buff and the state applied is 53 (smallest buff) nor add anything if you are applying a buff and the state currently applied is 52 (smallest de-buff). Did you change the numbers in the code properly? I used 51-56, but if things are as they currently are you are supposed to use 50-55 instead.
 

CuddleFox

Furry
Veteran
Joined
Feb 18, 2017
Messages
116
Reaction score
40
First Language
French
Primarily Uses
RMVXA
Thank you! Thank you! That's exactly what I needed ^^
 

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,860
Messages
1,017,038
Members
137,568
Latest member
invidious
Top