2022-12-21 22:33:41 +00:00
|
|
|
#include "CoilBackpackBase.h"
|
|
|
|
|
|
|
|
#include "Entity.h"
|
|
|
|
#include "SkillComponent.h"
|
|
|
|
|
|
|
|
void CoilBackpackBase::OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) {
|
2023-06-16 08:56:02 +00:00
|
|
|
itemOwner->Subscribe(this, "HitOrHealResult");
|
2022-12-21 22:33:41 +00:00
|
|
|
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) {
|
2023-06-09 08:27:05 +00:00
|
|
|
auto* skillComponent = self->GetComponent<SkillComponent>();
|
2022-12-21 22:33:41 +00:00
|
|
|
if (!skillComponent) return;
|
2023-02-10 08:30:17 +00:00
|
|
|
skillComponent->CastSkill(m_SkillId);
|
2022-12-21 22:33:41 +00:00
|
|
|
self->SetVar<uint8_t>(u"coilCount", 0);
|
|
|
|
}
|
2023-02-10 08:30:17 +00:00
|
|
|
}
|
2022-12-21 22:33:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CoilBackpackBase::OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) {
|
2023-06-16 08:56:02 +00:00
|
|
|
itemOwner->Unsubscribe(this, "HitOrHealResult");
|
2022-12-21 22:33:41 +00:00
|
|
|
}
|