Added canRevive parameter to Heal function, added Faint event.
This commit is contained in:
parent
3efd7a6974
commit
06336c64cd
|
@ -48,24 +48,18 @@ export size_t CreatureLib_Creature_GetTypesCount(Creature* p) { return p->GetTyp
|
|||
export const uint8_t* CreatureLib_Creature_GetTypes(Creature* p) { return p->GetTypes().data(); }
|
||||
export bool CreatureLib_Creature_HasType(Creature* p, uint8_t type) { return p->HasType(type); }
|
||||
SIMPLE_GET_FUNC(Creature, GetMaxHealth, uint32_t);
|
||||
export void CreatureLib_Creature_ChangeLevelBy(Creature* p, int8_t level) {
|
||||
return p->ChangeLevelBy(level);
|
||||
}
|
||||
export void CreatureLib_Creature_Damage(Creature* p, uint32_t damage, DamageSource source){
|
||||
export void CreatureLib_Creature_ChangeLevelBy(Creature* p, int8_t level) { return p->ChangeLevelBy(level); }
|
||||
export void CreatureLib_Creature_Damage(Creature* p, uint32_t damage, DamageSource source) {
|
||||
p->Damage(damage, source);
|
||||
}
|
||||
export void CreatureLib_Creature_Heal(Creature* p, uint32_t health){
|
||||
p->Heal(health);
|
||||
}
|
||||
export void CreatureLib_Creature_OverrideActiveTalent(Creature* p, const char* talent){
|
||||
export void CreatureLib_Creature_Heal(Creature* p, uint32_t health, bool canRevive) { p->Heal(health, canRevive); }
|
||||
export void CreatureLib_Creature_OverrideActiveTalent(Creature* p, const char* talent) {
|
||||
p->OverrideActiveTalent(ConstString(talent));
|
||||
}
|
||||
export void CreatureLib_Creature_AddExperience(Creature* p, uint32_t experience) {
|
||||
return p->AddExperience(experience);
|
||||
}
|
||||
export void CreatureLib_Creature_ClearVolatileScripts(Creature* p) {
|
||||
return p->ClearVolatileScripts();
|
||||
}
|
||||
export void CreatureLib_Creature_ClearVolatileScripts(Creature* p) { return p->ClearVolatileScripts(); }
|
||||
export void CreatureLib_Creature_AddVolatileScriptByName(Creature* p, const char* scriptName) {
|
||||
return p->AddVolatileScript(ConstString(scriptName));
|
||||
}
|
||||
|
|
|
@ -42,6 +42,16 @@ namespace CreatureLib::Battling {
|
|||
uint32_t GetOriginalHealth() const { return _originalHealth; }
|
||||
uint32_t GetNewHealth() const { return _newHealth; }
|
||||
};
|
||||
|
||||
class FaintEvent : public EventData {
|
||||
Creature* _creature;
|
||||
|
||||
public:
|
||||
FaintEvent(Creature* c) : _creature(c) {}
|
||||
EventDataKind GetKind() const override { return EventDataKind ::Faint; }
|
||||
Creature* GetCreature() const { return _creature; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_EVENTDATA_HPP
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#include <Arbutils/Enum.hpp>
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
ENUM(EventDataKind, uint8_t, Damage, Heal)
|
||||
ENUM(EventDataKind, uint8_t, Damage, Heal, Faint)
|
||||
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_EVENTDATAKIND_HPP
|
||||
|
|
|
@ -88,6 +88,9 @@ bool Battling::Creature::IsFainted() const { return this->_currentHealth <= 0; }
|
|||
|
||||
void Battling::Creature::OnFaint() {
|
||||
// HOOK: On Faint
|
||||
if (_battle != nullptr) {
|
||||
_battle->TriggerEventListener(new FaintEvent(this));
|
||||
}
|
||||
_library->GetExperienceLibrary()->HandleExperienceGain(this, _seenOpponents);
|
||||
|
||||
if (!_battle->CanSlotBeFilled(_side->GetSideIndex(), _side->GetCreatureIndex(this))) {
|
||||
|
@ -113,7 +116,10 @@ void Battling::Creature::Damage(uint32_t damage, Battling::DamageSource source)
|
|||
}
|
||||
}
|
||||
|
||||
void Battling::Creature::Heal(uint32_t amount) {
|
||||
void Battling::Creature::Heal(uint32_t amount, bool canRevive) {
|
||||
if (_currentHealth == 0 && !canRevive) {
|
||||
return;
|
||||
}
|
||||
if (amount > GetMaxHealth() - _currentHealth) {
|
||||
amount = GetMaxHealth() - _currentHealth;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace CreatureLib::Battling {
|
|||
uint32_t GetMaxHealth() const { return _boostedStats.GetHealth(); }
|
||||
void ChangeLevelBy(int8_t amount);
|
||||
void Damage(uint32_t damage, DamageSource source);
|
||||
void Heal(uint32_t amount);
|
||||
void Heal(uint32_t amount, bool canRevive = false);
|
||||
void OverrideActiveTalent(const ConstString& talent);
|
||||
void AddExperience(uint32_t amount);
|
||||
|
||||
|
|
Loading…
Reference in New Issue