forked from teamnwah/openmw-tes3coop
[Client] Add MechanicsHelper::assignAttackTarget()
This commit is contained in:
parent
17c4b6d4de
commit
c3375ba86f
3 changed files with 22 additions and 3 deletions
|
@ -54,7 +54,24 @@ Attack *MechanicsHelper::getDedicatedAttack(const MWWorld::Ptr& ptr)
|
||||||
return NULL;
|
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)
|
if (attack.pressed == false)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,9 @@ namespace mwmp
|
||||||
Attack *getLocalAttack(const MWWorld::Ptr& ptr);
|
Attack *getLocalAttack(const MWWorld::Ptr& ptr);
|
||||||
Attack *getDedicatedAttack(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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace mwmp
|
||||||
|
|
||||||
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
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());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue