ID:145105
 
Code:
        Moves()
while(src)
if(client)
if(ai!=1) return
var/location=src.loc
var/atk=0
if(!usr) return
sleep(5)
if(!usr) return
if(usr.target)
step_to(usr,usr.target,1)
if(get_dist(usr,usr.target)<=5)
usr.target=null
else
for(var/mob/M in view())
if(M.clan!=src.clan)
step_towards(src,M)
for(var/mob/M in view(1))
sleep(1)
if(M.clan!=src.clan)
atk=1
step_towards(src,M)
AttackB()
if(location==src.loc&&!atk)
step_rand(src)
continue


Problem description:
Edit:step_to(usr,usr.target,1)
for some reason he the usr freezes and doesnt move when i set the target to a mob in the world. Anyone know what I am doing wrong?
        Moves()
while(src)
if(client)
if(ai!=1) return
var/location=src.loc
var/atk=0
if(!usr) return
sleep(5)
if(!usr) return
if(usr.target)
step_to(usr,usr.target,1)
if(get_dist(usr,usr.target)<=5)
usr.target=null
else
for(var/mob/M in oview())
if(M.clan!=src.clan)
step_towards(src,M)
for(var/mob/M in oview(1))
sleep(1)
if(M.clan!=src.clan)
atk=1
step_towards(src,M)
AttackB()
if(location==src.loc&&!atk)
step_rand(src)
continue


since you used
for(var/mob/M in view())
The mob who's trying to move to someone else moves to itself.you should use
for(var/mob/M in oview())
instead so it cuts itself out of the picture walks to OTHERS instead of moving to itself.
In response to Metamorphman
if(M.clan!=src.clan) takes care of that so its not a real big deal, the only problem i have is getting the mobs to step_to

heres the other part of the code.

mob
Lords
verb
Attack_Wu_Castle()
set category="Lord"
for(var/mob/M in world)
if(M.name=="Wu Lord")
usr.target=M
for(var/mob/M in view())
if(M.client)
M<<"[usr] demands you to attack Wu Lord!"
M.target=usr.target
Attack_Wei_Castle()
set category="Lord"
for(var/mob/M in world)
if(M.name=="Wei Lord")
usr.target=M
for(var/mob/M in view())
if(M.client)
M<<"[usr] demands you to attack Wei Lord!"
M.target=usr.target
Attack_Shu_Castle()
set category="Lord"
for(var/mob/M in world)
if(M.name=="Shu Lord")
usr.target=M
for(var/mob/M in view())
if(M.client&&M!=usr)
M<<"[usr] demands you to attack Shu Lord!"
M.target=usr.target
Attack_GM_Castle()
set category="Lord"
for(var/mob/M in world)
if(M.name=="GM Lord")
usr.target=M
for(var/mob/M in view())
if(M.client)
M<<"[usr] demands you to attack GM Lord!"
M.target=usr.target
In response to Killer22
Killer22 wrote:
if(M.clan!=src.clan) takes care of that so its not a real big deal, the only problem i have is getting the mobs to step_to


No NO NO No No.If M is src which unless you use
for(var/mob/M in oview())
Then
if(M.clan == src.clan)
is useless.He'll still move to himself
In response to Metamorphman
trust me, its not that im having problems with, because he moves fine when i dont set a target, but when i do set a target, he stops, and doesnt move...
In response to Killer22
Killer22 wrote:
trust me, its not that im having problems with, because he moves fine when i dont set a target, but when i do set a target, he stops, and doesnt move...


OMG.The problem is that the TARGET is usr Which wont make ANYTHING move at all!!!!!
In response to Metamorphman
NO FOOL! I JUST TESTED THAT

(IN GAME)SYSTEM TEST: step_to(GM Soldier,Wu Lord,1)
In response to Killer22
Hmm, anyone able to help me?
In response to Killer22
I don't see walk_to neither step_to in that code... Sorry if I missed something.

As for an example of how to walk to someone,
mob/verb/step_towards_someone(mob/m in world)
while(src)
step_towards(src,m)
In response to DivineO'peanut
oops, i ment step_to... but its in there, here it is..
                if(usr.target)
step_to(usr,usr.target,1)
if(get_dist(usr,usr.target)<=5)
usr.target=null


I know how to make the mob move, but i don't want him to move in that direction, i want him to get to to target without having to worry about objects in his way.
In response to Killer22
You mean flot to him? Just set his density to 1. lol

Or do you mean teleport to him? Use locate() for that.
In response to DivineO'peanut
ehh, i want him to walk to the lord so he can kill, him, but i want the mob to move around objects... is that more clear?
In response to Killer22
Directly from Reference:
<small>
Move Ref on a path to the location Trg, taking obstacles into account. If Ref is within Min steps of Trg, no action will be taken. This is also the case if the target is too far away (more than twice world.view steps).
</small>