mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +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:
42
dScripts/02_server/Objects/StinkyFishTarget.cpp
Normal file
42
dScripts/02_server/Objects/StinkyFishTarget.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "StinkyFishTarget.h"
|
||||
#include "EntityManager.h"
|
||||
|
||||
void StinkyFishTarget::OnStartup(Entity* self) {
|
||||
auto position = self->GetPosition();
|
||||
position.SetY(position.GetY() - 0.5f);
|
||||
self->SetPosition(position);
|
||||
}
|
||||
|
||||
void StinkyFishTarget::OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) {
|
||||
if (message != "stinkfish" || self->GetVar<bool>(u"used"))
|
||||
return;
|
||||
|
||||
self->SetVar<bool>(u"used", true);
|
||||
self->SetVar<LWOOBJID>(u"player", caster->GetObjectID());
|
||||
|
||||
EntityInfo entityInfo{};
|
||||
entityInfo.pos = self->GetPosition();
|
||||
entityInfo.rot = self->GetRotation();
|
||||
entityInfo.spawnerID = self->GetObjectID();
|
||||
entityInfo.settings = {
|
||||
new LDFData<bool>(u"no_timed_spawn", true)
|
||||
};
|
||||
|
||||
auto* fish = EntityManager::Instance()->CreateEntity(entityInfo);
|
||||
EntityManager::Instance()->ConstructEntity(fish);
|
||||
|
||||
self->SetVar<LWOOBJID>(u"fish", fish->GetObjectID());
|
||||
self->AddTimer("smash", 5.0f);
|
||||
}
|
||||
|
||||
void StinkyFishTarget::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "smash") {
|
||||
const auto playerID = self->GetVar<LWOOBJID>(u"player");
|
||||
auto* fish = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"fish"));
|
||||
|
||||
if (fish != nullptr) {
|
||||
fish->Smash(playerID);
|
||||
self->Smash(playerID);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user