ID:1401746
 
(See the best response by Akando5959.)
Naruto Supreme Chaos

Problem description:Players usually experience some lag when they are around other players or NPC. I wanted to know what might be causing that

Do you have any code that does some kind of constant observation?

Such as a who type of event that looks for players/npcs or certain contents around the player?

I would suggest looking for things like that, also when you say lag do you mean network latency or are you referring to the CPU bottlenecking?
I am referring to movement lag, they kinda freeze up and no i coudn't find that, i only found a distance check proc to make sure they walk to them or somthing
So you have an ai proc that is looking for other mobs around them?

Is this proc available to both the player and npc mob tree, or only to the npc tree?
only to the npc, i have a player proc that checks to activate npc around them
Ok can you link the code for the players check then so we can see if that is causing it?
mob/var/tmp
controling=0
NPC=0
client
North()
if(usr.controling)
for(var/mob/puppet/P in view(25))
if(!P.Frozen)
step(P,NORTH)
return
if(!usr.Moveing)
if(!usr.Frozen)
for(var/mob/M in hearers(6))
if(M.NPC)
M.NpcActive = 1 //activate the mob
M.ai_random_wander()
sleep(100)
M.NpcActive = 0 //deactivate the mob
i need it so when the player moves AWAY from the npc it deactivates can u help me with that? I think that might by an issue cuz they stay active and walk around
Best response
for(var/mob/puppet/P in view(25))
if(!P.Frozen)
P.NpcActive = 1 //activate the mob
step(P,NORTH)
spawn(100)
P.NpcActive = 0
return


See if that helps.
no, i dont need it for puppet i need it for village shinobi for example so ill just change puppet to mob, P . M ok ill try
The thing is the var/mob/puppet/p in view(25) doesn't actually check if what you are passing into it is a puppet or not it is really checking:

for anything that the player can see within 25 tiles, but expect the player to only see puppet type mobs.

By specifying that the argument should be of type mob/puppet we are telling the for loop to expect a puppet type so we can use it's variables. In your above case you could write it as:

for(p in view(25))

and still have the same effect as we are not accessing any of P's variables inside the loop.

What you want to do is this:

for(var/mob/puppet/P in view(25))
if(istype(P,/mob/puppet)
if(!P.Frozen)

step(P,NORTH)

return


This way anything inside the players view space of 25 tiles that is not a puppet type will be just parsed through.

so how would i do it if they are OUT of a certain view then it deactivates?
for(var/mob/puppet/P in view(25))
if(istype(P,/mob/puppet)
if(!P.Frozen)
usr << output("test")
step(P,NORTH)

return


Do something like that, using whatever your output method is and see if it keeps calling the output even when you move 25 tiles away.

Now remember view(25) is not 25 pixels, but rather 25 tiles. So if your tiles are say 32x32 than the view you are specifying is really 25*32 = 800 pixels away from the player, which if you look at your normal resolution of say 1900 x whatever screen that would mean that with the player on one edge of the screen and the enemie on the other edge of the screen the distance between the enemie and player would be about 42% of your screen width.
Did you get it to work?
I added it, but it was still lagging when im around NPC and players
Which part did you add?
after i added that code you told me about (puppet one) i wud freeze up close to npc and lag sooo damn hard that i wud have to quit the game and restart it.
do u have something that is like... if they players GOES OFF THE SCREEN OF THE NPC (isnt in the npc view) the npc decativates
You could move this proc to the mob/enemie/npc type and have it look for the mob/player type within view 25 and if the npc sees a mob/player than it would move. However, then you will have a bunch of NPC's that are constantly searching for a player.

Also inside:

M.ai_random_wander()

Do you have something that checks if an NPC is active or note?
no, i had it b4 but it had caused even more lag, so im trying to make t so when player is on npc screen it activated then when player goes off screen itll deactivate
Page: 1 2 3 4 5