Users browsing this thread: 1 Guest(s)
C++ Object parameter question

#5
Posts: 159
Threads: 7
Thanks Received: 1
Thanks Given: 4
Joined: Jul 2012
Reputation: 3
Status
None
Just try to sub-categorize your effect so you wont have to repeat yourself. Heres how i proceed in my own game.
I have Effect object. A Characters (PC object) have an array of Effect ( Effect currently applied to the characters) and abilities have a single Effect ( the effect the abilities applies when used).
Before creating your abilities, you create your array of your basic effects with unique ID. Thereafter, when you create your abilities, you just have to pass on the ID of the effect. For example, Bio and Poison will probably use exactly the same "effect". Not just the same attack power and mp usage.

Also, if you a parameter that can have more than 2 value, dont use a boolean. For example, for my elements, i just use an int, 0 = No element/Physical and 1 to 7 for the other element.

Note that i also use a method very similar to what Madsiur suggested when you are "forced" to use a long list of boolean, however i do it in decimal.
Let's say each effects have a unique value,
Poison = 1,
Blind =2,
Confused = 4
Silence = 8
Paralyze = 16

When the character receive a status ailment, you add its value to an Int of the charcaters.
When you wanna know what status ailment the character have, you pass each and every status ailment value and check if its higher or equal to the character effect.
For example, if a character has a Effect value of 21.
If (char.effect >= 16)
{
//Char is paralyzed
char.effect = char.effect - 16
}
//(Char.effect now equal to 5)

If (char.effect >= 8)
{
//Char isnt silenced
char.effect = char.effect - 8
}

If (char.effect >= 4)
{
//Char is confused
char.effect = char.effect - 4
}
//(Char.effect now equal to 1)

//etc



[Image: rrj.gif]
  Find
 



Messages In This Thread
C++ Object parameter question - by Lloyd2k4 - 05-21-2013, 04:58 PM
RE: C++ Object parameter question - by Lockirby2 - 05-21-2013, 05:59 PM
RE: C++ Object parameter question - by madsiur - 05-21-2013, 06:27 PM
RE: C++ Object parameter question - by Lloyd2k4 - 05-23-2013, 02:30 PM
RE: C++ Object parameter question - by Daemoth - 05-23-2013, 04:32 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite