2021-12-05 17:54:36 +00:00
|
|
|
#include "AmSkeletonEngineer.h"
|
|
|
|
#include "DestroyableComponent.h"
|
|
|
|
#include "SkillComponent.h"
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void AmSkeletonEngineer::OnHit(Entity* self, Entity* attacker) {
|
|
|
|
auto* destroyableComponent = self->GetComponent<DestroyableComponent>();
|
|
|
|
auto* skillComponent = self->GetComponent<SkillComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (destroyableComponent == nullptr || skillComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (destroyableComponent->GetHealth() < 12 && !self->GetVar<bool>(u"injured")) {
|
|
|
|
self->SetVar(u"injured", true);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
skillComponent->CalculateBehavior(953, 19864, self->GetObjectID(), true);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
const auto attackerID = attacker->GetObjectID();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->AddCallbackTimer(4.5f, [this, self, attackerID]() {
|
|
|
|
self->Smash(attackerID);
|
|
|
|
});
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|