|
|
|
@ -143,13 +143,52 @@ Cast *MechanicsHelper::getDedicatedCast(const MWWorld::Ptr& ptr)
|
|
|
|
|
MWWorld::Ptr MechanicsHelper::getPlayerPtr(const Target& target)
|
|
|
|
|
{
|
|
|
|
|
if (target.guid == mwmp::Main::get().getLocalPlayer()->guid)
|
|
|
|
|
{
|
|
|
|
|
return MWMechanics::getPlayer();
|
|
|
|
|
else if (PlayerList::getPlayer(target.guid) != nullptr)
|
|
|
|
|
return PlayerList::getPlayer(target.guid)->getPtr();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mwmp::DedicatedPlayer* dedicatedPlayer = mwmp::PlayerList::getPlayer(target.guid);
|
|
|
|
|
|
|
|
|
|
if (dedicatedPlayer != nullptr)
|
|
|
|
|
{
|
|
|
|
|
return dedicatedPlayer->getPtr();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned int MechanicsHelper::getActorId(const mwmp::Target& target)
|
|
|
|
|
{
|
|
|
|
|
int actorId = -1;
|
|
|
|
|
MWWorld::Ptr targetPtr;
|
|
|
|
|
|
|
|
|
|
if (target.isPlayer)
|
|
|
|
|
{
|
|
|
|
|
targetPtr = getPlayerPtr(target);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
auto controller = mwmp::Main::get().getCellController();
|
|
|
|
|
if (controller->isLocalActor(target.refNum, target.mpNum))
|
|
|
|
|
{
|
|
|
|
|
targetPtr = controller->getLocalActor(target.refNum, target.mpNum)->getPtr();
|
|
|
|
|
}
|
|
|
|
|
else if (controller->isDedicatedActor(target.refNum, target.mpNum))
|
|
|
|
|
{
|
|
|
|
|
targetPtr = controller->getDedicatedActor(target.refNum, target.mpNum)->getPtr();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (targetPtr)
|
|
|
|
|
{
|
|
|
|
|
actorId = targetPtr.getClass().getCreatureStats(targetPtr).getActorId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return actorId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mwmp::Item MechanicsHelper::getItem(const MWWorld::Ptr& itemPtr, int count)
|
|
|
|
|
{
|
|
|
|
|
mwmp::Item item;
|
|
|
|
|