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."); } }integration
parent
aede42b875
commit
4f3fabae5b
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -258,6 +258,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
|||
int osGetSimulatorMemory();
|
||||
void osKickAvatar(string FirstName,string SurName,string alert);
|
||||
void osSetSpeed(string UUID, LSL_Float SpeedModifier);
|
||||
LSL_Float osGetHealth(string avatar);
|
||||
void osCauseHealing(string avatar, double healing);
|
||||
void osCauseDamage(string avatar, double damage);
|
||||
LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules);
|
||||
|
|
|
@ -865,7 +865,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
|||
{
|
||||
m_OSSL_Functions.osSetSpeed(UUID, SpeedModifier);
|
||||
}
|
||||
|
||||
|
||||
public LSL_Float osGetHealth(string avatar)
|
||||
{
|
||||
return m_OSSL_Functions.osGetHealth(avatar);
|
||||
}
|
||||
|
||||
public void osCauseDamage(string avatar, double damage)
|
||||
{
|
||||
m_OSSL_Functions.osCauseDamage(avatar, damage);
|
||||
|
|
Loading…
Reference in New Issue