Battle System:
mob/verb/Attack(mob/M in oview(1))//This will be used to make the demo challenging
var/damage = usr.Str/M.Def
M<<"[src] attacked you for [damage] damage!"
if(src.client)
src<<"You attacked [M] for [damage] damage!"
M.Hp -= damage
src.deathcheck(M)
if(src.client)//Only players can gain levels
//adds random exp points//calls the levelup proc
else
return..()//normal action
mob/proc/deathcheck(mob/M as mob)//handles death
if(M.Hp<=0)//checks health
if(M.client)//if is a player
M.loc = locate(11,4,1)//restarts
M.Hp = M.Mhp//resets health
M<<"[src] killed you!"//tells you, you were killed.
src.Levelup()
else//not a player
src<<"You killed [M]!"
del(M)//Tells you who you killed
src.Exp+=rand(10,50)
sleep(200)
world.Repop()
//random location after death
mob
proc
Levelup()
if(usr.Exp>=src.MExp)//If your exp var equals, or passes your maxexp var
usr.Lvl++//Add to your level
usr.Exp=0//resets your exp to 0
usr.MExp+=rand(1,25)//makes your maxexp double
usr.Str+=rand(1,10)
usr.Def+=rand(4,5)
usr<<"You gained a level!"
else
..()
Monster A.I:
mob/monster/Basilisk//Defines a /mob/NPC
icon = 'Monsters.dmi'
icon_state = "Basilisk"
Hp = 100
Str = 15
Def = 10
proc/move()//Now, this proc handles NPC movement
for(var/mob/M in oview())//loops over all mobs in view
if(get_step_away(src,M,3))//checks distance
if(!M.client)//Not a player
continue//continues through the loop
else//Player
walk_to(src,M,1,4)//Move to the person
else//4-or-more spaces away
continue
spawn(20) move()//loops the proc after 2 seconds
proc/attackplayer()//Handles attacking
for(var/mob/M in oview(1))//Within one space this time
if(get_step_away(src,M,1))
if(!M.client)
continue
else
src.Attack(M)//Calls the attack proc
else
return..()
spawn(20) attackplayer()
New()//When created
attackplayer()//Calls the procs for it
move()
Thanks in advance for your help.
~C