From: <ma...@us...> - 2007-12-20 23:54:31
|
Revision: 483 http://planeshift.svn.sourceforge.net/planeshift/?rev=483&view=rev Author: magodra Date: 2007-12-20 15:54:36 -0800 (Thu, 20 Dec 2007) Log Message: ----------- - Fixed chase operation to work in npc's warp space. This fix problems with odd behaviours when pets follow you between sectors. Like ( BT#1323 ) - Added dump of warp space table to npc client as well. Modified Paths: -------------- trunk/docs/history.txt trunk/src/npcclient/command.cpp trunk/src/npcclient/npcbehave.cpp Modified: trunk/docs/history.txt =================================================================== --- trunk/docs/history.txt 2007-12-20 23:12:06 UTC (rev 482) +++ trunk/docs/history.txt 2007-12-20 23:54:36 UTC (rev 483) @@ -1,4 +1,7 @@ *** 2007-12-20 by Anders Reggestad +- Fixed chase operation to work in npc's warp space. This fix problems with + odd behaviours when pets follow you between sectors. Like ( BT#1323 ) +- Added dump of warp space table to npc client as well. - Added support to only react to perception when target behavior is active. Had inactive_only from before. Now with active_only to it is possible to control turning on and off behaviors without steady increasing/descresing the need Modified: trunk/src/npcclient/command.cpp =================================================================== --- trunk/src/npcclient/command.cpp 2007-12-20 23:12:06 UTC (rev 482) +++ trunk/src/npcclient/command.cpp 2007-12-20 23:54:36 UTC (rev 483) @@ -39,6 +39,7 @@ #include "util/serverconsole.h" #include "util/log.h" #include "util/location.h" +#include "engine/psworld.h" #include "globals.h" #include "npcclient.h" @@ -336,9 +337,15 @@ return 0; } +int com_dumpwarpspace(char *) +{ + npcclient->GetWorld()->DumpWarpCache(); + return 0; +} /* add all new commands here */ COMMAND commands[] = { + { "dumpwarpspace",true, com_dumpwarpspace,"Dump the warp space table"}, { "charlist", false, com_charlist, "List all known characters"}, { "debugnpc", false, com_debugnpc, "Switches the debug mode on 1 NPC"}, { "entlist", false, com_entlist, "List all known entities"}, Modified: trunk/src/npcclient/npcbehave.cpp =================================================================== --- trunk/src/npcclient/npcbehave.cpp 2007-12-20 23:12:06 UTC (rev 482) +++ trunk/src/npcclient/npcbehave.cpp 2007-12-20 23:54:36 UTC (rev 483) @@ -2729,9 +2729,8 @@ psGameObject::GetPosition(target_entity,targetPos,dummyrot,targetSector); - // We now work in the target sector's space - csVector3 myOldPos(myPos); - npcclient->GetWorld()->WarpSpace(mySector, targetSector, myPos); + // We work in our sector's space + npcclient->GetWorld()->WarpSpace(targetSector, mySector, targetPos); // This prevents NPCs from wanting to occupy the same physical space as something else csVector3 displacement = targetPos - myPos; @@ -2750,9 +2749,8 @@ { npc->Printf("turn to target..\n"); path.SetDest(targetPos); - // path.CalcLocalDest(myPos, mySector, localDest); - path.CalcLocalDest(myPos, targetSector, localDest); - StartMoveTo(npc,eventmgr,localDest, targetSector, GetVelocity(npc),action, false); + path.CalcLocalDest(myPos, mySector, localDest); + StartMoveTo(npc,eventmgr,localDest, mySector, GetVelocity(npc),action, false); } @@ -2772,12 +2770,12 @@ { npc->Printf("We are at localDest..\n"); path.SetDest(targetPos); - path.CalcLocalDest(myPos, targetSector, localDest); - StartMoveTo(npc,eventmgr,localDest, targetSector,vel,action, false); + path.CalcLocalDest(myPos, mySector, localDest); + StartMoveTo(npc,eventmgr,localDest, mySector,vel,action, false); } } else - TurnTo(npc,localDest, targetSector,forward); + TurnTo(npc,localDest, mySector,forward); npc->Printf("advance: pos=(%f.2,%f.2,%f.2) rot=%.2f localDest=(%f.2,%f.2,%f.2) dist=%f\n", @@ -2798,15 +2796,10 @@ npc->Printf(5,"World position bodyVel=%s worldVel=%s",toString(bodyVel).GetDataSafe(),toString(worldVel).GetDataSafe()); - // if((fabs(myPos.x)> 1000 || fabs(myNewPos.x)> 1000) || (fabs(myPos.y)>1000 || fabs(myNewPos.y)>1000) || (fabs(myPos.z)>1000 || fabs(myNewPos.z)>1000)) - // { - // npc->Printf("Moved from %f %f %f to %f %f %f, timedelta is %f, chase error!\n", myPos.x,myPos.y,myPos.z, myNewPos.x,myNewPos.y,myNewPos.z, timedelta); - // } - // TODO: Use CheckMovedOk() istead ???? // This check must be done in our original sector's space - if ((myOldPos - myNewPos).SquaredNorm() < SMALL_EPSILON) // then stopped dead, presumably by collision + if ((myPos - myNewPos).SquaredNorm() < SMALL_EPSILON) // then stopped dead, presumably by collision { Perception collision("collision"); npc->TriggerEvent(&collision, eventmgr); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |