[Client] Send and read ActorAttack packets

0.6.1
David Cernat 8 years ago
parent 2e8714afaa
commit 6aa0fa85ab

@ -32,6 +32,7 @@ void ActorList::reset()
animPlayActors.clear();
speechActors.clear();
statsDynamicActors.clear();
attackActors.clear();
guid = mwmp::Main::get().getNetworking()->getLocalPlayer()->guid;
}
@ -70,6 +71,11 @@ void ActorList::addStatsDynamicActor(LocalActor localActor)
statsDynamicActors.push_back(localActor);
}
void ActorList::addAttackActor(LocalActor localActor)
{
attackActors.push_back(localActor);
}
void ActorList::sendPositionActors()
{
if (positionActors.size() > 0)
@ -120,6 +126,16 @@ void ActorList::sendStatsDynamicActors()
}
}
void ActorList::sendAttackActors()
{
if (attackActors.size() > 0)
{
baseActors = attackActors;
Main::get().getNetworking()->getActorPacket(ID_ACTOR_ATTACK)->setActorList(this);
Main::get().getNetworking()->getActorPacket(ID_ACTOR_ATTACK)->Send();
}
}
// TODO: Finish this
void ActorList::editActorsInCell(MWWorld::CellStore* cellStore)
{

@ -26,12 +26,14 @@ namespace mwmp
void addAnimPlayActor(LocalActor localActor);
void addSpeechActor(LocalActor localActor);
void addStatsDynamicActor(LocalActor localActor);
void addAttackActor(LocalActor localActor);
void sendPositionActors();
void sendAnimFlagsActors();
void sendAnimPlayActors();
void sendSpeechActors();
void sendStatsDynamicActors();
void sendAttackActors();
void editActorsInCell(MWWorld::CellStore* cellStore);
@ -45,6 +47,7 @@ namespace mwmp
std::vector<BaseActor> animPlayActors;
std::vector<BaseActor> speechActors;
std::vector<BaseActor> statsDynamicActors;
std::vector<BaseActor> attackActors;
};
}

@ -4,10 +4,12 @@
#include "../mwworld/worldimp.hpp"
#include "Cell.hpp"
#include "CellController.hpp"
#include "Main.hpp"
#include "Networking.hpp"
#include "LocalPlayer.hpp"
#include "CellController.hpp"
#include "MechanicsHelper.hpp"
using namespace mwmp;
mwmp::Cell::Cell(MWWorld::CellStore* cellStore)
@ -58,6 +60,7 @@ void Cell::updateLocal(bool forceUpdate)
actorList->sendAnimPlayActors();
actorList->sendSpeechActors();
actorList->sendStatsDynamicActors();
actorList->sendAttackActors();
}
void Cell::updateDedicated(float dt)
@ -174,6 +177,26 @@ void Cell::readSpeech(ActorList& actorList)
}
}
void Cell::readAttack(ActorList& actorList)
{
initializeDedicatedActors(actorList);
BaseActor baseActor;
for (unsigned int i = 0; i < actorList.count; i++)
{
baseActor = actorList.baseActors.at(i);
std::string mapIndex = Main::get().getCellController()->generateMapIndex(baseActor);
if (dedicatedActors.count(mapIndex) > 0)
{
DedicatedActor *actor = dedicatedActors[mapIndex];
actor->attack = baseActor.attack;
mwmp::Main::get().getMechanicsHelper()->processAttack(actor->attack, actor->getPtr());
}
}
}
void Cell::initializeLocalActors()
{
ESM::Cell esmCell = *store->getCell();

@ -23,6 +23,7 @@ namespace mwmp
void readAnimPlay(ActorList& actorList);
void readStatsDynamic(ActorList& actorList);
void readSpeech(ActorList& actorList);
void readAttack(ActorList& actorList);
void initializeLocalActors();
void initializeDedicatedActors(ActorList& actorList);

@ -154,6 +154,19 @@ void CellController::readSpeech(ActorList& actorList)
}
}
void CellController::readAttack(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
initializeCell(actorList.cell);
// If this now exists, send it the data
if (cellsActive.count(mapIndex) > 0)
{
cellsActive[mapIndex]->readAttack(actorList);
}
}
void CellController::setLocalActorRecord(std::string actorIndex, std::string cellIndex)
{
localActorsToCells[actorIndex] = cellIndex;

@ -27,6 +27,7 @@ namespace mwmp
void readAnimPlay(mwmp::ActorList& actorList);
void readStatsDynamic(mwmp::ActorList& actorList);
void readSpeech(mwmp::ActorList& actorList);
void readAttack(mwmp::ActorList& actorList);
void setLocalActorRecord(std::string actorIndex, std::string cellIndex);
void removeLocalActorRecord(std::string actorIndex);

@ -22,7 +22,7 @@ namespace mwmp
virtual void Do(ActorPacket &packet, ActorList &actorList)
{
//Main::get().getCellController()->readAttack(actorList);
}
};
}

Loading…
Cancel
Save