ElunaLuaEngine / Eluna

Eluna Lua Engine © for WoW Emulators
https://elunaluaengine.github.io
GNU General Public License v3.0
377 stars 362 forks source link

Fix WorldObject:SpawnCreature despawnTimer for TrinityCore #409

Closed anzz1 closed 2 years ago

anzz1 commented 2 years ago

TempSummon* WorldObject::SummonCreature takes std::chrono::milliseconds as an argument, not seconds (unlike GameObject* WorldObject::SummonGameObject which takes std::chrono::seconds)

TempSummon WorldObject::SummonCreature(uint32 id, float x, float y, float z, float o /= 0/, TempSummonType despawnType /= TEMPSUMMON_MANUAL_DESPAWN/, Milliseconds despawnTime /= 0s/, bool visibleBySummonerOnly /= false*/)

Casting uint32 -> Seconds -> Milliseconds makes a * 1000 happen so if you wanted to spawn a creature for 5000 milliseconds you end up spawning it for 5000000 milliseconds.

Currently doing a WorldObject:SpawnCreature(..., TEMPSUMMON_TIMED_DESPAWN, 5000) in AzerothCore works as it should according to the documentation (@param uint32 despawnTimer = 0 : despawn time in milliseconds) and spawns the creature for 5 seconds but doing that in TrinityCore makes it spawn for 5000 seconds.

edit: Add that I indeed tested AC vs TC behaviour in-game on both, not just assuming so.

anzz1 commented 2 years ago

thx, i guess the LuaEngine git submodule under https://github.com/ElunaLuaEngine/ElunaTrinityWotlk/tree/master/src/server/game could be updated too