mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
Merge branch 'main' into moreMovementAi
This commit is contained in:
commit
8c8fc2ae87
@ -16,8 +16,9 @@
|
|||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
|
#include "MovementAIComponent.h"
|
||||||
|
|
||||||
TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo): Component(parent) {
|
TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo) : Component(parent) {
|
||||||
m_Parent = parent;
|
m_Parent = parent;
|
||||||
m_Trigger = nullptr;
|
m_Trigger = nullptr;
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ void TriggerComponent::TriggerEvent(eTriggerEventType event, Entity* optionalTar
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity* optionalTarget) {
|
void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity* optionalTarget) {
|
||||||
auto argArray = GeneralUtils::SplitString(command->args, ',');
|
auto argArray = GeneralUtils::SplitString(command->args, ',');
|
||||||
|
|
||||||
// determine targets
|
// determine targets
|
||||||
std::vector<Entity*> targetEntities = GatherTargets(command, optionalTarget);
|
std::vector<Entity*> targetEntities = GatherTargets(command, optionalTarget);
|
||||||
@ -56,119 +57,119 @@ void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity
|
|||||||
if (!targetEntity) continue;
|
if (!targetEntity) continue;
|
||||||
|
|
||||||
switch (command->id) {
|
switch (command->id) {
|
||||||
case eTriggerCommandType::ZONE_PLAYER: break;
|
case eTriggerCommandType::ZONE_PLAYER: break;
|
||||||
case eTriggerCommandType::FIRE_EVENT:
|
case eTriggerCommandType::FIRE_EVENT:
|
||||||
HandleFireEvent(targetEntity, command->args);
|
HandleFireEvent(targetEntity, command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::DESTROY_OBJ:
|
case eTriggerCommandType::DESTROY_OBJ:
|
||||||
HandleDestroyObject(targetEntity, command->args);
|
HandleDestroyObject(targetEntity, command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::TOGGLE_TRIGGER:
|
case eTriggerCommandType::TOGGLE_TRIGGER:
|
||||||
HandleToggleTrigger(targetEntity, command->args);
|
HandleToggleTrigger(targetEntity, command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::RESET_REBUILD:
|
case eTriggerCommandType::RESET_REBUILD:
|
||||||
HandleResetRebuild(targetEntity, command->args);
|
HandleResetRebuild(targetEntity, command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::SET_PATH:
|
case eTriggerCommandType::SET_PATH:
|
||||||
HandleSetPath(targetEntity, argArray);
|
HandleSetPath(targetEntity, argArray);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::SET_PICK_TYPE: break;
|
case eTriggerCommandType::SET_PICK_TYPE: break;
|
||||||
case eTriggerCommandType::MOVE_OBJECT:
|
case eTriggerCommandType::MOVE_OBJECT:
|
||||||
HandleMoveObject(targetEntity, argArray);
|
HandleMoveObject(targetEntity, argArray);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::ROTATE_OBJECT:
|
case eTriggerCommandType::ROTATE_OBJECT:
|
||||||
HandleRotateObject(targetEntity, argArray);
|
HandleRotateObject(targetEntity, argArray);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::PUSH_OBJECT:
|
case eTriggerCommandType::PUSH_OBJECT:
|
||||||
HandlePushObject(targetEntity, argArray);
|
HandlePushObject(targetEntity, argArray);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::REPEL_OBJECT:
|
case eTriggerCommandType::REPEL_OBJECT:
|
||||||
HandleRepelObject(targetEntity, command->args);
|
HandleRepelObject(targetEntity, command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::SET_TIMER:
|
case eTriggerCommandType::SET_TIMER:
|
||||||
HandleSetTimer(targetEntity, argArray);
|
HandleSetTimer(targetEntity, argArray);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::CANCEL_TIMER:
|
case eTriggerCommandType::CANCEL_TIMER:
|
||||||
HandleCancelTimer(targetEntity, command->args);
|
HandleCancelTimer(targetEntity, command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::PLAY_CINEMATIC:
|
case eTriggerCommandType::PLAY_CINEMATIC:
|
||||||
HandlePlayCinematic(targetEntity, argArray);
|
HandlePlayCinematic(targetEntity, argArray);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::TOGGLE_BBB:
|
case eTriggerCommandType::TOGGLE_BBB:
|
||||||
HandleToggleBBB(targetEntity, command->args);
|
HandleToggleBBB(targetEntity, command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::UPDATE_MISSION:
|
case eTriggerCommandType::UPDATE_MISSION:
|
||||||
HandleUpdateMission(targetEntity, argArray);
|
HandleUpdateMission(targetEntity, argArray);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::SET_BOUNCER_STATE: break;
|
case eTriggerCommandType::SET_BOUNCER_STATE: break;
|
||||||
case eTriggerCommandType::BOUNCE_ALL_ON_BOUNCER: break;
|
case eTriggerCommandType::BOUNCE_ALL_ON_BOUNCER: break;
|
||||||
case eTriggerCommandType::TURN_AROUND_ON_PATH:
|
case eTriggerCommandType::TURN_AROUND_ON_PATH:
|
||||||
HandleTurnAroundOnPath(targetEntity);
|
HandleTurnAroundOnPath(targetEntity);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::GO_FORWARD_ON_PATH:
|
case eTriggerCommandType::GO_FORWARD_ON_PATH:
|
||||||
HandleGoForwardOnPath(targetEntity);
|
HandleGoForwardOnPath(targetEntity);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::GO_BACKWARD_ON_PATH:
|
case eTriggerCommandType::GO_BACKWARD_ON_PATH:
|
||||||
HandleGoBackwardOnPath(targetEntity);
|
HandleGoBackwardOnPath(targetEntity);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::STOP_PATHING:
|
case eTriggerCommandType::STOP_PATHING:
|
||||||
HandleStopPathing(targetEntity);
|
HandleStopPathing(targetEntity);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::START_PATHING:
|
case eTriggerCommandType::START_PATHING:
|
||||||
HandleStartPathing(targetEntity);
|
HandleStartPathing(targetEntity);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::LOCK_OR_UNLOCK_CONTROLS: break;
|
case eTriggerCommandType::LOCK_OR_UNLOCK_CONTROLS: break;
|
||||||
case eTriggerCommandType::PLAY_EFFECT:
|
case eTriggerCommandType::PLAY_EFFECT:
|
||||||
HandlePlayEffect(targetEntity, argArray);
|
HandlePlayEffect(targetEntity, argArray);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::STOP_EFFECT:
|
case eTriggerCommandType::STOP_EFFECT:
|
||||||
GameMessages::SendStopFXEffect(targetEntity, true, command->args);
|
GameMessages::SendStopFXEffect(targetEntity, true, command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::CAST_SKILL:
|
case eTriggerCommandType::CAST_SKILL:
|
||||||
HandleCastSkill(targetEntity, command->args);
|
HandleCastSkill(targetEntity, command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::DISPLAY_ZONE_SUMMARY:
|
case eTriggerCommandType::DISPLAY_ZONE_SUMMARY:
|
||||||
GameMessages::SendDisplayZoneSummary(targetEntity->GetObjectID(), targetEntity->GetSystemAddress(), false, command->args == "1", m_Parent->GetObjectID());
|
GameMessages::SendDisplayZoneSummary(targetEntity->GetObjectID(), targetEntity->GetSystemAddress(), false, command->args == "1", m_Parent->GetObjectID());
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::SET_PHYSICS_VOLUME_EFFECT:
|
case eTriggerCommandType::SET_PHYSICS_VOLUME_EFFECT:
|
||||||
HandleSetPhysicsVolumeEffect(targetEntity, argArray);
|
HandleSetPhysicsVolumeEffect(targetEntity, argArray);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::SET_PHYSICS_VOLUME_STATUS:
|
case eTriggerCommandType::SET_PHYSICS_VOLUME_STATUS:
|
||||||
HandleSetPhysicsVolumeStatus(targetEntity, command->args);
|
HandleSetPhysicsVolumeStatus(targetEntity, command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::SET_MODEL_TO_BUILD: break;
|
case eTriggerCommandType::SET_MODEL_TO_BUILD: break;
|
||||||
case eTriggerCommandType::SPAWN_MODEL_BRICKS: break;
|
case eTriggerCommandType::SPAWN_MODEL_BRICKS: break;
|
||||||
case eTriggerCommandType::ACTIVATE_SPAWNER_NETWORK:
|
case eTriggerCommandType::ACTIVATE_SPAWNER_NETWORK:
|
||||||
HandleActivateSpawnerNetwork(command->args);
|
HandleActivateSpawnerNetwork(command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::DEACTIVATE_SPAWNER_NETWORK:
|
case eTriggerCommandType::DEACTIVATE_SPAWNER_NETWORK:
|
||||||
HandleDeactivateSpawnerNetwork(command->args);
|
HandleDeactivateSpawnerNetwork(command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::RESET_SPAWNER_NETWORK:
|
case eTriggerCommandType::RESET_SPAWNER_NETWORK:
|
||||||
HandleResetSpawnerNetwork(command->args);
|
HandleResetSpawnerNetwork(command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::DESTROY_SPAWNER_NETWORK_OBJECTS:
|
case eTriggerCommandType::DESTROY_SPAWNER_NETWORK_OBJECTS:
|
||||||
HandleDestroySpawnerNetworkObjects(command->args);
|
HandleDestroySpawnerNetworkObjects(command->args);
|
||||||
break;
|
break;
|
||||||
case eTriggerCommandType::GO_TO_WAYPOINT: break;
|
case eTriggerCommandType::GO_TO_WAYPOINT: break;
|
||||||
case eTriggerCommandType::ACTIVATE_PHYSICS:
|
case eTriggerCommandType::ACTIVATE_PHYSICS:
|
||||||
HandleActivatePhysics(targetEntity, command->args);
|
HandleActivatePhysics(targetEntity, command->args);
|
||||||
break;
|
break;
|
||||||
// DEPRECATED BLOCK START
|
// DEPRECATED BLOCK START
|
||||||
case eTriggerCommandType::ACTIVATE_MUSIC_CUE: break;
|
case eTriggerCommandType::ACTIVATE_MUSIC_CUE: break;
|
||||||
case eTriggerCommandType::DEACTIVATE_MUSIC_CUE: break;
|
case eTriggerCommandType::DEACTIVATE_MUSIC_CUE: break;
|
||||||
case eTriggerCommandType::FLASH_MUSIC_CUE: break;
|
case eTriggerCommandType::FLASH_MUSIC_CUE: break;
|
||||||
case eTriggerCommandType::SET_MUSIC_PARAMETER: break;
|
case eTriggerCommandType::SET_MUSIC_PARAMETER: break;
|
||||||
case eTriggerCommandType::PLAY_2D_AMBIENT_SOUND: break;
|
case eTriggerCommandType::PLAY_2D_AMBIENT_SOUND: break;
|
||||||
case eTriggerCommandType::STOP_2D_AMBIENT_SOUND: break;
|
case eTriggerCommandType::STOP_2D_AMBIENT_SOUND: break;
|
||||||
case eTriggerCommandType::PLAY_3D_AMBIENT_SOUND: break;
|
case eTriggerCommandType::PLAY_3D_AMBIENT_SOUND: break;
|
||||||
case eTriggerCommandType::STOP_3D_AMBIENT_SOUND: break;
|
case eTriggerCommandType::STOP_3D_AMBIENT_SOUND: break;
|
||||||
case eTriggerCommandType::ACTIVATE_MIXER_PROGRAM: break;
|
case eTriggerCommandType::ACTIVATE_MIXER_PROGRAM: break;
|
||||||
case eTriggerCommandType::DEACTIVATE_MIXER_PROGRAM: break;
|
case eTriggerCommandType::DEACTIVATE_MIXER_PROGRAM: break;
|
||||||
// DEPRECATED BLOCK END
|
// DEPRECATED BLOCK END
|
||||||
default:
|
default:
|
||||||
LOG_DEBUG("Event %i was not handled!", command->id);
|
LOG_DEBUG("Event %i was not handled!", command->id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,20 +178,25 @@ std::vector<Entity*> TriggerComponent::GatherTargets(LUTriggers::Command* comman
|
|||||||
std::vector<Entity*> entities = {};
|
std::vector<Entity*> entities = {};
|
||||||
|
|
||||||
if (command->target == "self") entities.push_back(m_Parent);
|
if (command->target == "self") entities.push_back(m_Parent);
|
||||||
else if (command->target == "zone") { /*TODO*/ }
|
else if (command->target == "zone") {
|
||||||
else if (command->target == "target" && optionalTarget) entities.push_back(optionalTarget);
|
/*TODO*/
|
||||||
else if (command->target == "targetTeam" && optionalTarget) {
|
} else if (command->target == "target" && optionalTarget) {
|
||||||
|
entities.push_back(optionalTarget);
|
||||||
|
} else if (command->target == "targetTeam" && optionalTarget) {
|
||||||
auto* team = TeamManager::Instance()->GetTeam(optionalTarget->GetObjectID());
|
auto* team = TeamManager::Instance()->GetTeam(optionalTarget->GetObjectID());
|
||||||
for (const auto memberId : team->members) {
|
for (const auto memberId : team->members) {
|
||||||
auto* member = Game::entityManager->GetEntity(memberId);
|
auto* member = Game::entityManager->GetEntity(memberId);
|
||||||
if (member) entities.push_back(member);
|
if (member) entities.push_back(member);
|
||||||
}
|
}
|
||||||
} else if (command->target == "objGroup") entities = Game::entityManager->GetEntitiesInGroup(command->targetName);
|
} else if (command->target == "objGroup") {
|
||||||
else if (command->target == "allPlayers") {
|
entities = Game::entityManager->GetEntitiesInGroup(command->targetName);
|
||||||
|
} else if (command->target == "allPlayers") {
|
||||||
for (auto* player : PlayerManager::GetAllPlayers()) {
|
for (auto* player : PlayerManager::GetAllPlayers()) {
|
||||||
entities.push_back(player);
|
entities.push_back(player);
|
||||||
}
|
}
|
||||||
} else if (command->target == "allNPCs") { /*UNUSED*/ }
|
} else if (command->target == "allNPCs") {
|
||||||
|
/*UNUSED*/
|
||||||
|
}
|
||||||
|
|
||||||
return entities;
|
return entities;
|
||||||
}
|
}
|
||||||
@ -199,12 +205,12 @@ void TriggerComponent::HandleFireEvent(Entity* targetEntity, std::string args) {
|
|||||||
targetEntity->GetScript()->OnFireEventServerSide(targetEntity, m_Parent, args, 0, 0, 0);
|
targetEntity->GetScript()->OnFireEventServerSide(targetEntity, m_Parent, args, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args) {
|
||||||
const eKillType killType = GeneralUtils::TryParse<eKillType>(args).value_or(eKillType::VIOLENT);
|
const eKillType killType = GeneralUtils::TryParse<eKillType>(args).value_or(eKillType::VIOLENT);
|
||||||
targetEntity->Smash(m_Parent->GetObjectID(), killType);
|
targetEntity->Smash(m_Parent->GetObjectID(), killType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args) {
|
||||||
auto* triggerComponent = targetEntity->GetComponent<TriggerComponent>();
|
auto* triggerComponent = targetEntity->GetComponent<TriggerComponent>();
|
||||||
if (!triggerComponent) {
|
if (!triggerComponent) {
|
||||||
LOG_DEBUG("Trigger component not found!");
|
LOG_DEBUG("Trigger component not found!");
|
||||||
@ -213,7 +219,7 @@ void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string arg
|
|||||||
triggerComponent->SetTriggerEnabled(args == "1");
|
triggerComponent->SetTriggerEnabled(args == "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args) {
|
||||||
auto* quickBuildComponent = targetEntity->GetComponent<QuickBuildComponent>();
|
auto* quickBuildComponent = targetEntity->GetComponent<QuickBuildComponent>();
|
||||||
if (!quickBuildComponent) {
|
if (!quickBuildComponent) {
|
||||||
LOG_DEBUG("Rebuild component not found!");
|
LOG_DEBUG("Rebuild component not found!");
|
||||||
@ -222,19 +228,7 @@ void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args
|
|||||||
quickBuildComponent->ResetQuickBuild(args == "1");
|
quickBuildComponent->ResetQuickBuild(args == "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleSetPath(Entity* targetEntity, std::vector<std::string> argArray){
|
void TriggerComponent::HandleMoveObject(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||||
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
|
||||||
if (!movementAIComponent) return;
|
|
||||||
movementAIComponent->SetupPath(argArray.at(0));
|
|
||||||
if (argArray.size() >= 2) {
|
|
||||||
auto index = GeneralUtils::TryParse<int32_t>(argArray.at(1));
|
|
||||||
if (!index) return;
|
|
||||||
movementAIComponent->SetPathStartingWaypointIndex(index.value());
|
|
||||||
}
|
|
||||||
if (argArray.size() >= 3 && argArray.at(2) == "1") movementAIComponent->ReversePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriggerComponent::HandleMoveObject(Entity* targetEntity, std::vector<std::string> argArray){
|
|
||||||
if (argArray.size() <= 2) return;
|
if (argArray.size() <= 2) return;
|
||||||
|
|
||||||
NiPoint3 position = targetEntity->GetPosition();
|
NiPoint3 position = targetEntity->GetPosition();
|
||||||
@ -244,7 +238,7 @@ void TriggerComponent::HandleMoveObject(Entity* targetEntity, std::vector<std::s
|
|||||||
targetEntity->SetPosition(position);
|
targetEntity->SetPosition(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std::string> argArray){
|
void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||||
if (argArray.size() <= 2) return;
|
if (argArray.size() <= 2) return;
|
||||||
|
|
||||||
const NiPoint3 vector = GeneralUtils::TryParse<NiPoint3>(argArray).value_or(NiPoint3Constant::ZERO);
|
const NiPoint3 vector = GeneralUtils::TryParse<NiPoint3>(argArray).value_or(NiPoint3Constant::ZERO);
|
||||||
@ -253,7 +247,7 @@ void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std:
|
|||||||
targetEntity->SetRotation(rotation);
|
targetEntity->SetRotation(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::string> argArray){
|
void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||||
if (argArray.size() < 3) return;
|
if (argArray.size() < 3) return;
|
||||||
|
|
||||||
auto* phantomPhysicsComponent = m_Parent->GetComponent<PhantomPhysicsComponent>();
|
auto* phantomPhysicsComponent = m_Parent->GetComponent<PhantomPhysicsComponent>();
|
||||||
@ -271,7 +265,7 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::s
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args) {
|
||||||
auto* phantomPhysicsComponent = m_Parent->GetComponent<PhantomPhysicsComponent>();
|
auto* phantomPhysicsComponent = m_Parent->GetComponent<PhantomPhysicsComponent>();
|
||||||
if (!phantomPhysicsComponent) {
|
if (!phantomPhysicsComponent) {
|
||||||
LOG_DEBUG("Phantom Physics component not found!");
|
LOG_DEBUG("Phantom Physics component not found!");
|
||||||
@ -295,7 +289,7 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args)
|
|||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::string> argArray){
|
void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||||
if (argArray.size() != 2) {
|
if (argArray.size() != 2) {
|
||||||
LOG_DEBUG("Not enough variables!");
|
LOG_DEBUG("Not enough variables!");
|
||||||
return;
|
return;
|
||||||
@ -304,7 +298,7 @@ void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::str
|
|||||||
m_Parent->AddTimer(argArray.at(0), time);
|
m_Parent->AddTimer(argArray.at(0), time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleCancelTimer(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleCancelTimer(Entity* targetEntity, std::string args) {
|
||||||
m_Parent->CancelTimer(args);
|
m_Parent->CancelTimer(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,7 +346,7 @@ void TriggerComponent::HandleUpdateMission(Entity* targetEntity, std::vector<std
|
|||||||
// then we need a good way to convert this from a string to that enum
|
// then we need a good way to convert this from a string to that enum
|
||||||
if (argArray.at(0) != "exploretask") return;
|
if (argArray.at(0) != "exploretask") return;
|
||||||
MissionComponent* missionComponent = targetEntity->GetComponent<MissionComponent>();
|
MissionComponent* missionComponent = targetEntity->GetComponent<MissionComponent>();
|
||||||
if (!missionComponent){
|
if (!missionComponent) {
|
||||||
LOG_DEBUG("Mission component not found!");
|
LOG_DEBUG("Mission component not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -394,7 +388,7 @@ void TriggerComponent::HandlePlayEffect(Entity* targetEntity, std::vector<std::s
|
|||||||
const auto effectID = GeneralUtils::TryParse<int32_t>(argArray.at(1));
|
const auto effectID = GeneralUtils::TryParse<int32_t>(argArray.at(1));
|
||||||
if (!effectID) return;
|
if (!effectID) return;
|
||||||
std::u16string effectType = GeneralUtils::UTF8ToUTF16(argArray.at(2));
|
std::u16string effectType = GeneralUtils::UTF8ToUTF16(argArray.at(2));
|
||||||
|
|
||||||
float priority = 1;
|
float priority = 1;
|
||||||
if (argArray.size() == 4) {
|
if (argArray.size() == 4) {
|
||||||
priority = GeneralUtils::TryParse<float>(argArray.at(3)).value_or(priority);
|
priority = GeneralUtils::TryParse<float>(argArray.at(3)).value_or(priority);
|
||||||
@ -403,7 +397,7 @@ void TriggerComponent::HandlePlayEffect(Entity* targetEntity, std::vector<std::s
|
|||||||
GameMessages::SendPlayFXEffect(targetEntity, effectID.value(), effectType, argArray.at(0), LWOOBJID_EMPTY, priority);
|
GameMessages::SendPlayFXEffect(targetEntity, effectID.value(), effectType, argArray.at(0), LWOOBJID_EMPTY, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args) {
|
||||||
auto* skillComponent = targetEntity->GetComponent<SkillComponent>();
|
auto* skillComponent = targetEntity->GetComponent<SkillComponent>();
|
||||||
if (!skillComponent) {
|
if (!skillComponent) {
|
||||||
LOG_DEBUG("Skill component not found!");
|
LOG_DEBUG("Skill component not found!");
|
||||||
@ -431,7 +425,7 @@ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::v
|
|||||||
phantomPhysicsComponent->SetEffectType(effectType);
|
phantomPhysicsComponent->SetEffectType(effectType);
|
||||||
phantomPhysicsComponent->SetDirectionalMultiplier(std::stof(argArray.at(1)));
|
phantomPhysicsComponent->SetDirectionalMultiplier(std::stof(argArray.at(1)));
|
||||||
if (argArray.size() > 4) {
|
if (argArray.size() > 4) {
|
||||||
const NiPoint3 direction =
|
const NiPoint3 direction =
|
||||||
GeneralUtils::TryParse<NiPoint3>(argArray.at(2), argArray.at(3), argArray.at(4)).value_or(NiPoint3Constant::ZERO);
|
GeneralUtils::TryParse<NiPoint3>(argArray.at(2), argArray.at(3), argArray.at(4)).value_or(NiPoint3Constant::ZERO);
|
||||||
|
|
||||||
phantomPhysicsComponent->SetDirection(direction);
|
phantomPhysicsComponent->SetDirection(direction);
|
||||||
@ -457,25 +451,25 @@ void TriggerComponent::HandleSetPhysicsVolumeStatus(Entity* targetEntity, std::s
|
|||||||
Game::entityManager->SerializeEntity(targetEntity);
|
Game::entityManager->SerializeEntity(targetEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleActivateSpawnerNetwork(std::string args){
|
void TriggerComponent::HandleActivateSpawnerNetwork(std::string args) {
|
||||||
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
||||||
if (spawner) spawner->Activate();
|
if (spawner) spawner->Activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleDeactivateSpawnerNetwork(std::string args){
|
void TriggerComponent::HandleDeactivateSpawnerNetwork(std::string args) {
|
||||||
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
||||||
if (spawner) spawner->Deactivate();
|
if (spawner) spawner->Deactivate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleResetSpawnerNetwork(std::string args){
|
void TriggerComponent::HandleResetSpawnerNetwork(std::string args) {
|
||||||
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
||||||
if (spawner) spawner->Reset();
|
if (spawner) spawner->Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleDestroySpawnerNetworkObjects(std::string args){
|
void TriggerComponent::HandleDestroySpawnerNetworkObjects(std::string args) {
|
||||||
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
||||||
if (spawner) spawner->DestroyAllEntities();
|
if (spawner) spawner->DestroyAllEntities();
|
||||||
}
|
}
|
||||||
@ -484,9 +478,50 @@ void TriggerComponent::HandleDestroySpawnerNetworkObjects(std::string args){
|
|||||||
void TriggerComponent::HandleActivatePhysics(Entity* targetEntity, std::string args) {
|
void TriggerComponent::HandleActivatePhysics(Entity* targetEntity, std::string args) {
|
||||||
if (args == "true") {
|
if (args == "true") {
|
||||||
// TODO add physics entity if there isn't one
|
// TODO add physics entity if there isn't one
|
||||||
} else if (args == "false"){
|
} else if (args == "false") {
|
||||||
// TODO remove Phsyics entity if there is one
|
// TODO remove Phsyics entity if there is one
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("Invalid argument for ActivatePhysics Trigger: %s", args.c_str());
|
LOG_DEBUG("Invalid argument for ActivatePhysics Trigger: %s", args.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TriggerComponent::HandleSetPath(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||||
|
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||||
|
if (!movementAIComponent) return;
|
||||||
|
// movementAIComponent->SetupPath(argArray.at(0));
|
||||||
|
if (argArray.size() >= 2) {
|
||||||
|
auto index = GeneralUtils::TryParse<int32_t>(argArray.at(1));
|
||||||
|
if (!index) return;
|
||||||
|
// movementAIComponent->SetPathStartingWaypointIndex(index.value());
|
||||||
|
}
|
||||||
|
if (argArray.size() >= 3 && argArray.at(2) == "1") {
|
||||||
|
// movementAIComponent->ReversePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriggerComponent::HandleTurnAroundOnPath(Entity* targetEntity) {
|
||||||
|
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||||
|
// if (movementAIComponent) movementAIComponent->ReversePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriggerComponent::HandleGoForwardOnPath(Entity* targetEntity) {
|
||||||
|
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||||
|
if (!movementAIComponent) return;
|
||||||
|
// if (movementAIComponent->GetIsInReverse()) movementAIComponent->ReversePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriggerComponent::HandleGoBackwardOnPath(Entity* targetEntity) {
|
||||||
|
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||||
|
if (!movementAIComponent) return;
|
||||||
|
// if (!movementAIComponent->GetIsInReverse()) movementAIComponent->ReversePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriggerComponent::HandleStopPathing(Entity* targetEntity) {
|
||||||
|
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||||
|
// if (movementAIComponent) movementAIComponent->Pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriggerComponent::HandleStartPathing(Entity* targetEntity) {
|
||||||
|
auto* movementAIComponent = targetEntity->GetComponent<MovementAIComponent>();
|
||||||
|
// if (movementAIComponent) movementAIComponent->Resume();
|
||||||
|
}
|
||||||
|
@ -50,6 +50,12 @@ private:
|
|||||||
void HandleResetSpawnerNetwork(std::string args);
|
void HandleResetSpawnerNetwork(std::string args);
|
||||||
void HandleDestroySpawnerNetworkObjects(std::string args);
|
void HandleDestroySpawnerNetworkObjects(std::string args);
|
||||||
void HandleActivatePhysics(Entity* targetEntity, std::string args);
|
void HandleActivatePhysics(Entity* targetEntity, std::string args);
|
||||||
|
void HandleTurnAroundOnPath(Entity* targetEntity);
|
||||||
|
void HandleGoForwardOnPath(Entity* targetEntity);
|
||||||
|
void HandleGoBackwardOnPath(Entity* targetEntity);
|
||||||
|
void HandleStopPathing(Entity* targetEntity);
|
||||||
|
void HandleStartPathing(Entity* targetEntity);
|
||||||
|
void HandleSetPath(Entity* targetEntity, std::vector<std::string> argArray);
|
||||||
|
|
||||||
LUTriggers::Trigger* m_Trigger;
|
LUTriggers::Trigger* m_Trigger;
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ void StoryBoxInteractServer::OnUse(Entity* self, Entity* user) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self->HasVar(u"storyText") || !self->HasVar(u"altFlagID")) return;
|
if (!self->HasVar(u"storyText")) return;
|
||||||
const auto storyText = self->GetVarAsString(u"storyText");
|
const auto storyText = self->GetVarAsString(u"storyText");
|
||||||
if (storyText.length() > 2) {
|
if (storyText.length() > 2) {
|
||||||
auto storyValue = GeneralUtils::TryParse<uint32_t>(storyText.substr(storyText.length() - 2));
|
auto storyValue = GeneralUtils::TryParse<uint32_t>(storyText.substr(storyText.length() - 2));
|
||||||
|
@ -453,18 +453,20 @@ void Zone::LoadPath(std::istream& file) {
|
|||||||
std::string value;
|
std::string value;
|
||||||
BinaryIO::ReadString<uint8_t>(file, value, BinaryIO::ReadType::WideString);
|
BinaryIO::ReadString<uint8_t>(file, value, BinaryIO::ReadType::WideString);
|
||||||
|
|
||||||
LDFBaseData* ldfConfig = nullptr;
|
|
||||||
if (path.pathType == PathType::Movement || path.pathType == PathType::Rail) {
|
if (path.pathType == PathType::Movement || path.pathType == PathType::Rail) {
|
||||||
// cause NetDevil puts spaces in things that don't need spaces
|
// cause NetDevil puts spaces in things that don't need spaces
|
||||||
parameter.erase(std::remove_if(parameter.begin(), parameter.end(), ::isspace), parameter.end());
|
parameter.erase(std::remove_if(parameter.begin(), parameter.end(), ::isspace), parameter.end());
|
||||||
auto waypointCommand = WaypointCommandType::StringToWaypointCommandType(parameter);
|
auto waypointCommand = WaypointCommandType::StringToWaypointCommandType(parameter);
|
||||||
if (waypointCommand == eWaypointCommandType::DELAY) value.erase(std::remove_if(value.begin(), value.end(), ::isspace), value.end());
|
if (waypointCommand == eWaypointCommandType::DELAY) value.erase(std::remove_if(value.begin(), value.end(), ::isspace), value.end());
|
||||||
if (waypointCommand != eWaypointCommandType::INVALID) waypoint.commands.push_back(WaypointCommand(waypointCommand, value));
|
if (waypointCommand != eWaypointCommandType::INVALID) {
|
||||||
else LOG("Tried to load invalid waypoint command '%s'", parameter.c_str());
|
auto& command = waypoint.commands.emplace_back();
|
||||||
|
command.command = waypointCommand;
|
||||||
|
command.data = value;
|
||||||
|
} else LOG("Tried to load invalid waypoint command '%s'", parameter.c_str());
|
||||||
} else {
|
} else {
|
||||||
ldfConfig = LDFBaseData::DataFromString(parameter + "=" + value);
|
waypoint.config.emplace_back(LDFBaseData::DataFromString(parameter + "=" + value));
|
||||||
if (ldfConfig) waypoint.config.push_back(ldfConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,15 +14,13 @@ namespace LUTriggers {
|
|||||||
class Level;
|
class Level;
|
||||||
|
|
||||||
enum class eWaypointCommandType : uint32_t;
|
enum class eWaypointCommandType : uint32_t;
|
||||||
|
|
||||||
struct WaypointCommand {
|
struct WaypointCommand {
|
||||||
eWaypointCommandType command;
|
eWaypointCommandType command;
|
||||||
std::string data;
|
std::string data;
|
||||||
WaypointCommand(eWaypointCommandType command, std::string data){
|
|
||||||
this->command = command;
|
|
||||||
this->data = data;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct SceneRef {
|
struct SceneRef {
|
||||||
std::string filename;
|
std::string filename;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
Loading…
Reference in New Issue
Block a user