You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Player A uses a skill which coats the room in oil (adding an Oil-Covered effect to the room).
Player B uses an area of effect fire spell. The room's oil effect should be able to listen for AoE fire damage and explode dealing extra damage
Solution
Create new AreaOfEffectDamage and AreaOfEffectHeal classes in core which extend Damage and Heal respectively. They will have two differences from base damage/heal:
A Character[] getValidTargets(Room|Character commitTarget) method which will find valid targets based on where the damage is committed, e.g., if the commit target is a room it will return all players/npcs in the room. This method can be overridden by a subclass to customize valid targets.
An override of the commit(Character target) method to accept Room|Character target. If the target is a Room then it should call getValidTargets(room), call super.commit(target) for each valid target, then finally emit a areaDamage or areaHeal event on the room passing in AreaOfEffectDamage/Heal instance and the commit target.
classAreaOfEffectDamageextendsDamage{/** * @param {Room|Character} target */commit(room){if(!(roominstanceofRoom)){super.commit(target);return;}consttargets=this.getValidTargets(room);for(consttargetoftargets){super.commit(target);}room.emit('areaDamage',this,targets);}/** * Override this method to customize valid targets such as * only targeting hostile npcs, or only targeting players, etc. * @param {Room} room * @return {Array<Character>} */getValidTargets(room){return[...room.npcs];},}
The text was updated successfully, but these errors were encountered:
Related to #60
Use-case
Solution
Create new
AreaOfEffectDamage
andAreaOfEffectHeal
classes in core which extendDamage
andHeal
respectively. They will have two differences from base damage/heal:Character[] getValidTargets(Room|Character commitTarget)
method which will find valid targets based on where the damage is committed, e.g., if the commit target is a room it will return all players/npcs in the room. This method can be overridden by a subclass to customize valid targets.commit(Character target)
method to acceptRoom|Character target
. If the target is aRoom
then it should callgetValidTargets(room)
, callsuper.commit(target)
for each valid target, then finally emit aareaDamage
orareaHeal
event on the room passing inAreaOfEffectDamage/Heal
instance and the commit target.The text was updated successfully, but these errors were encountered: