early code to allow scripts to force npcs not to fly when moving to target

this is to allow walking on prims.  it will be up to the script writer to be sure that there is a continuous path.
currently implemented in osNpcMoveToTarget(), but none of this is final.
bulletsim
Justin Clark-Casey (justincc) 2011-08-10 01:47:37 +01:00
parent 4cb8d6379d
commit 5d6c9644fa
15 changed files with 45 additions and 18 deletions

View File

@ -169,7 +169,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
float y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]); float y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]);
float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]); float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]);
Vector3 vector = new Vector3(x, y, z); Vector3 vector = new Vector3(x, y, z);
presence.MoveToTarget(vector); presence.MoveToTarget(vector, false);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -935,7 +935,7 @@ namespace OpenSim.Framework
event ScriptReset OnScriptReset; event ScriptReset OnScriptReset;
event GetScriptRunning OnGetScriptRunning; event GetScriptRunning OnGetScriptRunning;
event SetScriptRunning OnSetScriptRunning; event SetScriptRunning OnSetScriptRunning;
event Action<Vector3> OnAutoPilotGo; event Action<Vector3, bool> OnAutoPilotGo;
event TerrainUnacked OnUnackedTerrain; event TerrainUnacked OnUnackedTerrain;
event ActivateGesture OnActivateGesture; event ActivateGesture OnActivateGesture;

View File

@ -231,7 +231,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event ScriptReset OnScriptReset; public event ScriptReset OnScriptReset;
public event GetScriptRunning OnGetScriptRunning; public event GetScriptRunning OnGetScriptRunning;
public event SetScriptRunning OnSetScriptRunning; public event SetScriptRunning OnSetScriptRunning;
public event Action<Vector3> OnAutoPilotGo; public event Action<Vector3, bool> OnAutoPilotGo;
public event TerrainUnacked OnUnackedTerrain; public event TerrainUnacked OnUnackedTerrain;
public event ActivateGesture OnActivateGesture; public event ActivateGesture OnActivateGesture;
public event DeactivateGesture OnDeactivateGesture; public event DeactivateGesture OnDeactivateGesture;
@ -11628,9 +11628,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
locy = Convert.ToSingle(args[1]) - (float)regionY; locy = Convert.ToSingle(args[1]) - (float)regionY;
locz = Convert.ToSingle(args[2]); locz = Convert.ToSingle(args[2]);
Action<Vector3> handlerAutoPilotGo = OnAutoPilotGo; Action<Vector3, bool> handlerAutoPilotGo = OnAutoPilotGo;
if (handlerAutoPilotGo != null) if (handlerAutoPilotGo != null)
handlerAutoPilotGo(new Vector3(locx, locy, locz)); handlerAutoPilotGo(new Vector3(locx, locy, locz), false);
} }
/// <summary> /// <summary>

View File

@ -222,7 +222,7 @@ namespace OpenSim.Region.Examples.SimpleModule
public event ScriptReset OnScriptReset; public event ScriptReset OnScriptReset;
public event GetScriptRunning OnGetScriptRunning; public event GetScriptRunning OnGetScriptRunning;
public event SetScriptRunning OnSetScriptRunning; public event SetScriptRunning OnSetScriptRunning;
public event Action<Vector3> OnAutoPilotGo; public event Action<Vector3, bool> OnAutoPilotGo;
public event TerrainUnacked OnUnackedTerrain; public event TerrainUnacked OnUnackedTerrain;

View File

@ -67,8 +67,12 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="agentID">The UUID of the NPC</param> /// <param name="agentID">The UUID of the NPC</param>
/// <param name="scene"></param> /// <param name="scene"></param>
/// <param name="pos"></param> /// <param name="pos"></param>
/// <param name="noFly">
/// If true, then the avatar will attempt to walk to the location even if it's up in the air.
/// This is to allow walking on prims.
/// </param>
/// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos); bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly);
/// <summary> /// <summary>
/// Stop the NPC's current movement. /// Stop the NPC's current movement.

View File

@ -1650,7 +1650,7 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
if (avatar != null) if (avatar != null)
{ {
avatar.MoveToTarget(target); avatar.MoveToTarget(target, false);
} }
} }
else else

View File

@ -1684,7 +1684,12 @@ namespace OpenSim.Region.Framework.Scenes
/// Move to the given target over time. /// Move to the given target over time.
/// </summary> /// </summary>
/// <param name="pos"></param> /// <param name="pos"></param>
public void MoveToTarget(Vector3 pos) /// <param name="noFly">
/// If true, then don't allow the avatar to fly to the target, even if it's up in the air.
/// This is to allow movement to targets that are known to be on an elevated platform with a continuous path
/// from start to finish.
/// </param>
public void MoveToTarget(Vector3 pos, bool noFly)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", // "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}",
@ -1718,7 +1723,7 @@ namespace OpenSim.Region.Framework.Scenes
"[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}",
Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
if (pos.Z > terrainHeight) if (!noFly && pos.Z > terrainHeight)
PhysicsActor.Flying = true; PhysicsActor.Flying = true;
MovingToTarget = true; MovingToTarget = true;

