ID:268561
 
Ok, how do I sell eggs and then make thr eggs hatch into montsers that can attack mobs, follow you, and evolve?
I pretty much have a slight feeling of what someoen migth say when respondign to this post... >_<
You mean someone saying "http://bwicki.byond.com/?TheCode"? :P

For a more serious answer... First you need to create your "eggs". You need to decide what type of information you need to know about the eggs. You need to decide what you can do with the eggs. You also have to decide where in the big scheme of things that an /egg would go. Here's an example of a possible egg:

obj
item // An item already has necessary things like a Get() verb, so
// it's easier(less work) to program additional things like an "egg"
egg
icon = 'eggs.dmi'
var
monsterType // Eg: "/mob/monster/chicken"
color

New(loc, eggcolor, eggtype)
..() // First, create the obj as normal
src.color = eggcolor // Set any passed variables
src.monsterType = eggtype // It might be a good idea to do some
src.icon_state = src.color // error checking here (in case eggcolor
// and eggtype are not passed)

proc
Hatch(location) // Call this to turn the egg into a monster
// This is a simple way of "hatching" the egg. A new mob
// of the type stored in the egg's monsterType variable
// is created at the location passed.

// The mob is returned so that the caller has a chance to do
// something with it, if necessary. The egg obj is deleted.

// spawn() is necessary, or else when src is deleted, the proc
// will end without being able to return M.
var/mob/M = new src.monsterType(location)
spawn() del src
return M


Of course, lots of this probably isn't what you want at all in your vision of an "egg". That's why it pays to be descriptive. Even if you're trying to do it yourself, if you have your general plan written down, it's easier to program what you want.


Also, if you don't want to use spawn as in the Hatch() example, here's another possible way of programming it:

proc/Hatch(location)
. = new src.monsterType(location)
del(src)


. is the default thing that gets returned. So when src gets deleted, I think that the procedure will end up returning the new mob stored in "."