From 4f3fabae5bec8a71f9953ef9f4c247e086e4757f Mon Sep 17 00:00:00 2001 From: TBG Renfold Date: Thu, 9 Aug 2012 18:03:26 +0100 Subject: Adds osGetHealth. Returns the amount of health (in an integer) that an avatar has left in the scene. If an avatar is not found or safe is enabled on a region, -1 is returned. Example usage: default { touch_end(integer _t) { key agentID = llDetectedKey(0); osCauseDamage(agentID, 50); llSay(0, llKey2Name(agentID) + " has " + (string)osGetHealth(agentID) + "% health left."); } } --- .../Shared/Api/Implementation/OSSL_Api.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 1e8b51b..3d233d7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2895,6 +2895,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } }); } + + public LSL_Float osGetHealth(string avatar) + { + CheckThreatLevel(ThreatLevel.None, "osGetHealth"); + m_host.AddScriptLPS(1); + + UUID avatarId = new UUID(avatar); + Vector3 pos = m_host.GetWorldPosition(); + + LSL_Float health = new LSL_Float(-1); + ScenePresence presence = World.GetScenePresence(avatarId); + if (presence != null) + { + LandData land = World.GetLandData((float)pos.X, (float)pos.Y); + if ((land.Flags & (uint)ParcelFlags.AllowDamage) == (uint)ParcelFlags.AllowDamage) + { + health = presence.Health; + } + } + return health; + } public void osCauseDamage(string avatar, double damage) { -- cgit v1.1