diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index 592a9f6cb9..aa617ed846 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -321,6 +321,7 @@ ElunaRegister UnitMethods[] = // {"GetVehicle", &LuaUnit::GetVehicle}, // :GetVehicle() - UNDOCUMENTED - Gets the Vehicle kit of the vehicle the unit is on { "GetMovementType", &LuaUnit::GetMovementType }, { "GetAttackers", &LuaUnit::GetAttackers }, + { "GetThreat", &LuaUnit::GetThreat }, // Setters { "SetFaction", &LuaUnit::SetFaction }, @@ -454,6 +455,8 @@ ElunaRegister UnitMethods[] = { "DealHeal", &LuaUnit::DealHeal }, { "AddThreat", &LuaUnit::AddThreat }, { "ModifyThreatPct", &LuaUnit::ModifyThreatPct }, + { "ClearThreat", &LuaUnit::ClearThreat }, + { "ResetAllThreat", &LuaUnit::ResetAllThreat }, { NULL, NULL } }; diff --git a/src/LuaEngine/methods/UnitMethods.h b/src/LuaEngine/methods/UnitMethods.h index 529dc51b11..51fa341ab6 100644 --- a/src/LuaEngine/methods/UnitMethods.h +++ b/src/LuaEngine/methods/UnitMethods.h @@ -2714,5 +2714,41 @@ namespace LuaUnit Eluna::Push(L, summon); return 1; }*/ + + /** + * Clear the threat of a [Unit] in the threat list. + * + * @param [Unit] target + */ + int ClearThreat(lua_State* L, Unit* unit) + { + Unit* target = Eluna::CHECKOBJ(L, 2); + + unit->GetThreatMgr().ClearThreat(target); + return 0; + } + + /** + * Resets the [Unit]'s threat list, setting all threat targets' threat to 0. + */ + int ResetAllThreat(lua_State* /*L*/, Unit* unit) + { + unit->GetThreatMgr().ResetAllThreat(); + return 0; + } + + /** + * Returns the threat of a [Unit]. + * + * @param [Unit] target + * @return float threat + */ + int GetThreat(lua_State* L, Unit* unit) + { + Unit* target = Eluna::CHECKOBJ(L, 2); + + Eluna::Push(L, unit->GetThreatMgr().GetThreat(target)); + return 1; + } }; #endif