mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +00:00
Organize dScripts (#814)
* Organize dScripts whitespace Remove parent scope Remove parent scope from initial setter Remove debug Remove helper programs * Fix NtImagimeterVisibility script Co-authored-by: aronwk-aaron <aronwk.aaron@gmail.com>
This commit is contained in:
9
dScripts/client/CMakeLists.txt
Normal file
9
dScripts/client/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
set(DSCRIPTS_SOURCES_CLIENT)
|
||||
|
||||
add_subdirectory(ai)
|
||||
|
||||
foreach(file ${DSCRIPTS_SOURCES_CLIENT_AI})
|
||||
set(DSCRIPTS_SOURCES_CLIENT ${DSCRIPTS_SOURCES_CLIENT} "ai/${file}")
|
||||
endforeach()
|
||||
|
||||
set(DSCRIPTS_SOURCES_CLIENT ${DSCRIPTS_SOURCES_CLIENT} PARENT_SCOPE)
|
9
dScripts/client/ai/CMakeLists.txt
Normal file
9
dScripts/client/ai/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
set(DSCRIPTS_SOURCES_CLIENT_AI)
|
||||
|
||||
add_subdirectory(PR)
|
||||
|
||||
foreach(file ${DSCRIPTS_SOURCES_CLIENT_AI_PR})
|
||||
set(DSCRIPTS_SOURCES_CLIENT_AI ${DSCRIPTS_SOURCES_CLIENT_AI} "PR/${file}")
|
||||
endforeach()
|
||||
|
||||
set(DSCRIPTS_SOURCES_CLIENT_AI ${DSCRIPTS_SOURCES_CLIENT_AI} PARENT_SCOPE)
|
4
dScripts/client/ai/PR/CMakeLists.txt
Normal file
4
dScripts/client/ai/PR/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
set(DSCRIPTS_SOURCES_CLIENT_AI_PR
|
||||
"PrWhistle.cpp"
|
||||
"CrabServer.cpp"
|
||||
PARENT_SCOPE)
|
43
dScripts/client/ai/PR/CrabServer.cpp
Normal file
43
dScripts/client/ai/PR/CrabServer.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "CrabServer.h"
|
||||
#include "PetComponent.h"
|
||||
|
||||
void CrabServer::OnStartup(Entity* self) {
|
||||
auto* petComponent = self->GetComponent<PetComponent>();
|
||||
if (petComponent == nullptr || petComponent->GetOwner() != nullptr)
|
||||
return;
|
||||
|
||||
// Triggers the local crab script for taming etc.
|
||||
auto tamer = self->GetVar<LWOOBJID>(u"tamer");
|
||||
// Client compares this with player:GetID() which is a string, so we'll have to give it a string
|
||||
self->SetNetworkVar(u"crabtamer", std::to_string(tamer));
|
||||
|
||||
// Kill if the player decides that the crab is not worthy
|
||||
self->AddTimer("killself", 45.0f);
|
||||
}
|
||||
|
||||
void CrabServer::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "killself") {
|
||||
|
||||
// Don't accidentally kill a pet that is already owned
|
||||
auto* petComponent = self->GetComponent<PetComponent>();
|
||||
if (petComponent == nullptr || petComponent->GetOwner() != nullptr)
|
||||
return;
|
||||
|
||||
self->Smash(self->GetObjectID(), SILENT);
|
||||
}
|
||||
}
|
||||
|
||||
void CrabServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) {
|
||||
if (type == NOTIFY_TYPE_BEGIN) {
|
||||
self->CancelTimer("killself");
|
||||
} else if (type == NOTIFY_TYPE_QUIT || type == NOTIFY_TYPE_FAILED) {
|
||||
self->Smash(self->GetObjectID(), SILENT);
|
||||
} else if (type == NOTIFY_TYPE_SUCCESS) {
|
||||
auto* petComponent = self->GetComponent<PetComponent>();
|
||||
if (petComponent == nullptr)
|
||||
return;
|
||||
// TODO: Remove custom group?
|
||||
// Command the pet to the player as it may otherwise go to its spawn point which is non existant
|
||||
// petComponent->Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 6, 202, true);
|
||||
}
|
||||
}
|
10
dScripts/client/ai/PR/CrabServer.h
Normal file
10
dScripts/client/ai/PR/CrabServer.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class CrabServer : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) override;
|
||||
};
|
14
dScripts/client/ai/PR/PrWhistle.cpp
Normal file
14
dScripts/client/ai/PR/PrWhistle.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "PrWhistle.h"
|
||||
#include "Character.h"
|
||||
#include "Entity.h"
|
||||
|
||||
void PrWhistle::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
|
||||
int32_t param3) {
|
||||
if (args == "unlockEmote") {
|
||||
auto* character = sender->GetCharacter();
|
||||
|
||||
if (character != nullptr) {
|
||||
character->UnlockEmote(115);
|
||||
}
|
||||
}
|
||||
}
|
10
dScripts/client/ai/PR/PrWhistle.h
Normal file
10
dScripts/client/ai/PR/PrWhistle.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class PrWhistle : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
|
||||
int32_t param3) override;
|
||||
};
|
||||
|
Reference in New Issue
Block a user