mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-01 01:51:34 +00:00
[General] Implement OnObjectHit packet, part 3
Include damage, block states and knockdown states in ObjectHit packets about successful hits. Add serverside script functions for reading that information.
This commit is contained in:
parent
c18aab5357
commit
32c7406eda
3 changed files with 52 additions and 0 deletions
|
@ -189,6 +189,21 @@ bool ObjectFunctions::GetObjectHitSuccess(unsigned int index) noexcept
|
|||
return readObjectList->baseObjects.at(index).hitAttack.success;
|
||||
}
|
||||
|
||||
double ObjectFunctions::GetObjectHitDamage(unsigned int index) noexcept
|
||||
{
|
||||
return readObjectList->baseObjects.at(index).hitAttack.damage;
|
||||
}
|
||||
|
||||
bool ObjectFunctions::GetObjectHitBlock(unsigned int index) noexcept
|
||||
{
|
||||
return readObjectList->baseObjects.at(index).hitAttack.block;
|
||||
}
|
||||
|
||||
bool ObjectFunctions::GetObjectHitKnockdown(unsigned int index) noexcept
|
||||
{
|
||||
return readObjectList->baseObjects.at(index).hitAttack.knockdown;
|
||||
}
|
||||
|
||||
bool ObjectFunctions::DoesObjectHavePlayerHitting(unsigned int index) noexcept
|
||||
{
|
||||
return readObjectList->baseObjects.at(index).hittingActor.isPlayer;
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
{"GetObjectActivatingName", ObjectFunctions::GetObjectActivatingName},\
|
||||
\
|
||||
{"GetObjectHitSuccess", ObjectFunctions::GetObjectHitSuccess},\
|
||||
{"GetObjectHitDamage", ObjectFunctions::GetObjectHitDamage},\
|
||||
{"GetObjectHitBlock", ObjectFunctions::GetObjectHitBlock},\
|
||||
{"GetObjectHitKnockdown", ObjectFunctions::GetObjectHitKnockdown},\
|
||||
{"DoesObjectHavePlayerHitting", ObjectFunctions::DoesObjectHavePlayerHitting},\
|
||||
{"GetObjectHittingPid", ObjectFunctions::GetObjectHittingPid},\
|
||||
{"GetObjectHittingRefId", ObjectFunctions::GetObjectHittingRefId},\
|
||||
|
@ -427,6 +430,33 @@ public:
|
|||
*/
|
||||
static bool GetObjectHitSuccess(unsigned int index) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Get the damage caused to the object at a certain index in the read object list
|
||||
* in a hit.
|
||||
*
|
||||
* \param index The index of the object.
|
||||
* \return The damage.
|
||||
*/
|
||||
static double GetObjectHitDamage(unsigned int index) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Check whether the object at a certain index in the read object list has
|
||||
* blocked the hit on it.
|
||||
*
|
||||
* \param index The index of the object.
|
||||
* \return The block state.
|
||||
*/
|
||||
static bool GetObjectHitBlock(unsigned int index) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Check whether the object at a certain index in the read object list has been
|
||||
* knocked down.
|
||||
*
|
||||
* \param index The index of the object.
|
||||
* \return The knockdown state.
|
||||
*/
|
||||
static bool GetObjectHitKnockdown(unsigned int index) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Check whether the object at a certain index in the read object list has been
|
||||
* hit by a player.
|
||||
|
|
|
@ -44,6 +44,13 @@ void PacketObjectHit::Packet(RakNet::BitStream *newBitstream, bool send)
|
|||
|
||||
RW(baseObject.hitAttack.success, send);
|
||||
|
||||
if (baseObject.hitAttack.success)
|
||||
{
|
||||
RW(baseObject.hitAttack.damage, send);
|
||||
RW(baseObject.hitAttack.block, send);
|
||||
RW(baseObject.hitAttack.knockdown, send);
|
||||
}
|
||||
|
||||
if (!send)
|
||||
objectList->baseObjects.push_back(baseObject);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue