mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 02:04:04 +00:00
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:
@@ -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})
|
||||
|
@@ -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")
|
||||
|
@@ -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);
|
||||
|
3
dScripts/EquipmentTriggers/CMakeLists.txt
Normal file
3
dScripts/EquipmentTriggers/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
set(DSCRIPTS_SOURCES_EQUIPMENTTRIGGERSSCRIPTS
|
||||
"CoilBackpackBase.cpp"
|
||||
PARENT_SCOPE)
|
25
dScripts/EquipmentTriggers/CoilBackpackBase.cpp
Normal file
25
dScripts/EquipmentTriggers/CoilBackpackBase.cpp
Normal 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");
|
||||
}
|
21
dScripts/EquipmentTriggers/CoilBackpackBase.h
Normal file
21
dScripts/EquipmentTriggers/CoilBackpackBase.h
Normal 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__
|
14
dScripts/EquipmentTriggers/GemPack.h
Normal file
14
dScripts/EquipmentTriggers/GemPack.h
Normal 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__
|
14
dScripts/EquipmentTriggers/ShardArmor.h
Normal file
14
dScripts/EquipmentTriggers/ShardArmor.h
Normal 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__
|
14
dScripts/EquipmentTriggers/TeslaPack.h
Normal file
14
dScripts/EquipmentTriggers/TeslaPack.h
Normal 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__
|
Reference in New Issue
Block a user