[DiscordArchive] Is it possible to schedule an event to happen f...
[DiscordArchive] Is it possible to schedule an event to happen f...
Archived author: Drikish • Posted: 2024-12-18T23:18:50.141000+00:00
Original source
If you already replied to this then sorry, I was assuming it would just be doing quick check and return vs letting the logic run perma
Archived author: stoneharry • Posted: 2024-12-18T23:30:03.396000+00:00
Original source
```c++
class spell_my_custom_map_script : public WorldMapScript
{
public:
spell_my_custom_map_script(const char* name, uint32 mapId) : WorldMapScript(name, mapId)
{
}
void OnUpdate(Map* map, uint32 diff)
{
// Ensure we don't tick more than once a second
_elapsedTime += diff;
if (_elapsedTime < 1000)
return;
_elapsedTime = 0;
// More expensive logic
}
private:
uint32 _elapsedTime = 0;
};
void AddCustomScripts()
{
new spell_my_custom_map_script("spell_my_custom_map_script", 1u);
}
```
Archived author: Drikish • Posted: 2024-12-18T23:33:24.120000+00:00
Original source
Ty for sharing and all your help
Archived author: Drikish • Posted: 2024-12-18T23:34:29.717000+00:00
Original source
The big thing I am going to have to do is keep track of the time on this map somehow
Archived author: Drikish • Posted: 2024-12-18T23:35:01.222000+00:00
Original source
This map has its own time logic so i'll need to have that stored and ready to send to players when they hit this map
Archived author: Drikish • Posted: 2024-12-18T23:39:07.718000+00:00
Original source
I think I can handle that, <@271350028985958408> I only have one more question if you get a second:
How would I go about interacting with this? Lets say for example someone clicks on an object in game and I want to call a function on this map - something like "ProgressToMidnight()" if that was a public function available on this map.
Archived author: stoneharry • Posted: 2024-12-18T23:45:36.172000+00:00
Original source
Add it as a function on Map.h and Map.cpp. You have that object available in the update method
Archived author: stoneharry • Posted: 2024-12-18T23:45:51.533000+00:00
Original source
and your script can set it, as it can access the map object easily
Archived author: stoneharry • Posted: 2024-12-18T23:45:55.574000+00:00
Original source
WorldObject::GetMap
Archived author: stoneharry • Posted: 2024-12-18T23:46:20.967000+00:00
Original source
you would set a variable that the OnUpdate reads on next tick and reacts to it