ID:176425
 
Well i know this is a long shot and ive been tring But can some one make it so if a mobs is attack they will attack back ?

Please hears my code....Thank you

mob/monsters/Bandit
HP = 40
icon = 'monsters.dmi'
icon_state = "bandit"
mouse_opacity = 2
Click()
if(get_dist(usr,src) <= 1)
usr.attack(src)
sleep(100)
else
...()

proc/move()
for(var/mob/M in oview())
if(get_step_away(src,M,1))
if(!M.client)
continue
else
walk_to(src,M,1,2)
else
continue
spawn(20)
move()

proc/attackplayer()
for(var/mob/M in oview(1))
if(get_step_away(src,M,1))
if(!M.client)
continue
else
src.attack(M)
else
return..()
spawn(20) attackplayer()

New()
attackplayer()
goldgiven = rand(5,10)
expgiven = rand(1,5)
move()
Mordor wrote:
Well i know this is a long shot and ive been tring But can some one make it so if a mobs is attack they will attack back ?

In your attack(mob/M) proc, you should put the line M.attackplayer(src) somewhere. But only if it's not attacking, otherwise it will fall into an infinite loop. Maybe you should call attack() straght away instead of attackplayer? It depends on how your combat system is designed.


/Gazoot
In response to Gazoot
Will thank you i got it to work
In response to Mordor
Great! Now when I read my post again I find my advice to be a little confusing. So I'm glad you figured it out.

/Gazoot
You should make one other change: Don't forget to change oview(1) to oview(1,src) in the attack proc. oview() uses usr as a center by default, which isn't the right thing in the case of a mob attacking a player.

Lummox JR