aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorMelanie Thielker2008-10-16 20:50:28 +0000
committerMelanie Thielker2008-10-16 20:50:28 +0000
commit4bbc28e4459d1801ef1a8bc1864866bad30d5aaa (patch)
tree4217a66ab4f6dfda8f9ea3188496b1df8a9dcb8f /OpenSim/Region/Environment
parent* minor: get rid of pointless ipeSender (diff)
downloadopensim-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')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Combat/CombatModule.cs155
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs55
2 files changed, 155 insertions, 55 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Net.Sockets;
33using System.Reflection;
34using System.Xml;
35using OpenMetaverse;
36using log4net;
37using Nini.Config;
38using Nwc.XmlRpc;
39using OpenSim.Framework;
40using OpenSim.Region.Environment.Interfaces;
41using OpenSim.Region.Interfaces;
42using OpenSim.Region.Environment.Scenes;
43using OpenSim.Framework.Communications.Cache;
44
45namespace 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}
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
index 1f57fb5..4de6fa2 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
@@ -180,7 +180,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
180 scene.EventManager.OnClientClosed += ClientLoggedOut; 180 scene.EventManager.OnClientClosed += ClientLoggedOut;
181 scene.EventManager.OnValidateLandBuy += ValidateLandBuy; 181 scene.EventManager.OnValidateLandBuy += ValidateLandBuy;
182 scene.EventManager.OnLandBuy += processLandBuy; 182 scene.EventManager.OnLandBuy += processLandBuy;
183 scene.EventManager.OnAvatarKilled += KillAvatar;
184 } 183 }
185 } 184 }
186 185
@@ -1492,60 +1491,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1492 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); 1491 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
1493 } 1492 }
1494 1493
1495 private void KillAvatar(uint killerObjectLocalID, ScenePresence DeadAvatar)
1496 {
1497 if (killerObjectLocalID == 0)
1498 DeadAvatar.ControllingClient.SendAgentAlertMessage("You committed suicide!", true);
1499 else
1500 {
1501 bool foundResult = false;
1502 string resultstring = "";
1503 List<ScenePresence> allav = DeadAvatar.Scene.GetScenePresences();
1504 try
1505 {
1506 foreach (ScenePresence av in allav)
1507 {
1508 if (av.LocalId == killerObjectLocalID)
1509 {
1510 av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname);
1511 resultstring = av.Firstname + " " + av.Lastname;
1512 foundResult = true;
1513 }
1514 }
1515 } catch (System.InvalidOperationException)
1516 {
1517
1518 }
1519
1520 if (!foundResult)
1521 {
1522 SceneObjectPart part = DeadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID);
1523 if (part != null)
1524 {
1525 ScenePresence av = DeadAvatar.Scene.GetScenePresence(part.OwnerID);
1526 if (av != null)
1527 {
1528 av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname);
1529 resultstring = av.Firstname + " " + av.Lastname;
1530 DeadAvatar.ControllingClient.SendAgentAlertMessage("You got killed by " + resultstring + "!", true);
1531 }
1532 else
1533 {
1534 string killer = DeadAvatar.Scene.CommsManager.UUIDNameRequestString(part.OwnerID);
1535 DeadAvatar.ControllingClient.SendAgentAlertMessage("You impaled yourself on " + part.Name + " owned by " + killer +"!", true);
1536 }
1537 //DeadAvatar.Scene. part.ObjectOwner
1538 }
1539 else
1540 {
1541 DeadAvatar.ControllingClient.SendAgentAlertMessage("You died!", true);
1542 }
1543 }
1544 }
1545 DeadAvatar.Health = 100;
1546 DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient);
1547 }
1548
1549 public int GetBalance(IClientAPI client) 1494 public int GetBalance(IClientAPI client)
1550 { 1495 {
1551 GetClientFunds(client); 1496 GetClientFunds(client);