From: <ma...@us...> - 2010-05-21 21:34:37
|
Revision: 5931 http://planeshift.svn.sourceforge.net/planeshift/?rev=5931&view=rev Author: magodra Date: 2010-05-21 21:34:30 +0000 (Fri, 21 May 2010) Log Message: ----------- - Added support to percept NPCs when teleported. This will enable server to handle situations like described in PS#756. The Smith will not Go back to home when teleported away. Since smith is the only NPC that have teleport perceptions other NPCs under control of the NPC client will not react to teleport. - Added back info to user on teleport of NPCs that it might not work. Since not all NPCs might be expected to have teleported reactions. - Updated test data to test this. Modified Paths: -------------- trunk/data/npcbehave.xml trunk/src/common/net/message.h trunk/src/common/net/messages.h trunk/src/common/net/npcmessages.cpp trunk/src/common/net/npcmessages.h trunk/src/npcclient/networkmgr.cpp trunk/src/npcclient/networkmgr.h trunk/src/npcclient/npcbehave.cpp trunk/src/npcclient/npcoperations.cpp trunk/src/npcclient/npcoperations.h trunk/src/npcclient/perceptions.cpp trunk/src/npcclient/perceptions.h trunk/src/server/adminmanager.cpp trunk/src/server/command.cpp trunk/src/server/database/mysql/characters.sql trunk/src/server/database/mysql/sc_locations.sql trunk/src/server/npcmanager.cpp trunk/src/server/npcmanager.h trunk/src/server/spawnmanager.cpp trunk/src/server/spawnmanager.h Modified: trunk/data/npcbehave.xml =================================================================== --- trunk/data/npcbehave.xml 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/data/npcbehave.xml 2010-05-21 21:34:30 UTC (rev 5931) @@ -1,111 +1,125 @@ <npctypes> - <npctype name="smith" vel="2"> - <behavior name="do nothing" decay="0" growth="0" initial="10"> - <wait duration="1" anim="stand" /> - </behavior> - <behavior name="go_climbing1" initial="0" completion_decay="20" loop="no"> - <moveto x="-53.6003" y="0.0" z="-155.041" anim="walk" /> - <moveto x="-8.89576" y="0.0" z="-162.498" anim="walk" /> - <moveto x="18.4303" y="21.9941" z="-163.082" anim="walk" /> - <moveto x="-9.01569" y="0.0" z="-159.477" anim="walk" /> - <moveto x="-19.7409" y="0.0" z="-153.539" anim="walk" /> - <moveto x="-42.8985" y="0.0" z="-146.811" anim="walk" /> - <moveto x="-53.6242" y="0.0" z="-155.023" anim="walk" /> - <wait duration="60" anim="stand" /> - <moveto x="-53.6242" y="0.0" z="-155.023" anim="walk" /> - <moveto x="-42.8985" y="0.0" z="-146.811" anim="walk" /> - <moveto x="-19.7409" y="0.0" z="-153.539" anim="walk" /> - <moveto x="-9.01569" y="0.0" z="-159.477" anim="walk" /> - <moveto x="18.4303" y="21.9941" z="-163.082" anim="walk" /> - <moveto x="-8.89576" y="0.0" z="-162.498" anim="walk" /> - <moveto x="-53.6003" y="0.0" z="-155.041" anim="walk" /> - </behavior> - <behavior name="go_obstacles1" initial="0" completion_decay="20" loop="no"> - <moveto x="-53.5112" y="0.0" z="-155.135" anim="walk" /> - <moveto x="-44.2481" y="0.0" z="-153.507" anim="walk" /> - <moveto x="-27.3333" y="0.0" z="-163.914" anim="walk" /> - <moveto x="-32.8587" y="0.0" z="-199.55" anim="walk" /> - <moveto x="-45.5557" y="0.0" z="-213.535" anim="walk" /> - <moveto x="-45.5928" y="0.0" z="-225.046" anim="walk" /> - <moveto x="-42.5066" y="0.0" z="-247.016" anim="walk" /> - <moveto x="-35.3197" y="0.0" z="-246.967" anim="walk" /> - <moveto x="-35.1166" y="0.0" z="-237.451" anim="walk" /> - <moveto x="-26.9788" y="0.0" z="-237.333" anim="walk" /> - <moveto x="-26.5143" y="0.0" z="-248.163" anim="walk" /> - <moveto x="-19.3833" y="0.0" z="-247.596" anim="walk" /> - <moveto x="-19.4912" y="0.0" z="-236.566" anim="walk" /> - <moveto x="-10.7207" y="0.0" z="-236.432" anim="walk" /> - <moveto x="-11.0175" y="0.0" z="-249.279" anim="walk" /> - <moveto x="-4.43381" y="0.0" z="-248.536" anim="walk" /> - <moveto x="-4.49285" y="0.0" z="-236.315" anim="walk" /> - <moveto x="1.82961" y="0.0" z="-235.959" anim="walk" /> - <moveto x="1.64485" y="0.0" z="-249.233" anim="walk" /> - <moveto x="8.12992" y="0.0" z="-249.23" anim="walk" /> - <moveto x="8.19972" y="0.0" z="-230.12" anim="walk" /> - <moveto x="-24.0757" y="0.0" z="-222.12" anim="walk" /> - <moveto x="-24.8802" y="0.0" z="-205.212" anim="walk" /> - <moveto x="-42.7254" y="0.0" z="-166.754" anim="walk" /> - <moveto x="-46.2027" y="0.0" z="-152.995" anim="walk" /> - <moveto x="-53.5608" y="0.0" z="-155.176" anim="walk" /> - <wait duration="30" anim="stand" /> - <moveto x="-53.5608" y="0.0" z="-155.176" anim="walk" /> - <moveto x="-46.2027" y="0.0" z="-152.995" anim="walk" /> - <moveto x="-42.7254" y="0.0" z="-166.754" anim="walk" /> - <moveto x="-24.8802" y="0.0" z="-205.212" anim="walk" /> - <moveto x="-24.0757" y="0.0" z="-222.12" anim="walk" /> - <moveto x="8.19972" y="0.0" z="-230.12" anim="walk" /> - <moveto x="8.12992" y="0.0" z="-249.23" anim="walk" /> - <moveto x="1.64485" y="0.0" z="-249.233" anim="walk" /> - <moveto x="1.82961" y="0.0" z="-235.959" anim="walk" /> - <moveto x="-4.49285" y="0.0" z="-236.315" anim="walk" /> - <moveto x="-4.43381" y="0.0" z="-248.536" anim="walk" /> - <moveto x="-11.0175" y="0.0" z="-249.279" anim="walk" /> - <moveto x="-10.7207" y="0.0" z="-236.432" anim="walk" /> - <moveto x="-19.4912" y="0.0" z="-236.566" anim="walk" /> - <moveto x="-19.3833" y="0.0" z="-247.596" anim="walk" /> - <moveto x="-26.5143" y="0.0" z="-248.163" anim="walk" /> - <moveto x="-26.9788" y="0.0" z="-237.333" anim="walk" /> - <moveto x="-35.1166" y="0.0" z="-237.451" anim="walk" /> - <moveto x="-35.3197" y="0.0" z="-246.967" anim="walk" /> - <moveto x="-42.5066" y="0.0" z="-247.016" anim="walk" /> - <moveto x="-45.5928" y="0.0" z="-225.046" anim="walk" /> - <moveto x="-45.5557" y="0.0" z="-213.535" anim="walk" /> - <moveto x="-32.8587" y="0.0" z="-199.55" anim="walk" /> - <moveto x="-27.3333" y="0.0" z="-163.914" anim="walk" /> - <moveto x="-44.2481" y="0.0" z="-153.507" anim="walk" /> - <moveto x="-53.5112" y="0.0" z="-155.135" anim="walk" /> - </behavior> - <behavior name="go_other_sector1" initial="0" completion_decay="20" loop="no"> - <moveto x="-53.546" y="0.0" z="-155.243" anim="walk" /> - <moveto x="-42.1452" y="0.0" z="-140.879" anim="walk" /> - <moveto x="-55.2024" y="0.0" z="-126.302" anim="walk" /> - <moveto x="-57.6445" y="0.0" z="-113.753" anim="walk" /> - <wait duration="30" anim="stand" /> - <moveto x="-57.6445" y="0.0" z="-113.753" anim="walk" /> - <moveto x="-55.2024" y="0.0" z="-126.302" anim="walk" /> - <moveto x="-42.1452" y="0.0" z="-140.879" anim="walk" /> - <moveto x="-53.546" y="0.0" z="-155.243" anim="walk" /> - </behavior> - <behavior name="go_sleep1" initial="0" completion_decay="20" loop="no"> - <moveto x="-53.6185" y="0.0" z="-155.243" anim="walk" /> - <moveto x="-51.4396" y="0.0" z="-149.481" anim="walk" /> - <moveto x="-54.8432" y="0.0" z="-146.474" anim="walk" /> - <moveto x="-55.6514" y="0.0" z="-147.652" anim="walk" /> - <invisible/> - <wait duration="30" anim="stand" /> - <visible/> - <moveto x="-55.6514" y="0.0" z="-147.652" anim="walk" /> - <moveto x="-54.8432" y="0.0" z="-146.474" anim="walk" /> - <moveto x="-51.4396" y="0.0" z="-149.481" anim="walk" /> - <moveto x="-53.6185" y="0.0" z="-155.243" anim="walk" /> - </behavior> - <react event="time" value="8,0,,," behavior="go_other_sector1" delta="20" /> - <react event="time" value="10,0,,," behavior="go_sleep1" delta="20" /> - <react event="time" value="12,0,,," behavior="go_obstacles1" delta="20" /> - <react event="time" value="14,0,,," behavior="go_climbing1" delta="20" /> - </npctype> + <npctype name="GoHomeOnTeleport"> + <behavior name="Teleported" completion_decay="-1" growth="0" initial="0"> + <locate obj="perception" /> + <teleport /> <!-- Teleport to located position --> + <locate obj="waypoint" static="no" /> <!-- Locate nearest waypoint --> + <navigate anim="walk" /> <!-- Local navigation --> + <locate obj="home:$name" /> + <wander anim="walk" /> <!-- Navigate using waypoints --> + <navigate anim="walk" /> <!-- Local navigation --> + </behavior> + <react event="teleported" behavior="Teleported" /> + </npctype> + + <npctype name="smith" vel="2" parent="GoHomeOnTeleport" > + <behavior name="do nothing" decay="0" growth="0" initial="10"> + <wait duration="1" anim="stand" /> + </behavior> + <behavior name="go_climbing1" initial="0" completion_decay="20" loop="no"> + <moveto x="-53.6003" y="0.0" z="-155.041" anim="walk" /> + <moveto x="-8.89576" y="0.0" z="-162.498" anim="walk" /> + <moveto x="18.4303" y="21.9941" z="-163.082" anim="walk" /> + <moveto x="-9.01569" y="0.0" z="-159.477" anim="walk" /> + <moveto x="-19.7409" y="0.0" z="-153.539" anim="walk" /> + <moveto x="-42.8985" y="0.0" z="-146.811" anim="walk" /> + <moveto x="-53.6242" y="0.0" z="-155.023" anim="walk" /> + <wait duration="60" anim="stand" /> + <moveto x="-53.6242" y="0.0" z="-155.023" anim="walk" /> + <moveto x="-42.8985" y="0.0" z="-146.811" anim="walk" /> + <moveto x="-19.7409" y="0.0" z="-153.539" anim="walk" /> + <moveto x="-9.01569" y="0.0" z="-159.477" anim="walk" /> + <moveto x="18.4303" y="21.9941" z="-163.082" anim="walk" /> + <moveto x="-8.89576" y="0.0" z="-162.498" anim="walk" /> + <moveto x="-53.6003" y="0.0" z="-155.041" anim="walk" /> + </behavior> + <behavior name="go_obstacles1" initial="0" completion_decay="20" loop="no"> + <moveto x="-53.5112" y="0.0" z="-155.135" anim="walk" /> + <moveto x="-44.2481" y="0.0" z="-153.507" anim="walk" /> + <moveto x="-27.3333" y="0.0" z="-163.914" anim="walk" /> + <moveto x="-32.8587" y="0.0" z="-199.55" anim="walk" /> + <moveto x="-45.5557" y="0.0" z="-213.535" anim="walk" /> + <moveto x="-45.5928" y="0.0" z="-225.046" anim="walk" /> + <moveto x="-42.5066" y="0.0" z="-247.016" anim="walk" /> + <moveto x="-35.3197" y="0.0" z="-246.967" anim="walk" /> + <moveto x="-35.1166" y="0.0" z="-237.451" anim="walk" /> + <moveto x="-26.9788" y="0.0" z="-237.333" anim="walk" /> + <moveto x="-26.5143" y="0.0" z="-248.163" anim="walk" /> + <moveto x="-19.3833" y="0.0" z="-247.596" anim="walk" /> + <moveto x="-19.4912" y="0.0" z="-236.566" anim="walk" /> + <moveto x="-10.7207" y="0.0" z="-236.432" anim="walk" /> + <moveto x="-11.0175" y="0.0" z="-249.279" anim="walk" /> + <moveto x="-4.43381" y="0.0" z="-248.536" anim="walk" /> + <moveto x="-4.49285" y="0.0" z="-236.315" anim="walk" /> + <moveto x="1.82961" y="0.0" z="-235.959" anim="walk" /> + <moveto x="1.64485" y="0.0" z="-249.233" anim="walk" /> + <moveto x="8.12992" y="0.0" z="-249.23" anim="walk" /> + <moveto x="8.19972" y="0.0" z="-230.12" anim="walk" /> + <moveto x="-24.0757" y="0.0" z="-222.12" anim="walk" /> + <moveto x="-24.8802" y="0.0" z="-205.212" anim="walk" /> + <moveto x="-42.7254" y="0.0" z="-166.754" anim="walk" /> + <moveto x="-46.2027" y="0.0" z="-152.995" anim="walk" /> + <moveto x="-53.5608" y="0.0" z="-155.176" anim="walk" /> + <wait duration="30" anim="stand" /> + <moveto x="-53.5608" y="0.0" z="-155.176" anim="walk" /> + <moveto x="-46.2027" y="0.0" z="-152.995" anim="walk" /> + <moveto x="-42.7254" y="0.0" z="-166.754" anim="walk" /> + <moveto x="-24.8802" y="0.0" z="-205.212" anim="walk" /> + <moveto x="-24.0757" y="0.0" z="-222.12" anim="walk" /> + <moveto x="8.19972" y="0.0" z="-230.12" anim="walk" /> + <moveto x="8.12992" y="0.0" z="-249.23" anim="walk" /> + <moveto x="1.64485" y="0.0" z="-249.233" anim="walk" /> + <moveto x="1.82961" y="0.0" z="-235.959" anim="walk" /> + <moveto x="-4.49285" y="0.0" z="-236.315" anim="walk" /> + <moveto x="-4.43381" y="0.0" z="-248.536" anim="walk" /> + <moveto x="-11.0175" y="0.0" z="-249.279" anim="walk" /> + <moveto x="-10.7207" y="0.0" z="-236.432" anim="walk" /> + <moveto x="-19.4912" y="0.0" z="-236.566" anim="walk" /> + <moveto x="-19.3833" y="0.0" z="-247.596" anim="walk" /> + <moveto x="-26.5143" y="0.0" z="-248.163" anim="walk" /> + <moveto x="-26.9788" y="0.0" z="-237.333" anim="walk" /> + <moveto x="-35.1166" y="0.0" z="-237.451" anim="walk" /> + <moveto x="-35.3197" y="0.0" z="-246.967" anim="walk" /> + <moveto x="-42.5066" y="0.0" z="-247.016" anim="walk" /> + <moveto x="-45.5928" y="0.0" z="-225.046" anim="walk" /> + <moveto x="-45.5557" y="0.0" z="-213.535" anim="walk" /> + <moveto x="-32.8587" y="0.0" z="-199.55" anim="walk" /> + <moveto x="-27.3333" y="0.0" z="-163.914" anim="walk" /> + <moveto x="-44.2481" y="0.0" z="-153.507" anim="walk" /> + <moveto x="-53.5112" y="0.0" z="-155.135" anim="walk" /> + </behavior> + <behavior name="go_other_sector1" initial="0" completion_decay="20" loop="no"> + <moveto x="-53.546" y="0.0" z="-155.243" anim="walk" /> + <moveto x="-42.1452" y="0.0" z="-140.879" anim="walk" /> + <moveto x="-55.2024" y="0.0" z="-126.302" anim="walk" /> + <moveto x="-57.6445" y="0.0" z="-113.753" anim="walk" /> + <wait duration="30" anim="stand" /> + <moveto x="-57.6445" y="0.0" z="-113.753" anim="walk" /> + <moveto x="-55.2024" y="0.0" z="-126.302" anim="walk" /> + <moveto x="-42.1452" y="0.0" z="-140.879" anim="walk" /> + <moveto x="-53.546" y="0.0" z="-155.243" anim="walk" /> + </behavior> + <behavior name="go_sleep1" initial="0" completion_decay="20" loop="no"> + <moveto x="-53.6185" y="0.0" z="-155.243" anim="walk" /> + <moveto x="-51.4396" y="0.0" z="-149.481" anim="walk" /> + <moveto x="-54.8432" y="0.0" z="-146.474" anim="walk" /> + <moveto x="-55.6514" y="0.0" z="-147.652" anim="walk" /> + <invisible/> + <wait duration="30" anim="stand" /> + <visible/> + <moveto x="-55.6514" y="0.0" z="-147.652" anim="walk" /> + <moveto x="-54.8432" y="0.0" z="-146.474" anim="walk" /> + <moveto x="-51.4396" y="0.0" z="-149.481" anim="walk" /> + <moveto x="-53.6185" y="0.0" z="-155.243" anim="walk" /> + </behavior> + <react event="time" value="8,0,,," behavior="go_other_sector1" delta="20" /> + <react event="time" value="10,0,,," behavior="go_sleep1" delta="20" /> + <react event="time" value="12,0,,," behavior="go_obstacles1" delta="20" /> + <react event="time" value="14,0,,," behavior="go_climbing1" delta="20" /> + </npctype> + <!-- Basic movement to keep a NPC within the bounds of an region. Will not influence, unless a region is defined and moving out of bounds. --> Modified: trunk/src/common/net/message.h =================================================================== --- trunk/src/common/net/message.h 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/common/net/message.h 2010-05-21 21:34:30 UTC (rev 5931) @@ -27,7 +27,12 @@ #include <csutil/threading/atomicops.h> #include <csutil/refcount.h> #include <csutil/csendian.h> +#include <csutil/strhashr.h> +#include <csutil/strset.h> #include <csgeom/vector3.h> +#include <iengine/sector.h> +#include <iengine/engine.h> +#include <csutil/csobject.h> #include "util/log.h" #include "net/packing.h" @@ -549,7 +554,27 @@ current += 3*sizeof(uint32); } + void Add(iSector* sector, csStringSet* msgstrings, csStringHashReversible* msgstringshash = NULL) + { + const char* sectorName = sector->QueryObject ()->GetName (); + csStringID sectorNameStrId = csInvalidStringID; + if (msgstrings) + { + sectorNameStrId = msgstrings->Request(sectorName); + } else if (msgstringshash) + { + sectorNameStrId = msgstringshash->Request(sectorName); + } + + Add( (uint32_t) sectorNameStrId ); + + if (sectorNameStrId == csInvalidStringID) + { + Add(sectorName); + } + } + /// Add a processed buffer of some kind; should only be used by files and the like. // NOTE THIS IS NOT ENDIAN-CONVERTED: YOUR DATA MUST ALREADY BE ENDIAN SAFE. void Add(const void *datastream,const uint32_t length) @@ -808,6 +833,36 @@ return v; } + iSector* GetSector(csStringSet* msgstrings, csStringHashReversible* msgstringshash, iEngine *engine) + { + csString sectorName; + csStringID sectorNameStrId; + sectorNameStrId = GetUInt32(); + if (sectorNameStrId != csStringID(uint32_t(csInvalidStringID))) + { + if(msgstrings) + { + sectorName = msgstrings->Request(sectorNameStrId); + } + else if(msgstringshash) + { + sectorName = msgstringshash->Request(sectorNameStrId); + } + } + else + { + sectorName = GetStr(); + } + + if(!sectorName.IsEmpty()) + { + return engine->GetSectors ()->FindByName (sectorName); + } + + return NULL; + } + + // Get a pre-converted data buffer with recorded length from the current psMessageBytes buffer. void * GetBufferPointerUnsafe(uint32_t& length) { Modified: trunk/src/common/net/messages.h =================================================================== --- trunk/src/common/net/messages.h 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/common/net/messages.h 2010-05-21 21:34:30 UTC (rev 5931) @@ -47,7 +47,7 @@ // NPC Networking version is separate so we don't have to break compatibility // with clients to enhance the superclients. Made it a large number to ensure // no inadvertent overlaps. -#define PS_NPCNETVERSION 0x1016 +#define PS_NPCNETVERSION 0x1017 enum Slot_Containers { Modified: trunk/src/common/net/npcmessages.cpp =================================================================== --- trunk/src/common/net/npcmessages.cpp 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/common/net/npcmessages.cpp 2010-05-21 21:34:30 UTC (rev 5931) @@ -484,10 +484,8 @@ EID character_id = EID(msg->GetUInt32()); float rot = msg->GetFloat(); - where.x = msg->GetFloat(); - where.y = msg->GetFloat(); - where.z = msg->GetFloat(); - csString sector = msg->GetStr(); + where = msg->GetVector(); + iSector* sector = msg->GetSector(access_ptrs->msgstrings, 0, access_ptrs->engine); // Make sure we haven't run past the end of the buffer if (msg->overrun) @@ -496,8 +494,8 @@ break; } - msgtext.AppendFmt("ID: %u Rot: %.2f Where: (%.2f,%.2f,%.2f) Sector: %s ", - character_id.Unbox(),rot,where.x,where.y,where.z,sector.GetDataSafe()); + msgtext.AppendFmt("Char: %s Rot: %.2f Where: %s ", + ShowID(character_id),rot,toString(where,sector).GetDataSafe()); break; } @@ -728,6 +726,20 @@ msgtext.AppendFmt("PID: %u EID: %u EID: %u TribeMemberType: %u", spawned_pid.Unbox(), spawned_eid.Unbox(), spawner_eid.Unbox(),tribeMemberType); break; } + case psNPCCommandsMessage::PCPT_TELEPORT: + { + msgtext.Append("PCPT_TELEPORT: "); + + // Extract the data + EID npc_eid = EID(msg->GetUInt32()); + csVector3 pos = msg->GetVector(); + float yrot = msg->GetFloat(); + iSector* sector = msg->GetSector( access_ptrs->msgstrings, 0, access_ptrs->engine ); + InstanceID instance = msg->GetUInt32(); + + msgtext.AppendFmt("NPC: %s Pos: %s Rot: %f Inst: %d",ShowID(npc_eid),toString(pos,sector).GetDataSafe(),yrot,instance); + break; + } } @@ -765,19 +777,8 @@ void psAllEntityPosMessage::Add(EID id, csVector3& pos, iSector*& sector, InstanceID instance, csStringSet* msgstrings, bool forced) { msg->Add(id.Unbox()); - msg->Add(pos.x); - msg->Add(pos.y); - msg->Add(pos.z); - - const char* sectorName = sector->QueryObject ()->GetName (); - csStringID sectorNameStrId = msgstrings ? msgstrings->Request(sectorName) : csInvalidStringID; - - msg->Add( (uint32_t) sectorNameStrId ); - - if (sectorNameStrId == csInvalidStringID) - { - msg->Add(sectorName); - } + msg->Add(pos); + msg->Add(sector, msgstrings); msg->Add( (int32_t)instance ); msg->Add(forced); } @@ -786,32 +787,8 @@ csStringHashReversible* msgstringshash, iEngine *engine) { EID eid(msg->GetUInt32()); - pos.x = msg->GetFloat(); - pos.y = msg->GetFloat(); - pos.z = msg->GetFloat(); - - csString sectorName; - csStringID sectorNameStrId; - sectorNameStrId = msg->GetUInt32(); - if (sectorNameStrId != csStringID(uint32_t(csInvalidStringID))) - { - if(msgstrings) - sectorName = msgstrings->Request(sectorNameStrId); - else if(msgstringshash) - sectorName = msgstringshash->Request(sectorNameStrId); - } - else - { - sectorName = msg->GetStr(); - } - if(!sectorName.IsEmpty()) - { - sector = engine->GetSectors ()->FindByName (sectorName); - } - else - { - sector = NULL; - } + pos = msg->GetVector(); + sector = msg->GetSector(msgstrings, msgstringshash, engine); instance = msg->GetUInt32(); forced = msg->GetBool(); return eid; @@ -831,7 +808,7 @@ EID eid = Get(pos, sector, instance, forced, access_ptrs->msgstrings, 0, access_ptrs->engine); - msgtext.AppendFmt(" ID: %u Pos: %s Inst: %d", eid.Unbox(), toString(pos,sector).GetDataSafe(), instance); + msgtext.AppendFmt(" ID: %s Pos: %s Inst: %d", ShowID(eid), toString(pos,sector).GetDataSafe(), instance); } return msgtext; Modified: trunk/src/common/net/npcmessages.h =================================================================== --- trunk/src/common/net/npcmessages.h 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/common/net/npcmessages.h 2010-05-21 21:34:30 UTC (rev 5931) @@ -228,7 +228,8 @@ PCPT_FLAG, PCPT_NPCCMD, PCPT_TRANSFER, - PCPT_SPAWNED + PCPT_SPAWNED, + PCPT_TELEPORT }; enum PerceptionTalkType Modified: trunk/src/npcclient/networkmgr.cpp =================================================================== --- trunk/src/npcclient/networkmgr.cpp 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/npcclient/networkmgr.cpp 2010-05-21 21:34:30 UTC (rev 5931) @@ -41,6 +41,7 @@ #include "net/msghandler.h" #include "net/npcmessages.h" #include "engine/linmove.h" +#include "util/strutil.h" //============================================================================= // Local Space Includes @@ -465,7 +466,7 @@ InstanceID instance; bool forced; - EID id = updates.Get(pos, sector, instance, forced, 0, npcclient->GetNetworkMgr()->GetMsgStrings(), engine); + EID id = updates.Get(pos, sector, instance, forced, 0, GetMsgStrings(), engine); npcclient->SetEntityPos(id, pos, sector, instance, forced); } } @@ -885,6 +886,25 @@ npcclient->CheckAttachTribes(spawned_npc); break; } + case psNPCCommandsMessage::PCPT_TELEPORT: + { + EID npc_eid = EID(msg->GetUInt32()); + csVector3 pos = msg->GetVector(); + float yrot = msg->GetFloat(); + iSector* sector = msg->GetSector( 0, GetMsgStrings(), engine ); + InstanceID instance = msg->GetUInt32(); + + NPC *npc = npcclient->FindNPC(npc_eid); + + if (!npc) + break; + + npc->Printf("Got teleport perception to %s\n",toString(pos,sector).GetDataSafe()); + + PositionPerception pcpt("teleported",NULL,instance,sector,pos,yrot,0.0); + npc->TriggerEvent(&pcpt); + break; + } default: { @@ -1185,17 +1205,15 @@ } -void NetworkManager::QueueResurrectCommand(csVector3 where, float rot, csString sector, PID character_id) +void NetworkManager::QueueResurrectCommand(csVector3 where, float rot, iSector* sector, PID character_id) { CheckCommandsOverrun(100); outbound->msg->Add( (int8_t) psNPCCommandsMessage::CMD_RESURRECT); outbound->msg->Add(character_id.Unbox()); outbound->msg->Add( (float)rot ); - outbound->msg->Add( (float)where.x ); - outbound->msg->Add( (float)where.y ); - outbound->msg->Add( (float)where.z ); - outbound->msg->Add( sector ); + outbound->msg->Add( where ); + outbound->msg->Add( sector, 0, GetMsgStrings() ); if ( outbound->msg->overrun ) { Modified: trunk/src/npcclient/networkmgr.h =================================================================== --- trunk/src/npcclient/networkmgr.h 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/npcclient/networkmgr.h 2010-05-21 21:34:30 UTC (rev 5931) @@ -127,7 +127,7 @@ void QueueDigCommand(gemNPCActor *entity, csString resource); void QueueTransferCommand(gemNPCActor *entity, csString item, int count, csString target); void QueueDropCommand(gemNPCActor *entity, csString slot); - void QueueResurrectCommand(csVector3 where, float rot, csString sector, PID character_id); + void QueueResurrectCommand(csVector3 where, float rot, iSector* sector, PID character_id); void QueueSequenceCommand(csString name, int cmd, int count); void QueueImperviousCommand(gemNPCActor * entity, bool impervious); void SendAllCommands(bool final = false); Modified: trunk/src/npcclient/npcbehave.cpp =================================================================== --- trunk/src/npcclient/npcbehave.cpp 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/npcclient/npcbehave.cpp 2010-05-21 21:34:30 UTC (rev 5931) @@ -732,6 +732,10 @@ { op = new TalkOperation; } + else if ( strcmp( node->GetValue(), "teleport" ) == 0 ) + { + op = new TeleportOperation; + } else if ( strcmp( node->GetValue(), "transfer" ) == 0 ) { op = new TransferOperation; Modified: trunk/src/npcclient/npcoperations.cpp =================================================================== --- trunk/src/npcclient/npcoperations.cpp 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/npcclient/npcoperations.cpp 2010-05-21 21:34:30 UTC (rev 5931) @@ -2633,19 +2633,19 @@ tribe->GetHome(where,radius,sector); float x, z, xDist, zDist; - do { - // Pick random point in circumscribed rectangle. - x = psGetRandom() * (radius*2.0); - z = psGetRandom() * (radius*2.0); - xDist = radius - x; - zDist = radius - z; - // Keep looping until the point is inside a circle. - } while(xDist * xDist + zDist * zDist > radius * radius); - - where.x += x - radius; - where.z += z - radius; + do { + // Pick random point in circumscribed rectangle. + x = psGetRandom() * (radius*2.0); + z = psGetRandom() * (radius*2.0); + xDist = radius - x; + zDist = radius - z; + // Keep looping until the point is inside a circle. + } while(xDist * xDist + zDist * zDist > radius * radius); + + where.x += x - radius; + where.z += z - radius; - npcclient->GetNetworkMgr()->QueueResurrectCommand(where, rot, sector->QueryObject()->GetName(), npc->GetPID()); + npcclient->GetNetworkMgr()->QueueResurrectCommand(where, rot, sector, npc->GetPID()); return true; // Nothing more to do for this op. } @@ -3185,6 +3185,41 @@ //--------------------------------------------------------------------------- +bool TeleportOperation::Load(iDocumentNode *node) +{ + return true; +} + +ScriptOperation *TeleportOperation::MakeCopy() +{ + TeleportOperation *op = new TeleportOperation; + return op; +} + +bool TeleportOperation::Run(NPC *npc, EventManager *eventmgr, bool interrupted) +{ + gemNPCActor* actor = npc->GetActor(); + + if (!actor) + { + npc->Printf(1,"No actor for telport operation."); + return true; // Nothing more to do for this op. + } + + csVector3 pos; + iSector* sector; + float rot; + + npc->GetActiveLocate(pos,sector,rot); + npc->Printf(5, "Teleport to %s",toString(pos,sector).GetDataSafe()); + + psGameObject::SetPosition(npc->GetActor(), pos, sector); + + return true; // Nothing more to do for this op. +} + +//--------------------------------------------------------------------------- + bool TransferOperation::Load(iDocumentNode *node) { item = node->GetAttributeValue("item"); Modified: trunk/src/npcclient/npcoperations.h =================================================================== --- trunk/src/npcclient/npcoperations.h 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/npcclient/npcoperations.h 2010-05-21 21:34:30 UTC (rev 5931) @@ -858,6 +858,24 @@ //----------------------------------------------------------------------------- /** +* Teleport will teleport the NPC to the target position. +*/ +class TeleportOperation : public ScriptOperation +{ +protected: + +public: + + TeleportOperation(): ScriptOperation("Teleport") {}; + virtual ~TeleportOperation() {}; + virtual bool Run(NPC *npc,EventManager *eventmgr,bool interrupted); + virtual bool Load(iDocumentNode *node); + virtual ScriptOperation *MakeCopy(); +}; + +//----------------------------------------------------------------------------- + +/** * Transfer will transfer a item from the NPC to a target. The * target might be a tribe. */ Modified: trunk/src/npcclient/perceptions.cpp =================================================================== --- trunk/src/npcclient/perceptions.cpp 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/npcclient/perceptions.cpp 2010-05-21 21:34:30 UTC (rev 5931) @@ -624,6 +624,36 @@ //--------------------------------------------------------------------------------- + +bool PositionPerception::ShouldReact(Reaction *reaction, NPC *npc) +{ + if (name == reaction->GetEventType() && (reaction->GetType().IsEmpty() || type == reaction->GetType())) + { + return true; + } + return false; +} + +bool PositionPerception::GetLocation(csVector3& pos, iSector*& sector) +{ + pos = this->pos; + sector = this->sector; + return true; +} + +Perception *PositionPerception::MakeCopy() +{ + PositionPerception *p = new PositionPerception(name,type,instance,sector,pos,yrot,radius); + return p; +} + +float PositionPerception::GetRadius() const +{ + return radius; +} + +//--------------------------------------------------------------------------------- + Perception *AttackPerception::MakeCopy() { AttackPerception *p = new AttackPerception(name,attacker); Modified: trunk/src/npcclient/perceptions.h =================================================================== --- trunk/src/npcclient/perceptions.h 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/npcclient/perceptions.h 2010-05-21 21:34:30 UTC (rev 5931) @@ -292,6 +292,30 @@ iEngine* engine; }; +/** + * Percept a position. + */ +class PositionPerception : public Perception +{ +protected: + InstanceID instance; + iSector* sector; + csVector3 pos; + float yrot; + + float radius; + +public: + PositionPerception(const char *n, const char*type,InstanceID& instance, iSector* sector, csVector3& pos, float yrot, float radius) + : Perception(n,type), instance(instance), sector(sector), pos(pos), yrot(yrot), radius(radius) {} + virtual ~PositionPerception() {} + + virtual bool ShouldReact(Reaction *reaction, NPC *npc); + virtual Perception *MakeCopy(); + virtual bool GetLocation(csVector3& pos, iSector*& sector); + virtual float GetRadius() const; +}; + //----------------------------------------------------------------------------- /** Modified: trunk/src/server/adminmanager.cpp =================================================================== --- trunk/src/server/adminmanager.cpp 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/server/adminmanager.cpp 2010-05-21 21:34:30 UTC (rev 5931) @@ -2655,12 +2655,17 @@ return; } - //Client* superclient = clients->FindAccount( subject->GetSuperclientID() ); - //if(superclient && subject->GetSuperclientID()!=0) - //{ - // psserver->SendSystemError(client->GetClientNum(), "This entity %s is controlled by superclient %s and can't be teleported.", subject->GetName(), ShowID(subject->GetSuperclientID())); - // return; - //} + Client* superclient = clients->FindAccount( subject->GetSuperclientID() ); + if(superclient && subject->GetSuperclientID()!=0) + { + gemNPC* npc = dynamic_cast<gemNPC*>(subject); + if (npc) + { + psserver->SendSystemInfo(client->GetClientNum(), "%s is controlled by superclient %s and might not be teleported.", + subject->GetName(), ShowID(subject->GetSuperclientID())); + psserver->GetNPCManager()->QueueTeleportPerception(npc,targetPoint,yRot,targetSector,targetInstance); + } + } if ( !MoveObject(client,subject,targetPoint,yRot,targetSector,targetInstance) ) return; Modified: trunk/src/server/command.cpp =================================================================== --- trunk/src/server/command.cpp 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/server/command.cpp 2010-05-21 21:34:30 UTC (rev 5931) @@ -1714,17 +1714,18 @@ csHash<gemObject*, EID>::GlobalIterator i(gems.GetIterator()); gemObject* obj; - CPrintf(CON_CMDOUTPUT ,"%-9s %-5s %-9s %-10s %-20s\n","PID","EID","CNUM","Type","Name"); + CPrintf(CON_CMDOUTPUT ,"%-9s %-5s %-9s %-9s %-10s %-20s\n","PID","EID","CNUM","SCNUM","Type","Name"); while ( i.HasNext() ) { obj = i.Next(); gemActor* actor = dynamic_cast<gemActor*>(obj); if (actor) { - CPrintf(CON_CMDOUTPUT ,"%9u %5u %9u %-10s %-20s\n", + CPrintf(CON_CMDOUTPUT ,"%9u %5u %9u %9u %-10s %-20s\n", actor->GetCharacterData()->GetPID().Unbox(), actor->GetEID().Unbox(), actor->GetClientID(), + actor->GetSuperclientID().Unbox(), actor->GetObjectType(), actor->GetName()); } Modified: trunk/src/server/database/mysql/characters.sql =================================================================== --- trunk/src/server/database/mysql/characters.sql 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/server/database/mysql/characters.sql 2010-05-21 21:34:30 UTC (rev 5931) @@ -132,21 +132,21 @@ INSERT INTO `characters` VALUES (61,'Mount1','','',32,3,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-42.86,-0.01,-152.30,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',1,6,'Y',9,0,2,0,0,'description','','','',10,'',0,'0000-00-00 00:00:00',0,0); INSERT INTO `characters` VALUES (62,'Hunter','','',7,1,44.00,40.00,44.00,40.00,40.00,40.00,50.00,100.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-90.00,0.00,-230.00,0.00,0,0,0,0,0,'','',0,NULL,'1,30,3,30,4,-50','',0,62,'N',9,0,0,0,0,'Tribe member. Used in tribe testing.','','','',500,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (63,'RespawnCircle','','',2,1,65.00,65.00,65.00,60.00,60.00,60.00,50.00,100.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-65.00,0.00,-415.00,0.00,0,0,0,0,0,'','',0,NULL,'1,30,2,-30','',100,63,'N',9,0,2,0,0,'Test respawn rule in circle','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (64,'RespawnCircle','','',2,1,65.00,65.00,65.00,60.00,60.00,60.00,50.00,100.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-65.00,0.00,-415.00,0.00,0,0,0,0,0,'','',0,NULL,'1,30,2,-30','',100,63,'N',9,0,2,0,0,'Test respawn rule in circle','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (65,'RespawnCircle','','',2,1,65.00,65.00,65.00,60.00,60.00,60.00,50.00,100.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-65.00,0.00,-415.00,0.00,0,0,0,0,0,'','',0,NULL,'1,30,2,-30','',100,63,'N',9,0,2,0,0,'Test respawn rule in circle','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (66,'RespawnArea','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-55.00,0.00,-417.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',101,63,'N',9,0,2,0,0,'Test respawn rule in area','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (67,'RespawnArea','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-55.00,0.00,-417.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',101,63,'N',9,0,2,0,0,'Test respawn rule in area','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (68,'RespawnArea','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-55.00,0.00,-417.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',101,63,'N',9,0,2,0,0,'Test respawn rule in area','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (69,'RespawnLine','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-42.00,0.00,-379.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',102,63,'N',9,0,2,0,0,'Test respawn rule in line','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (70,'RespawnLine','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-42.00,0.00,-379.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',102,63,'N',9,0,2,0,0,'Test respawn rule in line','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (71,'RespawnLine','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-42.00,0.00,-379.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',102,63,'N',9,0,2,0,0,'Test respawn rule in line','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (72,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',9,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (73,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',9,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (74,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',9,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (75,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',9,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (76,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',9,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); -INSERT INTO `characters` VALUES (77,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',9,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (63,'RespawnCircle','','',2,1,65.00,65.00,65.00,60.00,60.00,60.00,50.00,100.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-65.00,0.00,-415.00,0.00,0,0,0,0,0,'','',0,NULL,'1,30,2,-30','',100,63,'N',0,0,2,0,0,'Test respawn rule in circle','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (64,'RespawnCircle','','',2,1,65.00,65.00,65.00,60.00,60.00,60.00,50.00,100.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-65.00,0.00,-415.00,0.00,0,0,0,0,0,'','',0,NULL,'1,30,2,-30','',100,63,'N',0,0,2,0,0,'Test respawn rule in circle','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (65,'RespawnCircle','','',2,1,65.00,65.00,65.00,60.00,60.00,60.00,50.00,100.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-65.00,0.00,-415.00,0.00,0,0,0,0,0,'','',0,NULL,'1,30,2,-30','',100,63,'N',0,0,2,0,0,'Test respawn rule in circle','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (66,'RespawnArea','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-55.00,0.00,-417.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',101,63,'N',0,0,2,0,0,'Test respawn rule in area','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (67,'RespawnArea','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-55.00,0.00,-417.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',101,63,'N',0,0,2,0,0,'Test respawn rule in area','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (68,'RespawnArea','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-55.00,0.00,-417.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',101,63,'N',0,0,2,0,0,'Test respawn rule in area','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (69,'RespawnLine','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-42.00,0.00,-379.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',102,63,'N',0,0,2,0,0,'Test respawn rule in line','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (70,'RespawnLine','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-42.00,0.00,-379.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',102,63,'N',0,0,2,0,0,'Test respawn rule in line','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (71,'RespawnLine','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-42.00,0.00,-379.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',102,63,'N',0,0,2,0,0,'Test respawn rule in line','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (72,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',0,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (73,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',0,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (74,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',0,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (75,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',0,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (76,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',0,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); +INSERT INTO `characters` VALUES (77,'RespawnCombination','','',3,1,100.00,100.00,100.00,100.00,100.00,100.00,200.00,200.00,100.00,100.00,100.00,100.00,100,100,100,100,100,100,100,100,0,3,-70.00,0.00,-380.00,0.00,0,0,0,0,0,'','',0,NULL,'1,35,2,-35','',103,63,'N',0,0,2,0,0,'Test respawn rule in combination','','','',10,'',0,'0000-00-00 00:00:00',0,0); Modified: trunk/src/server/database/mysql/sc_locations.sql =================================================================== --- trunk/src/server/database/mysql/sc_locations.sql 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/server/database/mysql/sc_locations.sql 2010-05-21 21:34:30 UTC (rev 5931) @@ -66,6 +66,7 @@ INSERT INTO `sc_locations` VALUES (38,11, -1, 'Hunting ground 3','-20.0', '0.0', '-140.0', 10, 0.0,'', 3); INSERT INTO `sc_locations` VALUES (39,11, -1, 'Hunting ground 4','-20.0', '0.0', '-160.0', 10, 0.0,'', 3); INSERT INTO `sc_locations` VALUES (40,11, -1, 'Hunting ground 5','-20.0', '0.0', '-220.0', 10, 0.0,'', 3); +INSERT INTO `sc_locations` VALUES (41, 8, -1, 'Smith','-53.54', '0.01', '-155.11', 0, 0.5,'', 3); Modified: trunk/src/server/npcmanager.cpp =================================================================== --- trunk/src/server/npcmanager.cpp 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/server/npcmanager.cpp 2010-05-21 21:34:30 UTC (rev 5931) @@ -1199,13 +1199,11 @@ csVector3 where; PID playerID = PID(list.msg->GetUInt32()); float rot = list.msg->GetFloat(); - where.x = list.msg->GetFloat(); - where.y = list.msg->GetFloat(); - where.z = list.msg->GetFloat(); - csString sector = list.msg->GetStr(); + where = list.msg->GetVector(); + iSector* sector = list.msg->GetSector(psserver->GetCacheManager()->GetMsgStrings(), 0, psserver->entitymanager->GetEngine()); - Debug7(LOG_SUPERCLIENT, playerID.Unbox(), "-->Got resurrect cmd: %s Rot: %.2f Where: (%.2f,%.2f,%.2f) Sector: %s\n", - ShowID(playerID), rot, where.x, where.y, where.z, sector.GetDataSafe()); + Debug4(LOG_SUPERCLIENT, playerID.Unbox(), "-->Got resurrect cmd: %s Rot: %.2f Where: %s\n", + ShowID(playerID), rot, toString(where, sector).GetDataSafe()); // Make sure we haven't run past the end of the buffer if (list.msg->overrun) @@ -2079,7 +2077,7 @@ void NPCManager::QueueSpawnedPerception(gemNPC *spawned, gemNPC *spawner, uint32_t tribeMemberType) { - CheckSendPerceptionQueue(sizeof(int8_t)+sizeof(uint32_t)*3); + CheckSendPerceptionQueue(sizeof(int8_t)+sizeof(uint32_t)*4); outbound->msg->Add( (int8_t) psNPCCommandsMessage::PCPT_SPAWNED); outbound->msg->Add(spawned->GetCharacterData()->GetPID().Unbox()); outbound->msg->Add(spawned->GetEID().Unbox()); @@ -2089,6 +2087,21 @@ Debug3(LOG_NPC, spawner->GetEID().Unbox(), "Added spawn perception: %s from %s.\n", ShowID(spawned->GetEID()), ShowID(spawner->GetEID()) ); } +void NPCManager::QueueTeleportPerception(gemNPC* npc, csVector3& pos, float yrot, iSector* sector, InstanceID instance) +{ + CheckSendPerceptionQueue(sizeof(int8_t)+sizeof(uint32_t)*3+sizeof(float)*4+strlen(sector->QueryObject()->GetName())); + outbound->msg->Add( (int8_t) psNPCCommandsMessage::PCPT_TELEPORT); + outbound->msg->Add(npc->GetEID().Unbox()); + outbound->msg->Add(pos); + outbound->msg->Add(yrot); + outbound->msg->Add(sector, psserver->GetCacheManager()->GetMsgStrings()); + outbound->msg->Add(instance); + cmd_count++; + Debug3(LOG_NPC, npc->GetEID().Unbox(), "Added teleport perception for %s to %s.\n", ShowID(npc->GetEID()), toString(pos,sector).GetDataSafe() ); +} + + + void NPCManager::SendAllCommands(bool createNewTick) { if (cmd_count) Modified: trunk/src/server/npcmanager.h =================================================================== --- trunk/src/server/npcmanager.h 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/server/npcmanager.h 2010-05-21 21:34:30 UTC (rev 5931) @@ -120,6 +120,9 @@ /// Let the superclient know the npc was spawned successfully. void QueueSpawnedPerception(gemNPC *spawned, gemNPC *spawner, uint32_t tribeMemberType ); + /// Let the superclient know that the npc was teleported + void QueueTeleportPerception(gemNPC* npc, csVector3& pos, float yrot, iSector* sector, InstanceID instance); + /// Send all queued commands and perceptions to active superclients and reset the queues. void SendAllCommands(bool createNewTick = true); Modified: trunk/src/server/spawnmanager.cpp =================================================================== --- trunk/src/server/spawnmanager.cpp 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/server/spawnmanager.cpp 2010-05-21 21:34:30 UTC (rev 5931) @@ -842,6 +842,7 @@ csVector3 pos; float angle; csString sectorName; + iSector *sector = NULL; InstanceID instance; int count = 4; // For random positions we try 4 times before going with the result. @@ -850,27 +851,27 @@ // on the first try. while (spawnRule->DetermineSpawnLoc(chardata, pos, angle, sectorName, instance) && spawnRule->GetMinSpawnSpacingDistance() > 0.0 && count-- > 0) { - iSector *sector = psserver->entitymanager->GetEngine()->GetSectors()->FindByName(sectorName); + sector = psserver->entitymanager->GetEngine()->GetSectors()->FindByName(sectorName); csArray<gemObject*> nearlist = psserver->entitymanager->GetGEM()->FindNearbyEntities(sector, pos, spawnRule->GetMinSpawnSpacingDistance(), false); if (nearlist.IsEmpty()) { break; // Nothing in the neare list so spawn position is ok. } - Debug5(LOG_SPAWN,0,"Spawn position %s in %s is occuplied by %d entities. %s", - toString(pos).GetDataSafe(),sectorName.GetDataSafe(), + Debug4(LOG_SPAWN,0,"Spawn position %s is occuplied by %d entities. %s", + toString(pos,sector).GetDataSafe(), nearlist.GetSize(),count>0?" Will Retry":"Last try"); } Debug1(LOG_SPAWN,0,"Position accepted"); - Respawn(chardata, instance, pos, angle, sectorName); + Respawn(chardata, instance, pos, angle, sector); } -void SpawnManager::Respawn(psCharacter* chardata, InstanceID instance, csVector3& where, float rot, csString& sector) +void SpawnManager::Respawn(psCharacter* chardata, InstanceID instance, csVector3& where, float rot, iSector* sector) { - psSectorInfo* spawnsector = cacheManager->GetSectorInfoByName(sector); + psSectorInfo* spawnsector = cacheManager->GetSectorInfoByName(sector->QueryObject()->GetName()); if (spawnsector==NULL) { Error2("Spawn message indicated unresolvable sector '%s'\n",(const char*)sector); Modified: trunk/src/server/spawnmanager.h =================================================================== --- trunk/src/server/spawnmanager.h 2010-05-19 03:10:56 UTC (rev 5930) +++ trunk/src/server/spawnmanager.h 2010-05-21 21:34:30 UTC (rev 5931) @@ -375,7 +375,7 @@ /** * Respawn a NPC in the given position. */ - void Respawn(psCharacter* chardata, InstanceID instance, csVector3& where, float rot, csString& sector); + void Respawn(psCharacter* chardata, InstanceID instance, csVector3& where, float rot, iSector* sector); /// Adds all items to the world. /** Called at the server startup to add all the items to the game. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |