Jump to content

ScriptedInstance Update


Recommended Posts

Posted

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.

Posted

I managed to solve the first problem, it was a combination of bad code and typo's

anyway i have edited the question to something else im having trouble with :P

Posted

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.

Posted

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)

Posted

Create a vector of guids (i would add guidids in OnCreatureCreate() as you already mentioned)

The function just have to loop through the vector and check if a creature is alive when return true.

×
×
  • 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