From 92fde6ed268f4c7357ca5ad96b967db0f0658446 Mon Sep 17 00:00:00 2001 From: Talun Date: Fri, 4 May 2012 19:37:13 +0100 Subject: Mantis 60004 problems with damage and llSetDamage. In damage enabled areas this patch - Deletes any objects that have damage set > 0 that deliver that damage to an avatar Stops Gods receiving damage, Stops volume detect objects causing damage Deletes NPCS when their helth reduces to zero Gradually "heals" damage to an avatar Resets health on going to a non damage area --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 53 ++++++++++++++++++++---- 1 file changed, 46 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 91e6e5a..7e49a5e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3312,23 +3312,53 @@ namespace OpenSim.Region.Framework.Scenes } } - if (Invulnerable) + // Gods do not take damage and Invulnerable is set depending on parcel/region flags + if (Invulnerable || GodLevel > 0) return; - + + // The following may be better in the ICombatModule + // probably tweaking of the values for ground and normal prim collisions will be needed float starthealth = Health; uint killerObj = 0; + SceneObjectPart part = null; foreach (uint localid in coldata.Keys) { - SceneObjectPart part = Scene.GetSceneObjectPart(localid); - - if (part != null && part.ParentGroup.Damage != -1.0f) - Health -= part.ParentGroup.Damage; + if (localid == 0) + { + part = null; + } + else + { + part = Scene.GetSceneObjectPart(localid); + } + if (part != null) + { + // Ignore if it has been deleted or volume detect + if (!part.ParentGroup.IsDeleted && !part.ParentGroup.IsVolumeDetect) + { + if (part.ParentGroup.Damage > 0.0f) + { + // Something with damage... + Health -= part.ParentGroup.Damage; + part.ParentGroup.Scene.DeleteSceneObject(part.ParentGroup, false); + } + else + { + // An ordinary prim + if (coldata[localid].PenetrationDepth >= 0.10f) + Health -= coldata[localid].PenetrationDepth * 5.0f; + } + } + } else { - if (coldata[localid].PenetrationDepth >= 0.10f) + // 0 is the ground + // what about collisions with other avatars? + if (localid == 0 && coldata[localid].PenetrationDepth >= 0.10f) Health -= coldata[localid].PenetrationDepth * 5.0f; } + if (Health <= 0.0f) { if (localid != 0) @@ -3344,7 +3374,16 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendHealth(Health); } if (Health <= 0) + { m_scene.EventManager.TriggerAvatarKill(killerObj, this); + } + if (starthealth == Health && Health < 100.0f) + { + Health += 0.03f; + if (Health > 100.0f) + Health = 100.0f; + ControllingClient.SendHealth(Health); + } } } -- cgit v1.1