ID:144331
 
Code:
mob
monsters
zombie
icon='Quxatrox.dmi'
icon_state = "Qux"
Hp = 50
MaxHp = 50
Strength = 7
Defense = 3
ExpGive = 10
Lvl = 1
attacking = 0

var/mob/Player/P
New()
.=..()
spawn(1)
Wander()
proc/Wander()
Deathcheck()
while(src)
if(attacking==1)
if(P in oview(5))
step_towards(src,P)
Deathcheck()
else
attacking = 0
Wander()
else
step_rand(src)
for(P in view(src))
break
sleep(5)
spawn(40)
Wander()
Bump(mob/Player/C)
if(ismob(C))
var/damage = usr.Strength - usr.ExStr
damage -= C.Defense - C.ExDef
if(damage > 0)
C << "[usr] attacks you and does [damage] damage"
usr << "You attack [P] for [damage] damage"
C.Hp -= damage

else
C << "[usr]'s attack bounces off of you!"
usr << "Your attack bounces off of [src]!"
C.Deathcheck()



mob
proc
Levelup()
if(src.Exp >= src.MaxExp)
src.Lvl += 1
src.MaxHp += 10
src.MaxMp += 10
src.Strength += 2
src.Defense += 1
src.MaxExp *= 2
src << "You gain a level"
src << "Your HP went up 10"
src << "Your MP went up 10"
src << "Your Strength went up 2"
src << "Your Defense went up 1"
src << "You need [MaxExp-Exp] more exp"
else
..()

Deathcheck()
if(src.Hp <= 0)
if(istype(src.client))
src << "You have died, [usr] killed you!"
usr << "You killed [src]"
src.loc = locate(1,1,1)
src.attacking = 0
else
usr.Exp += src.ExpGive
src.attacking = 0
usr << "You have killed [src]!"
del(src)
else
..()

verb
Attack()
if(attacking)
return
attacking = 1
for(var/mob/M in get_step(usr,usr.dir))
var/damage = usr.Strength - usr.ExStr
damage -= M.Defense - M.ExDef
if(damage > 0)
M << "[usr] attacks you and does [damage] damage"
usr << "You attack [M] for [damage] damage"
M.Hp-=damage
else
M << "[usr]'s attack bounces off of you!"
usr << "Your attack bounces off of [src]!"
M.Deathcheck()
usr.Levelup()


Problem description:
It wont attack the monster any one know wy?

under attack set it as if(!attaking) that might work unsure.:/
~Grand~
In response to KillerGrand
No, its because he sets attacking to 1 after 1 attack and never changes it back. You need to change it back to when the attack is over.

Also, the char you're testing it with will still have the attacking var stuck to 1, so create another char after making it 0 in the code (when the attack is done).
In response to Pyro_dragons
You need to pass an argument through the deathcheck, and not use usr.
you can change

for(var/mob/M in get_step(usr,usr.dir))

to

var/mob/M = locate(/mob) in get_step(src, dir)


It'll probably work if you add the option i gave you. It works for me :P
In response to King of Bums
King of Bums wrote:
you can change

for(var/mob/M in get_step(usr,usr.dir))

to

var/mob/M = locate(/mob) in get_step(src, dir)


It'll probably work if you add the option i gave you. It works for me :P

That's not bad, although it has one down side: If for some reason multiple mobs are allowed to stand in the same spot, now only one of them can be picked up by this routine. Although it's unlikely such a design would be done, my preference would be for the loop rather than locate(), just in case.

In most games they're equivalent.

Lummox JR