ID:143306
 
Code:
mob/Click()
for(var/mob/npcs/Bunshin in world)
if(Bunshin.owner == usr)
if(istype(src,/mob in get_step(usr,usr.dir)))
walk_towards(Bunshin,src)
var/Damage = round(usr.tai*2)//define var damage(you can make it better)
src.hp -= Damage//lose hp..
view()<<"[src] was attacked by [usr]'s Kage Bunshin for [Damage] damage!"//say it to those who are near you...
src.Killer = usr
src.Death(usr)//Call death proc
else
return


Problem description:My objective is: When I click over a mob, my mob (lets call it Bunshin) will approach the enemy and inflict some damage, however it doesnt work... It follows the enemy but it doesnt attack him when they are in get step... plz help me

Can you please answear me ?
In response to Cybork
Cmon...
First off, I've never seen "in" in istype() before and I'm guessing that's invalid. Also note that the mob that's being clicked on is the src and not the one who clicked.
mob/Click()
for(var/mob/npcs/Bunshin in world)
if(Bunshin.owner == usr)
for(var/mob/M in get_step(usr,usr.dir))
walk_towards(Bunshin,src)
var/Damage = round(usr.tai*2)
src.hp -= Damage
view()<<"[src] was attacked by [usr]'s Kage Bunshin for [Damage] damage!"
src.Killer = usr
src.Death(usr)//Call death proc
break
In response to Kakashi24142
Doesnt work :(
In response to Cybork
Edited my post try it again.
Cybork wrote:
it doesnt attack him when they are in get step... plz help me

Because certainly not how you do it; though code-wise you're actually pretty close. You want to look operators and procs up in the DM Reference (F1 in Dream Maker) before you use them; don't just stick in and such in your code because programming isn't writing sentences, you don't make things like /mob in get_step() and expect it to work on they're own (though again you've actually hit close in this lucky case). You want to use the DM Reference a lot and read the DM Guide so you will know how to program and what you are doing. For this matter at hand you'll want to look up in the DM Reference the 'in' operator and the 'locate()' proc (which uses 'in' as it's own syntax).
Also you should want to check whether the "bunshin" is even near the clicked object before you do anything with it and as such.