diff options
author | Justin Clark-Casey (justincc) | 2011-08-10 00:26:38 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-10 00:26:38 +0100 |
commit | 195c1dc9b8b8511980d9a607a242b24a5a91da17 (patch) | |
tree | f1e844250bf92895e39a41f8b6fac7797a09317f | |
parent | When an NPC appearance is loaded, rez the attachments too (diff) | |
download | opensim-SC-195c1dc9b8b8511980d9a607a242b24a5a91da17.zip opensim-SC-195c1dc9b8b8511980d9a607a242b24a5a91da17.tar.gz opensim-SC-195c1dc9b8b8511980d9a607a242b24a5a91da17.tar.bz2 opensim-SC-195c1dc9b8b8511980d9a607a242b24a5a91da17.tar.xz |
implement osNpcStopMoveTo() to cancel any current move target
6 files changed, 66 insertions, 9 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 1e09610..ebb5bd2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -566,8 +566,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
566 | /// <param name="silent"></param> | 566 | /// <param name="silent"></param> |
567 | protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | 567 | protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) |
568 | { | 568 | { |
569 | m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name, | 569 | m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", |
570 | attachmentpoint, attachOffset, so.RootPart.AttachedPos); | 570 | so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); |
571 | 571 | ||
572 | so.DetachFromBackup(); | 572 | so.DetachFromBackup(); |
573 | 573 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index 54575ca..763d2dc 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
58 | /// <param name="agentID"></param> | 58 | /// <param name="agentID"></param> |
59 | /// <param name="appearance"></param> | 59 | /// <param name="appearance"></param> |
60 | /// <param name="scene"></param> | 60 | /// <param name="scene"></param> |
61 | /// <returns></returns> | 61 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> |
62 | bool SetNPCAppearance(UUID agentID, AvatarAppearance appearance, Scene scene); | 62 | bool SetNPCAppearance(UUID agentID, AvatarAppearance appearance, Scene scene); |
63 | 63 | ||
64 | /// <summary> | 64 | /// <summary> |
@@ -67,7 +67,16 @@ namespace OpenSim.Region.Framework.Interfaces | |||
67 | /// <param name="agentID">The UUID of the NPC</param> | 67 | /// <param name="agentID">The UUID of the NPC</param> |
68 | /// <param name="scene"></param> | 68 | /// <param name="scene"></param> |
69 | /// <param name="pos"></param> | 69 | /// <param name="pos"></param> |
70 | void MoveToTarget(UUID agentID, Scene scene, Vector3 pos); | 70 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> |
71 | bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos); | ||
72 | |||
73 | /// <summary> | ||
74 | /// Stop the NPC's current movement. | ||
75 | /// </summary> | ||
76 | /// <param name="agentID">The UUID of the NPC</param> | ||
77 | /// <param name="scene"></param> | ||
78 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | ||
79 | bool StopMoveToTarget(UUID agentID, Scene scene); | ||
71 | 80 | ||
72 | /// <summary> | 81 | /// <summary> |
73 | /// Get the NPC to say something. | 82 | /// Get the NPC to say something. |
@@ -75,13 +84,15 @@ namespace OpenSim.Region.Framework.Interfaces | |||
75 | /// <param name="agentID">The UUID of the NPC</param> | 84 | /// <param name="agentID">The UUID of the NPC</param> |
76 | /// <param name="scene"></param> | 85 | /// <param name="scene"></param> |
77 | /// <param name="text"></param> | 86 | /// <param name="text"></param> |
78 | void Say(UUID agentID, Scene scene, string text); | 87 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> |
88 | bool Say(UUID agentID, Scene scene, string text); | ||
79 | 89 | ||
80 | /// <summary> | 90 | /// <summary> |
81 | /// Delete an NPC. | 91 | /// Delete an NPC. |
82 | /// </summary> | 92 | /// </summary> |
83 | /// <param name="agentID">The UUID of the NPC</param> | 93 | /// <param name="agentID">The UUID of the NPC</param> |
84 | /// <param name="scene"></param> | 94 | /// <param name="scene"></param> |
85 | void DeleteNPC(UUID agentID, Scene scene); | 95 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> |
96 | bool DeleteNPC(UUID agentID, Scene scene); | ||
86 | } | 97 | } |
87 | } \ No newline at end of file | 98 | } \ No newline at end of file |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 068eec8..87cb322 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -217,7 +217,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
217 | return npcAvatar.AgentId; | 217 | return npcAvatar.AgentId; |
218 | } | 218 | } |
219 | 219 | ||
220 | public void MoveToTarget(UUID agentID, Scene scene, Vector3 pos) | 220 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos) |
221 | { | 221 | { |
222 | lock (m_avatars) | 222 | lock (m_avatars) |
223 | { | 223 | { |
@@ -230,22 +230,49 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
230 | "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); | 230 | "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); |
231 | 231 | ||
232 | sp.MoveToTarget(pos); | 232 | sp.MoveToTarget(pos); |
233 | |||
234 | return true; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | return false; | ||
239 | } | ||
240 | |||
241 | public bool StopMoveToTarget(UUID agentID, Scene scene) | ||
242 | { | ||
243 | lock (m_avatars) | ||
244 | { | ||
245 | if (m_avatars.ContainsKey(agentID)) | ||
246 | { | ||
247 | ScenePresence sp; | ||
248 | scene.TryGetScenePresence(agentID, out sp); | ||
249 | |||
250 | sp.Velocity = Vector3.Zero; | ||
251 | sp.ResetMoveToTarget(); | ||
252 | |||
253 | return true; | ||
233 | } | 254 | } |
234 | } | 255 | } |
256 | |||
257 | return false; | ||
235 | } | 258 | } |
236 | 259 | ||
237 | public void Say(UUID agentID, Scene scene, string text) | 260 | public bool Say(UUID agentID, Scene scene, string text) |
238 | { | 261 | { |
239 | lock (m_avatars) | 262 | lock (m_avatars) |
240 | { | 263 | { |
241 | if (m_avatars.ContainsKey(agentID)) | 264 | if (m_avatars.ContainsKey(agentID)) |
242 | { | 265 | { |
243 | m_avatars[agentID].Say(text); | 266 | m_avatars[agentID].Say(text); |
267 | |||
268 | return true; | ||
244 | } | 269 | } |
245 | } | 270 | } |
271 | |||
272 | return false; | ||
246 | } | 273 | } |
247 | 274 | ||
248 | public void DeleteNPC(UUID agentID, Scene scene) | 275 | public bool DeleteNPC(UUID agentID, Scene scene) |
249 | { | 276 | { |
250 | lock (m_avatars) | 277 | lock (m_avatars) |
251 | { | 278 | { |
@@ -253,8 +280,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
253 | { | 280 | { |
254 | scene.RemoveClient(agentID); | 281 | scene.RemoveClient(agentID); |
255 | m_avatars.Remove(agentID); | 282 | m_avatars.Remove(agentID); |
283 | |||
284 | return true; | ||
256 | } | 285 | } |
257 | } | 286 | } |
287 | |||
288 | return false; | ||
258 | } | 289 | } |
259 | 290 | ||
260 | public void PostInitialise() | 291 | public void PostInitialise() |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index a05c623..9c32029 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2213,6 +2213,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2213 | } | 2213 | } |
2214 | } | 2214 | } |
2215 | 2215 | ||
2216 | public void osNpcStopMoveTo(LSL_Key npc) | ||
2217 | { | ||
2218 | CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); | ||
2219 | |||
2220 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2221 | if (module != null) | ||
2222 | module.StopMoveToTarget(new UUID(npc.m_string), World); | ||
2223 | } | ||
2224 | |||
2216 | public void osNpcSay(LSL_Key npc, string message) | 2225 | public void osNpcSay(LSL_Key npc, string message) |
2217 | { | 2226 | { |
2218 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); | 2227 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 92473ae..ab0097a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -173,6 +173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
173 | LSL_Key osNpcSaveAppearance(string avatar, string notecardName); | 173 | LSL_Key osNpcSaveAppearance(string avatar, string notecardName); |
174 | void osNpcLoadAppearance(string avatar, string notecardNameOrUuid); | 174 | void osNpcLoadAppearance(string avatar, string notecardNameOrUuid); |
175 | void osNpcMoveTo(key npc, vector position); | 175 | void osNpcMoveTo(key npc, vector position); |
176 | void osNpcStopMoveTo(LSL_Key npc); | ||
176 | void osNpcSay(key npc, string message); | 177 | void osNpcSay(key npc, string message); |
177 | void osNpcRemove(key npc); | 178 | void osNpcRemove(key npc); |
178 | 179 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 4b21c88..a7843dd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -498,6 +498,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
498 | m_OSSL_Functions.osNpcMoveTo(npc, position); | 498 | m_OSSL_Functions.osNpcMoveTo(npc, position); |
499 | } | 499 | } |
500 | 500 | ||
501 | public void osNpcStopMoveTo(LSL_Key npc) | ||
502 | { | ||
503 | m_OSSL_Functions.osNpcStopMoveTo(npc); | ||
504 | } | ||
505 | |||
501 | public void osNpcSay(key npc, string message) | 506 | public void osNpcSay(key npc, string message) |
502 | { | 507 | { |
503 | m_OSSL_Functions.osNpcSay(npc, message); | 508 | m_OSSL_Functions.osNpcSay(npc, message); |