Jump to content

ScriptedInstance Update


Guest Imagine

Recommended Posts

When a player enters an instance, the script associated with that instance is executed..

if that player then leaves the instance, the script continues to run.

This is what i have gathered so far from some tests, i would like to know if :

1) Is there some kind of auto timeout for instance scripts if no players are inside

2) Is there a way of disposing of that instance when there are no players inside

Also do scriptedAI scripts continue to run when there are no players inside of the same instance

the problem is im currently using the Update method in scriptedInstance to control some events (talking, moving, spawning mobs)

and im concerned about it causing unnecessary processor usage if the script is running when there are no players in that instance.

Link to comment
Share on other sites

This is the function responsible for updating all the instance maps:

void MapInstanced::Update(const uint32& t)
{
   // take care of loaded GridMaps (when unused, unload it!)
   Map::Update(t);

   // update the instanced maps
   InstancedMaps::iterator i = m_InstancedMaps.begin();

   while (i != m_InstancedMaps.end())
   {
       if(i->second->CanUnload(t))
       {
           DestroyInstance(i);                             // iterator incremented
       }
       else
       {
           // update only here, because it may schedule some bad things before delete
           i->second->Update(t);
           ++i;
       }
   }
}

As you can see, they will only update if they can't unload. Whether or not they can unload is dependant on your config:

#    Instance.UnloadDelay
#        Unload the instance map from memory after some time if no players are inside.
#        Default: 1800000 (miliseconds 30 minutes)
#                 0 (instance maps are kept in memory until they are reset)

By default, the map will only unload after it's empty for 30 minutes, so it will it's AI will continue to be updated for 30 minutes.

Link to comment
Share on other sites

thanks,

also as a side question, is there any method of getting a list of all creatures of entry X, Y or Z in an instance

or should i have to add them to a list using OnCreatureCreate()

Im trying to create a function that returns false if there are any creatures still alive that have a specific (or one of many) entry(s)

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use