1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-10-05 05:26:30 +00:00

Merge branch '0.8.1' of https://github.com/TES3MP/TES3MP into 0.8.1-vr

# Conflicts:
#	apps/openmw/mwworld/projectilemanager.cpp
This commit is contained in:
David Cernat 2022-05-01 22:01:57 +03:00
commit c90a9ab132
11 changed files with 185 additions and 5 deletions

View file

@ -274,6 +274,7 @@ void LocalActor::updateAttackOrCast()
{
mwmp::Main::get().getNetworking()->getActorList()->addCastActor(*this);
cast.shouldSend = false;
cast.hasProjectile = false;
}
}

View file

@ -589,6 +589,7 @@ void LocalPlayer::updateAttackOrCast()
getNetworking()->getPlayerPacket(ID_PLAYER_CAST)->Send();
cast.shouldSend = false;
cast.hasProjectile = false;
}
}

View file

@ -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);
}
}
};
}

View file

@ -17,8 +17,15 @@ namespace mwmp
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (player != 0)
MechanicsHelper::processCast(player->cast, 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::processCast(player->cast, playerPtr);
}
}
};
}

View file

@ -197,6 +197,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;
@ -235,6 +268,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;

View file

@ -52,6 +52,16 @@
#include "../mwvr/vranimation.hpp"
#endif
/*
Start of tes3mp addition
Include additional headers for multiplayer purposes
*/
#include "../mwmp/MechanicsHelper.hpp"
/*
End of tes3mp addition
*/
namespace
{
ESM::EffectList getMagicBoltData(std::vector<std::string>& projectileIDs, std::set<std::string>& sounds, float& speed, std::string& texture, std::string& sourceName, const std::string& id)
@ -292,6 +302,42 @@ namespace MWWorld
else
orient.makeRotate(osg::Vec3f(0,1,0), osg::Vec3f(fallbackDirection));
/*
Start of tes3mp addition
If the actor casting this is a LocalPlayer or LocalActor, track their projectile origin so it can be sent
in the next PlayerCast or ActorCast packet
Otherwise, set the projectileOrigin for a DedicatedPlayer or DedicatedActor
*/
mwmp::Cast* localCast = MechanicsHelper::getLocalCast(caster);
if (localCast)
{
localCast->hasProjectile = true;
localCast->projectileOrigin.origin[0] = pos.x();
localCast->projectileOrigin.origin[1] = pos.y();
localCast->projectileOrigin.origin[2] = pos.z();
localCast->projectileOrigin.orientation[0] = orient.x();
localCast->projectileOrigin.orientation[1] = orient.y();
localCast->projectileOrigin.orientation[2] = orient.z();
localCast->projectileOrigin.orientation[3] = orient.w();
}
else
{
mwmp::Cast* dedicatedCast = MechanicsHelper::getDedicatedCast(caster);
if (dedicatedCast)
{
pos = osg::Vec3f(dedicatedCast->projectileOrigin.origin[0], dedicatedCast->projectileOrigin.origin[1], dedicatedCast->projectileOrigin.origin[2]);
orient = osg::Quat(dedicatedCast->projectileOrigin.orientation[0], dedicatedCast->projectileOrigin.orientation[1], dedicatedCast->projectileOrigin.orientation[2],
dedicatedCast->projectileOrigin.orientation[3]);
}
}
/*
End of tes3mp addition
*/
MagicBoltState state;
state.mSpellId = spellId;
state.mCasterHandle = caster;

View file

@ -84,6 +84,12 @@ namespace mwmp
enchantmentCharge == rhs.enchantmentCharge && soul == rhs.soul;
}
};
struct ProjectileOrigin
{
float origin[3];
float orientation[4];
};
struct Target
{
@ -117,6 +123,7 @@ namespace mwmp
std::string rangedAmmoId;
ESM::Position hitPosition;
ProjectileOrigin projectileOrigin;
float damage = 0;
float attackStrength = 0;
@ -150,7 +157,8 @@ namespace mwmp
std::string spellId; // id of spell (e.g. "fireball")
std::string itemId;
ESM::Position hitPosition;
bool hasProjectile = false;
ProjectileOrigin projectileOrigin;
bool isHit;
bool success;

View file

@ -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)

View file

@ -36,4 +36,17 @@ void PacketActorCast::Actor(BaseActor &actor, bool send)
RW(actor.cast.instant, send);
RW(actor.cast.spellId, send, true);
}
RW(actor.cast.hasProjectile, send);
if (actor.cast.hasProjectile)
{
RW(actor.cast.projectileOrigin.origin[0], send);
RW(actor.cast.projectileOrigin.origin[1], send);
RW(actor.cast.projectileOrigin.origin[2], send);
RW(actor.cast.projectileOrigin.orientation[0], send);
RW(actor.cast.projectileOrigin.orientation[1], send);
RW(actor.cast.projectileOrigin.orientation[2], send);
RW(actor.cast.projectileOrigin.orientation[3], send);
}
}

View file

@ -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)

View file

@ -39,4 +39,19 @@ void PacketPlayerCast::Packet(RakNet::BitStream *newBitstream, bool send)
RW(player->cast.instant, send);
RW(player->cast.spellId, send, true);
}
RW(player->cast.hasProjectile, send);
if (player->cast.hasProjectile)
{
RW(player->cast.projectileOrigin.origin[0], send);
RW(player->cast.projectileOrigin.origin[1], send);
RW(player->cast.projectileOrigin.origin[2], send);
RW(player->cast.projectileOrigin.orientation[0], send);
RW(player->cast.projectileOrigin.orientation[1], send);
RW(player->cast.projectileOrigin.orientation[2], send);
RW(player->cast.projectileOrigin.orientation[3], send);
RW(player->position, send);
RW(player->direction, send);
}
}