mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-15 04:38:21 +00:00
Add some command handlers
This commit is contained in:
parent
2db8caadde
commit
84ba38bd1d
@ -20,7 +20,6 @@ enum class eWaypointCommandType : uint32_t {
|
|||||||
CHANGE_WAYPOINT,
|
CHANGE_WAYPOINT,
|
||||||
DELETE_SELF,
|
DELETE_SELF,
|
||||||
KILL_SELF,
|
KILL_SELF,
|
||||||
REMOVE_SELF,
|
|
||||||
SPAWN_OBJECT,
|
SPAWN_OBJECT,
|
||||||
PLAY_SOUND,
|
PLAY_SOUND,
|
||||||
};
|
};
|
||||||
@ -45,7 +44,7 @@ public:
|
|||||||
{"changeWP", eWaypointCommandType::CHANGE_WAYPOINT},
|
{"changeWP", eWaypointCommandType::CHANGE_WAYPOINT},
|
||||||
{"DeleteSelf", eWaypointCommandType::DELETE_SELF},
|
{"DeleteSelf", eWaypointCommandType::DELETE_SELF},
|
||||||
{"killself", eWaypointCommandType::KILL_SELF},
|
{"killself", eWaypointCommandType::KILL_SELF},
|
||||||
{"removeself", eWaypointCommandType::REMOVE_SELF},
|
{"removeself", eWaypointCommandType::DELETE_SELF},
|
||||||
{"spawnOBJ", eWaypointCommandType::SPAWN_OBJECT},
|
{"spawnOBJ", eWaypointCommandType::SPAWN_OBJECT},
|
||||||
{"playSound", eWaypointCommandType::PLAY_SOUND},
|
{"playSound", eWaypointCommandType::PLAY_SOUND},
|
||||||
};
|
};
|
||||||
|
@ -195,7 +195,7 @@ public:
|
|||||||
void ReversePath();
|
void ReversePath();
|
||||||
|
|
||||||
void HandleWaypointArrived();
|
void HandleWaypointArrived();
|
||||||
|
|
||||||
void SetupPath(const std::string& pathname);
|
void SetupPath(const std::string& pathname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -223,6 +223,21 @@ public:
|
|||||||
*/
|
*/
|
||||||
static float GetBaseSpeed(LOT lot);
|
static float GetBaseSpeed(LOT lot);
|
||||||
|
|
||||||
|
void SetCurrentPathWaypointIndex(uint32_t value) { m_CurrentPathWaypointIndex = value; };
|
||||||
|
void SetNextPathWaypointIndex(uint32_t value) { m_NextPathWaypointIndex = value; };
|
||||||
|
void HandleWaypointCommandGroupEmote(std::string data);
|
||||||
|
void HandleWaypointCommandSetVariable(std::string data);
|
||||||
|
void HandleWaypointCommandCastSkill(std::string data);
|
||||||
|
void HandleWaypointCommandEquipInventory(std::string data);
|
||||||
|
void HandleWaypointCommandUnequipInventory(std::string data);
|
||||||
|
void HandleWaypointCommandDelay(std::string data);
|
||||||
|
void HandleWaypointCommandEmote(std::string data);
|
||||||
|
void HandleWaypointCommandTeleport(std::string data);
|
||||||
|
void HandleWaypointCommandPathSpeed(std::string data);
|
||||||
|
void HandleWaypointCommandRemoveNPC(std::string data);
|
||||||
|
void HandleWaypointCommandChangeWaypoint(std::string data);
|
||||||
|
void HandleWaypointCommandSpawnObject(std::string data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -334,12 +349,12 @@ private:
|
|||||||
int32_t m_CurrentPathWaypointIndex;
|
int32_t m_CurrentPathWaypointIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The index of the current waypoint in the path
|
* The index of the next waypoint in the path
|
||||||
*/
|
*/
|
||||||
int32_t m_NextPathWaypointIndex;
|
int32_t m_NextPathWaypointIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the path is being read in reverse
|
* Whether or not the path is being read in reverse
|
||||||
*/
|
*/
|
||||||
bool m_IsInReverse;
|
bool m_IsInReverse;
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include "MovementAIComponent.h"
|
#include "MovementAIComponent.h"
|
||||||
#endif
|
#endif
|
||||||
#include "eWaypointCommandType.h"
|
#include "eWaypointCommandType.h"
|
||||||
|
#include "RenderComponent.h"
|
||||||
|
#include "SkillComponent.h"
|
||||||
|
|
||||||
void MovementAIComponent::HandleWaypointArrived() {
|
void MovementAIComponent::HandleWaypointArrived() {
|
||||||
if (!m_Path) return;
|
if (!m_Path) return;
|
||||||
@ -9,76 +11,138 @@ void MovementAIComponent::HandleWaypointArrived() {
|
|||||||
for(auto [command, data] : m_Path->pathWaypoints[m_CurrentPathWaypointIndex].commands){
|
for(auto [command, data] : m_Path->pathWaypoints[m_CurrentPathWaypointIndex].commands){
|
||||||
switch(command){
|
switch(command){
|
||||||
case eWaypointCommandType::STOP:
|
case eWaypointCommandType::STOP:
|
||||||
// call stop
|
Stop();
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::GROUP_EMOTE:
|
case eWaypointCommandType::GROUP_EMOTE:
|
||||||
// get group
|
HandleWaypointCommandGroupEmote(data);
|
||||||
// make them all emote
|
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::SET_VARIABLE:
|
case eWaypointCommandType::SET_VARIABLE:
|
||||||
// set network variable???
|
HandleWaypointCommandSetVariable(data);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::CAST_SKILL:
|
case eWaypointCommandType::CAST_SKILL:
|
||||||
// just call cast skill lol
|
HandleWaypointCommandCastSkill(data);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::EQUIP_INVENTORY:
|
case eWaypointCommandType::EQUIP_INVENTORY:
|
||||||
// equip item via ID (not lot???)
|
HandleWaypointCommandEquipInventory(data);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::UNEQUIP_INVENTORY:
|
case eWaypointCommandType::UNEQUIP_INVENTORY:
|
||||||
// unequip item via ID (not lot??)
|
HandleWaypointCommandUnequipInventory(data);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::DELAY:
|
case eWaypointCommandType::DELAY:
|
||||||
// number
|
HandleWaypointCommandDelay(data);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::EMOTE:
|
case eWaypointCommandType::EMOTE:
|
||||||
// emote name
|
HandleWaypointCommandEmote(data);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::TELEPORT:
|
case eWaypointCommandType::TELEPORT:
|
||||||
// x,y,z
|
HandleWaypointCommandTeleport(data);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::PATH_SPEED:
|
case eWaypointCommandType::PATH_SPEED:
|
||||||
// set speed?
|
HandleWaypointCommandPathSpeed(data);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::REMOVE_NPC:
|
case eWaypointCommandType::REMOVE_NPC:
|
||||||
// get objects in proximity
|
HandleWaypointCommandRemoveNPC(data);
|
||||||
// KillOBJS ???
|
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::CHANGE_WAYPOINT:
|
case eWaypointCommandType::CHANGE_WAYPOINT:
|
||||||
// std::string path_string = "";
|
HandleWaypointCommandChangeWaypoint(data);
|
||||||
// sometimes there's a path and what waypoint to start, which are comma separated
|
|
||||||
// if (intermed.find(",") != std::string::npos){
|
|
||||||
// auto datas = GeneralUtils::SplitString(intermed, ',');
|
|
||||||
// path_string = datas[0];
|
|
||||||
// m_PathIndex = stoi(datas[1]) - 1;
|
|
||||||
// } else {
|
|
||||||
// path_string = intermed;
|
|
||||||
// m_PathIndex = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (path_string != "") {
|
|
||||||
// SetMovementPath(const_cast<Path*>(dZoneManager::Instance()->GetZone()->GetPath(path_string)));
|
|
||||||
// } else m_MovementPath = nullptr;
|
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::KILL_SELF:
|
case eWaypointCommandType::KILL_SELF:
|
||||||
// Kill Silent
|
m_Parent->Smash(LWOOBJID_EMPTY, eKillType::SILENT);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::DELETE_SELF:
|
case eWaypointCommandType::DELETE_SELF:
|
||||||
case eWaypointCommandType::REMOVE_SELF:
|
m_Parent->Kill();
|
||||||
// Delete Object
|
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::SPAWN_OBJECT:
|
case eWaypointCommandType::SPAWN_OBJECT:
|
||||||
// just make a new object
|
HandleWaypointCommandSpawnObject(data);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::PLAY_SOUND:
|
case eWaypointCommandType::PLAY_SOUND:
|
||||||
// msgPlayNDAudioEmitter
|
GameMessages::SendPlayNDAudioEmitter(m_Parent, UNASSIGNED_SYSTEM_ADDRESS, data);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::BOUNCE:
|
case eWaypointCommandType::BOUNCE:
|
||||||
Game::logger->Log("MovementAIComponentAronwk", "Unusable Command %i", command);
|
Game::logger->LogDebug("MovementAIComponent", "Unusable Command %i", command);
|
||||||
break;
|
break;
|
||||||
case eWaypointCommandType::INVALID:
|
case eWaypointCommandType::INVALID:
|
||||||
default:
|
default:
|
||||||
Game::logger->LogDebug("MovementAIComponentAronwk", "Got invalid waypoint command %i", command);
|
Game::logger->LogDebug("MovementAIComponent", "Got invalid waypoint command %i", command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MovementAIComponent::HandleWaypointCommandGroupEmote(std::string data) {
|
||||||
|
const auto& split = GeneralUtils::SplitString(data, ';');
|
||||||
|
if (split.size() != 2) return;
|
||||||
|
const auto& entities = Game::entityManager->GetEntitiesInGroup(split[0]);
|
||||||
|
for (auto& entity: entities){
|
||||||
|
RenderComponent::PlayAnimation(entity, split[1]);
|
||||||
|
}
|
||||||
|
// delay for animation time
|
||||||
|
}
|
||||||
|
void MovementAIComponent::HandleWaypointCommandSetVariable(std::string data) {
|
||||||
|
const auto& split = GeneralUtils::SplitString(data, '=');
|
||||||
|
m_Parent->SetNetworkVar(GeneralUtils::ASCIIToUTF16(split[0]), split[1]);
|
||||||
|
}
|
||||||
|
void MovementAIComponent::HandleWaypointCommandCastSkill(std::string data) {
|
||||||
|
if (data.empty()) return;
|
||||||
|
auto* skillComponent = m_Parent->GetComponent<SkillComponent>();
|
||||||
|
if (!skillComponent) {
|
||||||
|
Game::logger->LogDebug("MovementAIComponent::HandleWaypointArrived", "Skill component not found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint32_t skillId = 0;
|
||||||
|
GeneralUtils::TryParse<uint32_t>(data, skillId);
|
||||||
|
if (skillId != 0) skillComponent->CastSkill(skillId);
|
||||||
|
// add some delay??
|
||||||
|
}
|
||||||
|
void MovementAIComponent::HandleWaypointCommandEquipInventory(std::string data) {
|
||||||
|
// equip item via ID (not lot???)
|
||||||
|
}
|
||||||
|
void MovementAIComponent::HandleWaypointCommandUnequipInventory(std::string data) {
|
||||||
|
// unequip item via ID (not lot??)
|
||||||
|
}
|
||||||
|
void MovementAIComponent::HandleWaypointCommandDelay(std::string data) {
|
||||||
|
Pause();
|
||||||
|
std::remove_if(data.begin(), data.end(), isspace);
|
||||||
|
// delay for time
|
||||||
|
}
|
||||||
|
void MovementAIComponent::HandleWaypointCommandEmote(std::string data) {
|
||||||
|
// pause fore animation time
|
||||||
|
auto delay = RenderComponent::PlayAnimation(m_Parent, data);
|
||||||
|
}
|
||||||
|
void MovementAIComponent::HandleWaypointCommandTeleport(std::string data) {
|
||||||
|
auto posString = GeneralUtils::SplitString(data, ',');
|
||||||
|
if (posString.size() == 0) return;
|
||||||
|
auto newPos = NiPoint3();
|
||||||
|
if (posString.size() == 1) GeneralUtils::TryParse<float>(posString[0], newPos.x);
|
||||||
|
if (posString.size() == 2) GeneralUtils::TryParse<float>(posString[1], newPos.y);
|
||||||
|
if (posString.size() == 3) GeneralUtils::TryParse<float>(posString[2], newPos.z);
|
||||||
|
GameMessages::SendTeleport(m_Parent->GetObjectID(), newPos, NiQuaternion::IDENTITY, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
}
|
||||||
|
void MovementAIComponent::HandleWaypointCommandPathSpeed(std::string data) {
|
||||||
|
float speed = 0.0;
|
||||||
|
GeneralUtils::TryParse<float>(data, speed);
|
||||||
|
SetMaxSpeed(speed);
|
||||||
|
}
|
||||||
|
void MovementAIComponent::HandleWaypointCommandRemoveNPC(std::string data) {
|
||||||
|
// get objects in proximity
|
||||||
|
// KillOBJS ???
|
||||||
|
}
|
||||||
|
void MovementAIComponent::HandleWaypointCommandChangeWaypoint(std::string data) {
|
||||||
|
std::string path_string = "";
|
||||||
|
int32_t index = 0;
|
||||||
|
// sometimes there's a path and what waypoint to start, which are comma separated
|
||||||
|
if (data.find(",") != std::string::npos){
|
||||||
|
auto datas = GeneralUtils::SplitString(data, ',');
|
||||||
|
path_string = datas[0];
|
||||||
|
index = stoi(datas[1]);
|
||||||
|
} else path_string = data;
|
||||||
|
|
||||||
|
if (path_string != "") {
|
||||||
|
SetupPath(path_string);
|
||||||
|
SetCurrentPathWaypointIndex(index);
|
||||||
|
SetNextPathWaypointIndex(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void MovementAIComponent::HandleWaypointCommandSpawnObject(std::string data) {
|
||||||
|
// just do it
|
||||||
|
}
|
||||||
|
@ -317,8 +317,8 @@ void GameMessages::SendPlayNDAudioEmitter(Entity* entity, const SystemAddress& s
|
|||||||
|
|
||||||
bitStream.Write(entity->GetObjectID());
|
bitStream.Write(entity->GetObjectID());
|
||||||
bitStream.Write((uint16_t)eGameMessageType::PLAY_ND_AUDIO_EMITTER);
|
bitStream.Write((uint16_t)eGameMessageType::PLAY_ND_AUDIO_EMITTER);
|
||||||
bitStream.Write0();
|
bitStream.Write0(); // callback message data {lwoobjid}
|
||||||
bitStream.Write0();
|
bitStream.Write0(); // audio emmitterid {uint32_t}}
|
||||||
|
|
||||||
uint32_t length = audioGUID.size();
|
uint32_t length = audioGUID.size();
|
||||||
bitStream.Write(length);
|
bitStream.Write(length);
|
||||||
@ -326,16 +326,9 @@ void GameMessages::SendPlayNDAudioEmitter(Entity* entity, const SystemAddress& s
|
|||||||
bitStream.Write(static_cast<char>(audioGUID[k]));
|
bitStream.Write(static_cast<char>(audioGUID[k]));
|
||||||
}
|
}
|
||||||
|
|
||||||
//PacketUtils::WriteString(bitStream, audioGUID, audioGUID.size());
|
bitStream.Write(uint32_t(0)); // size of NDAudioMetaEventName (then print he string like the guid)
|
||||||
|
bitStream.Write0(); //result {bool}
|
||||||
//bitStream.Write(uint32_t(audioGUID.size()));
|
bitStream.Write0(); // m_TargetObjectIDForNDAudioCallbackMessages {lwoobjid}
|
||||||
//for (char character : audioGUID) {
|
|
||||||
// bitStream.Write(character);
|
|
||||||
//}
|
|
||||||
|
|
||||||
bitStream.Write(uint32_t(0));
|
|
||||||
bitStream.Write0();
|
|
||||||
bitStream.Write0();
|
|
||||||
|
|
||||||
SEND_PACKET_BROADCAST;
|
SEND_PACKET_BROADCAST;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user