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:
David Markowitz
2022-11-03 10:57:54 -07:00
committed by GitHub
parent b974eed8f5
commit 8d37d9b681
567 changed files with 886 additions and 252 deletions

View 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);
}

View File

@@ -0,0 +1,6 @@
#pragma once
#include "ScriptedPowerupSpawner.h"
class AnvilOfArmor : public ScriptedPowerupSpawner {
void OnStartup(Entity* self) override;
};

View 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();
});
}
});
}

View File

@@ -0,0 +1,6 @@
#pragma once
#include "CppScripts.h"
class BuccaneerValiantShip : public CppScripts::Script {
void OnStartup(Entity* self) override;
};

View 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)

View 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);
}

View File

@@ -0,0 +1,6 @@
#pragma once
#include "ScriptedPowerupSpawner.h"
class CauldronOfLife : public ScriptedPowerupSpawner {
void OnStartup(Entity* self) override;
};

View 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);
}
}

View 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__

View 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);
}

View File

@@ -0,0 +1,6 @@
#pragma once
#include "ScriptedPowerupSpawner.h"
class FountainOfImagination : public ScriptedPowerupSpawner {
void OnStartup(Entity* self) override;
};

View 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);
}
}

View 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;
};

View 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);
}

View File

@@ -0,0 +1,6 @@
#pragma once
#include "ScriptedPowerupSpawner.h"
class Sunflower : public ScriptedPowerupSpawner {
void OnStartup(Entity* self) override;
};