* implemented basic targeting. new DefScript command: "target <name>". works only on players for now, and name must be exact.
This commit is contained in:
parent
1da69e7873
commit
6df34baf6a
@ -79,6 +79,7 @@ DefScriptFunctionTable *DefScriptPackage::_GetFunctionTable(void) const
|
||||
{"logdebug",&DefScriptPackage::SClogdebug},
|
||||
{"castspell", &DefScriptPackage::SCcastspell},
|
||||
{"queryitem", &DefScriptPackage::SCqueryitem},
|
||||
{"target", &DefScriptPackage::SCtarget},
|
||||
|
||||
// table termination
|
||||
{NULL,NULL}
|
||||
|
||||
@ -162,6 +162,7 @@ private:
|
||||
bool SClogerror(CmdSet);
|
||||
bool SCcastspell(CmdSet);
|
||||
bool SCqueryitem(CmdSet);
|
||||
bool SCtarget(CmdSet);
|
||||
|
||||
// Own variable declarations
|
||||
std::map<std::string, unsigned char> my_usrPermissionMap;
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "SharedDefines.h"
|
||||
#include "WorldSession.h"
|
||||
#include "Channel.h"
|
||||
#include "CacheHandler.h"
|
||||
|
||||
bool DefScriptPackage::SCshdn(CmdSet Set)
|
||||
{
|
||||
@ -208,6 +209,35 @@ bool DefScriptPackage::SCqueryitem(CmdSet Set){
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefScriptPackage::SCtarget(CmdSet Set)
|
||||
{
|
||||
// TODO: special targets: _self _pet _nearest ...
|
||||
|
||||
if(!(((PseuInstance*)parentMethod)->GetWSession() && ((PseuInstance*)parentMethod)->GetWSession()->IsValid()))
|
||||
{
|
||||
logerror("Invalid Script call: SCtarget: WorldSession not valid");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Set.defaultarg.empty())
|
||||
{
|
||||
((PseuInstance*)parentMethod)->GetWSession()->SendSetSelection(0); // no target
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: search through all objects. for now only allow to target player
|
||||
uint64 guid = (((PseuInstance*)parentMethod)->GetWSession()->plrNameCache.GetGuid(Set.defaultarg));
|
||||
|
||||
if( guid && ((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid) ) // object must be near
|
||||
((PseuInstance*)parentMethod)->GetWSession()->SendSetSelection(guid);
|
||||
else
|
||||
logdetail("Target '%s' not found!",Set.defaultarg.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DefScriptPackage::My_LoadUserPermissions(VarSet &vs)
|
||||
{
|
||||
static char *prefix = "USERS::";
|
||||
|
||||
@ -77,6 +77,15 @@ void WorldSession::SendQueryItem(uint32 id, uint64 guid) // is it a guid? not su
|
||||
// to prevent opcode spam, we need to make a list with already requested items
|
||||
}
|
||||
|
||||
void WorldSession::SendSetSelection(uint64 guid)
|
||||
{
|
||||
// TODO: MyCharacter.SetTarget(guid);
|
||||
logdebug("SetSelection GUID="I64FMT,guid);
|
||||
WorldPacket packet;
|
||||
packet << guid;
|
||||
packet.SetOpcode(CMSG_SET_SELECTION);
|
||||
SendWorldPacket(packet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -60,6 +60,7 @@ public:
|
||||
void SendPing(uint32);
|
||||
void SendEmote(uint32);
|
||||
void SendQueryItem(uint32, uint64);
|
||||
void SendSetSelection(uint64);
|
||||
|
||||
PlayerNameCache plrNameCache;
|
||||
ObjMgr objmgr;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user