ID:195124
 
//Title: Egg Hatching Sample
//Credit to: Dan of Dantom (slightly modified by Jtgibson)
//Contributed by: Jtgibson


//This is more of a niche snippet, in that it's very unlikely
// that you'll ever want or need this kind of a snippet in your
// own game, but it's a really neat thing to try out, and it's
// a valuable learning experience on how you can override Move()
// to suit your own needs as well.
//(I find the 10% chance of moving the egg especially interesting.)
//I added a couple more comments, updated the code to BYOND 3.0
// format, and made a couple minor adjustments and "improvements".
// -- Jtgibson



world/mob = /mob/player/dragon/egg


mob/player/dragon
name = "dragon"

proc/advance(new_type)
var/mob/M
M = new new_type(src.loc) // create the new guy
M.key = src.key // move us in!
del(src) // remove the old baggage

egg
//icon = 'egg.dmi'
var/strength = 100 // how tough is this egg?

Move(Loc,Dir) // bust out of the egg

var/damage = rand(0,10) //how much damage we inflict on the egg

if(damage > 7) //damage from 8-10
usr << "You smack hard against the sides of the egg!"
flick("wobble",src)

else if(damage > 4) //damage from 5-7
usr << "You smack the sides of the egg."
flick("wobble",src)

else if(damage > 1) //damage from 2-4
usr << "You gently nudge against the side of the egg."

else //damage from 0-1
usr << "You tap the side of egg."

src.strength -= damage // subtract strength from the egg

if(src.strength <= 0) //if the egg was destroyed,
usr << "You bust out of the egg!"
src.advance(/mob/player/dragon/hatchling) // we become a hatchling!

else // if the egg wasn't destroyed
if(prob(10)) // 10% chance of wobbling the egg
..(Loc,Dir) // by calling the default (inherited) Move() proc

hatchling
//icon = 'hatchling.dmi'