aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World/NPC
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs21
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs55
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs2
3 files changed, 58 insertions, 20 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index c3335f0..c9c12c6 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -76,22 +76,27 @@ namespace OpenSim.Region.OptionalModules.World.NPC
76 76
77 public void Say(string message) 77 public void Say(string message)
78 { 78 {
79 SendOnChatFromClient(message, ChatTypeEnum.Say); 79 SendOnChatFromClient(0, message, ChatTypeEnum.Say);
80 } 80 }
81 81
82 public void Shout(string message) 82 public void Say(int channel, string message)
83 { 83 {
84 SendOnChatFromClient(message, ChatTypeEnum.Shout); 84 SendOnChatFromClient(channel, message, ChatTypeEnum.Say);
85 } 85 }
86 86
87 public void Whisper(string message) 87 public void Shout(int channel, string message)
88 { 88 {
89 SendOnChatFromClient(message, ChatTypeEnum.Whisper); 89 SendOnChatFromClient(channel, message, ChatTypeEnum.Shout);
90 }
91
92 public void Whisper(int channel, string message)
93 {
94 SendOnChatFromClient(channel, message, ChatTypeEnum.Whisper);
90 } 95 }
91 96
92 public void Broadcast(string message) 97 public void Broadcast(string message)
93 { 98 {
94 SendOnChatFromClient(message, ChatTypeEnum.Broadcast); 99 SendOnChatFromClient(0, message, ChatTypeEnum.Broadcast);
95 } 100 }
96 101
97 public void GiveMoney(UUID target, int amount) 102 public void GiveMoney(UUID target, int amount)
@@ -146,10 +151,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
146 151
147 #region Internal Functions 152 #region Internal Functions
148 153
149 private void SendOnChatFromClient(string message, ChatTypeEnum chatType) 154 private void SendOnChatFromClient(int channel, string message, ChatTypeEnum chatType)
150 { 155 {
151 OSChatMessage chatFromClient = new OSChatMessage(); 156 OSChatMessage chatFromClient = new OSChatMessage();
152 chatFromClient.Channel = 0; 157 chatFromClient.Channel = channel;
153 chatFromClient.From = Name; 158 chatFromClient.From = Name;
154 chatFromClient.Message = message; 159 chatFromClient.Message = message;
155 chatFromClient.Position = StartPos; 160 chatFromClient.Position = StartPos;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index ebf5e84..9c77b59 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -155,18 +155,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
155 ScenePresence sp; 155 ScenePresence sp;
156 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) 156 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
157 { 157 {
158 m_log.DebugFormat(
159 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
160
161 sp.CompleteMovement(npcAvatar, false); 158 sp.CompleteMovement(npcAvatar, false);
162 m_avatars.Add(npcAvatar.AgentId, npcAvatar); 159 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
160 m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
163 } 161 }
164 else
165 {
166 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
167 npcAvatar.AgentId = UUID.Zero;
168 }
169
170 } 162 }
171 ev.Set(); 163 ev.Set();
172 }); 164 });
@@ -221,6 +213,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
221 213
222 public bool Say(UUID agentID, Scene scene, string text) 214 public bool Say(UUID agentID, Scene scene, string text)
223 { 215 {
216 return Say(agentID, scene, text, 0);
217 }
218
219 public bool Say(UUID agentID, Scene scene, string text, int channel)
220 {
224 lock (m_avatars) 221 lock (m_avatars)
225 { 222 {
226 if (m_avatars.ContainsKey(agentID)) 223 if (m_avatars.ContainsKey(agentID))
@@ -228,7 +225,25 @@ namespace OpenSim.Region.OptionalModules.World.NPC
228 ScenePresence sp; 225 ScenePresence sp;
229 scene.TryGetScenePresence(agentID, out sp); 226 scene.TryGetScenePresence(agentID, out sp);
230 227
231 m_avatars[agentID].Say(text); 228 m_avatars[agentID].Say(channel, text);
229
230 return true;
231 }
232 }
233
234 return false;
235 }
236
237 public bool Shout(UUID agentID, Scene scene, string text, int channel)
238 {
239 lock (m_avatars)
240 {
241 if (m_avatars.ContainsKey(agentID))
242 {
243 ScenePresence sp;
244 scene.TryGetScenePresence(agentID, out sp);
245
246 m_avatars[agentID].Shout(channel, text);
232 247
233 return true; 248 return true;
234 } 249 }
@@ -255,6 +270,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC
255 return false; 270 return false;
256 } 271 }
257 272
273 public bool Whisper(UUID agentID, Scene scene, string text, int channel)
274 {
275 lock (m_avatars)
276 {
277 if (m_avatars.ContainsKey(agentID))
278 {
279 ScenePresence sp;
280 scene.TryGetScenePresence(agentID, out sp);
281
282 m_avatars[agentID].Whisper(channel, text);
283
284 return true;
285 }
286 }
287
288 return false;
289 }
290
258 public bool Stand(UUID agentID, Scene scene) 291 public bool Stand(UUID agentID, Scene scene)
259 { 292 {
260 lock (m_avatars) 293 lock (m_avatars)
@@ -308,7 +341,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
308 scene.RemoveClient(agentID, false); 341 scene.RemoveClient(agentID, false);
309 m_avatars.Remove(agentID); 342 m_avatars.Remove(agentID);
310 343
311// m_log.DebugFormat("[NPC MODULE]: Removed {0} {1}", agentID, av.Name); 344 m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name);
312 return true; 345 return true;
313 } 346 }
314 } 347 }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index eea0b2e..a39257e 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -85,7 +85,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
85 m_attMod = new AttachmentsModule(); 85 m_attMod = new AttachmentsModule();
86 m_npcMod = new NPCModule(); 86 m_npcMod = new NPCModule();
87 87
88 m_scene = SceneHelpers.SetupScene(); 88 m_scene = new SceneHelpers().SetupScene();
89 SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule()); 89 SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule());
90 } 90 }
91 91