|
|
@ -86,13 +86,10 @@ Attack *MechanicsHelper::getDedicatedAttack(const MWWorld::Ptr& ptr)
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr MechanicsHelper::getPlayerPtr(const Target& target)
|
|
|
|
MWWorld::Ptr MechanicsHelper::getPlayerPtr(const Target& target)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (target.refId.empty())
|
|
|
|
if (target.guid == mwmp::Main::get().getLocalPlayer()->guid)
|
|
|
|
{
|
|
|
|
return MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
|
|
if (target.guid == mwmp::Main::get().getLocalPlayer()->guid)
|
|
|
|
else if (PlayerList::getPlayer(target.guid) != nullptr)
|
|
|
|
return MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
|
|
return PlayerList::getPlayer(target.guid)->getPtr();
|
|
|
|
else if (PlayerList::getPlayer(target.guid) != nullptr)
|
|
|
|
|
|
|
|
return PlayerList::getPlayer(target.guid)->getPtr();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -101,18 +98,19 @@ void MechanicsHelper::assignAttackTarget(Attack* attack, const MWWorld::Ptr& tar
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
|
|
|
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
attack->target.isPlayer = true;
|
|
|
|
attack->target.guid = mwmp::Main::get().getLocalPlayer()->guid;
|
|
|
|
attack->target.guid = mwmp::Main::get().getLocalPlayer()->guid;
|
|
|
|
attack->target.refId.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mwmp::PlayerList::isDedicatedPlayer(target))
|
|
|
|
else if (mwmp::PlayerList::isDedicatedPlayer(target))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
attack->target.isPlayer = true;
|
|
|
|
attack->target.guid = mwmp::PlayerList::getPlayer(target)->guid;
|
|
|
|
attack->target.guid = mwmp::PlayerList::getPlayer(target)->guid;
|
|
|
|
attack->target.refId.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWWorld::CellRef *targetRef = &target.getCellRef();
|
|
|
|
MWWorld::CellRef *targetRef = &target.getCellRef();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
attack->target.isPlayer = false;
|
|
|
|
attack->target.refId = targetRef->getRefId();
|
|
|
|
attack->target.refId = targetRef->getRefId();
|
|
|
|
attack->target.refNumIndex = targetRef->getRefNum().mIndex;
|
|
|
|
attack->target.refNumIndex = targetRef->getRefNum().mIndex;
|
|
|
|
attack->target.mpNum = targetRef->getMpNum();
|
|
|
|
attack->target.mpNum = targetRef->getMpNum();
|
|
|
@ -128,6 +126,8 @@ void MechanicsHelper::resetAttack(Attack* attack)
|
|
|
|
attack->applyProjectileEnchantment = false;
|
|
|
|
attack->applyProjectileEnchantment = false;
|
|
|
|
attack->target.guid = RakNet::RakNetGUID();
|
|
|
|
attack->target.guid = RakNet::RakNetGUID();
|
|
|
|
attack->target.refId.clear();
|
|
|
|
attack->target.refId.clear();
|
|
|
|
|
|
|
|
attack->target.refNumIndex = 0;
|
|
|
|
|
|
|
|
attack->target.mpNum = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MechanicsHelper::getSpellSuccess(std::string spellId, const MWWorld::Ptr& caster)
|
|
|
|
bool MechanicsHelper::getSpellSuccess(std::string spellId, const MWWorld::Ptr& caster)
|
|
|
@ -152,7 +152,7 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr victim;
|
|
|
|
MWWorld::Ptr victim;
|
|
|
|
|
|
|
|
|
|
|
|
if (attack.target.refId.empty())
|
|
|
|
if (attack.target.isPlayer)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (attack.target.guid == mwmp::Main::get().getLocalPlayer()->guid)
|
|
|
|
if (attack.target.guid == mwmp::Main::get().getLocalPlayer()->guid)
|
|
|
|
victim = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
|
|
victim = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
|
|