View File

@ -806,7 +806,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public event ScriptReset OnScriptReset; public event ScriptReset OnScriptReset;
public event GetScriptRunning OnGetScriptRunning; public event GetScriptRunning OnGetScriptRunning;
public event SetScriptRunning OnSetScriptRunning; public event SetScriptRunning OnSetScriptRunning;
public event Action<Vector3> OnAutoPilotGo; public event Action<Vector3, bool> OnAutoPilotGo;
public event TerrainUnacked OnUnackedTerrain; public event TerrainUnacked OnUnackedTerrain;
public event ActivateGesture OnActivateGesture; public event ActivateGesture OnActivateGesture;
public event DeactivateGesture OnDeactivateGesture; public event DeactivateGesture OnDeactivateGesture;

View File

@ -328,7 +328,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public event ScriptReset OnScriptReset; public event ScriptReset OnScriptReset;
public event GetScriptRunning OnGetScriptRunning; public event GetScriptRunning OnGetScriptRunning;
public event SetScriptRunning OnSetScriptRunning; public event SetScriptRunning OnSetScriptRunning;
public event Action<Vector3> OnAutoPilotGo; public event Action<Vector3, bool> OnAutoPilotGo;
public event TerrainUnacked OnUnackedTerrain; public event TerrainUnacked OnUnackedTerrain;

View File

@ -217,7 +217,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return npcAvatar.AgentId; return npcAvatar.AgentId;
} }
public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos) public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly)
{ {
lock (m_avatars) lock (m_avatars)
{ {
@ -229,7 +229,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
m_log.DebugFormat( m_log.DebugFormat(
"[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName);
sp.MoveToTarget(pos); sp.MoveToTarget(pos, noFly);
return true; return true;
} }

View File

@ -113,7 +113,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
Vector3 targetPos = startPos + new Vector3(0, 0, 10); Vector3 targetPos = startPos + new Vector3(0, 0, 10);
npcModule.MoveToTarget(npc.UUID, scene, targetPos); npcModule.MoveToTarget(npc.UUID, scene, targetPos, false);
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
@ -135,7 +135,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
// Try a second movement // Try a second movement
startPos = npc.AbsolutePosition; startPos = npc.AbsolutePosition;
targetPos = startPos + new Vector3(10, 0, 0); targetPos = startPos + new Vector3(10, 0, 0);
npcModule.MoveToTarget(npc.UUID, scene, targetPos); npcModule.MoveToTarget(npc.UUID, scene, targetPos, false);
scene.Update(); scene.Update();

View File

@ -2209,7 +2209,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (module != null) if (module != null)
{ {
Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
module.MoveToTarget(new UUID(npc.m_string), World, pos); module.MoveToTarget(new UUID(npc.m_string), World, pos, false);
}
}
public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int noFly)
{
CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget");
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
module.MoveToTarget(new UUID(npc.m_string), World, pos, noFly != 0);
} }
} }

View File

@ -173,6 +173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_Key osNpcSaveAppearance(string avatar, string notecardName); LSL_Key osNpcSaveAppearance(string avatar, string notecardName);
void osNpcLoadAppearance(string avatar, string notecardNameOrUuid); void osNpcLoadAppearance(string avatar, string notecardNameOrUuid);
void osNpcMoveTo(key npc, vector position); void osNpcMoveTo(key npc, vector position);
void osNpcMoveToTarget(key npc, vector position, int noFly);
void osNpcStopMoveTo(LSL_Key npc); void osNpcStopMoveTo(LSL_Key npc);
void osNpcSay(key npc, string message); void osNpcSay(key npc, string message);
void osNpcRemove(key npc); void osNpcRemove(key npc);

View File

@ -498,6 +498,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osNpcMoveTo(npc, position); m_OSSL_Functions.osNpcMoveTo(npc, position);
} }
public void osNpcMoveToTarget(key npc, vector position, int noFly)
{
m_OSSL_Functions.osNpcMoveToTarget(npc, position, noFly);
}
public void osNpcStopMoveTo(LSL_Key npc) public void osNpcStopMoveTo(LSL_Key npc)
{ {
m_OSSL_Functions.osNpcStopMoveTo(npc); m_OSSL_Functions.osNpcStopMoveTo(npc);

View File

@ -234,7 +234,7 @@ namespace OpenSim.Tests.Common.Mock
public event ScriptReset OnScriptReset; public event ScriptReset OnScriptReset;
public event GetScriptRunning OnGetScriptRunning; public event GetScriptRunning OnGetScriptRunning;
public event SetScriptRunning OnSetScriptRunning; public event SetScriptRunning OnSetScriptRunning;
public event Action<Vector3> OnAutoPilotGo; public event Action<Vector3, bool> OnAutoPilotGo;
public event TerrainUnacked OnUnackedTerrain; public event TerrainUnacked OnUnackedTerrain;