ID:160947
 
Can Someone tell me a simple code for maling a pokemon evolve?!!?
mob/proc/evolve()
if(src.pokemon.level>src.pokemon.evolution_level)
world<<"OMG POKEMON EVOLVING LOLZ"
else {..()}

Good luck asking for other people to program a game for you.
Read an english book, then read the DM guide.
There is no such thing as a simple way to do it. It's probably going to end up being confusing. If I were to do it, this may be one way:
mob/proc/transfer_mob(typepath, list/vars)
//This create a new path with the old vars of the mob,
//or, at least some basic ones that will probably be
//needed.
var/mob/m = new typepath
for(var/a in vars)
if((a in src.vars) && (a in m.vars))
//If the variable is in both m's and src's vars
//list, assign it to m.
m.vars[a] = src.vars[a]

m.loc = src.loc //This should always be reset.

spawn(1) del src //Delete the old mob after a moment.
return m //Return the new mob.

pokemon
parent_type = /mob

var
next_state //A typepath containing the next state
//to evolve to.
level //The level they're currently at.
level_up = -1 //The experience they need to evolve.
//If this is a negative number, then
//the Pokemon doesn't evolve into
//another state.

experience //Their current experience.
experience_up //The experience they need to go to
//the next level.

//This just sets some vars that should be passed on, for
//certain. Some are just implied (like skills).
transfer_mob(typepath, list/vars = list("name", "experience", "level", "skills"))
..(typepath, vars) //Call the parent proc with the
//arguments.

proc/Experience(n)
//This gains the experience for the Pokemon. n is
//the amount of experience they should gain.

//Add the experience to their current level.
experience += n
while(experience >= experience_up)
//As long as their experience is greater than
//the max experience, increase their level and
//remove the experience points needed, as well
//as recalculate the experience.

level ++
experience -= experience_up

//Arbitrary equation for calculating the next
//level. Replace it with whatever you want.
experience_up = round(experience_up ** 1.5, 1)

return LevelUp() //Call the proc to check levels,
//and return its value.

proc/LevelUp()
if(level >= level_up)
//If they are able to evolve, alter their state
//to the next state, and return the new mob.
return transfer_mob(next_state)

return 0

An example implementation would be such, using Pikachu's evolutionary states:
pokemon
var
number //Their number in the Pokedex.
element //Their element.

pichu
name = "Pichu"
number = 172
element = ELECTRIC //Not defined, but implied.

level_up = 5 //Couldn't find the actual level.
next_state = /pokemon/pikachu

pikachu
name = "Pikachu"
number = 25
element = ELECTRIC

level_up = 10 //Can't find actual data.
next_state = /pokemon/raichu

raichu
name = "Raichu"
number = 26
element = ELECTRIC

level_up = -1 //Final state, so no more evolutions.

If I remember correctly, there are certain states that have multiple evolutionary paths, which would require a more complicated system to work in. Still, this is a basic way that can be built upon.
In response to Popisfizzy
That's similar to what I do. As for the multiple evolutionary paths, an associative list would work best there. But there actually is a simple way that most pokemon games use >_>. It's terrible code, offers little flexibility, and anything could write it.


Terrible code \/
mob/Pokemon/var
Evo_icon
Evo_lv
Evo_icon2
Evo_lv2
level

mob/Pokemon/proc/Evolve()
if(level==Evo_lv)
icon = Evo_icon
if(level==Evo_lv2)
icon = Evo_icon2

mob/Pokemon
Pichu
Evo_icon = 'pikachu.dmi'
Evo_lv = 5
Evo_icon2 = 'Raichu.dmi'
Evo_lv = 10
In response to Jeff8500
I thought about an associative list, but decided against it as it would require a cache so there isn't an exhorbitant amount of lists. Doing it that way provides, I feel, is easier. You could also define other variables like moon_stone_state to indicate what happens when they come in contact with a moon stone, or perhaps modify the LevelUp proc if you want to deal with more complex situations (like Eevee evolving into Espeon and Umbreon, which I still have no idea how to do).
In response to Popisfizzy
Pichu evolves from happiness, and pikachu evolves using a thunderstone, so the level is pretty much irrelevant. That'd be why you couldn't find any data.

<_<
_>

Yeah, I play pokeymanz.
In response to Popisfizzy
With the amount of evolution stones in the pokemon games, I felt it was worth it (I think they're up to almost 10; plus one of them only evolves pokemon if they have a specific gender).

As for the Eevee thing, you would need a happiness var and a day/night system. Then when they level up, if the happiness is over a certain amount, they evolve differently depending on the time of day. Or, you can take the lazy route like me and use some of the new evolutionary stones to evolve them >_<
In response to Jeff8500
A demonstration of how I'd handle it. Some things aren't implemented - like isNight(), for example, or the actual evolution code (Pop's code would be useful here).

This code lets you have a pokemon evolve via stone, or via levelup, at your choice. It's not quite as simple as just setting an evolution level and type, but it handles eevee quite effectively, as you can see. (Incidentally, I left out glaceon and leafeon. I leave it as a reader exercise to fill it in. Plus, I can't remember precisely how one gets them)

mob/pokemon
proc/shouldEvolve()
return null

proc/getStoneEvolves()
return list()

proc/levelUp()
return null

proc/useStone(stone)
var/list/s = getStoneEvolves()
if(s[stone])
evolveInto(s[stone])

eevee
levelUp()
if(shouldEvolve())
evolveInto(shouldEvolve())

shouldEvolve()
if(happiness>150 && isNight()) return /mob/pokemon/umbreon
if(happiness>150 && isDay()) return /mob/pokemon/espeon

getStoneEvolves()
return list("firestone"=/mob/pokemon/flareon, "thunderstone"=/mob/pokemon/jolteon, "waterstone"=/mob/pokemon/vaporeon)

In response to Jp
Wow, I like that idea. That way you don't have to save lists or vars; I might consider using something similar, as I barely coded any pokemon in.

Also, you get glaceon and leafeon by leveling Eevee up within a certain distance from certain stones (which are objects on the map, not items).
In response to Jp
Oh, yea, now I remember that for Pikachu (totally didn't remember anything for Pichu). S'pose I chose a poor example for the code.