ID:141404
 
Code:
mob/Blueteam
Blueteam
name = "Blueteam"
icon = 'npc.dmi'
icon_state="Blueteam"
Health = 25
Mhealth = 25
team = "Blueteam"
var/mob/Redteam/RT
New()
. = ..()
spawn()
Wander()
proc/Wander()
while(src)
if(RT in oview(5)) //if a Player comes in 5 steps pf him
step_towards(src,RT ) //Chase him!
for(RT in oview(1))
break
for(RT in oview(2))
break
for(RT in oview(3))
break
for(RT in oview(4))
break
else
step_rand(src) //if no NPC is 5 blocks or less away walk around
sleep(10) //stop for 1 second
for(RT in oview(5)) //.......
break
sleep(5)
spawn(5)
Wander()//Wonder again...
Bump(mob/M)
if(M.team == "Redteam") //If the NPC bumps you
Fight(M)//Fight You!
else
Wander()



How do i make this npc stay in 1tile (not moving) but if a RedTeam player comes 5steps or less to this npc, it chases him. but if the RedTeam player got away, this npc teleports back to the same spot the creator put him in the map.
But if a BlueTeam comes 5steps or less to this npc, nothing happens(this npc doesn't move, it just stays in that spot til a RedTeam player comes)

//---
sorry if this is insulting but this is like one of those British guards
Don't copy other people's horrible code. Learn to use the language and write your own code.
In response to Kaioken
isn't that what demos and library for?
In response to XskyflakezX
Not really. Demos are generally demonstrations of how you can go about implementing something (Normally, of course. In the case of this one, it's how you should NOT go about it). The code there, like plain random code from outside sources, is not always meant to be copied or will work in your game after being copied. Libraries on the other hand are meant to be used, but not by copying any of their code, rather by including them in your project.
In response to Kaioken
Why did you completely ignore Fizz's advice?

Read the DM Guide.