[DiscordArchive] Is it possible to schedule an event to happen f...
[DiscordArchive] Is it possible to schedule an event to happen f...
Archived author: stoneharry • Posted: 2024-12-18T21:50:03.461000+00:00
Original source
something like:
```c++
// 47447 - Corrosive Spit
class spell_my_custom_map_script : public MapScript
{
PrepareMapScript(spell_my_custom_map_script );
void OnUpdate(Map* /map*/, uint32 /*diff*/)
{
// Your logic here
}
};
void AddCustomScripts()
{
RegisterMapScript(spell_my_custom_map_script)
}
```
Archived author: Drikish • Posted: 2024-12-18T21:59:28.357000+00:00
Original source
Thanks again for the reply, how do I actually assign it to the map ID itself?
Archived author: Drikish • Posted: 2024-12-18T22:00:58.193000+00:00
Original source
<@271350028985958408> - everything else i did via C++ there was a place to load / assign it in the DB but i can't see anything for map scripts
Archived author: Drikish • Posted: 2024-12-18T22:01:12.070000+00:00
Original source
or do I just check the map ID as part of the script logic and this runs regardless?
Archived author: stoneharry • Posted: 2024-12-18T22:08:55.636000+00:00
Original source
```c++
WorldMapScript::WorldMapScript(char const* name, uint32 mapId)
: ScriptObject(name), MapScript(sMapStore.LookupEntry(mapId))
{
if (!GetEntry())
TC_LOG_ERROR("scripts", "Invalid WorldMapScript for {}; no such map ID.", mapId);
if (GetEntry() && !GetEntry()->IsWorldMap())
TC_LOG_ERROR("scripts", "WorldMapScript for map {} is invalid.", mapId);
ScriptRegistry<WorldMapScript>::Instance()->AddScript(this);
}
````
`template class TC_GAME_API ScriptRegistry<WorldMapScript>;`
It looks like just declaring a map script adds it
Archived author: stoneharry • Posted: 2024-12-18T22:09:26.548000+00:00
Original source
so it would be something like:
```c++
class spell_my_custom_map_script : public WorldMapScript
{
PrepareMapScript(spell_my_custom_map_script );
void OnUpdate(Map* /*map*/, uint32 /*diff*/)
{
// Your logic here
}
};
void AddCustomScripts()
{
RegisterWorldMapScript(spell_my_custom_map_script)
}
```
Archived author: Drikish • Posted: 2024-12-18T22:13:14.508000+00:00
Original source
Hmmm that seems odd
Archived author: Drikish • Posted: 2024-12-18T22:13:32.238000+00:00
Original source
So I would need to check the ID inside the logic then
Archived author: Drikish • Posted: 2024-12-18T22:27:59.769000+00:00
Original source
<@271350028985958408> - you said there was a more efficient way to handle the onUpdate without it polling every tick, would this just be an immediate return if a condition didn't match?
Archived author: stoneharry • Posted: 2024-12-18T23:09:52.787000+00:00
Original source
yes