Post new topic    
Liquid Metal Slime
Send private message
How to wait for all NPCs on map without slow down? 
 PostFri Feb 23, 2018 6:49 am
Send private message Reply with quote
I noticed in the dictionary that "wait for all" doesn't properly wait for all NPCs. After testing this I realized that this is still true so I attempted to make my own wait for all command but I'm having mass slow downs because the way I've coded it checks through all NPCs 0-300. Is there a simpler way to wait for all NPCs with less slowdown?

For the time being I've replaced all my "wait for all npcs" commands with "wait(1)" and this seems to be sufficient time to allow for all NPCs to reach their destinations. I fear that this method of coding will break depending on how many NPCs I have on the map though and could lead to further problems.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Metal King Slime
Send private message
 
 PostFri Feb 23, 2018 7:04 am
Send private message Reply with quote
'wait for all' wrote:
if 'suspend npcs' is active, waits for all NPCs to stop walking


So, you want to wait for all NPCs but you don't want to use 'suspend npcs'? That's fair enough, if you want to do something like wait for all 'Chase' NPCs to reach the hero.

Looping through all 300 NPC references and checking whether they're moving won't cause a slowdown. Maybe the mistake you made was to loop through NPC IDs instead of NPC references, if you looped from 0 to 300 instead of from -1 to -300. That is a bit slower because for each NPC ID it needs to search for an NPC instance matching that ID. If you have 300 NPCs, that's roughly 300*300/2 = 45,000 steps. But that should definitely still not be enough to make the game run slower.

The best and most efficient way to loop through NPC instances is using the "next npc reference" command.

Edit:

After reading your other thread, I realise that what you want is this:
Code:
resume npcs
wait(1)  # Let NPCs start moving
suspend npcs
wait for all  # Get the NPCs to stop

Note that if an NPC is set to Wander, it randomly waits a few ticks before starting to move. So given just one tick it has, IIRC, only a 1/4 chance of moving. You would want to increase the wait(1) to work around that.
Liquid Metal Slime
Send private message
 
 PostFri Feb 23, 2018 7:59 am
Send private message Reply with quote
Thanks this seems to be working.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Display posts from previous: