Make wrapper for casting skills (#987)

* Make wrapper for casting skills
this is to reduce magic numbers in the code base

Only updated one use of this to demo that this works.
Will be do more in a sepearate PR.

Also, inadvertantly fix damage stacking and self-damage in the teslapack

* add skill<->behavior caching

* explicit by reference

* address emo's feedback
This commit is contained in:
Aaron Kimbrell
2023-02-10 02:30:17 -06:00
committed by GitHub
parent 91c0c1fcfb
commit 3cd0d1ec3d
7 changed files with 46 additions and 11 deletions

View File

@@ -14,10 +14,10 @@ void CoilBackpackBase::NotifyHitOrHealResult(Entity* self, Entity* attacker, int
if (self->GetVar<uint8_t>(u"coilCount") > 4) {
auto* skillComponent = self->GetComponent<SkillComponent>();
if (!skillComponent) return;
skillComponent->CalculateBehavior(m_SkillId, m_BehaviorId, self->GetObjectID());
skillComponent->CastSkill(m_SkillId);
self->SetVar<uint8_t>(u"coilCount", 0);
}
}
}
}
void CoilBackpackBase::OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) {

View File

@@ -5,9 +5,8 @@
class CoilBackpackBase: public CppScripts::Script {
public:
CoilBackpackBase(uint32_t skillId, uint32_t behaviorId) {
CoilBackpackBase(uint32_t skillId) {
m_SkillId = skillId;
m_BehaviorId = behaviorId;
};
void OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) override;
@@ -15,7 +14,6 @@ public:
void OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) override;
private:
uint32_t m_SkillId = 0;
uint32_t m_BehaviorId = 0;
};
#endif //!__GemPackBase__H__

View File

@@ -5,10 +5,9 @@
class GemPack : public CoilBackpackBase {
public:
GemPack() : CoilBackpackBase(skillId, behaviorId) {};
GemPack() : CoilBackpackBase(skillId) {};
private:
static const uint32_t skillId = 1488;
static const uint32_t behaviorId = 36779;
};
#endif //!__GEMPACK__H__

View File

@@ -5,10 +5,9 @@
class ShardArmor : public CoilBackpackBase {
public:
ShardArmor() : CoilBackpackBase(skillId, behaviorId) {};
ShardArmor() : CoilBackpackBase(skillId) {};
private:
static const uint32_t skillId = 1249;
static const uint32_t behaviorId = 29086;
};
#endif //!__SHARDARMOR__H__

View File

@@ -5,10 +5,9 @@
class TeslaPack : public CoilBackpackBase {
public:
TeslaPack() : CoilBackpackBase(skillId, behaviorId) {};
TeslaPack() : CoilBackpackBase(skillId) {};
private:
static const uint32_t skillId = 1001;
static const uint32_t behaviorId = 20917;
};
#endif //!__TESLAPACK__H__