package EndBoss import TowerBlockade import DestroyerSummoner import Tower import Boss import EndGame import ClosureForGroups import UnitSpawnSystem import TextTagEntity constant ENDBOSS_ID = 'n00P' constant m = new Music('0000', "Sound\\Music\\mp3Music\\Doom.mp3") constant stageTwoPercentage = .33 constant stageThreePercentage = .10 public EndBossFight currentEndBossFight public class EndBoss extends Boss int stage = 1 var damageCount = GetRandomReal(-1500, 500) EndBossFight bossFight construct(vec3 pos, int typId, int bounty, vec2 target, EndBossFight bossFight) super(pos, typId, bounty, target) this.bossFight = bossFight EventListener.add(actor, EVENT_UNIT_DAMAGED) -> damageCount += GetEventDamage() if damageCount > 2500 damageCount -= 2500 + GetRandomReal(500, 1500) onEnbossDamage() override function update() super.update() let percentage = actor.getHP() / actor.getMaxHP() if stage == 1 and percentage < stageTwoPercentage stage = 2 if stage == 2 and percentage < stageThreePercentage stage = 3 function onEnbossDamage() castAbility() function castAbility() new TextTagEntity(getPos(), vec3(GetRandomReal(-1, 1), 0, GetRandomReal(9, 12)), "Casting..", 12, 1., colorA(162, 9, 182, 255)) actor..pauseEx() ..setAnimation("spell") ..queueAnimation("spell") ..setTimeScale(0.25) let abil = GetRandomInt(0, 2) switch abil case 0 doAfter(GetRandomReal(1, 3)) -> blockadeCount = GetRandomInt(1, 2) actor..unpauseEx()..setTimeScale(1.) new TextTagEntity(getPos(), vec3(GetRandomReal(-1, 1),0, GetRandomReal(9, 12)), "Tower Blockade!", 12, 1., colorA(196, 163, 17, 255)) tryCastTowerBlockade() case 1 | 2 doAfter(GetRandomReal(1, 3)) -> actor..unpauseEx()..setTimeScale(1.) new TextTagEntity(getPos(), vec3(GetRandomReal(-1, 1),0, GetRandomReal(9, 12)), "Destroy Summoner!", 12, 1., colorA(196, 163, 17, 255)) castDestroyerSummoner() var blockadeCount = 0 function tryCastTowerBlockade() forUnitsInRange(pos.toVec2(), 1024.) u -> if blockadeCount > 0 and IsUnitType(u, UNIT_TYPE_STRUCTURE) and u.isAlive() and u.getEntity() instanceof Tower and pDatas[u.getOwner().getId()] != null let tower = u.getEntity() castTo Tower var hasBuff = false if u.hasBuffs() for bff in u.getBuffs() if bff instanceof TowerBlockadeBuff hasBuff = true break if not hasBuff castTowerBlockade(tower) blockadeCount-- function castTowerBlockade(Tower tower) new TowerBlockadeMissile(getPos().add(0, 0, 64), owner, tower) function castDestroyerSummoner() currentEndBossFight.createDestroyerSummoner(this) override function onDeath() super.onDeath() bossFight.onBossDeath(this) public class EndBossFight let bosses = new LinkedList() FinalBossSummoning destroyerSummoning boolean summoningComplete = false construct() PlayMusic(m.path) print("|cffE62121 Prepare for your end!") for j = 0 to startPosCount bosses.add(new EndBoss(spawnRects[j].randomPoint().toVec3(), ENDBOSS_ID, 175, middle, this)) destroyerSummoning = new FinalBossSummoning(this) function createDestroyerSummoner(EndBoss castingBoss) if not summoningComplete let summoner = new DestroyerSummoner(castingBoss.getPos()) destroyerSummoning.addSummoner(summoner) function endDestroyerSummoning() if not summoningComplete summoningComplete = true destroy destroyerSummoning function onBossDeath(EndBoss b) bosses.remove(b) if bosses.size() == 0 destroy this ondestroy endDestroyerSummoning() destroy bosses onVictory() public function startEndBoss() printTimed(" |cffFFC519Beat the final boss to win!", 25) stopSpawn() currentEndBossFight = new EndBossFight() public function onVictory() printTimed("|cffFFCC00>> |cffFFA53ACongratulations, you won!|r\n |cff7B7B7BThe game will end in 20 seconds.", 25) winGame() doAfter(20) -> for pd in allPlayers CustomVictoryBJ(pd.p, true, false) class Music int spellid string path real duration string name construct(int id, string path) this.spellid = id this.path = path this.duration = GetSoundFileDuration(path) / 1000. this.name = path.substring(path.lastIndexOf("\\") + 1, path.lastIndexOf("."))