ID:169049
 
Im making a game, I want mobs to randomly move and 1 in 2 turns itll goto the Client. How would I do this?
Can you explain that a little better? I'm not sure what you mean.
In response to Artekia
The NPC's will roam randomly, and I want it so every once in a while it will hoom in on the player for a second or two, then goto random again.
In response to Strawgate
Something like this?
mob/NPC/var/Follow
proc/NPCMove()
while(world)
sleep(5)
for(var/mob/NPC/M)
if(prob(20) || M.Follow)
if(!M.Follow)
var/mob/Target=pick(Players) // You can keep a list of players, and add/subtract from it when people log in/out
M.Follow = Target
step_towards(M,M.Follow)
else
step_rand(M)
if(prob(35)) M.Follow=null
world/New()
..()
NPCMove()

Untested, and there are a lot of ways you could do it, but I think that'd work.
In response to Artekia
Artekia wrote:
Something like this?
> mob/NPC/var/Follow
> proc/NPCMove()
> while(world)
> sleep(5)
> for(var/mob/NPC/M)
> if(prob(20) || M.Follow)
> if(!M.Follow)
> var/mob/Target=pick(Players) // You can keep a list of players, and add/subtract from it when people log in/out
> M.Follow = Target
> step_towards(M,M.Follow)
> else
> step_rand(M)
> if(prob(35)) M.Follow=null
> world/New()
> ..()
> NPCMove()
>

Untested, and there are a lot of ways you could do it, but I think that'd work.

The thing is... its a single Player game.
so would the target is the only player?
In response to Strawgate
You could do this to refer to the player-
var/Player
mob/Login()
Player=src

Then you can use Player as a reference, as long as only one person joins.
In response to Artekia
For some reason its not letting me call the NPCmove
In response to Strawgate
How can it not let you? I tested it and it worked.
In response to Artekia
Nevermind, I went over the code and realized what I did wrong. Its perfect thanks!
In response to Strawgate
Is there anyway I can use Deadron's Pathfinding to allow the NPC to go around walls?
In response to Strawgate
Sorry everyone but I must tell you im very sorry: BUMP
In response to Strawgate
Wait 24 hours before bumping, and make sure it's off of the front page.
Plus, Ron's lib already does that.
In response to Ol' Yeller
The thing only works on turfs, not mobs. The rule for bumping is off the front page or 1 day old. It was off the front page, so i bumped it.
In response to Strawgate
Strawgate wrote:
The rule for bumping is off the front page or 1 day old. It was off the front page, so i bumped it.

The rule for bumping is off the page and one day.
In response to Strawgate
It seems the step toward goes to walls then just isnt effecient.