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:
13
dScripts/EquipmentScripts/AnvilOfArmor.cpp
Normal file
13
dScripts/EquipmentScripts/AnvilOfArmor.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "AnvilOfArmor.h"
|
||||
|
||||
void AnvilOfArmor::OnStartup(Entity* self) {
|
||||
self->SetVar<uint32_t>(u"numCycles", 8);
|
||||
self->SetVar<float_t>(u"secPerCycle", 25.0f);
|
||||
self->SetVar<float_t>(u"delayToFirstCycle", 1.5f);
|
||||
self->SetVar<float_t>(u"deathDelay", 25.0f);
|
||||
self->SetVar<uint32_t>(u"numberOfPowerups", 4);
|
||||
self->SetVar<LOT>(u"lootLOT", 6431);
|
||||
|
||||
// Initiate the actual script
|
||||
OnTemplateStartup(self);
|
||||
}
|
6
dScripts/EquipmentScripts/AnvilOfArmor.h
Normal file
6
dScripts/EquipmentScripts/AnvilOfArmor.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include "ScriptedPowerupSpawner.h"
|
||||
|
||||
class AnvilOfArmor : public ScriptedPowerupSpawner {
|
||||
void OnStartup(Entity* self) override;
|
||||
};
|
18
dScripts/EquipmentScripts/BuccaneerValiantShip.cpp
Normal file
18
dScripts/EquipmentScripts/BuccaneerValiantShip.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "BuccaneerValiantShip.h"
|
||||
#include "SkillComponent.h"
|
||||
|
||||
void BuccaneerValiantShip::OnStartup(Entity* self) {
|
||||
self->AddCallbackTimer(1.0F, [self]() {
|
||||
auto* skillComponent = self->GetComponent<SkillComponent>();
|
||||
auto* owner = self->GetOwner();
|
||||
|
||||
if (skillComponent != nullptr && owner != nullptr) {
|
||||
skillComponent->CalculateBehavior(982, 20577, LWOOBJID_EMPTY, true, false, owner->GetObjectID());
|
||||
|
||||
// Kill self if missed
|
||||
self->AddCallbackTimer(1.1F, [self]() {
|
||||
self->Kill();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
6
dScripts/EquipmentScripts/BuccaneerValiantShip.h
Normal file
6
dScripts/EquipmentScripts/BuccaneerValiantShip.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class BuccaneerValiantShip : public CppScripts::Script {
|
||||
void OnStartup(Entity* self) override;
|
||||
};
|
9
dScripts/EquipmentScripts/CMakeLists.txt
Normal file
9
dScripts/EquipmentScripts/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
set(DSCRIPTS_SOURCES_EQUIPMENTSCRIPTS
|
||||
"Sunflower.cpp"
|
||||
"AnvilOfArmor.cpp"
|
||||
"FountainOfImagination.cpp"
|
||||
"CauldronOfLife.cpp"
|
||||
"PersonalFortress.cpp"
|
||||
"BuccaneerValiantShip.cpp"
|
||||
"FireFirstSkillonStartup.cpp"
|
||||
PARENT_SCOPE)
|
13
dScripts/EquipmentScripts/CauldronOfLife.cpp
Normal file
13
dScripts/EquipmentScripts/CauldronOfLife.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "CauldronOfLife.h"
|
||||
|
||||
void CauldronOfLife::OnStartup(Entity* self) {
|
||||
self->SetVar<uint32_t>(u"numCycles", 10);
|
||||
self->SetVar<float_t>(u"secPerCycle", 20.0f);
|
||||
self->SetVar<float_t>(u"delayToFirstCycle", 1.5f);
|
||||
self->SetVar<float_t>(u"deathDelay", 20.0f);
|
||||
self->SetVar<uint32_t>(u"numberOfPowerups", 3);
|
||||
self->SetVar<LOT>(u"lootLOT", 177);
|
||||
|
||||
// Initiate the actual script
|
||||
OnTemplateStartup(self);
|
||||
}
|
6
dScripts/EquipmentScripts/CauldronOfLife.h
Normal file
6
dScripts/EquipmentScripts/CauldronOfLife.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include "ScriptedPowerupSpawner.h"
|
||||
|
||||
class CauldronOfLife : public ScriptedPowerupSpawner {
|
||||
void OnStartup(Entity* self) override;
|
||||
};
|
24
dScripts/EquipmentScripts/FireFirstSkillonStartup.cpp
Normal file
24
dScripts/EquipmentScripts/FireFirstSkillonStartup.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "FireFirstSkillonStartup.h"
|
||||
#include "Entity.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "CDClientDatabase.h"
|
||||
#include "CDObjectSkillsTable.h"
|
||||
|
||||
void FireFirstSkillonStartup::OnStartup(Entity* self) {
|
||||
auto skillComponent = self->GetComponent<SkillComponent>();
|
||||
if (!skillComponent) return;
|
||||
|
||||
// Get the skill IDs of this object.
|
||||
CDObjectSkillsTable* skillsTable = CDClientManager::Instance()->GetTable<CDObjectSkillsTable>("ObjectSkills");
|
||||
std::vector<CDObjectSkills> skills = skillsTable->Query([=](CDObjectSkills entry) {return (entry.objectTemplate == self->GetLOT()); });
|
||||
|
||||
// For each skill, cast it with the associated behavior ID.
|
||||
for (auto skill : skills) {
|
||||
CDSkillBehaviorTable* skillBehaviorTable = CDClientManager::Instance()->GetTable<CDSkillBehaviorTable>("SkillBehavior");
|
||||
CDSkillBehavior behaviorData = skillBehaviorTable->GetSkillByID(skill.skillID);
|
||||
|
||||
// Should parent entity be null, make the originator self.
|
||||
const auto target = self->GetParentEntity() ? self->GetParentEntity()->GetObjectID() : self->GetObjectID();
|
||||
skillComponent->CalculateBehavior(skill.skillID, behaviorData.behaviorID, LWOOBJID_EMPTY, false, false, target);
|
||||
}
|
||||
}
|
12
dScripts/EquipmentScripts/FireFirstSkillonStartup.h
Normal file
12
dScripts/EquipmentScripts/FireFirstSkillonStartup.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#ifndef __FIREFIRSTSKILLONSTARTUP__H__
|
||||
#define __FIREFIRSTSKILLONSTARTUP__H__
|
||||
|
||||
#include "CppScripts.h"
|
||||
|
||||
class FireFirstSkillonStartup : public CppScripts::Script {
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
};
|
||||
|
||||
#endif //!__FIREFIRSTSKILLONSTARTUP__H__
|
15
dScripts/EquipmentScripts/FountainOfImagination.cpp
Normal file
15
dScripts/EquipmentScripts/FountainOfImagination.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "FountainOfImagination.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "Entity.h"
|
||||
|
||||
void FountainOfImagination::OnStartup(Entity* self) {
|
||||
self->SetVar<uint32_t>(u"numCycles", 6);
|
||||
self->SetVar<float_t>(u"secPerCycle", 30.0f);
|
||||
self->SetVar<float_t>(u"delayToFirstCycle", 1.5f);
|
||||
self->SetVar<float_t>(u"deathDelay", 30.0f);
|
||||
self->SetVar<uint32_t>(u"numberOfPowerups", 5);
|
||||
self->SetVar<LOT>(u"lootLOT", 935);
|
||||
|
||||
// Initiate the actual script
|
||||
OnTemplateStartup(self);
|
||||
}
|
6
dScripts/EquipmentScripts/FountainOfImagination.h
Normal file
6
dScripts/EquipmentScripts/FountainOfImagination.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include "ScriptedPowerupSpawner.h"
|
||||
|
||||
class FountainOfImagination : public ScriptedPowerupSpawner {
|
||||
void OnStartup(Entity* self) override;
|
||||
};
|
50
dScripts/EquipmentScripts/PersonalFortress.cpp
Normal file
50
dScripts/EquipmentScripts/PersonalFortress.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "PersonalFortress.h"
|
||||
#include "GameMessages.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "EntityManager.h"
|
||||
|
||||
void PersonalFortress::OnStartup(Entity* self) {
|
||||
auto* owner = self->GetOwner();
|
||||
self->AddTimer("FireSkill", 1.5);
|
||||
GameMessages::SendSetStunned(owner->GetObjectID(), PUSH, owner->GetSystemAddress(), LWOOBJID_EMPTY,
|
||||
true, true, true, true, true, true, true, true, true
|
||||
);
|
||||
|
||||
auto* destroyableComponent = owner->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent != nullptr) {
|
||||
destroyableComponent->PushImmunity();
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(owner);
|
||||
}
|
||||
|
||||
void PersonalFortress::OnDie(Entity* self, Entity* killer) {
|
||||
auto* owner = self->GetOwner();
|
||||
GameMessages::SendSetStunned(owner->GetObjectID(), POP, owner->GetSystemAddress(), LWOOBJID_EMPTY,
|
||||
true, true, true, true, true, true, true, true, true
|
||||
);
|
||||
|
||||
auto* destroyableComponent = owner->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent != nullptr) {
|
||||
destroyableComponent->PopImmunity();
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(owner);
|
||||
}
|
||||
|
||||
void PersonalFortress::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "FireSkill") {
|
||||
auto* owner = self->GetOwner();
|
||||
|
||||
auto* skillComponent = self->GetComponent<SkillComponent>();
|
||||
|
||||
if (skillComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
skillComponent->CalculateBehavior(650, 13364, LWOOBJID_EMPTY, true, false);
|
||||
}
|
||||
}
|
12
dScripts/EquipmentScripts/PersonalFortress.h
Normal file
12
dScripts/EquipmentScripts/PersonalFortress.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class PersonalFortress : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
|
||||
void OnDie(Entity* self, Entity* killer) override;
|
||||
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
};
|
14
dScripts/EquipmentScripts/Sunflower.cpp
Normal file
14
dScripts/EquipmentScripts/Sunflower.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "Sunflower.h"
|
||||
#include "Entity.h"
|
||||
|
||||
void Sunflower::OnStartup(Entity* self) {
|
||||
self->SetVar<uint32_t>(u"numCycles", 6);
|
||||
self->SetVar<float_t>(u"secPerCycle", 5.0f);
|
||||
self->SetVar<float_t>(u"delayToFirstCycle", 1.5f);
|
||||
self->SetVar<float_t>(u"deathDelay", 30.0f);
|
||||
self->SetVar<uint32_t>(u"numberOfPowerups", 4);
|
||||
self->SetVar<LOT>(u"lootLOT", 11910);
|
||||
|
||||
// Initiate the actual script
|
||||
OnTemplateStartup(self);
|
||||
}
|
6
dScripts/EquipmentScripts/Sunflower.h
Normal file
6
dScripts/EquipmentScripts/Sunflower.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include "ScriptedPowerupSpawner.h"
|
||||
|
||||
class Sunflower : public ScriptedPowerupSpawner {
|
||||
void OnStartup(Entity* self) override;
|
||||
};
|
Reference in New Issue
Block a user