diff --git a/src/map/lua/luautils.cpp b/src/map/lua/luautils.cpp index de3241451ef..ec812842905 100644 --- a/src/map/lua/luautils.cpp +++ b/src/map/lua/luautils.cpp @@ -145,7 +145,7 @@ namespace luautils /** * @brief Initialization of Lua user classes and global functions. */ - int32 init() + void init() { TracyZoneScoped; @@ -361,8 +361,6 @@ namespace luautils filewatcher = std::make_unique(std::vector{ "scripts", "modules", "settings" }); TracyReportLuaMemory(lua.lua_state()); - - return 0; } void cleanup() @@ -370,7 +368,7 @@ namespace luautils moduleutils::CleanupLuaModules(); } - int32 garbageCollectStep() + void garbageCollectStep() { TracyZoneScoped; TracyReportLuaMemory(lua.lua_state()); @@ -384,11 +382,9 @@ namespace luautils ShowInfo("Current State Top: %d, Total Memory Used: %dkb", lua_gettop(lua.lua_state()), lua.memory_used() / 1024); TracyReportLuaMemory(lua.lua_state()); - - return 0; } - int32 garbageCollectFull() + void garbageCollectFull() { TracyZoneScoped; TracyReportLuaMemory(lua.lua_state()); @@ -403,8 +399,6 @@ namespace luautils ShowInfo("Current State Top: %d, Total Memory Used: %dkb -> %dkb", lua_gettop(lua.lua_state()), before_mem_kb, after_mem_kb); TracyReportLuaMemory(lua.lua_state()); - - return 0; } void ReloadFilewatchList() @@ -1253,16 +1247,10 @@ namespace luautils return std::optional(PEntity); } - void WeekUpdateConquest(sol::variadic_args va) + void WeekUpdateConquest(uint8 updateType) { TracyZoneScoped; - - ConquestUpdate type = Conquest_Tally_Start; - if (va.size()) - { - type = static_cast(va.get(0)); - } - conquest::UpdateConquestGM(type); + conquest::UpdateConquestGM(static_cast(updateType)); } uint8 GetRegionOwner(uint8 type) @@ -1317,7 +1305,7 @@ namespace luautils * * ************************************************************************/ - int32 SetRegionalConquestOverseers(uint8 regionID) + void SetRegionalConquestOverseers(uint8 regionID) { TracyZoneScoped; @@ -1326,7 +1314,7 @@ namespace luautils { sol::error err = setRegionalConquestOverseers; ShowError("luautils::setRegionalConquestOverseers: %s", err.what()); - return -1; + return; } auto result = setRegionalConquestOverseers(regionID); @@ -1334,10 +1322,7 @@ namespace luautils { sol::error err = result; ShowError("luautils::setRegionalConquestOverseers: %s", err.what()); - return -1; } - - return 0; } void SendLuaFuncStringToZone(uint16 zoneId, std::string const& str) @@ -1841,7 +1826,7 @@ namespace luautils return true; } - int32 OnZoneInitialise(uint16 ZoneID) + void OnZoneInitialise(uint16 ZoneID) { TracyZoneScoped; @@ -1850,7 +1835,7 @@ namespace luautils if (PZone == nullptr) { ShowWarning("Skipping init for disabled zone %d.", ZoneID); - return -1; + return; } auto name = PZone->getName(); @@ -1863,7 +1848,7 @@ namespace luautils auto onInitialize = lua["xi"]["zones"][name]["Zone"]["onInitialize"]; if (!onInitialize.valid()) { - return -1; + return; } auto result = onInitialize(CLuaZone(PZone)); @@ -1871,10 +1856,7 @@ namespace luautils { sol::error err = result; ShowError("luautils::onInitialize: %s", err.what()); - return -1; } - - return 0; } void OnZoneTick(CZone* PZone) @@ -1900,7 +1882,7 @@ namespace luautils } } - int32 OnGameIn(CCharEntity* PChar, bool zoning) + void OnGameIn(CCharEntity* PChar, bool zoning) { TracyZoneScoped; @@ -1910,7 +1892,7 @@ namespace luautils if (!onGameIn.valid()) { ShowError("luautils::onGameIn"); - return -1; + return; } auto result = onGameIn(CLuaBaseEntity(PChar), PChar->GetPlayTime(false) == 0, zoning); @@ -1919,10 +1901,7 @@ namespace luautils sol::error err = result; ShowError("luautils::onGameIn: %s", err.what()); ReportErrorToPlayer(PChar, err.what()); - return -1; } - - return 0; } void OnZoneIn(CCharEntity* PChar) @@ -2017,14 +1996,14 @@ namespace luautils } } - int32 OnTriggerAreaEnter(CCharEntity* PChar, CTriggerArea* PTriggerArea) + void OnTriggerAreaEnter(CCharEntity* PChar, CTriggerArea* PTriggerArea) { TracyZoneScoped; // Do not enter trigger areas while loading in. Set in xi.player.onGameIn if (PChar->GetLocalVar("ZoningIn") > 0) { - return 0; + return; } std::string filename; @@ -2068,13 +2047,10 @@ namespace luautils sol::error err = result; ShowError("luautils::onTriggerAreaEnter: %s", err.what()); ReportErrorToPlayer(PChar, err.what()); - return -1; } - - return 0; } - int32 OnTriggerAreaLeave(CCharEntity* PChar, CTriggerArea* PTriggerArea) + void OnTriggerAreaLeave(CCharEntity* PChar, CTriggerArea* PTriggerArea) { TracyZoneScoped; @@ -2119,10 +2095,7 @@ namespace luautils sol::error err = result; ShowError("luautils::onTriggerAreaLeave: %s", err.what()); ReportErrorToPlayer(PChar, err.what()); - return -1; } - - return 0; } int32 OnTrigger(CCharEntity* PChar, CBaseEntity* PNpc) @@ -2288,7 +2261,7 @@ namespace luautils return 0; } - int32 OnTrade(CCharEntity* PChar, CBaseEntity* PNpc) + void OnTrade(CCharEntity* PChar, CBaseEntity* PNpc) { TracyZoneScoped; @@ -2310,26 +2283,23 @@ namespace luautils sol::error err = result; ShowError("luautils::onTrade: %s", err.what()); ReportErrorToPlayer(PChar, err.what()); - return -1; } - - return 0; } - int32 OnNpcSpawn(CBaseEntity* PNpc) + void OnNpcSpawn(CBaseEntity* PNpc) { TracyZoneScoped; if (PNpc == nullptr) { ShowError("luautils::onNpcSpawn: Npc not found!"); - return 0; + return; } auto onSpawn = getEntityCachedFunction(PNpc, "onSpawn"); if (!onSpawn.valid()) { - return -1; + return; } auto result = onSpawn(CLuaBaseEntity(PNpc)); @@ -2337,14 +2307,11 @@ namespace luautils { sol::error err = result; ShowError("luautils::onNpcSpawn: %s", err.what()); - return -1; } - - return 0; } // Used by mobs - int32 OnAdditionalEffect(CBattleEntity* PAttacker, CBattleEntity* PDefender, actionTarget_t* Action, int32 damage) + void OnAdditionalEffect(CBattleEntity* PAttacker, CBattleEntity* PDefender, actionTarget_t* Action, int32 damage) { TracyZoneScoped; @@ -2358,7 +2325,7 @@ namespace luautils if (!onAdditionalEffect.valid()) { - return -1; + return; } auto result = onAdditionalEffect(CLuaBaseEntity(PAttacker), CLuaBaseEntity(PDefender), damage); @@ -2366,18 +2333,16 @@ namespace luautils { sol::error err = result; ShowError("luautils::onAdditionalEffect: %s", err.what()); - return -1; + return; } Action->additionalEffect = (SUBEFFECT)(result.get_type(0) == sol::type::number ? result.get(0) : 0); Action->addEffectMessage = result.get_type(1) == sol::type::number ? result.get(1) : 0; Action->addEffectParam = result.get_type(2) == sol::type::number ? result.get(2) : 0; - - return 0; } // Used by mobs - int32 OnSpikesDamage(CBattleEntity* PDefender, CBattleEntity* PAttacker, actionTarget_t* Action, int32 damage) + void OnSpikesDamage(CBattleEntity* PDefender, CBattleEntity* PAttacker, actionTarget_t* Action, int32 damage) { TracyZoneScoped; @@ -2387,7 +2352,7 @@ namespace luautils auto onSpikesDamage = lua["xi"]["zones"][zone]["mobs"][name]["onSpikesDamage"]; if (!onSpikesDamage.valid()) { - return -1; + return; } auto result = onSpikesDamage(CLuaBaseEntity(PDefender), CLuaBaseEntity(PAttacker), damage); @@ -2395,14 +2360,12 @@ namespace luautils { sol::error err = result; ShowError("luautils::onSpikesDamage: %s", err.what()); - return -1; + return; } Action->spikesEffect = (SUBEFFECT)(result.get_type(0) == sol::type::number ? result.get(0) : 0); Action->spikesMessage = result.get_type(1) == sol::type::number ? result.get(1) : 0; Action->spikesParam = result.get_type(2) == sol::type::number ? result.get(2) : 0; - - return 0; } // Used by items @@ -2436,15 +2399,16 @@ namespace luautils return 0; } + // NOTE: This is currently unused // future use: migrating items to scripts\globals\additional_effects.lua - int32 additionalEffectSpikes(CBattleEntity* PDefender, CBattleEntity* PAttacker, CItemEquipment* PItem, actionTarget_t* Action, int32 baseAttackDamage) + void additionalEffectSpikes(CBattleEntity* PDefender, CBattleEntity* PAttacker, CItemEquipment* PItem, actionTarget_t* Action, int32 baseAttackDamage) { TracyZoneScoped; auto additionalEffectSpikes = lua["xi"]["additionalEffect"]["spikes"]; if (!additionalEffectSpikes.valid()) { - return -1; + return; } auto result = additionalEffectSpikes(CLuaBaseEntity(PDefender), CLuaBaseEntity(PAttacker), baseAttackDamage, CLuaItem(PItem)); @@ -2452,17 +2416,15 @@ namespace luautils { sol::error err = result; ShowError("luautils::additionalEffectSpikes: %s", err.what()); - return -1; + return; } Action->additionalEffect = (SUBEFFECT)(result.get_type(0) == sol::type::number ? result.get(0) : 0); Action->addEffectMessage = result.get_type(1) == sol::type::number ? result.get(1) : 0; Action->addEffectParam = result.get_type(2) == sol::type::number ? result.get(2) : 0; - - return 0; } - int32 OnEffectGain(CBattleEntity* PEntity, CStatusEffect* PStatusEffect) + void OnEffectGain(CBattleEntity* PEntity, CStatusEffect* PStatusEffect) { TracyZoneScoped; @@ -2471,7 +2433,7 @@ namespace luautils sol::function onEffectGain = GetCacheEntryFromFilename(filename)["onEffectGain"].get(); if (!onEffectGain.valid()) { - return -1; + return; } auto result = onEffectGain(CLuaBaseEntity(PEntity), CLuaStatusEffect(PStatusEffect)); @@ -2480,13 +2442,10 @@ namespace luautils sol::error err = result; ShowError("luautils::onEffectGain: %s", err.what()); ReportErrorToPlayer(PEntity, err.what()); - return -1; } - - return 0; } - int32 OnEffectTick(CBattleEntity* PEntity, CStatusEffect* PStatusEffect) + void OnEffectTick(CBattleEntity* PEntity, CStatusEffect* PStatusEffect) { TracyZoneScoped; @@ -2495,7 +2454,7 @@ namespace luautils sol::function onEffectTick = GetCacheEntryFromFilename(filename)["onEffectTick"].get(); if (!onEffectTick.valid()) { - return -1; + return; } auto result = onEffectTick(CLuaBaseEntity(PEntity), CLuaStatusEffect(PStatusEffect)); @@ -2504,13 +2463,10 @@ namespace luautils sol::error err = result; ShowError("luautils::onEffectTick: %s", err.what()); ReportErrorToPlayer(PEntity, err.what()); - return -1; } - - return 0; } - int32 OnEffectLose(CBattleEntity* PEntity, CStatusEffect* PStatusEffect) + void OnEffectLose(CBattleEntity* PEntity, CStatusEffect* PStatusEffect) { TracyZoneScoped; @@ -2519,7 +2475,7 @@ namespace luautils sol::function onEffectLose = GetCacheEntryFromFilename(filename)["onEffectLose"].get(); if (!onEffectLose.valid()) { - return -1; + return; } auto result = onEffectLose(CLuaBaseEntity(PEntity), CLuaStatusEffect(PStatusEffect)); @@ -2528,13 +2484,10 @@ namespace luautils sol::error err = result; ShowError("luautils::onEffectLose: %s", err.what()); ReportErrorToPlayer(PEntity, err.what()); - return -1; } - - return 0; } - int32 OnAttachmentEquip(CBattleEntity* PEntity, CItemPuppet* attachment) + void OnAttachmentEquip(CBattleEntity* PEntity, CItemPuppet* attachment) { TracyZoneScoped; @@ -2543,7 +2496,7 @@ namespace luautils auto onEquip = lua["xi"]["actions"]["abilities"]["pets"]["attachments"][name]["onEquip"]; if (!onEquip.valid()) { - return -1; + return; } auto result = onEquip(CLuaBaseEntity(PEntity), CLuaItem(attachment)); @@ -2551,13 +2504,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::onEquip: %s", err.what()); - return -1; } - - return 0; } - int32 OnAttachmentUnequip(CBattleEntity* PEntity, CItemPuppet* attachment) + void OnAttachmentUnequip(CBattleEntity* PEntity, CItemPuppet* attachment) { TracyZoneScoped; @@ -2566,7 +2516,7 @@ namespace luautils auto onUnequip = lua["xi"]["actions"]["abilities"]["pets"]["attachments"][name]["onUnequip"]; if (!onUnequip.valid()) { - return -1; + return; } auto result = onUnequip(CLuaBaseEntity(PEntity), CLuaItem(attachment)); @@ -2574,13 +2524,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::onUnequip: %s", err.what()); - return -1; } - - return 0; } - int32 OnManeuverGain(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers) + void OnManeuverGain(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers) { TracyZoneScoped; @@ -2589,7 +2536,7 @@ namespace luautils auto onManeuverGain = lua["xi"]["actions"]["abilities"]["pets"]["attachments"][name]["onManeuverGain"]; if (!onManeuverGain.valid()) { - return -1; + return; } auto result = onManeuverGain(CLuaBaseEntity(PEntity), CLuaItem(attachment), maneuvers); @@ -2597,13 +2544,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::onManeuverGain: %s", err.what()); - return -1; } - - return 0; } - int32 OnManeuverLose(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers) + void OnManeuverLose(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers) { TracyZoneScoped; @@ -2612,7 +2556,7 @@ namespace luautils auto onManeuverLose = lua["xi"]["actions"]["abilities"]["pets"]["attachments"][name]["onManeuverLose"]; if (!onManeuverLose.valid()) { - return -1; + return; } auto result = onManeuverLose(CLuaBaseEntity(PEntity), CLuaItem(attachment), maneuvers); @@ -2620,13 +2564,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::onManeuverLose: %s", err.what()); - return -1; } - - return 0; } - int32 OnUpdateAttachment(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers) + void OnUpdateAttachment(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers) { TracyZoneScoped; @@ -2635,7 +2576,7 @@ namespace luautils auto onUpdate = lua["xi"]["actions"]["abilities"]["pets"]["attachments"][name]["onUpdate"]; if (!onUpdate.valid()) { - return -1; + return; } auto result = onUpdate(CLuaBaseEntity(PEntity), CLuaItem(attachment), maneuvers); @@ -2643,15 +2584,12 @@ namespace luautils { sol::error err = result; ShowError("luautils::onUpdate: %s", err.what()); - return -1; } - - return 0; } // We check the possibility of using the item. // If all is well, then return value - 0, in case of failure - error message number - std::tuple OnItemCheck(CBaseEntity* PTarget, CItem* PItem, ITEMCHECK param, CBaseEntity* PCaster) + auto OnItemCheck(CBaseEntity* PTarget, CItem* PItem, ITEMCHECK param, CBaseEntity* PCaster) -> std::tuple { TracyZoneScoped; @@ -2688,7 +2626,7 @@ namespace luautils // We use the subject. The return value is the message number or 0. // It is also necessary to somehow pass the message parameter (for example, // number of recovered MP) - int32 OnItemUse(CBaseEntity* PUser, CBaseEntity* PTarget, CItem* PItem) + void OnItemUse(CBaseEntity* PUser, CBaseEntity* PTarget, CItem* PItem) { TracyZoneScoped; @@ -2697,7 +2635,7 @@ namespace luautils sol::function onItemUse = GetCacheEntryFromFilename(filename)["onItemUse"].get(); if (!onItemUse.valid()) { - return -1; + return; } // using an item removes invisible status effect @@ -2715,14 +2653,11 @@ namespace luautils sol::error err = result; ShowError("luautils::onItemUse: %s", err.what()); ReportErrorToPlayer(PUser, err.what()); - return -1; } - - return 0; } // Trigger Code on an item when it has been dropped - int32 OnItemDrop(CBaseEntity* PUser, CItem* PItem) + void OnItemDrop(CBaseEntity* PUser, CItem* PItem) { TracyZoneScoped; @@ -2731,7 +2666,7 @@ namespace luautils sol::function onItemDrop = GetCacheEntryFromFilename(filename)["onItemDrop"].get(); if (!onItemDrop.valid()) { - return -1; + return; } auto result = onItemDrop(CLuaBaseEntity(PUser), CLuaItem(PItem)); @@ -2740,13 +2675,10 @@ namespace luautils sol::error err = result; ShowError("luautils::onItemDrop: %s", err.what()); ReportErrorToPlayer(PUser, err.what()); - return -1; } - - return 0; } - int32 OnItemEquip(CBaseEntity* PUser, CItem* PItem) + void OnItemEquip(CBaseEntity* PUser, CItem* PItem) { TracyZoneScoped; @@ -2755,7 +2687,7 @@ namespace luautils sol::function onItemEquip = GetCacheEntryFromFilename(filename)["onItemEquip"].get(); if (!onItemEquip.valid()) { - return -1; + return; } auto result = onItemEquip(CLuaBaseEntity(PUser), CLuaItem(PItem)); @@ -2764,13 +2696,10 @@ namespace luautils sol::error err = result; ShowError("luautils::onItemEquip: %s", err.what()); ReportErrorToPlayer(PUser, err.what()); - return -1; } - - return 0; } - int32 OnItemUnequip(CBaseEntity* PUser, CItem* PItem) + void OnItemUnequip(CBaseEntity* PUser, CItem* PItem) { TracyZoneScoped; @@ -2779,7 +2708,7 @@ namespace luautils sol::function onItemUnequip = GetCacheEntryFromFilename(filename)["onItemUnequip"].get(); if (!onItemUnequip.valid()) { - return -1; + return; } auto result = onItemUnequip(CLuaBaseEntity(PUser), CLuaItem(PItem)); @@ -2788,21 +2717,18 @@ namespace luautils sol::error err = result; ShowError("luautils::onItemUnequip: %s", err.what()); ReportErrorToPlayer(PUser, err.what()); - return -1; } - - return 0; } // Check for gear sets (e.g Set: enhances haste effect) - int32 CheckForGearSet(CBaseEntity* PTarget) + void CheckForGearSet(CBaseEntity* PTarget) { TracyZoneScoped; auto checkForGearSet = lua["xi"]["gear_sets"]["checkForGearSet"]; if (!checkForGearSet.valid()) { - return 56; + return; } auto result = checkForGearSet(CLuaBaseEntity(PTarget)); @@ -2811,10 +2737,7 @@ namespace luautils sol::error err = result; ShowError("luautils::CheckForGearSet: %s", err.what()); ReportErrorToPlayer(PTarget, err.what()); - return -1; } - - return 0; } int32 OnSpellCast(CBattleEntity* PCaster, CBattleEntity* PTarget, CSpell* PSpell) @@ -2824,13 +2747,13 @@ namespace luautils if (PSpell == nullptr) { ShowError("luautils::OnSpellCast: Spell not found!"); - return -1; + return 0; } auto onSpellCast = getSpellCachedFunction(PSpell, "onSpellCast"); if (!onSpellCast.valid()) { - return -1; + return 0; } auto result = onSpellCast(CLuaBaseEntity(PCaster), CLuaBaseEntity(PTarget), CLuaSpell(PSpell)); @@ -2839,26 +2762,26 @@ namespace luautils sol::error err = result; ShowError("luautils::onSpellCast: %s", err.what()); ReportErrorToPlayer(PCaster, err.what()); - return -1; + return 0; } int32 retVal = result.get_type(0) == sol::type::number ? result.get(0) : 0; return retVal; } - int32 OnSpellPrecast(CBattleEntity* PCaster, CSpell* PSpell) + void OnSpellPrecast(CBattleEntity* PCaster, CSpell* PSpell) { TracyZoneScoped; if (PCaster->objtype != TYPE_MOB) { - return -1; + return; } sol::function onSpellPrecast = getEntityCachedFunction(PCaster, "onSpellPrecast"); if (!onSpellPrecast.valid()) { - return 0; + return; } auto result = onSpellPrecast(CLuaBaseEntity(PCaster), CLuaSpell(PSpell)); @@ -2867,10 +2790,7 @@ namespace luautils sol::error err = result; ShowError("luautils::onSpellPrecast: %s", err.what()); ReportErrorToPlayer(PCaster, err.what()); - return 0; } - - return 0; } std::optional OnMobMagicPrepare(CBattleEntity* PCaster, CBattleEntity* PTarget, std::optional startingSpellId) @@ -2914,19 +2834,19 @@ namespace luautils // Called when mob is targeted by a spell. // Note: does not differentiate between offensive and defensive spells - int32 OnMagicHit(CBattleEntity* PCaster, CBattleEntity* PTarget, CSpell* PSpell) + void OnMagicHit(CBattleEntity* PCaster, CBattleEntity* PTarget, CSpell* PSpell) { TracyZoneScoped; if (PSpell == nullptr) { - return -1; + return; } sol::function onMagicHit = getEntityCachedFunction(PTarget, "onMagicHit"); if (!onMagicHit.valid()) { - return 0; + return; } auto result = onMagicHit(CLuaBaseEntity(PCaster), CLuaBaseEntity(PTarget), CLuaSpell(PSpell)); @@ -2934,21 +2854,19 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMagicHit: %s", err.what()); - return -1; + return; } - - return result.get_type(0) == sol::type::number ? result.get(0) : 0; } // Called when mob is struck by a Weaponskill - int32 OnWeaponskillHit(CBattleEntity* PMob, CBaseEntity* PAttacker, uint16 PWeaponskill) + void OnWeaponskillHit(CBattleEntity* PMob, CBaseEntity* PAttacker, uint16 PWeaponskill) { TracyZoneScoped; sol::function onWeaponskillHit = getEntityCachedFunction(PMob, "onWeaponskillHit"); if (!onWeaponskillHit.valid()) { - return 0; + return; } auto result = onWeaponskillHit(CLuaBaseEntity(PMob), CLuaBaseEntity(PAttacker), PWeaponskill); @@ -2956,10 +2874,8 @@ namespace luautils { sol::error err = result; ShowError("luautils::onWeaponskillHit: %s", err.what()); - return 0; + return; } - - return result.get_type(0) == sol::type::number ? result.get(0) : 0; } bool OnTrustSpellCastCheckBattlefieldTrusts(CBattleEntity* PCaster) // Check if trust count would go over the limit when cast finishes (for simultaneous multi-party casts @@ -2984,14 +2900,14 @@ namespace luautils return result.get_type(0) == sol::type::boolean ? result.get(0) : true; } - int32 OnMobInitialize(CBaseEntity* PMob) + void OnMobInitialize(CBaseEntity* PMob) { TracyZoneScoped; sol::function onMobInitialize = getEntityCachedFunction(PMob, "onMobInitialize"); if (!onMobInitialize.valid()) { - return -1; + return; } auto result = onMobInitialize(CLuaBaseEntity(PMob)); @@ -2999,20 +2915,17 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobInitialize: %s", err.what()); - return -1; } - - return 0; } // Called during server startup, file reads are OK! - int32 ApplyMixins(CBaseEntity* PMob) + void ApplyMixins(CBaseEntity* PMob) { TracyZoneScoped; if (PMob == nullptr || PMob->objtype != TYPE_MOB) { - return -1; + return; } // Clear out globals @@ -3027,21 +2940,21 @@ namespace luautils auto script_result = lua.safe_script_file(filename); if (!script_result.valid()) { - return -1; + return; } // get the global function "applyMixins" sol::function applyMixins = lua["applyMixins"]; if (!applyMixins.valid()) { - return -1; + return; } // get the parameter "mixins" auto mixins = lua["mixins"]; if (!mixins.valid()) { - return -1; + return; } // get the parameter "mixinOptions" (optional) @@ -3053,18 +2966,16 @@ namespace luautils sol::error err = result; ShowError("luautils::applyMixins: %s", err.what()); } - - return 0; } // Called during server startup, file reads are OK! - int32 ApplyZoneMixins(CBaseEntity* PMob) + void ApplyZoneMixins(CBaseEntity* PMob) { TracyZoneScoped; if (PMob == nullptr || PMob->objtype != TYPE_MOB) { - return -1; + return; } // Clear out any previous global definitions @@ -3076,21 +2987,21 @@ namespace luautils auto script_result = lua.safe_script_file(filename); if (!script_result.valid()) { - return -1; + return; } // get the global function "applyMixins" sol::function applyMixins = lua["applyMixins"]; if (!applyMixins.valid()) { - return -1; + return; } // get the parameter "mixins" auto mixins = lua["mixins"]; if (!mixins.valid()) { - return -1; + return; } // get the parameter "mixinOptions" (optional) @@ -3101,25 +3012,22 @@ namespace luautils { sol::error err = result; ShowError("luautils::applyMixins %s", err.what()); - return -1; } - - return 0; } - int32 OnPath(CBaseEntity* PEntity) + void OnPath(CBaseEntity* PEntity) { TracyZoneScoped; if (PEntity == nullptr || PEntity->objtype == TYPE_PC) { - return -1; + return; } sol::function onPath = getEntityCachedFunction(PEntity, "onPath"); if (!onPath.valid()) { - return -1; + return; } auto result = onPath(CLuaBaseEntity(PEntity)); @@ -3127,25 +3035,22 @@ namespace luautils { sol::error err = result; ShowError("luautils::onPath: %s", err.what()); - return -1; } - - return 0; } - int32 OnPathPoint(CBaseEntity* PEntity) + void OnPathPoint(CBaseEntity* PEntity) { TracyZoneScoped; if (PEntity == nullptr || PEntity->objtype == TYPE_PC) { - return -1; + return; } sol::function onPathPoint = getEntityCachedFunction(PEntity, "onPathPoint"); if (!onPathPoint.valid()) { - return -1; + return; } auto result = onPathPoint(CLuaBaseEntity(PEntity)); @@ -3153,25 +3058,22 @@ namespace luautils { sol::error err = result; ShowError("luautils::OnPathPoint: %s", err.what()); - return -1; } - - return 0; } - int32 OnPathComplete(CBaseEntity* PEntity) + void OnPathComplete(CBaseEntity* PEntity) { TracyZoneScoped; if (PEntity == nullptr || PEntity->objtype == TYPE_PC) { - return -1; + return; } sol::function onPathComplete = getEntityCachedFunction(PEntity, "onPathComplete"); if (!onPathComplete.valid()) { - return -1; + return; } auto result = onPathComplete(CLuaBaseEntity(PEntity)); @@ -3179,10 +3081,7 @@ namespace luautils { sol::error err = result; ShowError("luautils::OnPathComplete: %s", err.what()); - return -1; } - - return 0; } int32 OnBattlefieldHandlerInitialise(CZone* PZone) @@ -3216,25 +3115,25 @@ namespace luautils return result.get_type(0) == sol::type::number ? result.get(0) : MaxAreas; } - int32 OnBattlefieldInitialise(CBattlefield* PBattlefield) + void OnBattlefieldInitialise(CBattlefield* PBattlefield) { TracyZoneScoped; if (PBattlefield == nullptr) { - return -1; + return; } - return invokeBattlefieldEvent(PBattlefield->GetID(), "onBattlefieldInitialise", CLuaBattlefield(PBattlefield)); + invokeBattlefieldEvent(PBattlefield->GetID(), "onBattlefieldInitialise", CLuaBattlefield(PBattlefield)); } - int32 OnBattlefieldTick(CBattlefield* PBattlefield) + void OnBattlefieldTick(CBattlefield* PBattlefield) { TracyZoneScoped; if (PBattlefield == nullptr) { - return -1; + return; } auto name = PBattlefield->GetName(); @@ -3242,32 +3141,31 @@ namespace luautils if (invokeBattlefieldEvent(PBattlefield->GetID(), "onBattlefieldTick", CLuaBattlefield(PBattlefield), seconds) == 0) { - return 0; + return; } ShowError("luautils::onBattlefieldTick: Unable to find onBattlefieldTick function for %s", name); - return -1; } - int32 OnBattlefieldStatusChange(CBattlefield* PBattlefield) + void OnBattlefieldStatusChange(CBattlefield* PBattlefield) { TracyZoneScoped; if (PBattlefield == nullptr) { - return -1; + return; } - return invokeBattlefieldEvent(PBattlefield->GetID(), "onBattlefieldStatusChange", CLuaBattlefield(PBattlefield), PBattlefield->GetStatus()); + invokeBattlefieldEvent(PBattlefield->GetID(), "onBattlefieldStatusChange", CLuaBattlefield(PBattlefield), PBattlefield->GetStatus()); } - int32 OnMobEngage(CBaseEntity* PMob, CBaseEntity* PTarget) + void OnMobEngage(CBaseEntity* PMob, CBaseEntity* PTarget) { TracyZoneScoped; if (PTarget == nullptr || PMob == nullptr) { - return -1; + return; } std::string filename; @@ -3289,7 +3187,7 @@ namespace luautils sol::function onMobEngage = getEntityCachedFunction(PMob, "onMobEngage"); if (!onMobEngage.valid()) { - return -1; + return; } auto result = onMobEngage(CLuaBaseEntity(PMob), CLuaBaseEntity(PTarget)); @@ -3297,25 +3195,22 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobEngage: %s", err.what()); - return -1; } - - return 0; } - int32 OnMobDisengage(CBaseEntity* PMob) + void OnMobDisengage(CBaseEntity* PMob) { TracyZoneScoped; if (PMob == nullptr) { - return -1; + return; } sol::function onMobDisengage = getEntityCachedFunction(PMob, "onMobDisengage"); if (!onMobDisengage.valid()) { - return -1; + return; } uint8 weather = PMob->loc.zone->GetWeather(); @@ -3325,24 +3220,21 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobDisengage: %s", err.what()); - return -1; } - - return 0; } - int32 OnMobFollow(CBaseEntity* PMob, CBaseEntity* PTarget) + void OnMobFollow(CBaseEntity* PMob, CBaseEntity* PTarget) { TracyZoneScoped; if (PTarget == nullptr || PMob == nullptr) { - return -1; + return; } sol::function onMobFollow = getEntityCachedFunction(PMob, "onMobFollow"); if (!onMobFollow.valid()) { - return -1; + return; } auto result = onMobFollow(CLuaBaseEntity(PMob), CLuaBaseEntity(PTarget)); @@ -3350,24 +3242,21 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobFollow: %s", err.what()); - return -1; } - - return 0; } - int32 OnMobUnfollow(CBaseEntity* PMob, CBaseEntity* PTarget) + void OnMobUnfollow(CBaseEntity* PMob, CBaseEntity* PTarget) { TracyZoneScoped; if (PTarget == nullptr || PMob == nullptr) { - return -1; + return; } sol::function onMobUnfollow = getEntityCachedFunction(PMob, "onMobUnfollow"); if (!onMobUnfollow.valid()) { - return -1; + return; } auto result = onMobUnfollow(CLuaBaseEntity(PMob), CLuaBaseEntity(PTarget)); @@ -3375,19 +3264,16 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobUnfollow: %s", err.what()); - return -1; } - - return 0; } - int32 OnMobDrawIn(CBaseEntity* PMob, CBaseEntity* PTarget) + void OnMobDrawIn(CBaseEntity* PMob, CBaseEntity* PTarget) { TracyZoneScoped; if (PTarget == nullptr || PMob == nullptr) { - return -1; + return; } auto filename = fmt::format("./scripts/zones/{}/mobs/{}.lua", PMob->loc.zone->getName(), PMob->getName()); @@ -3401,7 +3287,7 @@ namespace luautils sol::function onMobDrawIn = getEntityCachedFunction(PMob, "onMobDrawIn"); if (!onMobDrawIn.valid()) { - return -1; + return; } auto result = onMobDrawIn(CLuaBaseEntity(PMob), CLuaBaseEntity(PTarget)); @@ -3409,25 +3295,22 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobDrawIn: %s", err.what()); - return -1; } - - return 0; } - int32 OnMobFight(CBaseEntity* PMob, CBaseEntity* PTarget) + void OnMobFight(CBaseEntity* PMob, CBaseEntity* PTarget) { TracyZoneScoped; if (PTarget == nullptr || PMob == nullptr) { - return -1; + return; } sol::function onMobFight = getEntityCachedFunction(PMob, "onMobFight"); if (!onMobFight.valid()) { - return -1; + return; } auto result = onMobFight(CLuaBaseEntity(PMob), CLuaBaseEntity(PTarget)); @@ -3435,25 +3318,22 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobFight: %s", err.what()); - return -1; } - - return 0; } - int32 OnCriticalHit(CBattleEntity* PMob, CBattleEntity* PAttacker) + void OnCriticalHit(CBattleEntity* PMob, CBattleEntity* PAttacker) { TracyZoneScoped; if (PMob == nullptr) { - return -1; + return; } sol::function onCriticalHit = getEntityCachedFunction(PMob, "onCriticalHit"); if (!onCriticalHit.valid()) { - return -1; + return; } std::optional optionalKiller = std::nullopt; @@ -3467,19 +3347,16 @@ namespace luautils { sol::error err = result; ShowError("luautils::onCriticalHit %s", err.what()); - return -1; } - - return 0; } - int32 OnMobDeath(CBaseEntity* PMob, CBaseEntity* PKiller) + void OnMobDeath(CBaseEntity* PMob, CBaseEntity* PKiller) { TracyZoneScoped; if (PMob == nullptr) { - return -1; + return; } std::string zone_name = PMob->loc.zone->getName(); @@ -3498,7 +3375,7 @@ namespace luautils auto onMobDeathEx = lua["xi"]["mob"]["onMobDeathEx"]; if (!onMobDeathEx.valid()) { - return -1; + return; } // clang-format off @@ -3580,26 +3457,23 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobDeath: %s", err.what()); - return -1; } } - - return 0; } - int32 OnMobSpawn(CBaseEntity* PMob) + void OnMobSpawn(CBaseEntity* PMob) { TracyZoneScoped; if (PMob == nullptr) { - return -1; + return; } sol::function onMobSpawn = getEntityCachedFunction(PMob, "onMobSpawn"); if (!onMobSpawn.valid()) { - return -1; + return; } auto result = onMobSpawn(CLuaBaseEntity(PMob)); @@ -3607,25 +3481,22 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobSpawn: %s", err.what()); - return -1; } - - return 0; } - int32 OnMobRoamAction(CBaseEntity* PMob) + void OnMobRoamAction(CBaseEntity* PMob) { TracyZoneScoped; if (PMob == nullptr || PMob->objtype != TYPE_MOB) { - return -1; + return; } sol::function onMobRoamAction = getEntityCachedFunction(PMob, "onMobRoamAction"); if (!onMobRoamAction.valid()) { - return -1; + return; } auto result = onMobRoamAction(CLuaBaseEntity(PMob)); @@ -3633,20 +3504,17 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobRoonMobRoamActionam: %s", err.what()); - return -1; } - - return 0; } - int32 OnMobRoam(CBaseEntity* PMob) + void OnMobRoam(CBaseEntity* PMob) { TracyZoneScoped; sol::function onMobRoam = getEntityCachedFunction(PMob, "onMobRoam"); if (!onMobRoam.valid()) { - return -1; + return; } auto result = onMobRoam(CLuaBaseEntity(PMob)); @@ -3654,25 +3522,22 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobRoam: %s", err.what()); - return -1; } - - return 0; } - int32 OnMobDespawn(CBaseEntity* PMob) + void OnMobDespawn(CBaseEntity* PMob) { TracyZoneScoped; if (PMob == nullptr) { - return -1; + return; } auto onMobDespawn = getEntityCachedFunction(PMob, "onMobDespawn"); if (!onMobDespawn.valid()) { - return -1; + return; } auto result = onMobDespawn(CLuaBaseEntity(PMob)); @@ -3680,25 +3545,22 @@ namespace luautils { sol::error err = result; ShowError("luautils::onMobDespawn: %s", err.what()); - return -1; } - - return 0; } - int32 OnPetLevelRestriction(CBaseEntity* PMob) + void OnPetLevelRestriction(CBaseEntity* PMob) { TracyZoneScoped; if (PMob == nullptr || PMob->objtype != TYPE_PET) { - return -1; + return; } sol::function onPetLevelRestriction = getEntityCachedFunction(PMob, "onPetLevelRestriction"); if (!onPetLevelRestriction.valid()) { - return -1; + return; } auto result = onPetLevelRestriction(CLuaBaseEntity(PMob)); @@ -3706,13 +3568,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::onPetLevelRestriction: %s", err.what()); - return -1; } - - return 0; } - int32 OnGameDay(CZone* PZone) + void OnGameDay(CZone* PZone) { TracyZoneScoped; @@ -3721,7 +3580,7 @@ namespace luautils auto onGameDay = lua["xi"]["zones"][name]["Zone"]["onGameDay"]; if (!onGameDay.valid()) { - return -1; + return; } auto result = onGameDay(); @@ -3729,13 +3588,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::onGameDay: %s", err.what()); - return -1; } - - return 0; } - int32 OnGameHour(CZone* PZone) + void OnGameHour(CZone* PZone) { TracyZoneScoped; @@ -3744,7 +3600,7 @@ namespace luautils auto onGameHour = lua["xi"]["zones"][name]["Zone"]["onGameHour"]; if (!onGameHour.valid()) { - return -1; + return; } auto result = onGameHour(CLuaZone(PZone)); @@ -3752,13 +3608,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::onGameHour: %s", err.what()); - return -1; } - - return 0; } - int32 OnZoneWeatherChange(uint16 ZoneID, uint8 weather) + void OnZoneWeatherChange(uint16 ZoneID, uint8 weather) { TracyZoneScoped; @@ -3766,7 +3619,7 @@ namespace luautils if (PZone == nullptr) { ShowWarning("Invalid ZoneID passed to function (%d).", ZoneID); - return -1; + return; } auto name = PZone->getName(); @@ -3774,7 +3627,7 @@ namespace luautils auto onZoneWeatherChange = lua["xi"]["zones"][name]["Zone"]["onZoneWeatherChange"]; if (!onZoneWeatherChange.valid()) { - return -1; + return; } auto result = onZoneWeatherChange(weather); @@ -3782,13 +3635,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::onZoneWeatherChange: %s", err.what()); - return -1; } - - return 0; } - int32 OnTOTDChange(uint16 ZoneID, uint8 TOTD) + void OnTOTDChange(uint16 ZoneID, uint8 TOTD) { TracyZoneScoped; @@ -3796,7 +3646,7 @@ namespace luautils if (PZone == nullptr) { ShowWarning("Invalid ZoneID passed to function (%d).", ZoneID); - return -1; + return; } auto name = PZone->getName(); @@ -3804,7 +3654,7 @@ namespace luautils auto onTOTDChange = lua["xi"]["zones"][name]["Zone"]["onTOTDChange"]; if (!onTOTDChange.valid()) { - return -1; + return; } auto result = onTOTDChange(TOTD); @@ -3812,10 +3662,7 @@ namespace luautils { sol::error err = result; ShowError("luautils::onTOTDChange: %s", err.what()); - return -1; } - - return 0; } std::tuple OnUseWeaponSkill(CBattleEntity* PChar, CBaseEntity* PMob, CWeaponSkill* wskill, uint16 tp, bool primary, action_t& action, @@ -4421,7 +4268,7 @@ namespace luautils { sol::error err = result; ShowError("luautils::OnCanUseSpell: %s", err.what()); - return 0; + return false; } return result.get_type(0) == sol::type::boolean ? result.get(0) : true; @@ -4461,7 +4308,7 @@ namespace luautils return cachedInstanceScript; } - int32 OnInstanceZoneIn(CCharEntity* PChar, CInstance* PInstance) + void OnInstanceZoneIn(CCharEntity* PChar, CInstance* PInstance) { TracyZoneScoped; @@ -4472,7 +4319,7 @@ namespace luautils auto onInstanceZoneIn = lua["xi"]["zones"][name]["Zone"]["onInstanceZoneIn"]; if (!onInstanceZoneIn.valid()) { - return -1; + return; } auto result = onInstanceZoneIn(CLuaBaseEntity(PChar), CLuaInstance(PInstance)); @@ -4480,10 +4327,7 @@ namespace luautils { sol::error err = result; ShowError("luautils::onInstanceZoneIn %s", err.what()); - return -1; } - - return 0; } void AfterInstanceRegister(CBaseEntity* PChar) @@ -4536,7 +4380,7 @@ namespace luautils return result.get_type(0) == sol::type::number ? result.get(0) : 0; } - int32 OnInstanceTimeUpdate(CZone* PZone, CInstance* PInstance, uint32 time) + void OnInstanceTimeUpdate(CZone* PZone, CInstance* PInstance, uint32 time) { TracyZoneScoped; @@ -4545,7 +4389,7 @@ namespace luautils auto onInstanceTimeUpdate = GetCacheEntryFromFilename(instanceData.filename)["onInstanceTimeUpdate"]; if (!onInstanceTimeUpdate.valid()) { - return -1; + return; } auto result = onInstanceTimeUpdate(CLuaInstance(PInstance), time); @@ -4553,13 +4397,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::onInstanceTimeUpdate %s", err.what()); - return -1; } - - return 0; } - int32 OnInstanceFailure(CInstance* PInstance) + void OnInstanceFailure(CInstance* PInstance) { TracyZoneScoped; @@ -4568,7 +4409,7 @@ namespace luautils auto onInstanceFailure = GetCacheEntryFromFilename(instanceData.filename)["onInstanceFailure"]; if (!onInstanceFailure.valid()) { - return -1; + return; } auto result = onInstanceFailure(CLuaInstance(PInstance)); @@ -4576,10 +4417,7 @@ namespace luautils { sol::error err = result; ShowError("luautils::onInstanceFailure %s", err.what()); - return -1; } - - return 0; } /************************************************************************ @@ -4588,7 +4426,7 @@ namespace luautils * * ************************************************************************/ - int32 OnInstanceCreatedCallback(CCharEntity* PChar, CInstance* PInstance) + void OnInstanceCreatedCallback(CCharEntity* PChar, CInstance* PInstance) { TracyZoneScoped; @@ -4598,7 +4436,7 @@ namespace luautils if (!onInstanceCreatedCallback.valid()) { ShowError("luautils::OnInstanceCreatedCallback: undefined procedure onInstanceCreatedCallback"); - return -1; + return; } auto result = onInstanceCreatedCallback(CLuaBaseEntity(PChar), CLuaInstance(PInstance)); @@ -4606,13 +4444,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::OnInstanceCreatedCallback %s", err.what()); - return -1; } - - return 0; } - int32 OnInstanceCreated(CInstance* PInstance) + void OnInstanceCreated(CInstance* PInstance) { TracyZoneScoped; @@ -4622,7 +4457,7 @@ namespace luautils auto onInstanceCreated = lua["xi"]["zones"][zone]["instances"][name]["onInstanceCreated"]; if (!onInstanceCreated.valid()) { - return -1; + return; } auto result = onInstanceCreated(CLuaInstance(PInstance)); @@ -4630,13 +4465,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::onInstanceCreated %s", err.what()); - return -1; } - - return 0; } - int32 OnInstanceProgressUpdate(CInstance* PInstance) + void OnInstanceProgressUpdate(CInstance* PInstance) { TracyZoneScoped; @@ -4646,7 +4478,7 @@ namespace luautils auto onInstanceProgressUpdate = lua["xi"]["zones"][zone]["instances"][name]["onInstanceProgressUpdate"]; if (!onInstanceProgressUpdate.valid()) { - return -1; + return; } auto result = onInstanceProgressUpdate(CLuaInstance(PInstance), PInstance->GetProgress()); @@ -4654,13 +4486,11 @@ namespace luautils { sol::error err = result; ShowError("luautils::onInstanceProgressUpdate %s", err.what()); - return -1; } - - return 0; } - int32 OnInstanceStageChange(CInstance* PInstance) + // TODO: This is currently unused + void OnInstanceStageChange(CInstance* PInstance) { TracyZoneScoped; @@ -4670,7 +4500,7 @@ namespace luautils auto onInstanceStageChange = lua["xi"]["zones"][zone]["instances"][name]["onInstanceStageChange"]; if (!onInstanceStageChange.valid()) { - return -1; + return; } auto result = onInstanceStageChange(CLuaInstance(PInstance), PInstance->GetStage()); @@ -4678,13 +4508,10 @@ namespace luautils { sol::error err = result; ShowError("luautils::onInstanceStageChange %s", err.what()); - return -1; } - - return 0; } - int32 OnInstanceComplete(CInstance* PInstance) + void OnInstanceComplete(CInstance* PInstance) { TracyZoneScoped; @@ -4694,7 +4521,7 @@ namespace luautils auto onInstanceComplete = lua["xi"]["zones"][zone]["instances"][name]["onInstanceComplete"]; if (!onInstanceComplete.valid()) { - return -1; + return; } auto result = onInstanceComplete(CLuaInstance(PInstance)); @@ -4702,10 +4529,7 @@ namespace luautils { sol::error err = result; ShowError("luautils::onInstanceComplete %s", err.what()); - return -1; } - - return 0; } void StartElevator(uint32 ElevatorID) @@ -4788,7 +4612,7 @@ namespace luautils charutils::ClearCharVarFromAll(varName); } - int32 OnTransportEvent(CCharEntity* PChar, uint32 TransportID) + void OnTransportEvent(CCharEntity* PChar, uint32 TransportID) { TracyZoneScoped; @@ -4797,7 +4621,7 @@ namespace luautils auto onTransportEvent = lua["xi"]["zones"][name]["Zone"]["onTransportEvent"]; if (!onTransportEvent.valid()) { - return -1; + return; } auto result = onTransportEvent(CLuaBaseEntity(PChar), TransportID); @@ -4805,10 +4629,7 @@ namespace luautils { sol::error err = result; ShowError("luautils::onTransportEvent: %s", err.what()); - return -1; } - - return 0; } void OnTimeTrigger(CNpcEntity* PNpc, uint8 triggerID) @@ -4830,7 +4651,7 @@ namespace luautils } } - int32 OnConquestUpdate(CZone* PZone, ConquestUpdate type, uint8 influence, uint8 owner, uint8 ranking, bool isConquestAlliance) + void OnConquestUpdate(CZone* PZone, ConquestUpdate type, uint8 influence, uint8 owner, uint8 ranking, bool isConquestAlliance) { TracyZoneScoped; @@ -4839,7 +4660,7 @@ namespace luautils auto onConquestUpdate = lua["xi"]["zones"][name]["Zone"]["onConquestUpdate"]; if (!onConquestUpdate.valid()) { - return -1; + return; } CLuaZone LuaZone(PZone); @@ -4850,10 +4671,7 @@ namespace luautils { sol::error err = result; ShowError("luautils::onConquestUpdate: %s", err.what()); - return -1; } - - return 0; } void OnServerStart() diff --git a/src/map/lua/luautils.h b/src/map/lua/luautils.h index ec8dfd9dcde..993b810c48c 100644 --- a/src/map/lua/luautils.h +++ b/src/map/lua/luautils.h @@ -119,16 +119,14 @@ enum class Emote : uint8; namespace luautils { - void SafeApplyFunc_ReloadList(std::function&)> func); - - int32 init(); - int32 garbageCollectStep(); - int32 garbageCollectFull(); - void cleanup(); + void init(); + void garbageCollectStep(); + void garbageCollectFull(); + void cleanup(); void ReloadFilewatchList(); - std::vector GetContainerFilenamesList(); + auto GetContainerFilenamesList() -> std::vector; // Cache helpers auto getEntityCachedFunction(CBaseEntity* PEntity, std::string funcName) -> sol::function; @@ -147,13 +145,13 @@ namespace luautils auto GetMobByID(uint32 mobid, sol::object const& instanceObj) -> std::optional; auto GetEntityByID(uint32 mobid, sol::object const& instanceObj, sol::object const& arg3) -> std::optional; - void WeekUpdateConquest(sol::variadic_args va); + void WeekUpdateConquest(uint8 updateType); uint8 GetRegionOwner(uint8 type); uint8 GetRegionInfluence(uint8 type); // Return influence graphics uint8 GetNationRank(uint8 nation); uint8 GetConquestBalance(); bool IsConquestAlliance(); - int32 SetRegionalConquestOverseers(uint8 regionID); // Update NPC Conquest Guard + void SetRegionalConquestOverseers(uint8 regionID); // Update NPC Conquest Guard void SendLuaFuncStringToZone(uint16 zoneId, std::string const& str); auto GetReadOnlyItem(uint32 id) -> std::optional; // Returns a read only lookup item object of the specified ID @@ -206,22 +204,22 @@ namespace luautils int32 GetTextIDVariable(uint16 ZoneID, const char* variable); // Load the value of the TextID variable of the specified zone bool IsContentEnabled(const char* content); - int32 OnGameDay(CZone* PZone); - int32 OnGameHour(CZone* PZone); - int32 OnZoneWeatherChange(uint16 ZoneID, uint8 weather); - int32 OnTOTDChange(uint16 ZoneID, uint8 TOTD); - - int32 OnGameIn(CCharEntity* PChar, bool zoning); - void OnZoneIn(CCharEntity* PChar); - void OnZoneOut(CCharEntity* PChar); - void AfterZoneIn(CBaseEntity* PChar); - int32 OnZoneInitialise(uint16 ZoneID); - void OnZoneTick(CZone* PZone); - int32 OnTriggerAreaEnter(CCharEntity* PChar, CTriggerArea* PTriggerArea); - int32 OnTriggerAreaLeave(CCharEntity* PChar, CTriggerArea* PTriggerArea); - int32 OnTransportEvent(CCharEntity* PChar, uint32 TransportID); - void OnTimeTrigger(CNpcEntity* PNpc, uint8 triggerID); - int32 OnConquestUpdate(CZone* PZone, ConquestUpdate type, uint8 influence, uint8 owner, uint8 ranking, bool isConquestAlliance); // conquest update (hourly or tally) + void OnGameDay(CZone* PZone); + void OnGameHour(CZone* PZone); + void OnZoneWeatherChange(uint16 ZoneID, uint8 weather); + void OnTOTDChange(uint16 ZoneID, uint8 TOTD); + + void OnGameIn(CCharEntity* PChar, bool zoning); + void OnZoneIn(CCharEntity* PChar); + void OnZoneOut(CCharEntity* PChar); + void AfterZoneIn(CBaseEntity* PChar); + void OnZoneInitialise(uint16 ZoneID); + void OnZoneTick(CZone* PZone); + void OnTriggerAreaEnter(CCharEntity* PChar, CTriggerArea* PTriggerArea); + void OnTriggerAreaLeave(CCharEntity* PChar, CTriggerArea* PTriggerArea); + void OnTransportEvent(CCharEntity* PChar, uint32 TransportID); + void OnTimeTrigger(CNpcEntity* PNpc, uint8 triggerID); + void OnConquestUpdate(CZone* PZone, ConquestUpdate type, uint8 influence, uint8 owner, uint8 ranking, bool isConquestAlliance); // conquest update (hourly or tally) void OnServerStart(); void OnJSTMidnight(); @@ -231,61 +229,61 @@ namespace luautils int32 OnEventUpdate(CCharEntity* PChar, uint16 eventID, uint32 result); // triggered when game triggers event update during cutscene int32 OnEventUpdate(CCharEntity* PChar, std::string const& updateString); // triggered when game triggers event update during cutscene int32 OnEventFinish(CCharEntity* PChar, uint16 eventID, uint32 result); - int32 OnTrade(CCharEntity* PChar, CBaseEntity* PNpc); + void OnTrade(CCharEntity* PChar, CBaseEntity* PNpc); - int32 OnNpcSpawn(CBaseEntity* PNpc); // triggers when a patrol npc spawns + void OnNpcSpawn(CBaseEntity* PNpc); // triggers when a patrol npc spawns - int32 OnEffectGain(CBattleEntity* PEntity, CStatusEffect* StatusEffect); - int32 OnEffectTick(CBattleEntity* PEntity, CStatusEffect* StatusEffect); - int32 OnEffectLose(CBattleEntity* PEntity, CStatusEffect* StatusEffect); + void OnEffectGain(CBattleEntity* PEntity, CStatusEffect* StatusEffect); + void OnEffectTick(CBattleEntity* PEntity, CStatusEffect* StatusEffect); + void OnEffectLose(CBattleEntity* PEntity, CStatusEffect* StatusEffect); - int32 OnAttachmentEquip(CBattleEntity* PEntity, CItemPuppet* attachment); - int32 OnAttachmentUnequip(CBattleEntity* PEntity, CItemPuppet* attachment); - int32 OnManeuverGain(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers); - int32 OnManeuverLose(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers); - int32 OnUpdateAttachment(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers); + void OnAttachmentEquip(CBattleEntity* PEntity, CItemPuppet* attachment); + void OnAttachmentUnequip(CBattleEntity* PEntity, CItemPuppet* attachment); + void OnManeuverGain(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers); + void OnManeuverLose(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers); + void OnUpdateAttachment(CBattleEntity* PEntity, CItemPuppet* attachment, uint8 maneuvers); - int32 OnItemUse(CBaseEntity* PUser, CBaseEntity* PTarget, CItem* PItem); - auto OnItemCheck(CBaseEntity* PTarget, CItem* PItem, ITEMCHECK param = ITEMCHECK::NONE, CBaseEntity* PCaster = nullptr) -> std::tuple; - int32 OnItemDrop(CBaseEntity* PUser, CItem* PItem); - int32 OnItemEquip(CBaseEntity* PUser, CItem* PItem); - int32 OnItemUnequip(CBaseEntity* PUser, CItem* PItem); - int32 CheckForGearSet(CBaseEntity* PTarget); + void OnItemUse(CBaseEntity* PUser, CBaseEntity* PTarget, CItem* PItem); + auto OnItemCheck(CBaseEntity* PTarget, CItem* PItem, ITEMCHECK param = ITEMCHECK::NONE, CBaseEntity* PCaster = nullptr) -> std::tuple; + void OnItemDrop(CBaseEntity* PUser, CItem* PItem); + void OnItemEquip(CBaseEntity* PUser, CItem* PItem); + void OnItemUnequip(CBaseEntity* PUser, CItem* PItem); + void CheckForGearSet(CBaseEntity* PTarget); int32 OnMagicCastingCheck(CBaseEntity* PChar, CBaseEntity* PTarget, CSpell* PSpell); int32 OnSpellCast(CBattleEntity* PCaster, CBattleEntity* PTarget, CSpell* PSpell); - int32 OnSpellPrecast(CBattleEntity* PCaster, CSpell* PSpell); + void OnSpellPrecast(CBattleEntity* PCaster, CSpell* PSpell); auto OnMobMagicPrepare(CBattleEntity* PCaster, CBattleEntity* PTarget, std::optional startingSpellId) -> std::optional; - int32 OnMagicHit(CBattleEntity* PCaster, CBattleEntity* PTarget, CSpell* PSpell); - int32 OnWeaponskillHit(CBattleEntity* PMob, CBaseEntity* PAttacker, uint16 PWeaponskill); + void OnMagicHit(CBattleEntity* PCaster, CBattleEntity* PTarget, CSpell* PSpell); + void OnWeaponskillHit(CBattleEntity* PMob, CBaseEntity* PAttacker, uint16 PWeaponskill); bool OnTrustSpellCastCheckBattlefieldTrusts(CBattleEntity* PCaster); // Triggered if spell is a trust spell during onCast to determine to interrupt spell or not - int32 OnMobInitialize(CBaseEntity* PMob); - int32 ApplyMixins(CBaseEntity* PMob); - int32 ApplyZoneMixins(CBaseEntity* PMob); - int32 OnMobSpawn(CBaseEntity* PMob); - int32 OnMobRoamAction(CBaseEntity* PMob); // triggers when event mob is ready for a custom roam action - int32 OnMobRoam(CBaseEntity* PMob); - int32 OnMobEngage(CBaseEntity* PMob, CBaseEntity* PTarget); - int32 OnMobDisengage(CBaseEntity* PMob); - int32 OnMobFollow(CBaseEntity* PMob, CBaseEntity* PTarget); - int32 OnMobUnfollow(CBaseEntity* PMob, CBaseEntity* PTarget); - int32 OnMobDrawIn(CBaseEntity* PMob, CBaseEntity* PTarget); - int32 OnMobFight(CBaseEntity* PMob, CBaseEntity* PTarget); - int32 OnCriticalHit(CBattleEntity* PMob, CBattleEntity* PAttacker); - int32 OnMobDeath(CBaseEntity* PMob, CBaseEntity* PKiller); - int32 OnMobDespawn(CBaseEntity* PMob); - - int32 OnPetLevelRestriction(CBaseEntity* PMob); - - int32 OnPath(CBaseEntity* PEntity); - int32 OnPathPoint(CBaseEntity* PEntity); - int32 OnPathComplete(CBaseEntity* PEntity); + void OnMobInitialize(CBaseEntity* PMob); + void ApplyMixins(CBaseEntity* PMob); + void ApplyZoneMixins(CBaseEntity* PMob); + void OnMobSpawn(CBaseEntity* PMob); + void OnMobRoamAction(CBaseEntity* PMob); // triggers when event mob is ready for a custom roam action + void OnMobRoam(CBaseEntity* PMob); + void OnMobEngage(CBaseEntity* PMob, CBaseEntity* PTarget); + void OnMobDisengage(CBaseEntity* PMob); + void OnMobFollow(CBaseEntity* PMob, CBaseEntity* PTarget); + void OnMobUnfollow(CBaseEntity* PMob, CBaseEntity* PTarget); + void OnMobDrawIn(CBaseEntity* PMob, CBaseEntity* PTarget); + void OnMobFight(CBaseEntity* PMob, CBaseEntity* PTarget); + void OnCriticalHit(CBattleEntity* PMob, CBattleEntity* PAttacker); + void OnMobDeath(CBaseEntity* PMob, CBaseEntity* PKiller); + void OnMobDespawn(CBaseEntity* PMob); + + void OnPetLevelRestriction(CBaseEntity* PMob); + + void OnPath(CBaseEntity* PEntity); + void OnPathPoint(CBaseEntity* PEntity); + void OnPathComplete(CBaseEntity* PEntity); int32 OnBattlefieldHandlerInitialise(CZone* PZone); - int32 OnBattlefieldInitialise(CBattlefield* PBattlefield); // what to do when initialising battlefield, battlefield:setLocalVar("lootId") here for any which have loot - int32 OnBattlefieldTick(CBattlefield* PBattlefield); - int32 OnBattlefieldStatusChange(CBattlefield* PBattlefield); + void OnBattlefieldInitialise(CBattlefield* PBattlefield); // what to do when initialising battlefield, battlefield:setLocalVar("lootId") here for any which have loot + void OnBattlefieldTick(CBattlefield* PBattlefield); + void OnBattlefieldStatusChange(CBattlefield* PBattlefield); void OnBattlefieldEnter(CCharEntity* PChar, CBattlefield* PBattlefield); void OnBattlefieldLeave(CCharEntity* PChar, CBattlefield* PBattlefield, uint8 LeaveCode); // see battlefield.h BATTLEFIELD_LEAVE_CODE @@ -317,16 +315,16 @@ namespace luautils auto GetCachedInstanceScript(uint16 instanceId) -> sol::table; - int32 OnInstanceZoneIn(CCharEntity* PChar, CInstance* PInstance); + void OnInstanceZoneIn(CCharEntity* PChar, CInstance* PInstance); void AfterInstanceRegister(CBaseEntity* PChar); // triggers after a character is registered and zoned into an instance (the first time) int32 OnInstanceLoadFailed(CZone* PZone); // triggers when an instance load is failed (ie. instance no longer exists) - int32 OnInstanceTimeUpdate(CZone* PZone, CInstance* PInstance, uint32 time); // triggers every second for an instance - int32 OnInstanceFailure(CInstance* PInstance); // triggers when an instance is failed - int32 OnInstanceCreatedCallback(CCharEntity* PChar, CInstance* PInstance); // triggers when an instance is created (per character - waiting outside for entry) - int32 OnInstanceCreated(CInstance* PInstance); // triggers when an instance is created (instance setup) - int32 OnInstanceProgressUpdate(CInstance* PInstance); - int32 OnInstanceStageChange(CInstance* PInstance); - int32 OnInstanceComplete(CInstance* PInstance); + void OnInstanceTimeUpdate(CZone* PZone, CInstance* PInstance, uint32 time); // triggers every second for an instance + void OnInstanceFailure(CInstance* PInstance); // triggers when an instance is failed + void OnInstanceCreatedCallback(CCharEntity* PChar, CInstance* PInstance); // triggers when an instance is created (per character - waiting outside for entry) + void OnInstanceCreated(CInstance* PInstance); // triggers when an instance is created (instance setup) + void OnInstanceProgressUpdate(CInstance* PInstance); + void OnInstanceStageChange(CInstance* PInstance); + void OnInstanceComplete(CInstance* PInstance); uint32 GetMobRespawnTime(uint32 mobid); void DisallowRespawn(uint32 mobid, bool allowRespawn); @@ -335,10 +333,10 @@ namespace luautils std::string GetServerMessage(uint8 language); // Get the message to be delivered to player on first zone in of a session auto GetRecentFishers(uint16 minutes) -> sol::table; // returns a list of recently active fishers (that fished in the last specified minutes) - int32 OnAdditionalEffect(CBattleEntity* PAttacker, CBattleEntity* PDefender, actionTarget_t* Action, int32 damage); // for mobs with additional effects - int32 OnSpikesDamage(CBattleEntity* PDefender, CBattleEntity* PAttacker, actionTarget_t* Action, int32 damage); // for mobs with spikes + void OnAdditionalEffect(CBattleEntity* PAttacker, CBattleEntity* PDefender, actionTarget_t* Action, int32 damage); // for mobs with additional effects + void OnSpikesDamage(CBattleEntity* PDefender, CBattleEntity* PAttacker, actionTarget_t* Action, int32 damage); // for mobs with spikes int32 additionalEffectAttack(CBattleEntity* PAttacker, CBattleEntity* PDefender, CItemWeapon* PItem, actionTarget_t* Action, int32 baseAttackDamage); // for items with additional effects - int32 additionalEffectSpikes(CBattleEntity* PDefender, CBattleEntity* PAttacker, CItemEquipment* PItem, actionTarget_t* Action, int32 baseAttackDamage); // for armor with spikes + void additionalEffectSpikes(CBattleEntity* PDefender, CBattleEntity* PAttacker, CItemEquipment* PItem, actionTarget_t* Action, int32 baseAttackDamage); // for armor with spikes auto NearLocation(sol::table const& table, float radius, float theta) -> sol::table; auto GetFurthestValidPosition(CLuaBaseEntity* fromTarget, float distance, float theta) -> sol::table;