Attack effects/buffs (solved)

Subscribe to Attack effects/buffs (solved) 14 posts

avatar for gulzaibthegreat1 gulzaibthegr... 291 posts
Flag Post

how would i come around making effects/buffs such as: lose 10 mana every turn for 5 turns. Or block 550 damage. Or 10% health loss every turn for 5 turns?

this is a turn based game such as sonny/sonny2 in as2 so any suggestions would be gladly appreciated

 
avatar for JamesObscura JamesObscura 250 posts
Flag Post

I would have a buff(/debuff) class.

I would pass the constructor of that class the stat that is effected, how it is effected, and how many turns it is effected. I would have every entity keep a list of their buffs and during the update tick, run through everyone’s buffs and debuffs.

 
avatar for gulzaibthegreat1 gulzaibthegr... 291 posts
Flag Post

I hope u know I’m still a noob and I would need u to explain how exactly I would do this and how it would work

 
avatar for clasher235 clasher235 586 posts
Flag Post

Create an 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:

Give the Unit and 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:

Give Unit and Effect a Block integer, and give the former a MaxBlock integer. When applying an affect, add it’s Block to the unit’s MaxBlock and 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.


Edit:
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.

Regards,

Clasher

 
avatar for gulzaibthegreat1 gulzaibthegr... 291 posts
Flag Post

Okay clasher thank you! I am still a noob because I stopped coding and forgot everything… I am not using classes at all and what u said made little sense to me… I’m not sure what an array is or a parent/child etc etc. if u could link me to somewhere where it teaches this thank you. Also I am done just about all of the coding for my game, I just need to add more attacks/enemies/story/better graphics. So do u suggest I don’t do the buffs/effects for this game because I think that I shouldnt really quit until this game is what I want. This is actually the 2nd time i started this game… I started a long time ago and I quit because I couldn’t do it. But slowly I am getting there which is why I want to learn everything and do what I can. I don’t really want u to give me the code but show me a guide which explains what I need to know (also what u said was very helpful I just have to google the parts I don’t understand so thank u for ur reply)

 
avatar for clasher235 clasher235 586 posts
Flag Post

