ID:141402
 
its from a library

Code:
// Ok, let's make the variables firstly.

mob
var
hp=100 // Health var, define it to 100
mhp=500 /// as above except the MAX hp.
str=1000// strength var
mstr=99999999//max strength
def=100//defence
mdef=99999999/// max defence
npc=0//npc var for npc mobs
exp=0//exp for lvling
mexp=10//max exp.
level=1///level var
Gold = 0
/// variables finished.


/// onto the verbs!

mob
verb
Attack(mob/M as mob in get_step(src,src.dir)) // the mob has to be facing you to attack
set category="Fighting"/// you all know wut this is.
if(istype(M,/mob/)) // if it a Mob they we're attacking continue.
var/damage=round(usr.str-M.def/2) /// define a damage var. user's str vs. M's defence divided by two. you can edit this to your liking.
if(damage <= 0)// if the damage is less or equal to 0 make it 1 damage.
damage = 1//change it :P
M.hp-=damage//remove the damage from M's HP.
range()<<"[usr] attacked [M]! inflicting <font color=red>[damage]</font> damage!"/// tell the people in ranged M's being attacked.
usr.DeathCheck(M)//see if M is dead.
else
return
// thats the attack verb. now onto the death proc and level proc.

mob
proc
DeathCheck(mob/M)
if(M.hp<=0&&M.npc)// if the hp's 0 and its a NPC.
world<<"[src] has killed [M]"/// say theyve killed M
del(M) //delete the npc frm the world cuz its dead
src.exp+=rand(10,30) // give exp :)
src.Level()// call the lvl proc
return/// stop runtime errors =D
if(M.hp<=0&&M.client) // if hp 0 and its a client.
world<<"[src] has killed [M]"// same as before
M.hp=M.mhp//give them full hp back.
M.loc=locate(1,1,1)//take them to spawn point, dont DEL them.
src.exp+=rand(10,30)// give them exp!!
src.Level()/// call lvl proc


Level()
if(src.exp >= src.mexp)
src.level+=1
src.mstr+=rand(1,3)
src.mdef+=rand(1,3)
src.mhp+=rand(10,15)
src.mexp+=rand(10,20)
src.exp=src.mexp
src.exp=0
src.hp=src.mhp
src.def=src.mdef
src.str=src.mstr
src<<"You gained a level and are now level [src.level]!"

/// okay procs done, now the stat panel.

mob
Stat()
statpanel("Stats")
stat("Name: [usr]")
stat("Gold: src.Gold")
stat("Level: [level]")
stat("Health: [hp]/[mhp]")
stat("Str: [str]/[mstr]")
stat("Def: [def]/[mdef]")
stat("EXP: [exp]/[mexp]")

/// AND NOW THE ACTUAL NPC TO ATTACK!

mob
npc
wasp
icon='wasp.dmi'
name="Wasp"
npc=1
hp=950
def=5</b>


Problem description: The wasp wont die, it just stays there and disnt say that it dies even tho the char is hitting 950 and the wasps hp is only 950

the other problem is, where would i put a line to say that it has to drop gold when it dies


also how would i get the gold into the stat area of the code, it only comes up as src.Gold in the game

Post the code in <D M> </D M> tags (Without the spaces in them). It's a pain to read it otherwise.
In response to Howey
Ungh, no. Don't do stupid things like that; use entities. &lt; indicates < and &gt; indicates >. That way, you can show <dm> without having to do ridiculous things like separating them or putting in periods or whatever.
In response to Popisfizzy
I find it nice how he left the <dm> tags in there but failed to actually use them.
In response to ANiChowy
Happens daily.
You really shouldn't have useless variables like "NPC" or "Player" in your game. Just use type paths for that and then if()/else if()/else checks.

mob/NPC/wasp
hp = 1 //for testing purposes, always set their HP to something easily killed, then change it back to whatever once all tests are successful

mob/proc/deathCheck(mob/M)
if(M.hp <= 0)
if(istype(M,/mob/NPC)) //if M is an NPC...
//...
else if(istype(M,/mob/Player)) //if M is a Player...
//...
/*
No need for returns. The 'else if()' will only get tested if the first 'if()' is false.
*/


Also that return is unnecessary since that second if() has a client check

Now as for your Attack() verb >_>
mob/verb/Attack(mob/M in get_step(src,src.dir)) //no need for 'as mob' since it's already defined as a mob argument
//You also don't need that "istype()" check since, again, you already have the verb set to a mob-only argument >_>
if(!M) //I know I'm contradicting myself on this one, but I always have a sanity check for those "just in case ;p" situations
return
var/dmg = round(src.str-M.def/2)
if(dmg <= 0) dmg=1
M.hp -= dmg
viewers(M)<<"[src] hit [M] for [dmg] damage!" //anyone who can see M, will get that message
src.deathCheck(M) //call your death checking proc