diff options
author | Melanie Thielker | 2008-10-16 20:50:28 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-10-16 20:50:28 +0000 |
commit | 4bbc28e4459d1801ef1a8bc1864866bad30d5aaa (patch) | |
tree | 4217a66ab4f6dfda8f9ea3188496b1df8a9dcb8f /OpenSim/Region/Environment/Modules/Avatar/Combat | |
parent | * minor: get rid of pointless ipeSender (diff) | |
download | opensim-SC-4bbc28e4459d1801ef1a8bc1864866bad30d5aaa.zip opensim-SC-4bbc28e4459d1801ef1a8bc1864866bad30d5aaa.tar.gz opensim-SC-4bbc28e4459d1801ef1a8bc1864866bad30d5aaa.tar.bz2 opensim-SC-4bbc28e4459d1801ef1a8bc1864866bad30d5aaa.tar.xz |
Split the currency module into currency and a new Combat module, because
the combat function really doesn't belong into currency
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Combat')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Combat/CombatModule.cs | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Combat/CombatModule.cs new file mode 100644 index 0000000..1f16421 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/Avatar/Combat/CombatModule.cs | |||
@@ -0,0 +1,155 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Net.Sockets; | ||
33 | using System.Reflection; | ||
34 | using System.Xml; | ||
35 | using OpenMetaverse; | ||
36 | using log4net; | ||
37 | using Nini.Config; | ||
38 | using Nwc.XmlRpc; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Region.Environment.Interfaces; | ||
41 | using OpenSim.Region.Interfaces; | ||
42 | using OpenSim.Region.Environment.Scenes; | ||
43 | using OpenSim.Framework.Communications.Cache; | ||
44 | |||
45 | namespace OpenSim.Region.Environment.Modules.Avatar.Combat.CombatModule | ||
46 | { | ||
47 | public class CombatModule : IRegionModule | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | /// <summary> | ||
52 | /// Region UUIDS indexed by AgentID | ||
53 | /// </summary> | ||
54 | private Dictionary<UUID, UUID> m_rootAgents = new Dictionary<UUID, UUID>(); | ||
55 | |||
56 | /// <summary> | ||
57 | /// Scenes by Region Handle | ||
58 | /// </summary> | ||
59 | private Dictionary<ulong, Scene> m_scenel = new Dictionary<ulong, Scene>(); | ||
60 | |||
61 | /// <summary> | ||
62 | /// Startup | ||
63 | /// </summary> | ||
64 | /// <param name="scene"></param> | ||
65 | /// <param name="config"></param> | ||
66 | public void Initialise(Scene scene, IConfigSource config) | ||
67 | { | ||
68 | lock (m_scenel) | ||
69 | { | ||
70 | if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle)) | ||
71 | { | ||
72 | m_scenel[scene.RegionInfo.RegionHandle] = scene; | ||
73 | } | ||
74 | else | ||
75 | { | ||
76 | m_scenel.Add(scene.RegionInfo.RegionHandle, scene); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | scene.EventManager.OnAvatarKilled += KillAvatar; | ||
81 | } | ||
82 | |||
83 | public void PostInitialise() | ||
84 | { | ||
85 | } | ||
86 | |||
87 | public void Close() | ||
88 | { | ||
89 | } | ||
90 | |||
91 | public string Name | ||
92 | { | ||
93 | get { return "CombatModule"; } | ||
94 | } | ||
95 | |||
96 | public bool IsSharedModule | ||
97 | { | ||
98 | get { return true; } | ||
99 | } | ||
100 | |||
101 | private void KillAvatar(uint killerObjectLocalID, ScenePresence DeadAvatar) | ||
102 | { | ||
103 | if (killerObjectLocalID == 0) | ||
104 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You committed suicide!", true); | ||
105 | else | ||
106 | { | ||
107 | bool foundResult = false; | ||
108 | string resultstring = ""; | ||
109 | List<ScenePresence> allav = DeadAvatar.Scene.GetScenePresences(); | ||
110 | try | ||
111 | { | ||
112 | foreach (ScenePresence av in allav) | ||
113 | { | ||
114 | if (av.LocalId == killerObjectLocalID) | ||
115 | { | ||
116 | av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); | ||
117 | resultstring = av.Firstname + " " + av.Lastname; | ||
118 | foundResult = true; | ||
119 | } | ||
120 | } | ||
121 | } catch (System.InvalidOperationException) | ||
122 | { | ||
123 | |||
124 | } | ||
125 | |||
126 | if (!foundResult) | ||
127 | { | ||
128 | SceneObjectPart part = DeadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID); | ||
129 | if (part != null) | ||
130 | { | ||
131 | ScenePresence av = DeadAvatar.Scene.GetScenePresence(part.OwnerID); | ||
132 | if (av != null) | ||
133 | { | ||
134 | av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); | ||
135 | resultstring = av.Firstname + " " + av.Lastname; | ||
136 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You got killed by " + resultstring + "!", true); | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | string killer = DeadAvatar.Scene.CommsManager.UUIDNameRequestString(part.OwnerID); | ||
141 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You impaled yourself on " + part.Name + " owned by " + killer +"!", true); | ||
142 | } | ||
143 | //DeadAvatar.Scene. part.ObjectOwner | ||
144 | } | ||
145 | else | ||
146 | { | ||
147 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You died!", true); | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | DeadAvatar.Health = 100; | ||
152 | DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient); | ||
153 | } | ||
154 | } | ||
155 | } | ||