You aren’t using classes? I’d recommend using them, if only because it’s much more intuitive(For me, at least). I’m still fairly new at programming too(basic knowledge of VB and C#, made a fairly complex shooter type game with each of those to learn, plus other smaller projects, and currently working my way up in AS3) but coding an RPG without classes seems unnecessarily impractical and confusing. If you don’t know what an array or a parent/child is, you probably should be working on something much simpler than a full fledged RPG. Also, (I know this is a bit late) you may want to switch to AS3, as more people are familiar with it, and it is generally described as more capable. You say you have most of the code done, but I’m uncertain what you mean by this. If you really do have a complete engine done and could wrap the game up in a week or so, I’d personally suggest doing what you can to finish it for the sake of possibly learning a few new things and having a higher tier game up and on display, but if you’re far enough from a completed game, it may be better to start from the beginning and work your way up, creating a solid foundation and gaining a good understanding of key concepts, so that you’ll be able to create a better game in the long run, and have a much easier time doing so.


Edit: Here are some tutorials that may help you if you choose to use AS3.

Avoider tutorial, very well liked as a starting point

Making an asteroids game using the traditional method in flashdevelop, a free software that many people like more than flash due to its reliability and clarity

Making an asteroids game using blitting(More logical and easier to manage IMO, but the people who don’t use it have some good reasons too), it uses the same software as the other asteroids tutorial


The shootorial, if you’re absolutely locked into AS2, this should provide a good start and teach you pretty much everything that you absolutely need to know to create a good game

Adding links in a few seconds

 
avatar for elitim elitim 16 posts
Flag Post

I also highly recommend classes and AS3. I recently started converting from AS2 to AS3, and while AS3 is certainly stricter, it is so much more organized and for me has actually proved to be easier. And furthermore, classes allow you to organize things according to objects; for instance, all tiles can belong to a class that groups all coding related to those tiles.

There is also a set of Shootorials for AS3 that seem to be much less known. I did the first four or five before I started working on my own, using this AS3 reference to understand all the inherent classes, methods, and commands. I hope those references are helpful!

 
avatar for Degraiver Degraiver 9 posts
Flag Post

usually when I want to do something like that I add counters and after desired turn increase counter. Then create a if(counter==5){seteffect=false; buff/debufficon.visible = false; . I dont understand classes myself, so i end up writing longer codes but they work just the same for me. My friends a programmer, and he says my code pisses him off. lol So if you want a work around.

 
avatar for dragon_of_celts dragon_of_celts 282 posts
Flag Post

@Degraiver: Personally, I don’t like over-OOPed code, so I’d probably do something similar to what you have (albeit inside an Actor superclass for the players/enemies, and without the magic number). I find having classes and sub-classes for just about everything more difficult to read and edit than some spaghetti code. Finding a good balance is best, IMHO. Many would be appalled, I imagine (that my OOPiness isn’t OOPy enough)…
Edit: “probably” should say “possibly”
[excised bad humour… No, I wasn’t drunk (it’s amazingly hard to get drunk if you don’t drink), but I am the compliment of slightly sane]

You should try to learn about classes, though. I think once you get the hang of it (it isn’t that difficult), you’ll prefer using them to straight procedural programming.

 
avatar for clasher235 clasher235 586 posts
Flag Post
Originally posted by Degraiver:

usually when I want to do something like that I add counters and after desired turn increase counter. Then create a if(counter==5){seteffect=false; buff/debufficon.visible = false; . I dont understand classes myself, so i end up writing longer codes but they work just the same for me. My friends a programmer, and he says my code pisses him off. lol So if you want a work around.

That doesn’t allow for stacking effects, and stacking effects are key to many tactics in RPGs.(Book of Mages 2 in particular is a great example of that, the pure water clan pretty much needs them to remain combat effective.)

 
avatar for gulzaibthegreat1 gulzaibthegr... 291 posts
Flag Post

Wow thanks a lot guys I’ll try and lean as3 and use classes. When I said the code is almost done than what I meant was that all I need is basically quantity. More levels, more attacks, more enemies, than better graphics and maybe music (probably not) the biggest problem for coding ATM is the effects/buffs because that’s something I don’t really understand… So what I’m thinking of doing (please tell me if u think it’s a good/bad idea) is using up (lots) of my time switching the game up to as3 with classes. Another thing I can do is switching it just into classes and not as3. The problem for turning into as3 though is that the main fighting engine isn’t mine… I got it from a utube video I saw… Nonetheless I will attempt this

 
avatar for gulzaibthegreat1 gulzaibthegr... 291 posts
Flag Post

alright so switching to as3 and using classes didnt work. back to as2 and i have a turn variable which gets updated everytime somebody does their turn. i also have

 var effect1:boolean = false
and that boolean is set to true under certain conditions, now under
function onEnterFrame(){
i have it so that
if(effect1 = true){
and im not sure what to do there… can someone help me out?

 
avatar for dragon_of_celts dragon_of_celts 282 posts
Flag Post
Originally posted by gulzaibthegreat1:

alright so switching to as3 and using classes didnt work. back to as2 and i have a turn variable which gets updated everytime somebody does their turn. i also have

 var effect1:boolean = false
and that boolean is set to true under certain conditions, now under
function onEnterFrame(){
i have it so that
if(effect1 = true){
and im not sure what to do there… can someone help me out?

You’re setting effect1 to true in your if statement. Also, for a Boolean, all you need to use is if (effect1), since the if statement is evaluating whether what is inside the parentheses is true or not (a Boolean is a true or false value, so directly answers the if statements criteria).

Checking equivalence is done with ==, not = (the assignment operator).

 
avatar for gulzaibthegreat1 gulzaibthegr... 291 posts
Flag Post

thanks but i already fixed this issue. i forgot to put that as the title :p