ID:273900
 
Hey guys I been going over my AI and seen there that theres actually nothing there to make the monster respawn or to give the killer exp. I couldnt figure out how to do it so i turned here.

Heres my code:

mob
Move()
for(var/mob/monster/M in oview(5)) if(!M.woken) spawn() AI(M,src)
..()
Login()
client.view=8
..()
monster
New()
for(var/client/M in oview(5)) AI(src,M)
..()
Turtle
icon='turtle.dmi'
icon_state="strong turtle"
Level = 1
strenght = 10
defence = 10
var
woken
attacking

proc
Attack(mob/monster/T)
for(var/mob/M in get_step(T,T.dir))
var/damage = T.strenght - usr.defence
M.power -= damage
view(6)<<"[T] attacks [M] for [damage] damage!"
M:deathcheck()

AI(mob/monster/T,mob/M)
if(!T||T.client||!M.client) return
T.woken=10
while(T&&T.woken)
sleep(10)
if(T.woken>0&&get_dist(T,M)>5&&T&&M)
step_rand(T)
T.woken-=1
else if(get_dist(T,M)<6&&T&&M)
step_towards(T,M)
if(get_dist(T,M)<=1)
T.dir=get_dir(T,M)
Attack(T)


That was the AI code and here my Deathcheck

mob
proc
deathcheck()
if(src.power <= 0)
view() << "[src] dies!"
src.power = src.maxpower
src.Move(locate(42,22,3))

I would also wish to find out how to make it that if i kill a lvl 1 monster i receive less exp that killing a lvl 10 monster

Any help?
You will need to let the deathcheck() proc know what is causing the damage, so you can attribute the kill to it.
//Death Check declaration
mob/proc/deathcheck(mob/attacker)

//Death Check call in your attack code
target.deathcheck(attacker)


Making EXP. gained on kill depend on the victim's level shouldn't be hard with a variant of
killer.GainExp(EXP_RATE * victim.level)


Also: You are moving your dead thing to a certain spot on the map, including both a player and a monster that dies. I doubt that's intended behavior, as it may lead to a dead player getting absolutely swarmed on respawn, or worse: your town getting overrun by dead monsters.
In response to Yoran91
I still dont get how do you put the monster back on the map after some time
Okay, first off! It's pretty bad of you to try to pass off this library as your code. Shame on you! I've utilized this library about six months back to give myself an example of how to program AI. That is the reason you can't figure out how to do a simple deathcheck procedure or give your player experience. You don't know how to code.

This is a prime example of what is wrong with BYOND today. That is all
In response to Dj dovis
Dj dovis wrote:
I still dont get how do you put the monster back on the map after some time

Perhaps you can override the monster's Del() proc to create a new monster of the same type and set its location to what you want.
In response to Hashir
Its alright I figured out how to do it