mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-15 04:38:21 +00:00
Merge RC script from differnt branch
Add wandering vendor script Update proximity monitors to move with their respective entityies
This commit is contained in:
parent
e35b95f3c8
commit
691a42ba20
@ -279,6 +279,7 @@ set(INCLUDED_DIRECTORIES
|
|||||||
"dScripts/client/ai/PR"
|
"dScripts/client/ai/PR"
|
||||||
"dScripts/zone/AG"
|
"dScripts/zone/AG"
|
||||||
"dScripts/zone/LUPs"
|
"dScripts/zone/LUPs"
|
||||||
|
"dScripts/zone/LUPs/RobotCity_Intro"
|
||||||
"dScripts/zone/PROPERTY"
|
"dScripts/zone/PROPERTY"
|
||||||
"dScripts/zone/PROPERTY/FV"
|
"dScripts/zone/PROPERTY/FV"
|
||||||
"dScripts/zone/PROPERTY/GF"
|
"dScripts/zone/PROPERTY/GF"
|
||||||
|
@ -61,17 +61,17 @@ bool ProximityMonitorComponent::IsInProximity(const std::string& name, LWOOBJID
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProximityMonitorComponent::Update(float deltaTime) {
|
void ProximityMonitorComponent::Update(float deltaTime) {
|
||||||
for (const auto& prox : m_ProximitiesData) {
|
for (const auto& [name, dpentity] : m_ProximitiesData) {
|
||||||
if (!prox.second) continue;
|
if (!dpentity) continue;
|
||||||
|
dpentity->SetPosition(m_Parent->GetPosition());
|
||||||
//Process enter events
|
//Process enter events
|
||||||
for (auto* en : prox.second->GetNewObjects()) {
|
for (auto* en : dpentity->GetNewObjects()) {
|
||||||
m_Parent->OnCollisionProximity(en->GetObjectID(), prox.first, "ENTER");
|
m_Parent->OnCollisionProximity(en->GetObjectID(), name, "ENTER");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Process exit events
|
//Process exit events
|
||||||
for (auto* en : prox.second->GetRemovedObjects()) {
|
for (auto* en : dpentity->GetRemovedObjects()) {
|
||||||
m_Parent->OnCollisionProximity(en->GetObjectID(), prox.first, "LEAVE");
|
m_Parent->OnCollisionProximity(en->GetObjectID(), name, "LEAVE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
set(DSCRIPTS_SOURCES_02_SERVER_MAP_AM
|
set(DSCRIPTS_SOURCES_02_SERVER_MAP_AM
|
||||||
"AmConsoleTeleportServer.cpp"
|
"AmConsoleTeleportServer.cpp"
|
||||||
"RandomSpawnerFin.cpp"
|
"RandomSpawnerFin.cpp"
|
||||||
"RandomSpawnerPit.cpp"
|
"RandomSpawnerPit.cpp"
|
||||||
@ -16,4 +16,5 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_AM
|
|||||||
"AmSkullkinTower.cpp"
|
"AmSkullkinTower.cpp"
|
||||||
"AmBlueX.cpp"
|
"AmBlueX.cpp"
|
||||||
"AmTeapotServer.cpp"
|
"AmTeapotServer.cpp"
|
||||||
|
"WanderingVendor.cpp"
|
||||||
PARENT_SCOPE)
|
PARENT_SCOPE)
|
||||||
|
35
dScripts/02_server/Map/AM/WanderingVendor.cpp
Normal file
35
dScripts/02_server/Map/AM/WanderingVendor.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include "WanderingVendor.h"
|
||||||
|
#include "MovementAIComponent.h"
|
||||||
|
#include "ProximityMonitorComponent.h"
|
||||||
|
|
||||||
|
void WanderingVendor::OnStartup(Entity* self) {
|
||||||
|
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
||||||
|
if (!movementAIComponent) return;
|
||||||
|
movementAIComponent->Resume();
|
||||||
|
self->SetProximityRadius(10, "playermonitor");
|
||||||
|
}
|
||||||
|
|
||||||
|
void WanderingVendor::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
||||||
|
if (status == "ENTER" && entering->IsPlayer()) {
|
||||||
|
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
||||||
|
if (!movementAIComponent) return;
|
||||||
|
movementAIComponent->Pause();
|
||||||
|
self->CancelTimer("startWalking");
|
||||||
|
} else if (status == "LEAVE") {
|
||||||
|
auto* proximityMonitorComponent = self->GetComponent<ProximityMonitorComponent>();
|
||||||
|
if (!proximityMonitorComponent) {
|
||||||
|
Game::logger->LogDebug("MovementAIComponent::HandleWaypointCommandRemoveNPC", "Proximity monitor component not found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto proxObjs = proximityMonitorComponent->GetProximityObjects("playermonitor");
|
||||||
|
if (proxObjs.empty()) self->AddTimer("startWalking", 1.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WanderingVendor::OnTimerDone(Entity* self, std::string timerName) {
|
||||||
|
if (timerName == "startWalking") {
|
||||||
|
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
||||||
|
if (!movementAIComponent) return;
|
||||||
|
movementAIComponent->Resume();
|
||||||
|
}
|
||||||
|
}
|
10
dScripts/02_server/Map/AM/WanderingVendor.h
Normal file
10
dScripts/02_server/Map/AM/WanderingVendor.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "CppScripts.h"
|
||||||
|
|
||||||
|
class WanderingVendor : public CppScripts::Script {
|
||||||
|
public:
|
||||||
|
void OnStartup(Entity* self) override;
|
||||||
|
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
|
||||||
|
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||||
|
};
|
||||||
|
|
@ -235,6 +235,7 @@
|
|||||||
#include "AmDarklingDragon.h"
|
#include "AmDarklingDragon.h"
|
||||||
#include "AmBlueX.h"
|
#include "AmBlueX.h"
|
||||||
#include "AmTeapotServer.h"
|
#include "AmTeapotServer.h"
|
||||||
|
#include "WanderingVendor.h"
|
||||||
|
|
||||||
// NJ Scripts
|
// NJ Scripts
|
||||||
#include "NjGarmadonCelebration.h"
|
#include "NjGarmadonCelebration.h"
|
||||||
@ -762,6 +763,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
script = new AmBlueX();
|
script = new AmBlueX();
|
||||||
else if (scriptName == "scripts\\02_server\\Map\\AM\\L_TEAPOT_SERVER.lua")
|
else if (scriptName == "scripts\\02_server\\Map\\AM\\L_TEAPOT_SERVER.lua")
|
||||||
script = new AmTeapotServer();
|
script = new AmTeapotServer();
|
||||||
|
else if (scriptName == "scripts\\02_server\\Map\\AM\\L_WANDERING_VENDOR.lua")
|
||||||
|
script = new WanderingVendor();
|
||||||
|
|
||||||
// Ninjago
|
// Ninjago
|
||||||
else if (scriptName == "scripts\\02_server\\Map\\njhub\\L_GARMADON_CELEBRATION_SERVER.lua")
|
else if (scriptName == "scripts\\02_server\\Map\\njhub\\L_GARMADON_CELEBRATION_SERVER.lua")
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
#include "WblRobotCitizen.h"
|
|
||||||
#include "GameMessages.h"
|
|
||||||
|
|
||||||
void WblRobotCitizen::OnStartup(Entity* self) {
|
|
||||||
// TODO: make it move via controllable physics
|
|
||||||
}
|
|
||||||
|
|
||||||
void WblRobotCitizen::OnUse(Entity* self, Entity* user) {
|
|
||||||
auto movingPlatformComponent = self->GetComponent<MovingPlatformComponent>();
|
|
||||||
if (movingPlatformComponent) movingPlatformComponent->StopPathing();
|
|
||||||
auto face = NiQuaternion::LookAt(self->GetPosition(), user->GetPosition());
|
|
||||||
self->SetRotation(face);
|
|
||||||
GameMessages::SendPlayAnimation(self, u"wave");
|
|
||||||
self->AddTimer("animation time", m_AnimationTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WblRobotCitizen::OnTimerDone(Entity* self, std::string timerName) {
|
|
||||||
// TODO: make it move via controllable physics
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
set(DSCRIPTS_SOURCES_AI_WILD
|
set(DSCRIPTS_SOURCES_AI_WILD
|
||||||
"AllCrateChicken.cpp"
|
"AllCrateChicken.cpp"
|
||||||
|
"LupGenericInteract.cpp"
|
||||||
"WildAmbients.cpp"
|
"WildAmbients.cpp"
|
||||||
"WildAmbientCrab.cpp"
|
"WildAmbientCrab.cpp"
|
||||||
"WildAndScared.cpp"
|
"WildAndScared.cpp"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "LupGenericInteract.h"
|
#include "LupGenericInteract.h"
|
||||||
#include "GameMessages.h"
|
#include "GameMessages.h"
|
||||||
#include "dLogger.h"
|
|
||||||
|
|
||||||
void LupGenericInteract::OnUse(Entity* self, Entity* user) {
|
void LupGenericInteract::OnUse(Entity* self, Entity* user) {
|
||||||
GameMessages::SendPlayAnimation(self, u"interact");
|
GameMessages::SendPlayAnimation(self, u"interact");
|
@ -1,3 +1,12 @@
|
|||||||
set(DSCRIPTS_SOURCES_ZONE_LUPS
|
|
||||||
|
set(DSCRIPTS_SOURCES_ZONE_LUPS
|
||||||
"WblGenericZone.cpp"
|
"WblGenericZone.cpp"
|
||||||
PARENT_SCOPE)
|
)
|
||||||
|
|
||||||
|
add_subdirectory(RobotCity_Intro)
|
||||||
|
|
||||||
|
foreach(file ${DSCRIPTS_SOURCES_ZONE_LUPS_ROBOTCITYINTRO})
|
||||||
|
set(DSCRIPTS_SOURCES_ZONE_LUPS ${DSCRIPTS_SOURCES_ZONE_LUPS} "RobotCity_Intro/${file}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(DSCRIPTS_SOURCES_ZONE_LUPS ${DSCRIPTS_SOURCES_ZONE_LUPS} PARENT_SCOPE)
|
||||||
|
3
dScripts/zone/LUPs/RobotCity_Intro/CMakeLists.txt
Normal file
3
dScripts/zone/LUPs/RobotCity_Intro/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
set(DSCRIPTS_SOURCES_ZONE_LUPS_ROBOTCITYINTRO
|
||||||
|
"WblRobotCitizen.cpp"
|
||||||
|
PARENT_SCOPE)
|
25
dScripts/zone/LUPs/RobotCity_Intro/WblRobotCitizen.cpp
Normal file
25
dScripts/zone/LUPs/RobotCity_Intro/WblRobotCitizen.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include "WblRobotCitizen.h"
|
||||||
|
#include "MovementAIComponent.h"
|
||||||
|
#include "RenderComponent.h"
|
||||||
|
|
||||||
|
void WblRobotCitizen::OnStartup(Entity* self) {
|
||||||
|
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
||||||
|
if (!movementAIComponent) return;
|
||||||
|
movementAIComponent->Resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WblRobotCitizen::OnUse(Entity* self, Entity* user) {
|
||||||
|
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
||||||
|
if (!movementAIComponent) return;
|
||||||
|
movementAIComponent->Pause();
|
||||||
|
auto face = NiQuaternion::LookAt(self->GetPosition(), user->GetPosition());
|
||||||
|
self->SetRotation(face);
|
||||||
|
auto timer = RenderComponent::PlayAnimation(self, "wave");
|
||||||
|
self->AddTimer("animation time", timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WblRobotCitizen::OnTimerDone(Entity* self, std::string timerName) {
|
||||||
|
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
||||||
|
if (!movementAIComponent) return;
|
||||||
|
movementAIComponent->Resume();
|
||||||
|
}
|
@ -6,7 +6,5 @@ public:
|
|||||||
void OnStartup(Entity* self) override;
|
void OnStartup(Entity* self) override;
|
||||||
void OnUse(Entity* self, Entity* user) override;
|
void OnUse(Entity* self, Entity* user) override;
|
||||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||||
private:
|
|
||||||
const float m_AnimationTime = 2.5;
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user