Implement the Imaginite Backpack and Shard armor scripts (#886)

* Imaginite Pack now works

* Remove unused params

* Address issues

* Add TeslaPack script

Co-authored-by: aronwk-aaron <aronwk.aaron@gmail.com>
This commit is contained in:
David Markowitz
2022-12-21 14:33:41 -08:00
committed by GitHub
parent 51dd56f0a0
commit bd7f532a28
16 changed files with 249 additions and 1 deletions

View File

@@ -39,6 +39,12 @@ foreach(file ${DSCRIPTS_SOURCES_EQUIPMENTSCRIPTS})
set(DSCRIPTS_SOURCES ${DSCRIPTS_SOURCES} "EquipmentScripts/${file}")
endforeach()
add_subdirectory(EquipmentTriggers)
foreach(file ${DSCRIPTS_SOURCES_EQUIPMENTTRIGGERSSCRIPTS})
set(DSCRIPTS_SOURCES ${DSCRIPTS_SOURCES} "EquipmentTriggers/${file}")
endforeach()
add_subdirectory(zone)
foreach(file ${DSCRIPTS_SOURCES_ZONE})

View File

@@ -278,6 +278,9 @@
#include "ImaginationBackpackHealServer.h"
#include "LegoDieRoll.h"
#include "BuccaneerValiantShip.h"
#include "GemPack.h"
#include "ShardArmor.h"
#include "TeslaPack.h"
// Survival scripts
#include "AgSurvivalStromling.h"
@@ -837,6 +840,12 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
script = new BuccaneerValiantShip();
else if (scriptName == "scripts\\EquipmentScripts\\FireFirstSkillonStartup.lua")
script = new FireFirstSkillonStartup();
else if (scriptName == "scripts\\equipmenttriggers\\gempack.lua")
script = new GemPack();
else if (scriptName == "scripts\\equipmenttriggers\\shardarmor.lua")
script = new ShardArmor();
else if (scriptName == "scripts\\equipmenttriggers\\coilbackpack.lua")
script = new TeslaPack();
// FB
else if (scriptName == "scripts\\ai\\NS\\WH\\L_ROCKHYDRANT_BROKEN.lua")

View File

@@ -172,6 +172,13 @@ namespace CppScripts {
*/
virtual void OnHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) {};
/**
* Invoked when self has received either a hit or heal. Only used for scripts subscribed to an entity.
*
* Equivalent to 'function notifyHitOrHealResult(self, msg)'
*/
virtual void NotifyHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) {};
/**
* Invoked when a player has responsed to a mission.
*
@@ -316,6 +323,22 @@ namespace CppScripts {
virtual void OnCinematicUpdate(Entity* self, Entity* sender, eCinematicEvent event, const std::u16string& pathName,
float_t pathTime, float_t totalTime, int32_t waypoint) {
};
/**
* Used by items to tell their owner that they were equipped.
*
* @param itemOwner The owner of the item
* @param itemObjId The items Object ID
*/
virtual void OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) {};
/**
* Used by items to tell their owner that they were unequipped.
*
* @param itemOwner The owner of the item
* @param itemObjId The items Object ID
*/
virtual void OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) {};
};
Script* GetScript(Entity* parent, const std::string& scriptName);

View File

@@ -0,0 +1,3 @@
set(DSCRIPTS_SOURCES_EQUIPMENTTRIGGERSSCRIPTS
"CoilBackpackBase.cpp"
PARENT_SCOPE)

View File

@@ -0,0 +1,25 @@
#include "CoilBackpackBase.h"
#include "Entity.h"
#include "SkillComponent.h"
void CoilBackpackBase::OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) {
itemOwner->Subscribe(itemObjId, this, "HitOrHealResult");
itemOwner->SetVar<uint8_t>(u"coilCount", 0);
}
void CoilBackpackBase::NotifyHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) {
if (damage > 0) {
self->SetVar<uint8_t>(u"coilCount", self->GetVar<uint8_t>(u"coilCount") + 1);
if (self->GetVar<uint8_t>(u"coilCount") > 4) {
auto* skillComponent = self->GetComponent<SkillComponent>();
if (!skillComponent) return;
skillComponent->CalculateBehavior(m_SkillId, m_BehaviorId, self->GetObjectID());
self->SetVar<uint8_t>(u"coilCount", 0);
}
}
}
void CoilBackpackBase::OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) {
itemOwner->Unsubscribe(itemObjId, "HitOrHealResult");
}

View File

@@ -0,0 +1,21 @@
#ifndef __GemPackBase__H__
#define __GemPackBase__H__
#include "CppScripts.h"
class CoilBackpackBase: public CppScripts::Script {
public:
CoilBackpackBase(uint32_t skillId, uint32_t behaviorId) {
m_SkillId = skillId;
m_BehaviorId = behaviorId;
};
void OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) override;
void NotifyHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) override;
void OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) override;
private:
uint32_t m_SkillId = 0;
uint32_t m_BehaviorId = 0;
};
#endif //!__GemPackBase__H__

View File

@@ -0,0 +1,14 @@
#ifndef __GEMPACK__H__
#define __GEMPACK__H__
#include "CoilBackpackBase.h"
class GemPack : public CoilBackpackBase {
public:
GemPack() : CoilBackpackBase(skillId, behaviorId) {};
private:
static const uint32_t skillId = 1488;
static const uint32_t behaviorId = 36779;
};
#endif //!__GEMPACK__H__

View File

@@ -0,0 +1,14 @@
#ifndef __SHARDARMOR__H__
#define __SHARDARMOR__H__
#include "CoilBackpackBase.h"
class ShardArmor : public CoilBackpackBase {
public:
ShardArmor() : CoilBackpackBase(skillId, behaviorId) {};
private:
static const uint32_t skillId = 1249;
static const uint32_t behaviorId = 29086;
};
#endif //!__SHARDARMOR__H__

View File

@@ -0,0 +1,14 @@
#ifndef __TESLAPACK__H__
#define __TESLAPACK__H__
#include "CoilBackpackBase.h"
class TeslaPack : public CoilBackpackBase {
public:
TeslaPack() : CoilBackpackBase(skillId, behaviorId) {};
private:
static const uint32_t skillId = 1001;
static const uint32_t behaviorId = 20917;
};
#endif //!__TESLAPACK__H__