mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 03:45:35 +00:00
[General] Synchronize origin and orientation for magical projectiles
This commit is contained in:
parent
da079fcfd8
commit
f0a22495a2
7 changed files with 93 additions and 3 deletions
|
@ -274,6 +274,7 @@ void LocalActor::updateAttackOrCast()
|
|||
{
|
||||
mwmp::Main::get().getNetworking()->getActorList()->addCastActor(*this);
|
||||
cast.shouldSend = false;
|
||||
cast.hasProjectile = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -589,6 +589,7 @@ void LocalPlayer::updateAttackOrCast()
|
|||
getNetworking()->getPlayerPacket(ID_PLAYER_CAST)->Send();
|
||||
|
||||
cast.shouldSend = false;
|
||||
cast.hasProjectile = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -47,6 +47,16 @@
|
|||
#include "../mwphysics/physicssystem.hpp"
|
||||
#include "../mwphysics/projectile.hpp"
|
||||
|
||||
/*
|
||||
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)
|
||||
|
@ -278,6 +288,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;
|
||||
|
|
|
@ -85,6 +85,12 @@ namespace mwmp
|
|||
}
|
||||
};
|
||||
|
||||
struct ProjectileOrigin
|
||||
{
|
||||
float origin[3];
|
||||
float orientation[4];
|
||||
};
|
||||
|
||||
struct Target
|
||||
{
|
||||
bool isPlayer;
|
||||
|
@ -150,7 +156,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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue