forked from mirror/openmw-tes3mp
[General] Add & implement PlayerShapeshift packet for werewolf states
This commit is contained in:
parent
f17aa2a323
commit
43a3daf0aa
18 changed files with 195 additions and 58 deletions
|
@ -131,9 +131,10 @@ set(PROCESSORS_PLAYER
|
|||
processors/player/ProcessorPlayerJournal.hpp processors/player/ProcessorPlayerKillCount.hpp
|
||||
processors/player/ProcessorPlayerLevel.hpp processors/player/ProcessorPlayerMap.hpp
|
||||
processors/player/ProcessorPlayerPosition.hpp processors/player/ProcessorPlayerRest.hpp
|
||||
processors/player/ProcessorPlayerResurrect.hpp processors/player/ProcessorPlayerSkill.hpp
|
||||
processors/player/ProcessorPlayerSpeech.hpp processors/player/ProcessorPlayerSpellbook.hpp
|
||||
processors/player/ProcessorPlayerStatsDynamic.hpp processors/player/ProcessorPlayerTopic.hpp
|
||||
processors/player/ProcessorPlayerResurrect.hpp processors/player/ProcessorPlayerShapeshift.hpp
|
||||
processors/player/ProcessorPlayerSkill.hpp processors/player/ProcessorPlayerSpeech.hpp
|
||||
processors/player/ProcessorPlayerSpellbook.hpp processors/player/ProcessorPlayerStatsDynamic.hpp
|
||||
processors/player/ProcessorPlayerTopic.hpp
|
||||
)
|
||||
|
||||
source_group(tes3mp-server\\processors\\player FILES ${PROCESSORS_PLAYER})
|
||||
|
|
|
@ -145,6 +145,7 @@ public:
|
|||
{"OnPlayerInventory", Function<void, unsigned short>()},
|
||||
{"OnPlayerJournal", Function<void, unsigned short>()},
|
||||
{"OnPlayerFaction", Function<void, unsigned short>()},
|
||||
{"OnPlayerShapeshift", Function<void, unsigned short>()},
|
||||
{"OnPlayerSpellbook", Function<void, unsigned short>()},
|
||||
{"OnPlayerTopic", Function<void, unsigned short>()},
|
||||
{"OnPlayerDisposition", Function<void, unsigned short>()},
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "player/ProcessorPlayerPosition.hpp"
|
||||
#include "player/ProcessorPlayerRest.hpp"
|
||||
#include "player/ProcessorPlayerResurrect.hpp"
|
||||
#include "player/ProcessorPlayerShapeshift.hpp"
|
||||
#include "player/ProcessorPlayerSkill.hpp"
|
||||
#include "player/ProcessorPlayerSpeech.hpp"
|
||||
#include "player/ProcessorPlayerSpellbook.hpp"
|
||||
|
@ -101,6 +102,7 @@ void ProcessorInitializer()
|
|||
PlayerProcessor::AddProcessor(new ProcessorPlayerPosition());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerRest());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerResurrect());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerShapeshift());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerSkill());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerSpeech());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerSpellbook());
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP
|
||||
#define OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP
|
||||
|
||||
#include "../PlayerProcessor.hpp"
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class ProcessorPlayerShapeshift : public PlayerProcessor
|
||||
{
|
||||
public:
|
||||
ProcessorPlayerShapeshift()
|
||||
{
|
||||
BPP_INIT(ID_PLAYER_SHAPESHIFT)
|
||||
}
|
||||
|
||||
void Do(PlayerPacket &packet, Player &player) override
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
|
||||
|
||||
packet.Send(true);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerShapeshift")>(player.getId());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP
|
|
@ -117,8 +117,8 @@ add_openmw_dir (mwmp/processors/player ProcessorChatMessage ProcessorGUIMessageB
|
|||
ProcessorPlayerBook ProcessorPlayerBounty ProcessorPlayerCellChange ProcessorPlayerCellState ProcessorPlayerCharClass
|
||||
ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerDisposition ProcessorPlayerEquipment ProcessorPlayerFaction
|
||||
ProcessorPlayerInventory ProcessorPlayerJail ProcessorPlayerJournal ProcessorPlayerKillCount ProcessorPlayerLevel
|
||||
ProcessorPlayerMap ProcessorPlayerPosition ProcessorPlayerResurrect ProcessorPlayerSkill ProcessorPlayerSpeech
|
||||
ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic ProcessorPlayerTopic
|
||||
ProcessorPlayerMap ProcessorPlayerPosition ProcessorPlayerResurrect ProcessorPlayerShapeshift ProcessorPlayerSkill
|
||||
ProcessorPlayerSpeech ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic ProcessorPlayerTopic
|
||||
)
|
||||
|
||||
add_openmw_dir (mwmp/processors/world BaseObjectProcessor ProcessorConsoleCommand ProcessorContainer ProcessorDoorState
|
||||
|
|
|
@ -237,6 +237,11 @@ void DedicatedPlayer::setCell()
|
|||
Main::get().getCellController()->getCell(cell)->updateLocal(true);
|
||||
}
|
||||
|
||||
void DedicatedPlayer::setShapeshift()
|
||||
{
|
||||
MWBase::Environment::get().getMechanicsManager()->setWerewolf(ptr, isWerewolf);
|
||||
}
|
||||
|
||||
void DedicatedPlayer::updateMarker()
|
||||
{
|
||||
if (!markerEnabled)
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace mwmp
|
|||
void setAnimFlags();
|
||||
void setEquipment();
|
||||
void setCell();
|
||||
void setShapeshift();
|
||||
|
||||
void updateMarker();
|
||||
void removeMarker();
|
||||
|
|
|
@ -149,8 +149,8 @@ bool LocalPlayer::charGenThread()
|
|||
else if (charGenStage.end != 0)
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
npc = *player.get<ESM::NPC>()->mBase;
|
||||
MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
|
||||
npc = *ptrPlayer.get<ESM::NPC>()->mBase;
|
||||
birthsign = world->getPlayer().getBirthSign();
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_BASEINFO to server with my CharGen info");
|
||||
|
@ -187,9 +187,9 @@ bool LocalPlayer::hasFinishedCharGen()
|
|||
|
||||
void LocalPlayer::updateStatsDynamic(bool forceUpdate)
|
||||
{
|
||||
MWWorld::Ptr player = getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
|
||||
MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player);
|
||||
MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
|
||||
MWMechanics::DynamicStat<float> health(ptrCreatureStats->getHealth());
|
||||
MWMechanics::DynamicStat<float> magicka(ptrCreatureStats->getMagicka());
|
||||
MWMechanics::DynamicStat<float> fatigue(ptrCreatureStats->getFatigue());
|
||||
|
@ -223,8 +223,8 @@ void LocalPlayer::updateStatsDynamic(bool forceUpdate)
|
|||
|
||||
void LocalPlayer::updateAttributes(bool forceUpdate)
|
||||
{
|
||||
MWWorld::Ptr player = getPlayerPtr();
|
||||
const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player);
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
const MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
bool attributesChanged = false;
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
|
@ -245,8 +245,8 @@ void LocalPlayer::updateAttributes(bool forceUpdate)
|
|||
|
||||
void LocalPlayer::updateSkills(bool forceUpdate)
|
||||
{
|
||||
MWWorld::Ptr player = getPlayerPtr();
|
||||
const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player);
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
const MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
|
||||
// Track whether skills have changed their values, but not whether
|
||||
// progress towards skill increases has changed (to not spam server
|
||||
|
@ -282,8 +282,8 @@ void LocalPlayer::updateSkills(bool forceUpdate)
|
|||
|
||||
void LocalPlayer::updateLevel(bool forceUpdate)
|
||||
{
|
||||
MWWorld::Ptr player = getPlayerPtr();
|
||||
const MWMechanics::CreatureStats &ptrCreatureStats = player.getClass().getCreatureStats(player);
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
const MWMechanics::CreatureStats &ptrCreatureStats = ptrPlayer.getClass().getCreatureStats(ptrPlayer);
|
||||
|
||||
if (ptrCreatureStats.getLevel() != creatureStats.mLevel || forceUpdate)
|
||||
{
|
||||
|
@ -299,8 +299,8 @@ void LocalPlayer::updateLevel(bool forceUpdate)
|
|||
|
||||
void LocalPlayer::updateBounty(bool forceUpdate)
|
||||
{
|
||||
MWWorld::Ptr player = getPlayerPtr();
|
||||
const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player);
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
const MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
|
||||
if (ptrNpcStats.getBounty() != npcStats.mBounty || forceUpdate)
|
||||
{
|
||||
|
@ -313,14 +313,14 @@ void LocalPlayer::updateBounty(bool forceUpdate)
|
|||
void LocalPlayer::updatePosition(bool forceUpdate)
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
|
||||
|
||||
static bool posWasChanged = false;
|
||||
static bool isJumping = false;
|
||||
static bool sentJumpEnd = true;
|
||||
static float oldRot[2] = {0};
|
||||
|
||||
position = player.getRefData().getPosition();
|
||||
position = ptrPlayer.getRefData().getPosition();
|
||||
|
||||
bool posIsChanging = (direction.pos[0] != 0 || direction.pos[1] != 0 ||
|
||||
position.rot[0] != oldRot[0] || position.rot[2] != oldRot[1]);
|
||||
|
@ -332,13 +332,13 @@ void LocalPlayer::updatePosition(bool forceUpdate)
|
|||
|
||||
posWasChanged = posIsChanging;
|
||||
|
||||
if (!isJumping && !world->isOnGround(player) && !world->isFlying(player))
|
||||
if (!isJumping && !world->isOnGround(ptrPlayer) && !world->isFlying(ptrPlayer))
|
||||
isJumping = true;
|
||||
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->setPlayer(this);
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->Send();
|
||||
}
|
||||
else if (isJumping && world->isOnGround(player))
|
||||
else if (isJumping && world->isOnGround(ptrPlayer))
|
||||
{
|
||||
isJumping = false;
|
||||
sentJumpEnd = false;
|
||||
|
@ -347,7 +347,7 @@ void LocalPlayer::updatePosition(bool forceUpdate)
|
|||
else if (!sentJumpEnd)
|
||||
{
|
||||
sentJumpEnd = true;
|
||||
position = player.getRefData().getPosition();
|
||||
position = ptrPlayer.getRefData().getPosition();
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->setPlayer(this);
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->Send();
|
||||
}
|
||||
|
@ -402,14 +402,14 @@ void LocalPlayer::updateChar()
|
|||
|
||||
void LocalPlayer::updateEquipment(bool forceUpdate)
|
||||
{
|
||||
MWWorld::Ptr player = getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
|
||||
static bool equipmentChanged = false;
|
||||
|
||||
if (forceUpdate)
|
||||
equipmentChanged = true;
|
||||
|
||||
MWWorld::InventoryStore &invStore = player.getClass().getInventoryStore(player);
|
||||
MWWorld::InventoryStore &invStore = ptrPlayer.getClass().getInventoryStore(ptrPlayer);
|
||||
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++)
|
||||
{
|
||||
auto &item = equipedItems[slot];
|
||||
|
@ -425,8 +425,8 @@ void LocalPlayer::updateEquipment(bool forceUpdate)
|
|||
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
||||
{
|
||||
MWMechanics::WeaponType weaptype;
|
||||
MWMechanics::getActiveWeapon(player.getClass().getCreatureStats(player),
|
||||
player.getClass().getInventoryStore(player), &weaptype);
|
||||
MWMechanics::getActiveWeapon(ptrPlayer.getClass().getCreatureStats(ptrPlayer),
|
||||
ptrPlayer.getClass().getInventoryStore(ptrPlayer), &weaptype);
|
||||
if (weaptype != MWMechanics::WeapType_Thrown)
|
||||
item.count = 1;
|
||||
}
|
||||
|
@ -536,9 +536,9 @@ void LocalPlayer::updateAttack()
|
|||
|
||||
void LocalPlayer::updateDeadState(bool forceUpdate)
|
||||
{
|
||||
MWWorld::Ptr player = getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
|
||||
MWMechanics::NpcStats *ptrNpcStats = &player.getClass().getNpcStats(player);
|
||||
MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
static bool isDead = false;
|
||||
|
||||
if (ptrNpcStats->isDead() && !isDead)
|
||||
|
@ -561,9 +561,9 @@ void LocalPlayer::updateDeadState(bool forceUpdate)
|
|||
void LocalPlayer::updateAnimFlags(bool forceUpdate)
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
|
||||
|
||||
MWMechanics::NpcStats ptrNpcStats = player.getClass().getNpcStats(player);
|
||||
MWMechanics::NpcStats ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
using namespace MWMechanics;
|
||||
|
||||
static bool wasRunning = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Run);
|
||||
|
@ -576,16 +576,16 @@ void LocalPlayer::updateAnimFlags(bool forceUpdate)
|
|||
bool isForceJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceJump);
|
||||
bool isForceMoveJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
|
||||
|
||||
isFlying = world->isFlying(player);
|
||||
bool isJumping = !world->isOnGround(player) && !isFlying;
|
||||
isFlying = world->isFlying(ptrPlayer);
|
||||
bool isJumping = !world->isOnGround(ptrPlayer) && !isFlying;
|
||||
|
||||
// We need to send a new packet at the end of jumping and flying too,
|
||||
// so keep track of what we were doing last frame
|
||||
static bool wasJumping = false;
|
||||
static bool wasFlying = false;
|
||||
|
||||
MWMechanics::DrawState_ currentDrawState = player.getClass().getNpcStats(player).getDrawState();
|
||||
static MWMechanics::DrawState_ lastDrawState = player.getClass().getNpcStats(player).getDrawState();
|
||||
MWMechanics::DrawState_ currentDrawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState();
|
||||
static MWMechanics::DrawState_ lastDrawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState();
|
||||
|
||||
if (wasRunning != isRunning ||
|
||||
wasSneaking != isSneaking || wasForceJumping != isForceJumping ||
|
||||
|
@ -714,9 +714,9 @@ void LocalPlayer::removeSpells()
|
|||
void LocalPlayer::setDynamicStats()
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
|
||||
|
||||
MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player);
|
||||
MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
|
||||
MWMechanics::DynamicStat<float> dynamicStat;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
|
@ -731,9 +731,9 @@ void LocalPlayer::setDynamicStats()
|
|||
void LocalPlayer::setAttributes()
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
|
||||
|
||||
MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player);
|
||||
MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
|
||||
MWMechanics::AttributeValue attributeValue;
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
|
@ -746,9 +746,9 @@ void LocalPlayer::setAttributes()
|
|||
void LocalPlayer::setSkills()
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
|
||||
|
||||
MWMechanics::NpcStats *ptrNpcStats = &player.getClass().getNpcStats(player);
|
||||
MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
MWMechanics::SkillValue skillValue;
|
||||
|
||||
for (int i = 0; i < 27; ++i)
|
||||
|
@ -766,25 +766,25 @@ void LocalPlayer::setSkills()
|
|||
void LocalPlayer::setLevel()
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
|
||||
|
||||
MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player);
|
||||
MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
|
||||
ptrCreatureStats->setLevel(creatureStats.mLevel);
|
||||
}
|
||||
|
||||
void LocalPlayer::setBounty()
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
|
||||
|
||||
MWMechanics::NpcStats *ptrNpcStats = &player.getClass().getNpcStats(player);
|
||||
MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
ptrNpcStats->setBounty(npcStats.mBounty);
|
||||
}
|
||||
|
||||
void LocalPlayer::setPosition()
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
|
||||
|
||||
// If we're ignoring this position packet because of an invalid cell change,
|
||||
// don't make the next one get ignored as well
|
||||
|
@ -793,8 +793,8 @@ void LocalPlayer::setPosition()
|
|||
else
|
||||
{
|
||||
world->getPlayer().setTeleported(true);
|
||||
world->moveObject(player, position.pos[0], position.pos[1], position.pos[2]);
|
||||
world->rotateObject(player, position.rot[0], position.rot[1], position.rot[2]);
|
||||
world->moveObject(ptrPlayer, position.pos[0], position.pos[1], position.pos[2]);
|
||||
world->rotateObject(ptrPlayer, position.rot[0], position.rot[1], position.rot[2]);
|
||||
}
|
||||
|
||||
updatePosition(true);
|
||||
|
@ -806,7 +806,7 @@ void LocalPlayer::setPosition()
|
|||
void LocalPlayer::setCell()
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
|
||||
ESM::Position pos;
|
||||
|
||||
// To avoid crashes, close any container menus this player may be in
|
||||
|
@ -829,12 +829,12 @@ void LocalPlayer::setCell()
|
|||
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
|
||||
|
||||
world->changeToExteriorCell(pos, true);
|
||||
world->fixPosition(player);
|
||||
world->fixPosition(ptrPlayer);
|
||||
}
|
||||
else if (world->findExteriorPosition(cell.mName, pos))
|
||||
{
|
||||
world->changeToExteriorCell(pos, true);
|
||||
world->fixPosition(player);
|
||||
world->fixPosition(ptrPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -950,8 +950,8 @@ void LocalPlayer::setSpellbook()
|
|||
|
||||
void LocalPlayer::setFactions()
|
||||
{
|
||||
MWWorld::Ptr player = getPlayerPtr();
|
||||
MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player);
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
|
||||
for (const auto &faction : factionChanges.factions)
|
||||
{
|
||||
|
@ -997,8 +997,8 @@ void LocalPlayer::setKills()
|
|||
|
||||
void LocalPlayer::setBooks()
|
||||
{
|
||||
MWWorld::Ptr player = getPlayerPtr();
|
||||
MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player);
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
|
||||
for (const auto &book : bookChanges.books)
|
||||
ptrNpcStats.flagAsUsed(book.bookId);
|
||||
|
@ -1006,8 +1006,8 @@ void LocalPlayer::setBooks()
|
|||
|
||||
void LocalPlayer::setMapExplored()
|
||||
{
|
||||
MWWorld::Ptr player = getPlayerPtr();
|
||||
MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player);
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
|
||||
for (const auto &cellExplored : mapChanges.cellsExplored)
|
||||
{
|
||||
|
@ -1018,6 +1018,12 @@ void LocalPlayer::setMapExplored()
|
|||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::setShapeshift()
|
||||
{
|
||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
MWBase::Environment::get().getMechanicsManager()->setWerewolf(ptrPlayer, isWerewolf);
|
||||
}
|
||||
|
||||
void LocalPlayer::sendClass()
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
|
@ -1259,6 +1265,16 @@ void LocalPlayer::sendBook(const std::string& bookId)
|
|||
getNetworking()->getPlayerPacket(ID_PLAYER_BOOK)->Send();
|
||||
}
|
||||
|
||||
void LocalPlayer::sendShapeshift(bool werewolfState)
|
||||
{
|
||||
isWerewolf = werewolfState;
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_SHAPESHIFT with isWerewolf of %s", isWerewolf ? "true" : "false");
|
||||
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_SHAPESHIFT)->setPlayer(this);
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_SHAPESHIFT)->Send();
|
||||
}
|
||||
|
||||
void LocalPlayer::clearCellStates()
|
||||
{
|
||||
cellStateChanges.cellStates.clear();
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace mwmp
|
|||
void setKills();
|
||||
void setBooks();
|
||||
void setMapExplored();
|
||||
void setShapeshift();
|
||||
|
||||
void sendClass();
|
||||
void sendInventory();
|
||||
|
@ -79,6 +80,7 @@ namespace mwmp
|
|||
void sendTopic(const std::string& topic);
|
||||
void sendKill(const std::string& refId, int number);
|
||||
void sendBook(const std::string& bookId);
|
||||
void sendShapeshift(bool isWerewolf);
|
||||
|
||||
void clearCellStates();
|
||||
void clearCurrentContainer();
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "player/ProcessorPlayerRegionAuthority.hpp"
|
||||
#include "player/ProcessorPlayerRest.hpp"
|
||||
#include "player/ProcessorPlayerResurrect.hpp"
|
||||
#include "player/ProcessorPlayerShapeshift.hpp"
|
||||
#include "player/ProcessorPlayerSkill.hpp"
|
||||
#include "player/ProcessorPlayerSpeech.hpp"
|
||||
#include "player/ProcessorPlayerSpellbook.hpp"
|
||||
|
@ -115,6 +116,7 @@ void ProcessorInitializer()
|
|||
PlayerProcessor::AddProcessor(new ProcessorPlayerRegionAuthority());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerRest());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerResurrect());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerShapeshift());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerSkill());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerSpeech());
|
||||
PlayerProcessor::AddProcessor(new ProcessorPlayerSpellbook());
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP
|
||||
#define OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP
|
||||
|
||||
#include "../PlayerProcessor.hpp"
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class ProcessorPlayerShapeshift : public PlayerProcessor
|
||||
{
|
||||
public:
|
||||
ProcessorPlayerShapeshift()
|
||||
{
|
||||
BPP_INIT(ID_PLAYER_SHAPESHIFT)
|
||||
}
|
||||
|
||||
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
||||
{
|
||||
if (isLocal())
|
||||
{
|
||||
static_cast<LocalPlayer *>(player)->setShapeshift();
|
||||
}
|
||||
else if (player != 0)
|
||||
{
|
||||
static_cast<DedicatedPlayer *>(player)->setShapeshift();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP
|
|
@ -1224,6 +1224,17 @@ namespace MWScript
|
|||
{
|
||||
MWWorld::Ptr ptr = R()(runtime);
|
||||
MWBase::Environment::get().getMechanicsManager()->setWerewolf(ptr, set);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
When the player's werewolf state changes, send an ID_PLAYER_SHAPESHIFT packet
|
||||
*/
|
||||
if (ptr == MWMechanics::getPlayer())
|
||||
mwmp::Main::get().getLocalPlayer()->sendShapeshift(set);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -182,7 +182,8 @@ add_component_dir (openmw-mp/Packets/Player
|
|||
PacketPlayerCellState PacketPlayerClass PacketPlayerDeath PacketPlayerEquipment PacketPlayerFaction
|
||||
PacketPlayerInventory PacketPlayerJail PacketPlayerJournal PacketPlayerKillCount PacketPlayerLevel
|
||||
PacketPlayerMap PacketPlayerPosition PacketPlayerRegionAuthority PacketPlayerRest PacketPlayerResurrect
|
||||
PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic PacketPlayerTopic
|
||||
PacketPlayerShapeshift PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic
|
||||
PacketPlayerTopic
|
||||
)
|
||||
|
||||
add_component_dir (openmw-mp/Packets/World
|
||||
|
|
|
@ -246,6 +246,8 @@ namespace mwmp
|
|||
std::string chatMessage;
|
||||
CGStage charGenStage;
|
||||
std::string passw;
|
||||
|
||||
bool isWerewolf;
|
||||
std::string creatureModel;
|
||||
bool useCreatureName;
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "../Packets/Player/PacketPlayerRegionAuthority.hpp"
|
||||
#include "../Packets/Player/PacketPlayerRest.hpp"
|
||||
#include "../Packets/Player/PacketPlayerResurrect.hpp"
|
||||
#include "../Packets/Player/PacketPlayerShapeshift.hpp"
|
||||
#include "../Packets/Player/PacketPlayerSkill.hpp"
|
||||
#include "../Packets/Player/PacketPlayerSpeech.hpp"
|
||||
#include "../Packets/Player/PacketPlayerSpellbook.hpp"
|
||||
|
@ -83,6 +84,7 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p
|
|||
AddPacket<PacketPlayerRegionAuthority>(&packets, peer);
|
||||
AddPacket<PacketPlayerRest>(&packets, peer);
|
||||
AddPacket<PacketPlayerResurrect>(&packets, peer);
|
||||
AddPacket<PacketPlayerShapeshift>(&packets, peer);
|
||||
AddPacket<PacketPlayerSkill>(&packets, peer);
|
||||
AddPacket<PacketPlayerSpeech>(&packets, peer);
|
||||
AddPacket<PacketPlayerSpellbook>(&packets, peer);
|
||||
|
|
|
@ -47,6 +47,7 @@ enum GameMessages
|
|||
ID_PLAYER_REGION_AUTHORITY,
|
||||
ID_PLAYER_RESURRECT,
|
||||
ID_PLAYER_REST,
|
||||
ID_PLAYER_SHAPESHIFT,
|
||||
ID_PLAYER_SKILL,
|
||||
ID_PLAYER_SPEECH,
|
||||
ID_PLAYER_SPELLBOOK,
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#include "PacketPlayerShapeshift.hpp"
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
|
||||
using namespace mwmp;
|
||||
|
||||
PacketPlayerShapeshift::PacketPlayerShapeshift(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
||||
{
|
||||
packetID = ID_PLAYER_SHAPESHIFT;
|
||||
}
|
||||
|
||||
void PacketPlayerShapeshift::Packet(RakNet::BitStream *bs, bool send)
|
||||
{
|
||||
PlayerPacket::Packet(bs, send);
|
||||
|
||||
RW(player->isWerewolf, send);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef OPENMW_PACKETPLAYERSHAPESHIFT_HPP
|
||||
#define OPENMW_PACKETPLAYERSHAPESHIFT_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class PacketPlayerShapeshift : public PlayerPacket
|
||||
{
|
||||
public:
|
||||
PacketPlayerShapeshift(RakNet::RakPeerInterface *peer);
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, bool send);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PACKETPLAYERSHAPESHIFT_HPP
|
Loading…
Reference in a new issue