[General] Include hit position in PlayerAttack and ActorAttack packets

fix/skillcap
David Cernat 6 years ago
parent dcd4478028
commit 8012d0d7b7

@ -300,14 +300,15 @@ namespace MWClass
/*
Start of tes3mp addition
If the attacker is a LocalPlayer or LocalActor, get their Attack and
assign data for its target
If the attacker is a LocalPlayer or LocalActor, get their Attack to assign its
hit position and target
*/
mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(ptr);
if (localAttack)
{
localAttack->success = true;
localAttack->hitPosition = MechanicsHelper::getPositionFromVector(hitPosition);
MechanicsHelper::assignAttackTarget(localAttack, victim);
}
/*

@ -628,14 +628,15 @@ namespace MWClass
/*
Start of tes3mp addition
If the attacker is a LocalPlayer or LocalActor, get their Attack and
assign data for its target
If the attacker is a LocalPlayer or LocalActor, get their Attack to assign its
hit position and target
*/
mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(ptr);
if (localAttack)
{
localAttack->success = true;
localAttack->hitPosition = MechanicsHelper::getPositionFromVector(hitPosition);
MechanicsHelper::assignAttackTarget(localAttack, victim);
}
/*

@ -31,6 +31,16 @@ osg::Vec3f MechanicsHelper::getLinearInterpolation(osg::Vec3f start, osg::Vec3f
return (start + osg::componentMultiply(position, (end - start)));
}
ESM::Position MechanicsHelper::getPositionFromVector(osg::Vec3f vector)
{
ESM::Position position;
position.pos[0] = vector.x();
position.pos[1] = vector.y();
position.pos[2] = vector.z();
return position;
}
// Inspired by similar code in mwclass\creaturelevlist.cpp
void MechanicsHelper::spawnLeveledCreatures(MWWorld::CellStore* cellStore)
{
@ -263,19 +273,19 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
if (attack.applyWeaponEnchantment)
{
MWMechanics::CastSpell cast(attacker, victim, false);
cast.mHitPosition = osg::Vec3f();
cast.mHitPosition = attack.hitPosition.asVec3();
cast.cast(weapon, false);
}
if (attack.applyProjectileEnchantment)
{
MWMechanics::CastSpell cast(attacker, victim, false);
cast.mHitPosition = osg::Vec3f();
cast.mHitPosition = attack.hitPosition.asVec3();
cast.cast(projectile, false);
}
}
victim.getClass().onHit(victim, attack.damage, healthdmg, weapon, attacker, osg::Vec3f(),
victim.getClass().onHit(victim, attack.damage, healthdmg, weapon, attacker, attack.hitPosition.asVec3(),
attack.success);
}
}

@ -11,6 +11,7 @@
namespace MechanicsHelper
{
osg::Vec3f getLinearInterpolation(osg::Vec3f start, osg::Vec3f end, float percent);
ESM::Position getPositionFromVector(osg::Vec3f vector);
void spawnLeveledCreatures(MWWorld::CellStore* cellStore);

@ -3,6 +3,7 @@
#include <string>
#include <components/esm/loadcell.hpp>
#include <components/esm/statstate.hpp>
#include <RakNetTypes.h>
@ -76,6 +77,8 @@ namespace mwmp
std::string spellId; // id of spell (e.g. "fireball")
std::string itemId;
ESM::Position hitPosition;
float damage;
bool success;

@ -31,6 +31,13 @@ void PacketActorAttack::Actor(BaseActor &actor, bool send)
RW(actor.attack.pressed, send);
RW(actor.attack.success, send);
if (actor.attack.success)
{
RW(actor.attack.hitPosition.pos[0], send);
RW(actor.attack.hitPosition.pos[1], send);
RW(actor.attack.hitPosition.pos[2], send);
}
if (actor.attack.type == mwmp::Attack::MELEE)
{
RW(actor.attack.damage, send);

@ -32,6 +32,13 @@ void PacketPlayerAttack::Packet(RakNet::BitStream *bs, bool send)
RW(player->attack.pressed, send);
RW(player->attack.success, send);
if (player->attack.success)
{
RW(player->attack.hitPosition.pos[0], send);
RW(player->attack.hitPosition.pos[1], send);
RW(player->attack.hitPosition.pos[2], send);
}
if (player->attack.type == mwmp::Attack::MELEE)
{
RW(player->attack.damage, send);

Loading…
Cancel
Save