Forums WoW Modding Support Archives WoWModding Threads [DiscordArchive] Is it possible to schedule an event to happen f...

[DiscordArchive] Is it possible to schedule an event to happen f...

[DiscordArchive] Is it possible to schedule an event to happen f...

Pages (10): Previous 1 2 3 4 5 6 10 Next  
rektbyfaith
Administrator
0
12-18-2024, 07:51 PM
#31
Archived author: stoneharry • Posted: 2024-12-18T19:51:26.748000+00:00
Original source

Check: `virtual void Update(uint32 /*diff*/) { }`

In: `InstanceScript`

That would be the way to script it, on map update you take the diff and check if it has passed a time. If it has, you can fire your logic and reset the timer. You can check if the server time has passed the 2 hour mark since the last call (currentTime - diff) and if it has fire your event.

You should probably also check if a minimum time has passed since you last checked the time as a performance gain (so you don't check every tick).
rektbyfaith
12-18-2024, 07:51 PM #31

Archived author: stoneharry • Posted: 2024-12-18T19:51:26.748000+00:00
Original source

Check: `virtual void Update(uint32 /*diff*/) { }`

In: `InstanceScript`

That would be the way to script it, on map update you take the diff and check if it has passed a time. If it has, you can fire your logic and reset the timer. You can check if the server time has passed the 2 hour mark since the last call (currentTime - diff) and if it has fire your event.

You should probably also check if a minimum time has passed since you last checked the time as a performance gain (so you don't check every tick).

rektbyfaith
Administrator
0
12-18-2024, 07:52 PM
#32
Archived author: stoneharry • Posted: 2024-12-18T19:52:18.641000+00:00
Original source

`void Map::Update(uint32 t_diff)` exists in `Map.cpp`

That's where most of the logic exists
rektbyfaith
12-18-2024, 07:52 PM #32

Archived author: stoneharry • Posted: 2024-12-18T19:52:18.641000+00:00
Original source

`void Map::Update(uint32 t_diff)` exists in `Map.cpp`

That's where most of the logic exists

rektbyfaith
Administrator
0
12-18-2024, 07:52 PM
#33
Archived author: stoneharry • Posted: 2024-12-18T19:52:55.486000+00:00
Original source

You can see that fires: `void ScriptMgr::OnMapUpdate(Map* map, uint32 diff)`
rektbyfaith
12-18-2024, 07:52 PM #33

Archived author: stoneharry • Posted: 2024-12-18T19:52:55.486000+00:00
Original source

You can see that fires: `void ScriptMgr::OnMapUpdate(Map* map, uint32 diff)`

rektbyfaith
Administrator
0
12-18-2024, 09:05 PM
#34
Archived author: Drikish • Posted: 2024-12-18T21:05:46.471000+00:00
Original source

<@271350028985958408> - so your saying write an instanceScript for this map?
rektbyfaith
12-18-2024, 09:05 PM #34

Archived author: Drikish • Posted: 2024-12-18T21:05:46.471000+00:00
Original source

<@271350028985958408> - so your saying write an instanceScript for this map?

rektbyfaith
Administrator
0
12-18-2024, 09:11 PM
#35
Archived author: stoneharry • Posted: 2024-12-18T21:11:31.669000+00:00
Original source

It can be a map script, see `ScriptMgr::OnMapUpdate(Map* map, uint32 diff)`
rektbyfaith
12-18-2024, 09:11 PM #35

Archived author: stoneharry • Posted: 2024-12-18T21:11:31.669000+00:00
Original source

It can be a map script, see `ScriptMgr::OnMapUpdate(Map* map, uint32 diff)`

rektbyfaith
Administrator
0
12-18-2024, 09:18 PM
#36
Archived author: Drikish • Posted: 2024-12-18T21:18:05.126000+00:00
Original source

```c++
class MapScript : public UpdatableScript<TMap>
{
MapEntry const* _mapEntry;

protected:

MapScript(uint32 mapId) : _mapEntry(sMapStore.LookupEntry(mapId))
{
if (!_mapEntry)
TC_LOG_ERROR("scripts", "Invalid MapScript for %u; no such map ID.", mapId);
}

public:

// Gets the MapEntry structure associated with this script. Can return NULL.
MapEntry const* GetEntry() { return _mapEntry; }

// Called when the map is created.
virtual void OnCreate(TMap* /*map*/) { }

// Called just before the map is destroyed.
virtual void OnDestroy(TMap* /*map*/) { }

// Called when a grid map is loaded.
virtual void OnLoadGridMap(TMap* /*map*/, GridMap* /*gmap*/, uint32 /*gx*/, uint32 /*gy*/) { }

// Called when a grid map is unloaded.
virtual void OnUnloadGridMap(TMap* /*map*/, GridMap* /*gmap*/, uint32 /*gx*/, uint32 /*gy*/) { }

// Called when a player enters the map.
virtual void OnPlayerEnter(TMap* /*map*/, Player* /*player*/) { }

// Called when a player leaves the map.
virtual void OnPlayerLeave(TMap* /*map*/, Player* /*player*/) { }

// Called on every map update tick.
virtual void OnUpdate(TMap* /*map*/, uint32 /*diff*/) { }
};
```
rektbyfaith
12-18-2024, 09:18 PM #36

Archived author: Drikish • Posted: 2024-12-18T21:18:05.126000+00:00
Original source

```c++
class MapScript : public UpdatableScript<TMap>
{
MapEntry const* _mapEntry;

protected:

MapScript(uint32 mapId) : _mapEntry(sMapStore.LookupEntry(mapId))
{
if (!_mapEntry)
TC_LOG_ERROR("scripts", "Invalid MapScript for %u; no such map ID.", mapId);
}

public:

// Gets the MapEntry structure associated with this script. Can return NULL.
MapEntry const* GetEntry() { return _mapEntry; }

// Called when the map is created.
virtual void OnCreate(TMap* /*map*/) { }

// Called just before the map is destroyed.
virtual void OnDestroy(TMap* /*map*/) { }

// Called when a grid map is loaded.
virtual void OnLoadGridMap(TMap* /*map*/, GridMap* /*gmap*/, uint32 /*gx*/, uint32 /*gy*/) { }

// Called when a grid map is unloaded.
virtual void OnUnloadGridMap(TMap* /*map*/, GridMap* /*gmap*/, uint32 /*gx*/, uint32 /*gy*/) { }

// Called when a player enters the map.
virtual void OnPlayerEnter(TMap* /*map*/, Player* /*player*/) { }

// Called when a player leaves the map.
virtual void OnPlayerLeave(TMap* /*map*/, Player* /*player*/) { }

// Called on every map update tick.
virtual void OnUpdate(TMap* /*map*/, uint32 /*diff*/) { }
};
```

rektbyfaith
Administrator
0
12-18-2024, 09:20 PM
#37
Archived author: Drikish • Posted: 2024-12-18T21:20:08.776000+00:00
Original source

```C++
WorldMapScript::WorldMapScript(std:Confusedtring name, uint32 mapId) : ScriptObject(name), MapScript<Map>(mapId)
{
if (GetEntry() && !GetEntry()->IsWorldMap())
TC_LOG_ERROR("scripts", "WorldMapScript for map %u is invalid.", mapId);

ScriptRegistry<WorldMapScript>::AddScript(this);
}
```
rektbyfaith
12-18-2024, 09:20 PM #37

Archived author: Drikish • Posted: 2024-12-18T21:20:08.776000+00:00
Original source

```C++
WorldMapScript::WorldMapScript(std:Confusedtring name, uint32 mapId) : ScriptObject(name), MapScript<Map>(mapId)
{
if (GetEntry() && !GetEntry()->IsWorldMap())
TC_LOG_ERROR("scripts", "WorldMapScript for map %u is invalid.", mapId);

ScriptRegistry<WorldMapScript>::AddScript(this);
}
```

rektbyfaith
Administrator
0
12-18-2024, 09:20 PM
#38
Archived author: Drikish • Posted: 2024-12-18T21:20:22.780000+00:00
Original source

I guess this? Sorry im not on the usual TC branch so things a bit diff
rektbyfaith
12-18-2024, 09:20 PM #38

Archived author: Drikish • Posted: 2024-12-18T21:20:22.780000+00:00
Original source

I guess this? Sorry im not on the usual TC branch so things a bit diff

rektbyfaith
Administrator
0
12-18-2024, 09:45 PM
#39
Archived author: stoneharry • Posted: 2024-12-18T21:45:55.702000+00:00
Original source

yes so you can hook `OnUpdate` on a script you create
rektbyfaith
12-18-2024, 09:45 PM #39

Archived author: stoneharry • Posted: 2024-12-18T21:45:55.702000+00:00
Original source

yes so you can hook `OnUpdate` on a script you create

rektbyfaith
Administrator
0
12-18-2024, 09:48 PM
#40
Archived author: stoneharry • Posted: 2024-12-18T21:48:13.923000+00:00
Original source

so create a script in https://github.com/TrinityCore/TrinityCo...loader.cpp
rektbyfaith
12-18-2024, 09:48 PM #40

Archived author: stoneharry • Posted: 2024-12-18T21:48:13.923000+00:00
Original source

so create a script in https://github.com/TrinityCore/TrinityCo...loader.cpp

Pages (10): Previous 1 2 3 4 5 6 10 Next  
Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)