ID:177089
 
ok im making a game, i have several classes, BUT how can i make the level up proc be different with each class?...
mob
var/class = "None"
Fighter
class = "Fighter"
Mage
class = "Mage"

mob/proc/levelup()
if(usr.class = "Fighter")
//do something
if(usr.class = "Mage")
//do something else
In response to Mrhat99au
Mrhat99au wrote:
mob
var/class = "None"
Fighter
class = "Fighter"
Mage
class = "Mage"

mob/proc/levelup()
if(usr.class = "Fighter")
//do something
if(usr.class = "Mage")
//do something else

While this is perfectly acceptable, it's a little neater if you use object inheritance to handle differences in levelling up. I would change this to:

mob
var/class
proc/levelup()
//do whatever happens to ALL classes upon levelup
Fighter
class = "Fighter"
levelup()
//do whatever happens to just Fighters
return ..() //neccessary to do default stuff
Mage
class = "Mage"
levelup()
//do whatever happens to just Mages
return ..()

-AbyssDragon
Also, you might want to remember that it's "medieval," not "medievil."
In response to AbyssDragon
I prefer to make the classes objects themselves. For example

datum/Class
proc
Level_Up()
//Customize here


and add them to the mob like so:

mob
var
datum/Class = new datum/Class/Fighter()
<dm>

That way, you can keep your classes and code for them seperate and managable apart from your mob code. Not much difference than using simple inheritances, but it does add a level of seperation. But, that's just my personal preference.
In response to Garthor
Garthor wrote:
Also, you might want to remember that it's "medieval,"
not "medievil."

Maybe he has a more 'evil' style of Medieval gaming?
In response to digitalmouse
Hey digitalmouse, i subcribed to your site and i cant download that map thing, it says im not subscribed to digitalmouse.programmingthings. How do you subscribe?
In response to Mrhat99au
MrHat - try now....and you could have easily emailed me with this instead of completely de-railing the thread, ya know... =p