diff --git a/apps/openmw/mwmp/ActorList.cpp b/apps/openmw/mwmp/ActorList.cpp index 509f0c237..d1b01acad 100644 --- a/apps/openmw/mwmp/ActorList.cpp +++ b/apps/openmw/mwmp/ActorList.cpp @@ -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) { diff --git a/apps/openmw/mwmp/ActorList.hpp b/apps/openmw/mwmp/ActorList.hpp index 5395cb04e..c75332368 100644 --- a/apps/openmw/mwmp/ActorList.hpp +++ b/apps/openmw/mwmp/ActorList.hpp @@ -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 animPlayActors; std::vector speechActors; std::vector statsDynamicActors; + std::vector attackActors; }; } diff --git a/apps/openmw/mwmp/Cell.cpp b/apps/openmw/mwmp/Cell.cpp index 8ae9c86f6..9c29019fa 100644 --- a/apps/openmw/mwmp/Cell.cpp +++ b/apps/openmw/mwmp/Cell.cpp @@ -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(); diff --git a/apps/openmw/mwmp/Cell.hpp b/apps/openmw/mwmp/Cell.hpp index 4f34c31d1..4e49d683a 100644 --- a/apps/openmw/mwmp/Cell.hpp +++ b/apps/openmw/mwmp/Cell.hpp @@ -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); diff --git a/apps/openmw/mwmp/CellController.cpp b/apps/openmw/mwmp/CellController.cpp index 1808a13ac..7ed73a4f5 100644 --- a/apps/openmw/mwmp/CellController.cpp +++ b/apps/openmw/mwmp/CellController.cpp @@ -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; diff --git a/apps/openmw/mwmp/CellController.hpp b/apps/openmw/mwmp/CellController.hpp index 98e4fe902..b9e47e66e 100644 --- a/apps/openmw/mwmp/CellController.hpp +++ b/apps/openmw/mwmp/CellController.hpp @@ -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); diff --git a/apps/openmw/mwmp/processors/actor/ProcessorActorAttack.hpp b/apps/openmw/mwmp/processors/actor/ProcessorActorAttack.hpp index 66cb95a0e..986071c25 100644 --- a/apps/openmw/mwmp/processors/actor/ProcessorActorAttack.hpp +++ b/apps/openmw/mwmp/processors/actor/ProcessorActorAttack.hpp @@ -22,7 +22,7 @@ namespace mwmp virtual void Do(ActorPacket &packet, ActorList &actorList) { - + //Main::get().getCellController()->readAttack(actorList); } }; }