mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +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:
@@ -1,4 +1,4 @@
|
||||
set(DSCRIPTS_SOURCES_02_SERVER_MAP_AM
|
||||
set(DSCRIPTS_SOURCES_02_SERVER_MAP_AM
|
||||
"AmConsoleTeleportServer.cpp"
|
||||
"RandomSpawnerFin.cpp"
|
||||
"RandomSpawnerPit.cpp"
|
||||
@@ -16,4 +16,5 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_AM
|
||||
"AmSkullkinTower.cpp"
|
||||
"AmBlueX.cpp"
|
||||
"AmTeapotServer.cpp"
|
||||
"WanderingVendor.cpp"
|
||||
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;
|
||||
};
|
||||
|
Reference in New Issue
Block a user