mob/Monster
Class="Monster" //placing a variable here will effect all types of mobs created under it
var/mob/Target //this variable will only exist for Monsters, and is by default typed as a mob
Hobgoblin
//since the following variables are tabbed in under the Hobgolin, they will only effect this 1 monster
icon='Hobgoblin.dmi'
Gold=2 //the gold you set on a monster will determine how much it gives when you kill it
Exp=1 //same goes for exp, the amount you set here will determine how much this monster is worth
Level=1 //these next few lines setup the basic stats for the monster
MaxHP=15 //since these variables are already defined elsewhere you dont need to mark them again here
var/ExtraVariable=0 //but if you wanted to define a new variable just for this monster you could
MaxMP=10
Str=3
Def=1
Hobgoblin_Level_2 //this guy is just a demo to show u how to code more then 1 monster
icon='Hobgoblin.dmi'
Gold=3
Exp=2
Level=2
MaxHP=20
MaxMP=15
Str=10
Def=5
New() //this is what happens when a new monster is created
src.HP=src.MaxHP //sets the monsters HP and MP to max
src.MP=src.MaxMP
spawn()
src.Wander() //when calling a proc that loops inside another proc you should ALWAYS spawn it
return ..() //this allows multiple New() procs to be ran on this mob, but make sure its at the end!
proc/Wander() //creates a new proc for Monster type mobs named Wander
while(src) //will loop as long as this mob exists
if(src.Target) //if the monster found a target do this
if(get_dist(src,src.Target)>1 && !step_to(src,src.Target,1)) //if they cant reach their target
src.Target=null;continue //then restart the loop without a target
src.dir=get_dir(src,src.Target) //make them face the target
src.Fight() //makes the monster attack!(coding shown below)
if(!ListCheck(src.Target,oview(5))) //ListCheck is a proc i created! you can find it in the Procedures.dm file
//note: placing a ! before an if means you want the oposite result, in this case if src.Target isnt in oview
src.Target=null //if their target wandered away, then null it out, which sets it to nothing basicaly
sleep(rand(10,15))
else
sleep(rand(15,25)) //then wait a random amount of time before taking another action
if(!src.Target) //if this mob doesnt already have a target
for(var/mob/M in oview(5)) //check for any targets within 5 blocks
if(M.key) //if any of the mobs around u are a player, then we'll target them
if(step_to(src,M,1)) //will make sure they can actualy reach the target
//(note: the step_to proc only knows how to check around dense turfs/areas)
src.Target=M //this sets the monsters target to the player it found
sleep(5)
break //as soon as it finds a target it can stop looking
proc/Fight()
for(var/mob/M in get_step(src,src.dir)) //finds any mobs directly in front of the monster
if(M.key)
flick("Attack[src.icon_state]",src)
var/damage=src.Str-M.Def //a simple damage calculation
damage=max(0,damage+rand(-1,1)) //make sure damage isnt negative and varry it a little
M.HP -= damage //subtract the damage off the victim's HP
M.DamageShow(damage,200,0,0) //flashes the damage on the screen
M.DeathCheck(src) //runs the DeathCheck proc on the victim of the attack
//(The DeathCheck proc can be found in the Procedures.dm file)
Problem description:
It's weird, I got this STRAIGHT from a Lib and it's not working in my game..
No errors or anything they just don't attack?
Got it from: http://www.byond.com/games/Falacy/RPGStarter
please help ... :(
Start here