aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorTalun2012-07-03 11:10:09 +0100
committerJustin Clark-Casey (justincc)2012-07-06 22:37:19 +0100
commit1b1f841c6aaf2453b3aca0eade84855ae658e655 (patch)
tree895b5f5bec7f0ae737e74017809e8762c05518b2 /OpenSim/Region
parentPull prim crossing/teleport checks up into Scene.IncomingCreateObject() from ... (diff)
downloadopensim-SC-1b1f841c6aaf2453b3aca0eade84855ae658e655.zip
opensim-SC-1b1f841c6aaf2453b3aca0eade84855ae658e655.tar.gz
opensim-SC-1b1f841c6aaf2453b3aca0eade84855ae658e655.tar.bz2
opensim-SC-1b1f841c6aaf2453b3aca0eade84855ae658e655.tar.xz
Mantis 6063 osNpcTouch.
Allow NPCS to touch obects.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Interfaces/INPCModule.cs8
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs39
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs35
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs5
6 files changed, 98 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
index 860483d..d582149 100644
--- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
@@ -184,6 +184,14 @@ namespace OpenSim.Region.Framework.Interfaces
184 bool Stand(UUID agentID, Scene scene); 184 bool Stand(UUID agentID, Scene scene);
185 185
186 /// <summary> 186 /// <summary>
187 /// Get the NPC to touch an object.
188 /// </summary>
189 /// <param name="agentID"></param>
190 /// <param name="partID"></param>
191 /// <returns>true if the touch is actually attempted, false if not</returns>
192 bool Touch(UUID agentID, UUID partID);
193
194 /// <summary>
187 /// Delete an NPC. 195 /// Delete an NPC.
188 /// </summary> 196 /// </summary>
189 /// <param name="agentID">The UUID of the NPC</param> 197 /// <param name="agentID">The UUID of the NPC</param>
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index b3e1069..43a09ec 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -104,6 +104,45 @@ namespace OpenSim.Region.OptionalModules.World.NPC
104 OnMoneyTransferRequest(m_uuid, target, amount, 1, "Payment"); 104 OnMoneyTransferRequest(m_uuid, target, amount, 1, "Payment");
105 } 105 }
106 106
107 public bool Touch(UUID target)
108 {
109 SceneObjectPart part = m_scene.GetSceneObjectPart(target);
110 if (part == null)
111 return false;
112 bool objectTouchable = hasTouchEvents(part); // Only touch an object that is scripted to respond
113 if (!objectTouchable && !part.IsRoot)
114 objectTouchable = hasTouchEvents(part.ParentGroup.RootPart);
115 if (!objectTouchable)
116 return false;
117 // Set up the surface args as if the touch is from a client that does not support this
118 SurfaceTouchEventArgs surfaceArgs = new SurfaceTouchEventArgs();
119 surfaceArgs.FaceIndex = -1; // TOUCH_INVALID_FACE
120 surfaceArgs.Binormal = Vector3.Zero; // TOUCH_INVALID_VECTOR
121 surfaceArgs.Normal = Vector3.Zero; // TOUCH_INVALID_VECTOR
122 surfaceArgs.STCoord = new Vector3(-1.0f, -1.0f, 0.0f); // TOUCH_INVALID_TEXCOORD
123 surfaceArgs.UVCoord = surfaceArgs.STCoord; // TOUCH_INVALID_TEXCOORD
124 List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
125 touchArgs.Add(surfaceArgs);
126 Vector3 offset = part.OffsetPosition * -1.0f;
127 if (OnGrabObject == null)
128 return false;
129 OnGrabObject(part.LocalId, offset, this, touchArgs);
130 if (OnGrabUpdate != null)
131 OnGrabUpdate(part.UUID, offset, part.ParentGroup.RootPart.GroupPosition, this, touchArgs);
132 if (OnDeGrabObject != null)
133 OnDeGrabObject(part.LocalId, this, touchArgs);
134 return true;
135 }
136
137 private bool hasTouchEvents(SceneObjectPart part)
138 {
139 if ((part.ScriptEvents & scriptEvents.touch) != 0 ||
140 (part.ScriptEvents & scriptEvents.touch_start) != 0 ||
141 (part.ScriptEvents & scriptEvents.touch_end) != 0)
142 return true;
143 return false;
144 }
145
107 public void InstantMessage(UUID target, string message) 146 public void InstantMessage(UUID target, string message)
108 { 147 {
109 OnInstantMessage(this, new GridInstantMessage(m_scene, 148 OnInstantMessage(this, new GridInstantMessage(m_scene,
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index d3456ab..1e85fb4 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -305,6 +305,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC
305 return false; 305 return false;
306 } 306 }
307 307
308 public bool Touch(UUID agentID, UUID objectID)
309 {
310 lock (m_avatars)
311 {
312 if (m_avatars.ContainsKey(agentID))
313 return m_avatars[agentID].Touch(objectID);
314 return false;
315 }
316 }
317
308 public UUID GetOwner(UUID agentID) 318 public UUID GetOwner(UUID agentID)
309 { 319 {
310 lock (m_avatars) 320 lock (m_avatars)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 7385dd9..61394af 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2677,6 +2677,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2677 } 2677 }
2678 } 2678 }
2679 2679
2680 public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num)
2681 {
2682 CheckThreatLevel(ThreatLevel.High, "osNpcTouch");
2683 m_host.AddScriptLPS(1);
2684 INPCModule module = World.RequestModuleInterface<INPCModule>();
2685 int linkNum = link_num.value;
2686 if (module != null || (linkNum < 0 && linkNum != ScriptBaseClass.LINK_THIS))
2687 {
2688 UUID npcId;
2689 if (!UUID.TryParse(npcLSL_Key, out npcId) || !module.CheckPermissions(npcId, m_host.OwnerID))
2690 return;
2691 SceneObjectPart part = null;
2692 UUID objectId;
2693 if (UUID.TryParse(LSL_String.ToString(object_key), out objectId))
2694 part = World.GetSceneObjectPart(objectId);
2695 if (part == null)
2696 return;
2697 if (linkNum != ScriptBaseClass.LINK_THIS)
2698 {
2699 if (linkNum == 0 || linkNum == ScriptBaseClass.LINK_ROOT)
2700 { // 0 and 1 are treated as root, find the root if the current part isnt it
2701 if (!part.IsRoot)
2702 part = part.ParentGroup.RootPart;
2703 }
2704 else
2705 { // Find the prim with the given link number if not found then fail silently
2706 part = part.ParentGroup.GetLinkNumPart(linkNum);
2707 if (part == null)
2708 return;
2709 }
2710 }
2711 module.Touch(npcId, part.UUID);
2712 }
2713 }
2714
2680 /// <summary> 2715 /// <summary>
2681 /// Save the current appearance of the script owner permanently to the named notecard. 2716 /// Save the current appearance of the script owner permanently to the named notecard.
2682 /// </summary> 2717 /// </summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index a8335aa..d38709e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -231,6 +231,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
231 void osNpcRemove(key npc); 231 void osNpcRemove(key npc);
232 void osNpcPlayAnimation(LSL_Key npc, string animation); 232 void osNpcPlayAnimation(LSL_Key npc, string animation);
233 void osNpcStopAnimation(LSL_Key npc, string animation); 233 void osNpcStopAnimation(LSL_Key npc, string animation);
234 void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num);
234 void osNpcWhisper(key npc, int channel, string message); 235 void osNpcWhisper(key npc, int channel, string message);
235 236
236 LSL_Key osOwnerSaveAppearance(string notecard); 237 LSL_Key osOwnerSaveAppearance(string notecard);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 500ed96..692bb0a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -626,6 +626,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
626 m_OSSL_Functions.osNpcWhisper(npc, channel, message); 626 m_OSSL_Functions.osNpcWhisper(npc, channel, message);
627 } 627 }
628 628
629 public void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num)
630 {
631 m_OSSL_Functions.osNpcTouch(npcLSL_Key, object_key, link_num);
632 }
633
629 public LSL_Key osOwnerSaveAppearance(string notecard) 634 public LSL_Key osOwnerSaveAppearance(string notecard)
630 { 635 {
631 return m_OSSL_Functions.osOwnerSaveAppearance(notecard); 636 return m_OSSL_Functions.osOwnerSaveAppearance(notecard);