mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 21:19:40 +00:00
[General] Synchronize origin and orientation for non-magical projectiles
This commit is contained in:
parent
f0a22495a2
commit
a7eeba03a1
5 changed files with 92 additions and 2 deletions
|
@ -17,8 +17,15 @@ namespace mwmp
|
|||
|
||||
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
||||
{
|
||||
if (player != 0)
|
||||
MechanicsHelper::processAttack(player->attack, static_cast<DedicatedPlayer*>(player)->getPtr());
|
||||
if (!isLocal() && player != 0)
|
||||
{
|
||||
DedicatedPlayer& dedicatedPlayer = static_cast<DedicatedPlayer&>(*player);
|
||||
MWWorld::Ptr playerPtr = dedicatedPlayer.getPtr();
|
||||
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||
world->moveObject(playerPtr, dedicatedPlayer.position.pos[0], dedicatedPlayer.position.pos[1], dedicatedPlayer.position.pos[2]);
|
||||
world->rotateObject(playerPtr, dedicatedPlayer.position.rot[0], 0, dedicatedPlayer.position.rot[2]);
|
||||
MechanicsHelper::processAttack(player->attack, playerPtr);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -184,6 +184,39 @@ void WeaponAnimation::releaseArrow(MWWorld::Ptr actor, float attackStrength)
|
|||
return;
|
||||
osg::Vec3f launchPos = osg::computeLocalToWorld(nodepaths[0]).getTrans();
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
If the actor shooting this is a LocalPlayer or LocalActor, track their projectile origin so it can be sent
|
||||
in the next PlayerAttack or ActorAttack packet
|
||||
|
||||
Otherwise, set the projectileOrigin for a DedicatedPlayer or DedicatedActor
|
||||
*/
|
||||
if (localAttack)
|
||||
{
|
||||
localAttack->projectileOrigin.origin[0] = launchPos.x();
|
||||
localAttack->projectileOrigin.origin[1] = launchPos.y();
|
||||
localAttack->projectileOrigin.origin[2] = launchPos.z();
|
||||
localAttack->projectileOrigin.orientation[0] = orient.x();
|
||||
localAttack->projectileOrigin.orientation[1] = orient.y();
|
||||
localAttack->projectileOrigin.orientation[2] = orient.z();
|
||||
localAttack->projectileOrigin.orientation[3] = orient.w();
|
||||
}
|
||||
else
|
||||
{
|
||||
mwmp::Attack* dedicatedAttack = MechanicsHelper::getDedicatedAttack(actor);
|
||||
|
||||
if (dedicatedAttack)
|
||||
{
|
||||
launchPos = osg::Vec3f(dedicatedAttack->projectileOrigin.origin[0], dedicatedAttack->projectileOrigin.origin[1], dedicatedAttack->projectileOrigin.origin[2]);
|
||||
orient = osg::Quat(dedicatedAttack->projectileOrigin.orientation[0], dedicatedAttack->projectileOrigin.orientation[1], dedicatedAttack->projectileOrigin.orientation[2],
|
||||
dedicatedAttack->projectileOrigin.orientation[3]);
|
||||
}
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
float fThrownWeaponMinSpeed = gmst.find("fThrownWeaponMinSpeed")->mValue.getFloat();
|
||||
float fThrownWeaponMaxSpeed = gmst.find("fThrownWeaponMaxSpeed")->mValue.getFloat();
|
||||
float speed = fThrownWeaponMinSpeed + (fThrownWeaponMaxSpeed - fThrownWeaponMinSpeed) * attackStrength;
|
||||
|
@ -222,6 +255,39 @@ void WeaponAnimation::releaseArrow(MWWorld::Ptr actor, float attackStrength)
|
|||
return;
|
||||
osg::Vec3f launchPos = osg::computeLocalToWorld(nodepaths[0]).getTrans();
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
If the actor shooting this is a LocalPlayer or LocalActor, track their projectile origin so it can be sent
|
||||
in the next PlayerAttack or ActorAttack packet
|
||||
|
||||
Otherwise, set the projectileOrigin for a DedicatedPlayer or DedicatedActor
|
||||
*/
|
||||
if (localAttack)
|
||||
{
|
||||
localAttack->projectileOrigin.origin[0] = launchPos.x();
|
||||
localAttack->projectileOrigin.origin[1] = launchPos.y();
|
||||
localAttack->projectileOrigin.origin[2] = launchPos.z();
|
||||
localAttack->projectileOrigin.orientation[0] = orient.x();
|
||||
localAttack->projectileOrigin.orientation[1] = orient.y();
|
||||
localAttack->projectileOrigin.orientation[2] = orient.z();
|
||||
localAttack->projectileOrigin.orientation[3] = orient.w();
|
||||
}
|
||||
else
|
||||
{
|
||||
mwmp::Attack* dedicatedAttack = MechanicsHelper::getDedicatedAttack(actor);
|
||||
|
||||
if (dedicatedAttack)
|
||||
{
|
||||
launchPos = osg::Vec3f(dedicatedAttack->projectileOrigin.origin[0], dedicatedAttack->projectileOrigin.origin[1], dedicatedAttack->projectileOrigin.origin[2]);
|
||||
orient = osg::Quat(dedicatedAttack->projectileOrigin.orientation[0], dedicatedAttack->projectileOrigin.orientation[1], dedicatedAttack->projectileOrigin.orientation[2],
|
||||
dedicatedAttack->projectileOrigin.orientation[3]);
|
||||
}
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
float fProjectileMinSpeed = gmst.find("fProjectileMinSpeed")->mValue.getFloat();
|
||||
float fProjectileMaxSpeed = gmst.find("fProjectileMaxSpeed")->mValue.getFloat();
|
||||
float speed = fProjectileMinSpeed + (fProjectileMaxSpeed - fProjectileMinSpeed) * attackStrength;
|
||||
|
|
|
@ -123,6 +123,7 @@ namespace mwmp
|
|||
std::string rangedAmmoId;
|
||||
|
||||
ESM::Position hitPosition;
|
||||
ProjectileOrigin projectileOrigin;
|
||||
|
||||
float damage = 0;
|
||||
float attackStrength = 0;
|
||||
|
|
|
@ -40,6 +40,14 @@ void PacketActorAttack::Actor(BaseActor &actor, bool send)
|
|||
RW(actor.attack.attackStrength, send);
|
||||
RW(actor.attack.rangedWeaponId, send, true);
|
||||
RW(actor.attack.rangedAmmoId, send, true);
|
||||
|
||||
RW(actor.attack.projectileOrigin.origin[0], send);
|
||||
RW(actor.attack.projectileOrigin.origin[1], send);
|
||||
RW(actor.attack.projectileOrigin.origin[2], send);
|
||||
RW(actor.attack.projectileOrigin.orientation[0], send);
|
||||
RW(actor.attack.projectileOrigin.orientation[1], send);
|
||||
RW(actor.attack.projectileOrigin.orientation[2], send);
|
||||
RW(actor.attack.projectileOrigin.orientation[3], send);
|
||||
}
|
||||
|
||||
if (actor.attack.isHit)
|
||||
|
|
|
@ -41,6 +41,14 @@ void PacketPlayerAttack::Packet(RakNet::BitStream *newBitstream, bool send)
|
|||
RW(player->attack.attackStrength, send);
|
||||
RW(player->attack.rangedWeaponId, send, true);
|
||||
RW(player->attack.rangedAmmoId, send, true);
|
||||
|
||||
RW(player->attack.projectileOrigin.origin[0], send);
|
||||
RW(player->attack.projectileOrigin.origin[1], send);
|
||||
RW(player->attack.projectileOrigin.origin[2], send);
|
||||
RW(player->attack.projectileOrigin.orientation[0], send);
|
||||
RW(player->attack.projectileOrigin.orientation[1], send);
|
||||
RW(player->attack.projectileOrigin.orientation[2], send);
|
||||
RW(player->attack.projectileOrigin.orientation[3], send);
|
||||
}
|
||||
|
||||
if (player->attack.isHit)
|
||||
|
|
Loading…
Reference in a new issue