Effect class with a variable for each stat that can be changed by a buff, as well as a
TimeLeft integer. Give each unit stats for what you want the effects to change but are not already there, and give each unit an
Effects array. Every turn, iterate through the effects array, subtract 1 from each effect’s
TimeLeft, and once it reaches zero, undo the changes to the units stats and remove the effect(remember to also do this at the end of each battle. When a unit is hit with an effect inducing attack, add the effect to that unit’s
Effects array, and apply the change induced by the effect to the unit’s stats.
I am unsure how you are doing attacks, but if you are using a class, just add an
EffectToInduce variable to them and apply that effect to the target when the attack is used.
Example: Adding a mana drain effect:
Effect classes a
ManaDrain integer. Each turn, subtract that integer from the unit’s total mana. When a mana drain effect is applied through an attack, add it’s
ManaDrain value to the target’s own. When an effect’s
TimeLeft reaches 0, undo the effect by subtracting it’s
ManaDrain value from that of the affected unit and remove it from the array.
Example: Adding a damage block:
Block integer, and give the former a
MaxBlock integer. When applying an affect, add it’s
Block to the unit’s
Block. When removing the effect, subtract it’s
Block from the unit’s
MaxBlock, then, if the
Block exceeds maximum, set it equal to the newly decreased maximum. It goes without saying that, when attacked, you would check if the unit’s
Block stat was more than 0, and, if so, check if it was more than the attack damage. If so, subtract the attack damage from it, if not, subtract it from the attack damage, then subtract what’s left from the unit’s health.
Example: Adding a percent damage drain:
Simple enough, add a
PercentHealthDrain int to both classes, and every turn, subtract
Health(or maxhealth, you weren't clear on which one, but I assume the former, as it's more interesting) / 100 * PercentHealthDrain from the unit’s health.
To make the effects visible is easy enough, just make them whichever
DisplayObject you choose and render them just like all the others(make sure to use
RemoveChild() when splicing them out of the array). You can determine the location by getting the length of the
Effects array and multiplying it by the width of the effect graphics.
JamesObscura pretty much said the same thing but more elegantly. This is a little more explanatory, but if what he said doesn’t make it clear enough for you, you may wish to try something much simpler than an RPG. Trust me, making a full fledged RPG with your current level of programming experience(determined by the game you uploaded, you may have improved since then, but you did say you were a “noob”, so that’s probably an indicator that you should try something less difficult. Buffs are a fairly simple feature to add, and the forums probably won’t code your entire game for you.) has about a 50 percent chance of wasting hours of your time being frustrated that could have been spent learning more efficiently and in smaller steps, and a 49 percent chance of making you give up, thinking it’s just too hard. Look at some of the great ones, and see that not even they just jumped into creating something complex. Far too many Devs think their second or third .swf file will bring them to the top of the ratings list, that they’ve come up with the game idea that will bring everyone to awe, but that’s simply not realistic, and it’s important to shelve those beliefs before they, rather ironically, become the very things that keep you from success. Heck, even nerdook made four games before he even broke the 3/5 rating barrier, and it took him until 2010 to break 4/5(for the record, he registered in 2007). That should give you an idea of how much practice it takes to get good. There’s no shame in walking one step at a time, and trying anything more than that might end up making you trip.