package BossSpellTarget import SetupObject import Escaper import HomingProjectile import Assets import ClosureTimers import HashMap public constant int SPELLTARGET_ID = 'u00F' public constant int AOE_ID = 'A06V' public constant int MISSILE_ID = 'A06W' public enum SpellType NONE AOE LINE MISSILE public HashMap> targets = new HashMap>() public class SpellTarget extends SetupObject SpellType stype = SpellType.NONE construct(vec2 pos, player owner) super(createUnit(owner, SPELLTARGET_ID, pos, angle(0))..addAbility(LOCUST_ID), createUnit(owner, SPELLTARGET_ID, pos, angle(0)), 32) stype = SpellType.NONE EventListener.add(setup, EVENT_PLAYER_UNIT_SPELL_CAST, () -> onCast()) if not targets.has(owner.getId()) targets.put(owner.getId(), new LinkedList()) targets.get(owner.getId()).add(this) function onCast() let id = GetSpellAbilityId() switch id case AOE_ID stype = SpellType.AOE actor..setVertexColor(255,255,0,255) ..removeAbility(AOE_ID) ..addAbility(MISSILE_ID) case MISSILE_ID stype = SpellType.MISSILE actor..setVertexColor(0,255,255,255) ..removeAbility(MISSILE_ID) ..addAbility(AOE_ID) function castAoe() addEffect("war3mapImported\\DarknessMeteor.mdx", pos).destr() let tpos = getPos().toVec2() doAfter(1.) -> forUnitsInRange(tpos, 200) u -> if u.getEntity() instanceof Escaper actor.damageTarget(u, 100) let escaper = u.getEntity() castTo Escaper escaper.addVel((escaper.pos-tpos)*0.5) ondestroy targets.get(owner.getId()).remove(this) // function castAOE(Boss root) // DestroyEffect(AddSpecialEffect(aoe_spell[root.aoe_id].sfx,pos.x,pos.y)) // GroupEnumUnitsInRange(ENUM_GROUP,pos.x, pos.y, aoe_spell[root.aoe_id].aoe, null) // for u in ENUM_GROUP // var e = u.getEntity() // if e instanceof Escaper // var es = e castTo Escaper // if not es.flying // actor.damageTarget(u,aoe_spell[root.aoe_id].damage) // GroupClear(ENUM_GROUP) // constant MISSILE_RADIUS = 64. constant MISSILE_SPEED = 12. public class BossMissile extends HomingProjectile unit caster = null construct(unit caster, Entity target) super(caster.getPos3with(92), MISSILE_RADIUS, owner, pos.angleTo2d(target.getPos()), Abilities.greenDragonMissile) this.caster = caster setTarget(target,HOMING.attract,MISSILE_SPEED) setSpeed(14.) setTimed(10) override function update() super.update() sleeps = false // If outside boss region, terminate the missile if this.getCurrentRegion() != getRegionData(caster.getPos()) terminate() for e in escapers if pos.distanceToSq(e.pos) < radius*radius caster.damageTarget(e.actor, 100) terminate() return