Browse Source

Merge branch '1968-aftergivehp' into 'master'

feat #1968: Add afterGiveHp event

Closes #1968

See merge request Isleward/isleward!608
tags/v0.12.0
Big Bad Waffle 1 year ago
parent
commit
9b88244d48
2 changed files with 23 additions and 2 deletions
  1. +16
    -1
      src/server/components/stats.js
  2. +7
    -1
      src/server/config/spells/spellSingleTargetHeal.js

+ 16
- 1
src/server/components/stats.js View File

@@ -596,7 +596,17 @@ module.exports = {
source.fireEvent('afterDealDamage', damage, obj);
},

getHp: function (heal, source) {
/*
Gives hp to heal.target
heal: Damage object returned by combat.getDamage
source: Source object
event: Optional config object. We want to eventually phase out the first 2 args.
heal: Same as 1st parameter
source: Same as 2nd parameter
target: Target object (heal.target)
spell: Optional spell object that caused this event
*/
getHp: function (heal, source, event) {
let amount = heal.amount;
if (amount === 0)
return;
@@ -646,6 +656,11 @@ module.exports = {
}

this.obj.syncer.setObject(false, 'stats', 'values', 'hp', values.hp);

//We want to eventually replace the first two args with the event object
// For now, only fire the event when the event object is specified.
if (!heal.noEvents && event)
source.fireEvent('afterGiveHp', event);
},

save: function () {


+ 7
- 1
src/server/config/spells/spellSingleTargetHeal.js View File

@@ -18,7 +18,13 @@ module.exports = {
const { x, y } = target;

const amount = this.getDamage(target, true);
target.stats.getHp(amount, this.obj);
const event = {
heal: amount,
source: this.obj,
target,
spell: this
};
target.stats.getHp(amount, this.obj, event);

const effect = {
x,


Loading…
Cancel
Save