package Boss import PlayerData import SoundUtils import public BossSpellTarget import CustomBar import Minion import ChannelAbilityPreset constant BOSS_TOMB_ID = 'n01P' constant HP_UP_ID = 'A06U' constant HP_DOWN_ID = 'A06T' constant REAL_HP_BIG_ID = 'A06X' constant REAL_HP_SMALL_ID = 'A06Y' constant DMG_UP_ID = 'A001' constant DMG_DOWN_ID = 'A001' constant REAL_DMG_BIG_ID = 'A001' constant REAL_DMG_SMALL_ID = 'A001' constant AOE_SPELL_ID = 'A06V' constant MISSILE_SPELL_ID = 'A06W' constant REVIVE_ID = 'A07L' constant SUMMON_MINION_ID = compiletime(ABIL_ID_GEN.next()) constant ENTER_SOUND = new SoundDefinition("Units\\Undead\\Varimathras\\VarimathrasReady1.wav", false) constant MINION_SPAWN_SOUND = new SoundDefinition("Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeTargetWaveNonLoop1.waw", false) constant REVIVE_SOUND = new SoundDefinition("Units\\Undead\\Varimathras\\VarimathrasReady1.wav", false) public class Boss extends SetupObject real maxHp = 400. real currentHP = 400. CustomBar hpBar construct(player owner, vec2 tpos, int id) super(createUnit(owner, id, tpos, angle(0))..addAbility(LOCUST_ID), createUnit(owner, id, tpos, angle(0)), 64) setup..addAbility(SUMMON_MINION_ID) sleeps = false EventListener.add(setup, EVENT_PLAYER_UNIT_SPELL_CAST, () -> onCast()) hpBar = new CustomBar(pos, "|", 120, 6) hpBar.setForeground(colorA(200,255,125,255)) override function update() super.update() hpBar.setPosXY(pos.x-100, pos.y + 100) hpBar.setValue(currentHP / maxHp * 100.0) function onDamage(Escaper _escaper, real dmg) currentHP -= dmg if currentHP < 1 Log.debug("Our boss is dead") actor.kill() function onCast() let id = GetSpellAbilityId() actor.setAnimation("spell") switch id case HP_UP_ID let bighp = GetUnitAbilityLevel(actor, REAL_HP_BIG_ID) let smallhp = GetUnitAbilityLevel(actor, REAL_HP_SMALL_ID) if smallhp == 4 if bighp < 4 if bighp == 0 actor.addAbility(REAL_HP_BIG_ID) else SetUnitAbilityLevel(actor,REAL_HP_BIG_ID, bighp+1) SetUnitAbilityLevel(actor,REAL_HP_SMALL_ID, 0) else createFText(pos, vec2(0,0.05), "|cffC51019Max HP", 10, 2., colorA(255,255,255,0), owner) else if smallhp == 0 actor.addAbility(REAL_HP_SMALL_ID) else SetUnitAbilityLevel(actor,REAL_HP_SMALL_ID, smallhp+1) case HP_DOWN_ID let bighp = GetUnitAbilityLevel(actor, REAL_HP_BIG_ID) let smallhp = GetUnitAbilityLevel(actor, REAL_HP_SMALL_ID) if smallhp == 0 if bighp > 0 SetUnitAbilityLevel(actor,REAL_HP_BIG_ID, bighp-1) SetUnitAbilityLevel(actor,REAL_HP_SMALL_ID, 4) else createFText(pos, vec2(0,0.05), "|cffC51019Min HP", 10, 2., colorA(255,255,255,0), owner) else SetUnitAbilityLevel(actor,REAL_HP_SMALL_ID, smallhp-1) case AOE_SPELL_ID let tgts = getSpellTargets(SpellType.AOE) for target in tgts target.castAoe() destroy tgts case MISSILE_SPELL_ID let tgts = getSpellTargets(SpellType.MISSILE) for target in tgts new BossMissile(actor,target) destroy tgts case SUMMON_MINION_ID // TODO `for spawner in minionspawners` new Minion(pos.toVec2(), owner, actor.getFacingAngle()) MINION_SPAWN_SOUND.playOnPoint(pos) case REVIVE_ID revive() function getSpellTargets(SpellType stype) returns LinkedList let tgs = targets.get(owner.getId()) let newTgs = new LinkedList() for target from tgs.staticItr() if target.stype == stype newTgs.add(target) return newTgs function revive() REVIVE_SOUND.play() destroy this @objectgen function genBoss() new ChannelAbilityPreset(SUMMON_MINION_ID, 1, true) ..presetManaCost(lvl -> 0) ..setHeroAbility(false) ..presetCooldown(lvl -> 10) ..setName("Summon Minion") ..presetIcon("ReplaceableTextures\\CommandButtons\\BTNZombie.blp") ..presetHotkey("A") ..presetTooltipNormal(lvl -> "Summon Minion [|cffFFCC00A|r]") ..presetTooltipNormalExtended(lvl -> "Summons a minion that follows the nearest escaper") ..presetButtonPosNormal(0, 1)