1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:19:56 +00:00

[Client] Add MechanicsHelper::assignAttackTarget()

This commit is contained in:
David Cernat 2017-04-19 11:05:13 +03:00
parent 17c4b6d4de
commit c3375ba86f
3 changed files with 22 additions and 3 deletions

View file

@ -54,7 +54,24 @@ Attack *MechanicsHelper::getDedicatedAttack(const MWWorld::Ptr& ptr)
return NULL;
}
void MechanicsHelper::processAttack(const MWWorld::Ptr& attacker, Attack attack)
void MechanicsHelper::assignAttackTarget(Attack* attack, const MWWorld::Ptr& target)
{
if (mwmp::PlayerList::isDedicatedPlayer(target))
{
attack->target.guid = mwmp::PlayerList::getPlayer(target)->guid;
attack->target.refId.clear();
}
else
{
MWWorld::CellRef *targetRef = &target.getCellRef();
attack->target.refId = targetRef->getRefId();
attack->target.refNumIndex = targetRef->getRefNum().mIndex;
attack->target.mpNum = targetRef->getMpNum();
}
}
void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
{
if (attack.pressed == false)
{

View file

@ -19,7 +19,9 @@ namespace mwmp
Attack *getLocalAttack(const MWWorld::Ptr& ptr);
Attack *getDedicatedAttack(const MWWorld::Ptr& ptr);
void processAttack(const MWWorld::Ptr& attacker, Attack attack);
void assignAttackTarget(Attack* attack, const MWWorld::Ptr& target);
void processAttack(Attack attack, const MWWorld::Ptr& attacker);
};
}

View file

@ -27,7 +27,7 @@ namespace mwmp
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
Main::get().getMechanicsHelper()->processAttack(static_cast<DedicatedPlayer*>(player)->getPtr(), player->attack);
Main::get().getMechanicsHelper()->processAttack(player->attack, static_cast<DedicatedPlayer*>(player)->getPtr());
}
};
}