ID:1718823
 
(See the best response by Audeuro.)
Problem description: How to force the mob to move to the nearest player?
IF you mean by teleporting the mob to the nearest player, the code below should work.

mob/proc/MoveToNearestPlayer()
var/mob/n = null
var/d = 999999
for (var/mob/m in world)
if (m.client)
var/e = Distance_Get2D(src, m)
if (e < d)
n = m
d = e
if (n)
loc = n.loc


proc/Distance_Get2D(mob/M1, mob/M2)
return abs(M2.x - M1.x) + abs(M2.y - M1.y)
How to activate this process?
Best response
Mmmm, Z-level issues there could be. Restrict with block, I would.

Call the proc MoveToNearestPlayer() you must.
I call it from the mob, but not fucking work. This is still the first question.

Code:
mob/blink_dealer
icon = 'blink_dealer.dmi'
MoveToNearestPlayer()
Ahh, improperly using it, you are. As an example, this serves:

mob/blink_deaker
icon = 'blink_dealer.dmi'
verb/MoveMe()
MoveToNearestPlayer()


Where you have it, MoveToNearestPlayer() is being considered a re-definition of the proc. To properly call it, it needs to be within a proc or verb.
Not working. We need to constantly chase the player mob, without activation.
SS13 fan, we have. Never read DM Guide, he must.
Write a working example - 1 minute, read the guide - the week.
In response to Gelium
Gelium wrote:
Write a working example - 1 minute, read the guide - the week.



Yeah but then we don't get these stupid ducking threads where the OP is a rude birch. Just saying.
Sorry. I already searched in Guide, and therefore addressed here. But if you find it difficult to throw a working example then fine. I'll go re-read guides again. Thank you all.
In response to Gelium
Gelium wrote:
Sorry. I already searched in Guide, and therefore addressed here. But if you find it difficult to throw a working example then fine. I'll go re-read guides again. Thank you all.

the guide isn't meant to give you working examples for all your problems.

You need a brain and basic knowledge and understanding of the language for that.
In response to Gelium
Write a working example - you never learn and just use developer help as a plug-and-play.

Explain what needs done and/or give you (references to)learning material to help you solve your issue - you learn and gradually get better, requiring less and less outside help.
Да не тупите вы! Если вы вкинете рабочий пример, то я пойму устройство, то, как это работает! Иначе бы я не просил.

Yes you be smart! If you give me a working example, I understand the device, how it works! Otherwise I would not ask.
Think about it. If you need something to be continuous, it should go into a loop.
In response to Mightymo
Mightymo wrote:
Think about it. If you need something to be continuous, it should go into a loop.

I don't think he understands loops.
For what it's worth, I wouldn't do it as a loop if this is what he wants to do:

atom/Move

atom/var/list/followers
atom/proc/GainFollower
atom/proc/LoseFollower
atom/proc/InitiateFollowing() // "MoveToNearestPlayer"
Yeah, that would probably be a bit better.