After reading several tutorials on formulas, I've written quite a few on my own, however, with the latest one, I stumbled upon a weird problem. I really don't know why it doesn't work (mostly due to my lack of sleep over the last days I suppose), but this here is my setup for a skill, that first gives you a random elemental buff (the strongest of them with a lesser chance), then removes all others of the same kind, while dealing damage to yourself.
My code looks like this:
#Blade Infusal. Choose one of 4 random stats, thunder is the rarest. def blade_infusal(a, c = 1 + rand(100) if c >= 0 && c <= 29 #Add Element, Remove similar ones, Deal damage to self a.add_state(37); a.remove_state(38); a.remove_state(39); a.remove_state(40); a.hp * 0.1 elsif c >= 30 && c <= 59 #Add Element, Remove similar ones, Deal damage to self a.add_state(38); a.remove_state(37); a.remove_state(39); a.remove_state(40); a.hp * 0.1 elsif c >= 60 && c <= 89 #Add Element, Remove similar ones, Deal damage to self a.add_state(39); a.remove_state(38); a.remove_state(37); a.remove_state(40); a.hp * 0.1 elsif c >= 90 #Add Element, Remove similar ones, Deal damage to self a.add_state(40); a.remove_state(38); a.remove_state(39); a.remove_state(37); a.hp * 0.1 end endWhat's happening is that I do get a random stat, and I do get the intended damage to myself, however, the states already present are not being removed and I can basically stack something like "Water Blade" with "Fire Blade" which is pretty nonsensical.
Terribly sorry if I sound rude, I'm just a little bit tired. It would be amazing if somebody could help me out here! (It's probably something obvious, isn't it.. D🙂
While I'm at it, what would that even do? If I have two states on that both affect the element of physical attacks, which one is used for calculations? The one with higher priority?
(I know this is a bit of scripting, but I guess it's mostly formula, as it's the same use?! If I should have rather posted this in script support, I'm sorry, my bad.)
My code looks like this:
#Blade Infusal. Choose one of 4 random stats, thunder is the rarest. def blade_infusal(a, c = 1 + rand(100) if c >= 0 && c <= 29 #Add Element, Remove similar ones, Deal damage to self a.add_state(37); a.remove_state(38); a.remove_state(39); a.remove_state(40); a.hp * 0.1 elsif c >= 30 && c <= 59 #Add Element, Remove similar ones, Deal damage to self a.add_state(38); a.remove_state(37); a.remove_state(39); a.remove_state(40); a.hp * 0.1 elsif c >= 60 && c <= 89 #Add Element, Remove similar ones, Deal damage to self a.add_state(39); a.remove_state(38); a.remove_state(37); a.remove_state(40); a.hp * 0.1 elsif c >= 90 #Add Element, Remove similar ones, Deal damage to self a.add_state(40); a.remove_state(38); a.remove_state(39); a.remove_state(37); a.hp * 0.1 end endWhat's happening is that I do get a random stat, and I do get the intended damage to myself, however, the states already present are not being removed and I can basically stack something like "Water Blade" with "Fire Blade" which is pretty nonsensical.
Terribly sorry if I sound rude, I'm just a little bit tired. It would be amazing if somebody could help me out here! (It's probably something obvious, isn't it.. D🙂
While I'm at it, what would that even do? If I have two states on that both affect the element of physical attacks, which one is used for calculations? The one with higher priority?
(I know this is a bit of scripting, but I guess it's mostly formula, as it's the same use?! If I should have rather posted this in script support, I'm sorry, my bad.)