diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs | 77 |
1 files changed, 37 insertions, 40 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 3614915..9df6074 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs | |||
@@ -89,60 +89,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule | |||
89 | get { return true; } | 89 | get { return true; } |
90 | } | 90 | } |
91 | 91 | ||
92 | private void KillAvatar(uint killerObjectLocalID, ScenePresence DeadAvatar) | 92 | private void KillAvatar(uint killerObjectLocalID, ScenePresence deadAvatar) |
93 | { | 93 | { |
94 | string deadAvatarMessage; | ||
95 | ScenePresence killingAvatar = null; | ||
96 | string killingAvatarMessage; | ||
97 | |||
94 | if (killerObjectLocalID == 0) | 98 | if (killerObjectLocalID == 0) |
95 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You committed suicide!", true); | 99 | deadAvatarMessage = "You committed suicide!"; |
96 | else | 100 | else |
97 | { | 101 | { |
98 | bool foundResult = false; | 102 | // Try to get the avatar responsible for the killing |
99 | string resultstring = String.Empty; | 103 | killingAvatar = deadAvatar.Scene.GetScenePresence(killerObjectLocalID); |
100 | ScenePresence[] allav = DeadAvatar.Scene.GetScenePresences(); | 104 | if (killingAvatar == null) |
101 | try | ||
102 | { | 105 | { |
103 | for (int i = 0; i < allav.Length; i++) | 106 | // Try to get the object which was responsible for the killing |
107 | SceneObjectPart part = deadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID); | ||
108 | if (part == null) | ||
104 | { | 109 | { |
105 | ScenePresence av = allav[i]; | 110 | // Cause of death: Unknown |
106 | 111 | deadAvatarMessage = "You died!"; | |
107 | if (av.LocalId == killerObjectLocalID) | ||
108 | { | ||
109 | av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); | ||
110 | resultstring = av.Firstname + " " + av.Lastname; | ||
111 | foundResult = true; | ||
112 | } | ||
113 | } | 112 | } |
114 | } catch (InvalidOperationException) | 113 | else |
115 | { | ||
116 | |||
117 | } | ||
118 | |||
119 | if (!foundResult) | ||
120 | { | ||
121 | SceneObjectPart part = DeadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID); | ||
122 | if (part != null) | ||
123 | { | 114 | { |
124 | ScenePresence av = DeadAvatar.Scene.GetScenePresence(part.OwnerID); | 115 | // Try to find the avatar wielding the killing object |
125 | if (av != null) | 116 | killingAvatar = deadAvatar.Scene.GetScenePresence(part.OwnerID); |
126 | { | 117 | if (killingAvatar == null) |
127 | av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); | 118 | deadAvatarMessage = String.Format("You impaled yourself on {0} owned by {1}!", part.Name, deadAvatar.Scene.GetUserName(part.OwnerID)); |
128 | resultstring = av.Firstname + " " + av.Lastname; | ||
129 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You got killed by " + resultstring + "!", true); | ||
130 | } | ||
131 | else | 119 | else |
132 | { | 120 | { |
133 | string killer = DeadAvatar.Scene.GetUserName(part.OwnerID); | 121 | killingAvatarMessage = String.Format("You fragged {0}!", deadAvatar.Name); |
134 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You impaled yourself on " + part.Name + " owned by " + killer +"!", true); | 122 | deadAvatarMessage = String.Format("You got killed by {0}!", killingAvatar.Name); |
135 | } | 123 | } |
136 | //DeadAvatar.Scene. part.ObjectOwner | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You died!", true); | ||
141 | } | 124 | } |
142 | } | 125 | } |
126 | else | ||
127 | { | ||
128 | killingAvatarMessage = String.Format("You fragged {0}!", deadAvatar.Name); | ||
129 | deadAvatarMessage = String.Format("You got killed by {0}!", killingAvatar.Name); | ||
130 | } | ||
143 | } | 131 | } |
144 | DeadAvatar.Health = 100; | 132 | try |
145 | DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient); | 133 | { |
134 | deadAvatar.ControllingClient.SendAgentAlertMessage(deadAvatarMessage, true); | ||
135 | if(killingAvatar != null) | ||
136 | killingAvatar.ControllingClient.SendAlertMessage("You fragged " + deadAvatar.Firstname + " " + deadAvatar.Lastname); | ||
137 | } | ||
138 | catch (InvalidOperationException) | ||
139 | { } | ||
140 | |||
141 | deadAvatar.Health = 100; | ||
142 | deadAvatar.Scene.TeleportClientHome(deadAvatar.UUID, deadAvatar.ControllingClient); | ||
146 | } | 143 | } |
147 | 144 | ||
148 | private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) | 145 | private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) |