package PresetBuffs import public Buff /** When applied to a unit that already has the buff, the existing Buff's duration gets set to this buff's duration */ public abstract class NormalBuff extends Buff construct(real dur, buffTuple buffData) super(dur, buffData) override function apply(unit target) if target.isAlive() this.target = target if target.hasBuffs() for bff in target.getBuffs() if bff.typeId == this.typeId bff.duration = duration this.target = null terminate() return target.addBuff(this) refresh() onApply() /** When applied to a unit that already has the buff, another buff instance is added */ public abstract class StackingBuff extends Buff construct(real dur, buffTuple buffData) super(dur, buffData) override function apply(unit target) if target.isAlive() this.target = target target.addBuff(this) refresh() onApply() /** Can only be applied once. If the unit already has the buff nothing happens */ public abstract class FixedBuff extends Buff construct(real dur, buffTuple buffData) super(dur, buffData) override function apply(unit target) this.target = target for bff in target.getBuffs() if bff.typeId == this.typeId this.target = null terminate() return target.addBuff(this) refresh() onApply() /** Negates a certain amount of damage. If the unit already has this buff, the block damage of this buff gets addedto the existing one's */ public class ShieldBuff extends NormalBuff real blockAmount construct(real dur, buffTuple buffData, real amount) super(dur, buffData) blockAmount = amount override function update() super.update() if blockAmount <= 0 terminate() override function apply(unit target) if target.isAlive() this.target = target if target.hasBuffs() for bff in target.getBuffs() if bff.typeId == this.typeId and bff != this let sd = bff castTo thistype sd.duration = duration sd.blockAmount += blockAmount this.target = null terminate() return target.addBuff(this) refresh() onApply() override function defenseModifier() let dmg = DamageEvent.getAmount() if dmg >= blockAmount DamageEvent.addAmount(-blockAmount) blockAmount = 0 terminate() else DamageEvent.setAmount(0) blockAmount = blockAmount - dmg