package Bomber import SetupObject import Attackspeed import ClosureTimers import ChannelAbilityPreset constant BOMBER_ID = 'bmbr' constant int AUTOATTACK_ID = 'A03B' constant int ATTACK_ORDER = 851983 constant int ATTACK_GROUND_ORDER = 851984 constant int STOP_ORDER = 851972 constant int MOVE_ORDER = 851971 public class Bomber extends UnitEntity unit setup boolean realorder = true construct(vec2 pos, player owner) super(createUnit(owner, BOMBER_ID, pos, angle(0))) this.setCurrentRegion() setup = createUnit(owner, BOMBER_ID, pos, angle(0))..addAbility(GHOST_INVIS_ID)..setEntity(this) actor..addAbility(LOCUST_ID) UnitAddType(setup, UNIT_TYPE_PEON) UnitAddType(actor, UNIT_TYPE_PEON) EventListener.add(setup, EVENT_PLAYER_UNIT_ISSUED_ORDER, () -> checkOrder()) EventListener.add(setup, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, () -> checkOrder()) EventListener.add(setup, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, () -> checkOrder()) EventListener.add(setup, EVENT_PLAYER_UNIT_ATTACKED, () -> checkOrder()) EventListener.add(setup, EVENT_PLAYER_UNIT_SPELL_CAST, () -> onCast()) setup.abortOrder() actor.abortOrder() function onCast() let id = GetSpellAbilityId() onAttackspeedCast(id, actor) if id == AUTOATTACK_ID if IsUnitType(actor, UNIT_TYPE_PEON) UnitRemoveType(actor, UNIT_TYPE_PEON) setup.setPropWindow(0 .fromDeg()) actor.setOwner(players[PLAYER_NEUTRAL_AGGRESSIVE], false) actor.setPropWindow(0 .fromDeg()) createFText(getPos(), vec2(0,0.05), "ON", 10, 2., colorA(200,0,0,0), owner) doAfter(0.1, () -> actor.issueImmediateOrder("stop")) else UnitAddType(actor, UNIT_TYPE_PEON) setup.setPropWindow(60 .fromDeg()) actor.setPropWindow(60 .fromDeg()) actor.setOwner(owner, false) createFText(getPos(), vec2(0,0.05), "OFF", 10, 2., colorA(0,200,0,0), owner) doAfter(0.1, () -> actor.issueImmediateOrder("stop")) static function orderSetup() var obj = GetExpiredTimer().getData() castTo Bomber obj.realorder = false IssueImmediateOrderById(obj.setup, STOP_ORDER) GetExpiredTimer().release() function checkOrder() let i = GetIssuedOrderId() let e = GetOrderedUnit().getEntity() let tpos = EventData.getSpellTargetPos() if tpos != ZERO2 and not getRegionData(tpos).canBuild(owner) GetOrderedUnit().abortOrder() return if e instanceof Bomber var obj = e castTo Bomber if GetOrderedUnit() == obj.setup if i == MOVE_ORDER IssuePointOrderById(obj.actor,i, GetOrderPointX(),GetOrderPointY()) if i == ATTACK_GROUND_ORDER IssuePointOrderById(obj.actor,i, GetOrderPointX(),GetOrderPointY()) getTimer()..start(0.1, function Bomber.orderSetup)..setData(obj castTo int) else if i == ATTACK_ORDER IssueTargetOrderById(obj.actor,i, GetOrderTargetUnit()) getTimer()..start(0.1, function Bomber.orderSetup)..setData(obj castTo int) else if i == STOP_ORDER if obj.realorder IssueImmediateOrderById(obj.actor, STOP_ORDER) else obj.realorder = true ondestroy unregisterEvents(setup.getIndex()) setup.setEntity(null) setup.remove() override function serialize() returns Json let json = super.serialize() json ..addProperty(new Property(KEY_TYPE, BOMBER_INDEX.toString())) return json @objectgen function genBomber() new UnitDefinition(BOMBER_ID, 'hmtm') ..setAttack1DamageBase(1000) ..setAttack1CooldownTime(2) ..setAttack1ProjectileSpeed(1150) ..setAttack1Range(1750) ..setAttack1TargetsAllowed("air,allies,ground,notself,vulnerable") ..setAttack1AreaofEffectFullDamage(92) ..setAttack1AreaofEffectMediumDamage(96) ..setAttack1AreaofEffectSmallDamage(98) ..setAttack1AreaofEffectTargets("air,alive,allies,debris,enemies,friend,ground,hero,notself,vulnerable") ..setAttack1ProjectileSpeed(1150) ..setAttack1DamageFactorSmall(0) ..setAttack1DamageFactorMedium(0) ..setAttack1DamageSidesperDie(1) ..setAcquisitionRange(850) ..setMinimumAttackRange(50) ..setAttacksEnabled(1) ..setTargetedAs("air") ..setAnimationBlendTimeseconds(0) ..setAnimationCastBackswing(0) ..setAnimationCastPoint(0) ..setSelectionScale(1) ..setUnitSoundSet("") ..setCollisionSize(0) ..setNormalAbilities(commaList('A03B', ATTACK_SPEED_INCREASE, ATTACK_SPEED_DECREASE, REMOVE_OBJECT_ID, GHOST_VIS_ID, INVULNERABILITY_ID)) ..setHotkey("E") ..setName("|cFFFFFF00Bomber|r") ..setTooltipBasic("|cFFFF8000B|r|cFFFFFF00o|r|cFFFF8000mber|r [E]") ..setTooltipExtended("") ..setUpgradesUsed("") ..setHitPointsMaximumBase(100000000) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setGoldCost(0) ..setFoodCost(0) ..setLumberCost(0) ..setHideMinimapDisplay(true)