ID:146983
 
Below is my attack verb and deathcheck proc, they work fine, i can attack monsters, but one problem, how do i make the monsters attack me back? Please help. Thanks.
mob
verb
Attack(mob/M as mob in oview(1))
var/damage = rand(usr.strength-M.defense)
if(damage <= 0)
usr << "[M] easily dodges your attack!"
M << "You easily dodge [usr]'s attack."
else
M.hp -= damage
view() << "[usr] attacks [M] for [damage] Damage!"
M:DeathCheck()
mob
proc
DeathCheck()
if(src.hp <= 0)
view() << "[src] dies!"
src.hp = 10
if(monster == 1)
del(src)
else
src.Move(locate(1,1,1))
Dude, I don't think you are going to get an answer, this is the third time you've posted this, and the other two didn't get answers. So, this is the THIRD post on the SAME topic, all within what..24 hours? 12 hours? less?
Just look for a demo or library in the search. You could have found it if Kunark still had RPG tutorial but he just took it off the hub.
You have to create an A.I. loop. Basically, you just have to create something of a looping procedure that tells the monsters to walk towards players, and attack them. This is the second simplest kind of monster A.I. in my opinion.

I'm not the best at this kind of thing, but I'l give this a stab.

mob/npc
AI_loop()
if(locate(/mob in oview(6,src))
//we begin to detect the monster's target here
var/mob/target
var/trange = 7
for(var/mob/M in oview(6,src))
if(M.client)
if(get_dist(src,M)<trange)
trange = get_dist(src,M)
target = M
if(trange==1)
break
if(trange==1)
//attack the player
else
src.step_towards(target)
spawn(X)//replace X with an ammount. The lower, the less time between steps and attacks.
src.AI_loop()
New()
..()
spawn()
src.AI_loop()


This should do it. And by the way, I'm certain other people may have brought this up, but it is rude to make multiple posts if your question dies. If nobody answers, wait a day and try again. DO NOT, however, make multiple posts on different forums on the same topic. You really annoy people when you do stuff like this. Plus, try making your title a bit more descriptive. "Please help" doesn't say a lot. I'd have titled it something along the lines of "Enemy AI help.". Just a heads up for next time.
In response to Lenox
Lenox wrote:
Dude, I don't think you are going to get an answer, this is the third time you've posted this, and the other two didn't get answers. So, this is the THIRD post on the SAME topic, all within what..24 hours? 12 hours? less?

I agree with Lenox, you shouldn't post the same thing 3 times in the same day. If you question doesn't get answered within a short period of time that doesn't mean you need to repost your question again. Anyways, this post should be in newbie central.
In response to Zaltron
Zaltron wrote:
Anyways, this post should be in newbie central.

It is... twice. =P
In response to YMIHere
YMIHere wrote:
Zaltron wrote:
Anyways, this post should be in newbie central.

It is... twice. =P

*checks newbie central* You're right, but that makes 4 times <_<. I'm annoyed though; I wrote up a really long and in-depth mini-tutorial for this, but then, I accidently pressed Ctrl+B(Back) instead of Ctrl+V(Paste) <_<