From: <ma...@us...> - 2007-12-18 10:33:27
|
Revision: 471 http://planeshift.svn.sourceforge.net/planeshift/?rev=471&view=rev Author: magodra Date: 2007-12-18 02:33:30 -0800 (Tue, 18 Dec 2007) Log Message: ----------- - Added loading of disabled flag from npc definitions. Modified Paths: -------------- trunk/data/npcbehave.xml trunk/docs/history.txt trunk/src/client/pscelclient.h trunk/src/npcclient/npc.cpp trunk/src/npcclient/npc.h trunk/src/npcclient/npcbehave.cpp trunk/src/npcclient/npcclient.cpp trunk/src/server/adminmanager.cpp trunk/src/server/database/mysql/sc_npc_definitions.sql trunk/src/server/database/mysql/server_options.sql trunk/src/server/database/mysql/upgrade_schema.sql trunk/src/server/psserver.cpp Modified: trunk/data/npcbehave.xml =================================================================== --- trunk/data/npcbehave.xml 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/data/npcbehave.xml 2007-12-18 10:33:30 UTC (rev 471) @@ -142,8 +142,9 @@ <behavior name="do nothing" decay="0" growth="0" initial="50"> <wait duration="1" anim="stand" /> </behavior> - <behavior name="turn" completion_decay="100" growth="0" initial="0"> - <rotate type="random" min="90" max="270" anim="walk" ang_vel="30" /> + <behavior name="turn" completion_decay="-1" growth="0" initial="0"> + <rotate type="random" min="90" max="270" anim="walk" ang_vel="30" /> + <move vel="2" anim="walk" duration="1.0"/> </behavior> <behavior name="fight" decay="0" growth="0" initial="0"> <locate obj="target" range="50"/> @@ -153,8 +154,8 @@ <behavior name="chase" completion_decay="100" growth="0" initial="0"> <chase type="target" anim="run" vel="5" /> </behavior> - <react event="collision" behavior="turn" delta="100" /> - <react event="out of bounds" behavior="turn" delta="100" /> + <react event="collision" behavior="turn" delta="0" /> + <react event="out of bounds" behavior="turn" delta="0" /> <react event="attack" behavior="fight" delta="0" /> <react event="damage" behavior="fight" delta="20" weight="1" /> <react event="target out of range" behavior="chase" delta="0" /> @@ -164,7 +165,7 @@ <npctype name="On Sight Fighter" parent="Fighter"> <!-- Test use of parent to expand the parent behavior --> - <behavior name="turn to face" completion_decay="100" growth="0" initial="0"> + <behavior name="turn to face" completion_decay="-1" growth="0" initial="0"> <locate obj="perception" /> <rotate type="locatedest" anim="walk" ang_vel="120" /> </behavior> Modified: trunk/docs/history.txt =================================================================== --- trunk/docs/history.txt 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/docs/history.txt 2007-12-18 10:33:30 UTC (rev 471) @@ -1,4 +1,5 @@ *** 2007-12-18 by Anders Reggestad +- Added loading of diabled npc flag from npc definitions. - Added display of db sector id in server command sectors. - Update help text on message filtering. - Compiler warning fixes. Modified: trunk/src/client/pscelclient.h =================================================================== --- trunk/src/client/pscelclient.h 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/src/client/pscelclient.h 2007-12-18 10:33:30 UTC (rev 471) @@ -119,8 +119,6 @@ void RemoveObject(GEMClientObject* entity); - void SendPersist(); - psClientDR* GetClientDR() { return clientdr; } const csPDelArray<GEMClientObject>& GetEntities () const { return entities; } bool IsMeshSubjectToAction(const char* sector,const char* mesh); Modified: trunk/src/npcclient/npc.cpp =================================================================== --- trunk/src/npcclient/npc.cpp 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/src/npcclient/npc.cpp 2007-12-18 10:33:30 UTC (rev 471) @@ -43,8 +43,10 @@ #include "gem.h" #include "util/psdatabase.h" #include "util/location.h" +#include "util/strutil.h" #include "engine/psworld.h" #include "networkmgr.h" +#include "util/waypoint.h" extern iDataConnection *db; @@ -129,6 +131,16 @@ owner_id = row.GetInt("char_id_owner"); + const char *e = row["disabled"]; + if (e && (*e=='Y' || *e=='y')) + { + disabled = true; + } + else + { + disabled = false; + } + brain = new NPCType(*t); // deep copy constructor return true; // success @@ -318,6 +330,24 @@ npcclient->GetNetworkMgr()->QueueImperviousCommand(GetEntity(),true); } +void NPC::DumpState() +{ + CPrintf(CON_CMDOUTPUT, "States for %s (PID: %u)\n",name.GetData(),pid); + CPrintf(CON_CMDOUTPUT, "---------------------------------------------\n"); + CPrintf(CON_CMDOUTPUT, "DR Counter: %d\n",DRcounter); + CPrintf(CON_CMDOUTPUT, "Debugging: %d\n",debugging); + CPrintf(CON_CMDOUTPUT, "Alive: %s\n",alive?"True":"False"); + CPrintf(CON_CMDOUTPUT, "Disabled: %s\n",disabled?"True":"False"); + CPrintf(CON_CMDOUTPUT, "Checked: %s\n",checked?"True":"False"); + CPrintf(CON_CMDOUTPUT, "Active locate: %s\n",toString(active_locate_pos,active_locate_sector).GetDataSafe()); + CPrintf(CON_CMDOUTPUT, "Active locate WP: %s\n",active_locate_wp?active_locate_wp->GetName():""); + CPrintf(CON_CMDOUTPUT, "Ang vel: %.2f\n",ang_vel); + CPrintf(CON_CMDOUTPUT, "Vel: %.2f\n",vel); + CPrintf(CON_CMDOUTPUT, "Walk velocity: %.2f\n",walkVelocity); + CPrintf(CON_CMDOUTPUT, "Run velocity: %.2f\n",runVelocity); +} + + void NPC::DumpBehaviorList() { CPrintf(CON_CMDOUTPUT, "Behaviors for %s (PID: %u)\n",name.GetData(),pid); Modified: trunk/src/npcclient/npc.h =================================================================== --- trunk/src/npcclient/npc.h 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/src/npcclient/npc.h 2007-12-18 10:33:30 UTC (rev 471) @@ -129,7 +129,8 @@ Behavior *GetCurrentBehavior() { return brain->GetCurrentBehavior(); } NPCType *GetBrain() { return brain; } - + + void DumpState(); void DumpBehaviorList(); void DumpHateList(); Modified: trunk/src/npcclient/npcbehave.cpp =================================================================== --- trunk/src/npcclient/npcbehave.cpp 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/src/npcclient/npcbehave.cpp 2007-12-18 10:33:30 UTC (rev 471) @@ -398,6 +398,8 @@ void BehaviorSet::DumpBehaviorList(NPC *npc) { + CPrintf(CON_CMDOUTPUT, "Appl. %-30s %5s %5s\n","Behavior","Curr","New"); + for (size_t i=0; i<behaviors.GetSize(); i++) { char applicable = 'N'; @@ -406,7 +408,7 @@ applicable = 'Y'; } - CPrintf(CON_CMDOUTPUT, "%c %s%-30s %5.1f %5.1f\n",applicable, + CPrintf(CON_CMDOUTPUT, "%c %s%-30s %5.1f %5.1f\n",applicable, (behaviors[i]->IsInterrupted()?"*":" "), behaviors[i]->GetName(),behaviors[i]->CurrentNeed(), behaviors[i]->NewNeed()); @@ -885,7 +887,7 @@ return AtInterruptedAngle(pos,sector,angle); } -bool ScriptOperation::CheckMovedOk(NPC *npc,EventManager *eventmgr, const csVector3 & oldPos, const csVector3 & newPos, iSector* newSector, float timedelta) +bool ScriptOperation::CheckMovedOk(NPC *npc, EventManager *eventmgr, const csVector3 & oldPos, const csVector3 & newPos, iSector* newSector, float timedelta) { csRef<iPcMesh> pcmesh = CEL_QUERY_PROPCLASS(npc->GetEntity()->GetPropertyClassList(), iPcMesh); @@ -3113,12 +3115,22 @@ ScopedTimer st(250, "chase extrapolate %.2f time for EID: %u",timedelta,npc->GetEntity()->GetID()); npc->GetLinMove()->ExtrapolatePosition(timedelta); } - npc->GetLinMove()->GetLastPosition(myNewPos,myRot,mySector); - 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); - } + // npc->GetLinMove()->GetLastPosition(myNewPos,myRot,mySector); + bool on_ground; + float speed,ang_vel; + csVector3 bodyVel,worldVel; + npc->GetLinMove()->GetDRData(on_ground,speed,myNewPos,myRot,mySector,bodyVel,worldVel,ang_vel); + + 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 { @@ -3126,6 +3138,14 @@ npc->TriggerEvent(&collision, eventmgr); npc->Printf("Collided! Moving from %f %f %f to %f %f %f, timedelta is %f!\n", myPos.x,myPos.y,myPos.z, myNewPos.x,myNewPos.y,myNewPos.z, timedelta); } + + // Check if the slope is to steep + if ( (-worldVel.y)*2 > GetVelocity(npc)) // then stopped dead, presumably by collision + { + Perception collision("collision"); + npc->TriggerEvent(&collision, eventmgr); + npc->Printf("Collided! Moving from %f %f %f to %f %f %f, timedelta is %f!\n", myPos.x,myPos.y,myPos.z, myNewPos.x,myNewPos.y,myNewPos.z, timedelta); + } } void ChaseOperation::InterruptOperation(NPC *npc,EventManager *eventmgr) Modified: trunk/src/npcclient/npcclient.cpp =================================================================== --- trunk/src/npcclient/npcclient.cpp 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/src/npcclient/npcclient.cpp 2007-12-18 10:33:30 UTC (rev 471) @@ -1142,9 +1142,14 @@ void psNPCClient::DumpNPC(NPC * npc) { + npc->DumpState(); + CPrintf(CON_CMDOUTPUT,"\n"); + npc->DumpBehaviorList(); + CPrintf(CON_CMDOUTPUT,"\n"); npc->DumpHateList(); + CPrintf(CON_CMDOUTPUT,"\n"); } bool psNPCClient::DumpRace(const char *pattern) Modified: trunk/src/server/adminmanager.cpp =================================================================== --- trunk/src/server/adminmanager.cpp 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/src/server/adminmanager.cpp 2007-12-18 10:33:30 UTC (rev 471) @@ -2042,6 +2042,11 @@ }; psSectorInfo * si = CacheManager::GetSingleton().GetSectorInfoByName(sectorName); + if (!si) + { + Error2("No sector info for %s",sectorName.GetDataSafe()); + return -1; + } psStringArray values; values.FormatPush("%s", name.GetDataSafe()); @@ -2417,7 +2422,7 @@ msg.SendMessage(); } client->WaypointSetIsDisplaying(true); - psserver->SendSystemInfo(me->clientnum, "Displaying all WP in sector"); + psserver->SendSystemInfo(me->clientnum, "Displaying all WPs in sector %s",sectorName.GetDataSafe()); } else if (data.subCmd == "hide") { @@ -2441,6 +2446,11 @@ }; psSectorInfo * si = CacheManager::GetSingleton().GetSectorInfoByName(sectorName); + if (!si) + { + Error2("No sector info for %s",sectorName.GetDataSafe()); + return -1; + } psStringArray values; values.FormatPush("%u", pathID ); @@ -2579,7 +2589,7 @@ } client->PathSetIsDisplaying(true); - psserver->SendSystemInfo(me->clientnum, "Displaying all Path Points in sector"); + psserver->SendSystemInfo(me->clientnum, "Displaying all Path Points in sector %s",sectorName.GetDataSafe()); } else if (data.subCmd == "hide") { Modified: trunk/src/server/database/mysql/sc_npc_definitions.sql =================================================================== --- trunk/src/server/database/mysql/sc_npc_definitions.sql 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/src/server/database/mysql/sc_npc_definitions.sql 2007-12-18 10:33:30 UTC (rev 471) @@ -16,6 +16,7 @@ ang_vel_override float(10,2) DEFAULT '0.00' , char_id_owner int(10) unsigned DEFAULT '0' , console_debug char(1) DEFAULT '0' , + disabled char(1) DEFAULT 'N' , PRIMARY KEY (char_id) ); @@ -24,26 +25,26 @@ # Dumping data for table 'sc_npc_definitions' # -INSERT INTO sc_npc_definitions VALUES("4","MaleEnki","Wanderer","wander region","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("5","Smith","smith","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("6","Fighter1","Fighter","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("7","Fighter2","On Sight Fighter","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("8","Merchant","Wanderer","wander region","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("14","DictMaster1","Answerer","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("15","DictMaster2","Answerer","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("20","TribeMember","Tribe","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("21","MoveMaster1","MoveTest1","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("22","MoveMaster2","MoveTest2","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("23","MoveMaster3","MoveTest3","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("24","MoveMaster4","MoveTest4","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("25","Fighter3","Fighter","NPC Room Fighter region 1","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("26","Fighter4","On Sight Fighter","NPC Room Fighter region 1","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("27","MoveMaster5A","MoveTest5","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("28","MoveMaster5B","MoveTest5","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("29","MoveMaster5C","MoveTest5","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("30","WinchBeast1","WinchBeast","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("40","WinchMover1","WinchMover","","0.00","0.00","0","N"); -INSERT INTO sc_npc_definitions VALUES("50","FAMILIAR:Rogue","Minion","","0.00","0.00","0","Y"); -INSERT INTO sc_npc_definitions VALUES("51","FAMILIAR:Clacker","Minion","","0.00","0.00","0","Y"); -INSERT INTO sc_npc_definitions VALUES("52","FAMILIAR:Rat","Minion","","0.00","0.00","0","Y"); +INSERT INTO sc_npc_definitions VALUES("4","MaleEnki","Wanderer","wander region","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("5","Smith","smith","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("6","Fighter1","Fighter","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("7","Fighter2","On Sight Fighter","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("8","Merchant","Wanderer","wander region","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("14","DictMaster1","Answerer","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("15","DictMaster2","Answerer","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("20","TribeMember","Tribe","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("21","MoveMaster1","MoveTest1","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("22","MoveMaster2","MoveTest2","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("23","MoveMaster3","MoveTest3","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("24","MoveMaster4","MoveTest4","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("25","Fighter3","Fighter","NPC Room Fighter region 1","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("26","Fighter4","On Sight Fighter","NPC Room Fighter region 1","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("27","MoveMaster5A","MoveTest5","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("28","MoveMaster5B","MoveTest5","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("29","MoveMaster5C","MoveTest5","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("30","WinchBeast1","WinchBeast","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("40","WinchMover1","WinchMover","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("50","FAMILIAR:Rogue","Minion","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("51","FAMILIAR:Clacker","Minion","","0.00","0.00","0","N","N"); +INSERT INTO sc_npc_definitions VALUES("52","FAMILIAR:Rat","Minion","","0.00","0.00","0","N","N"); Modified: trunk/src/server/database/mysql/server_options.sql =================================================================== --- trunk/src/server/database/mysql/server_options.sql 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/src/server/database/mysql/server_options.sql 2007-12-18 10:33:30 UTC (rev 471) @@ -28,7 +28,7 @@ # Dumping data for table server_options # -INSERT INTO `server_options` VALUES ('db_version','1170'); +INSERT INTO `server_options` VALUES ('db_version','1171'); INSERT INTO `server_options` VALUES ('standard_motd','This is the message of the day from server_options table.'); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; Modified: trunk/src/server/database/mysql/upgrade_schema.sql =================================================================== --- trunk/src/server/database/mysql/upgrade_schema.sql 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/src/server/database/mysql/upgrade_schema.sql 2007-12-18 10:33:30 UTC (rev 471) @@ -825,6 +825,9 @@ PRIMARY KEY (`accountid`, `warningGM`, `timeOfWarn`) ); +#### 1171 - Anders Reggestad - Added disabled flag for NPCs, default to No. +ALTER TABLE `sc_npc_definitions` ADD COLUMN disabled char(1) DEFAULT 'N'; +UPDATE `server_options` SET `option_value`='1171' WHERE `option_name`='db_version'; # # Insert your upgrade before this line. Remember when you set a new db_version Modified: trunk/src/server/psserver.cpp =================================================================== --- trunk/src/server/psserver.cpp 2007-12-18 09:53:48 UTC (rev 470) +++ trunk/src/server/psserver.cpp 2007-12-18 10:33:30 UTC (rev 471) @@ -92,7 +92,7 @@ #include "introductionmanager.h" // Remember to bump this in server_options.sql and add to upgrade_schema.sql! -#define DATABASE_VERSION_STR "1170" +#define DATABASE_VERSION_STR "1171" psCharacterLoader psServer::CharacterLoader; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |