package Bombertower import BaseObject import Attackspeed import ClosureTimers constant int ATTACK_ORDER = 851983 constant int ATTACK_GROUND_ORDER = 851984 constant int STOP_ORDER = 851972 public class Bombertower extends StaticBaseObject unit dummy boolean skipOrder = false construct(vec2 pos, player owner) super(pos, createUnit(owner, BOMB_TOWER_ID, pos, angle(0)), 0., null, null) actor..addAbility(GHOST_VIS_ID)..addAbility(LOCUST_ID) dummy = createUnit(owner, BOMB_TOWER_ID, pos, angle(0)) dummy..addAbility(GHOST_INVIS_ID)..setEntity(this)..setScale(0.5) EventListener.add(dummy, EVENT_PLAYER_UNIT_ISSUED_ORDER, () -> checkOrder()) EventListener.add(dummy, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, () -> checkOrder()) EventListener.add(dummy, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, () -> checkOrder()) EventListener.onCast(dummy) id -> onAttackspeedCast(id, actor) SetUnitPathing(dummy, true) ondestroy unregisterEvents(dummy.getIndex()) dummy.setEntity(null) dummy.remove() override function serialize() returns Json let json = super.serialize() json.addProperty(new Property(KEY_TYPE, BOMBTOWER_INDEX.toString())) return json function checkOrder() let i = GetIssuedOrderId() let e = GetOrderedUnit().getEntity() let tpos = EventData.getOrderPos() if tpos != ZERO2 and not getRegionData(tpos).canBuild(owner) GetOrderedUnit().abortOrder() return if e instanceof Bombertower var obj = e castTo Bombertower if obj.skipOrder obj.skipOrder = false return if GetOrderedUnit() == obj.dummy obj.clearQuestionmark() if i == ATTACK_GROUND_ORDER IssuePointOrderById(obj.actor,i, GetOrderPointX(),GetOrderPointY()) obj.skipOrder = true doAfter(0.1,() -> obj.dummy.issueImmediateOrder("stop")) else if i == ATTACK_ORDER IssueTargetOrderById(obj.actor,i, GetOrderTargetUnit()) obj.skipOrder = true doAfter(0.1,() -> obj.dummy.issueImmediateOrder("stop")) else if i == STOP_ORDER IssueImmediateOrderById(obj.actor, STOP_ORDER) @objectgen function genBombTower() new BuildingDefinition(BOMB_TOWER_ID, 'hctw') ..setName("|cff5A3108Bomb Tower") ..setHotkey("W") ..setTooltipBasic("|cffFFCC00Build |cff5A3108Bomb Tower [W]") ..setTooltipExtended("Can only attack \"Bomb Tower attack target\"" + "\nAttackspeed can be modified.") ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNCannonTower.blp") ..setNormalAbilities(commaList(ATTACK_SPEED_DECREASE, ATTACK_SPEED_INCREASE, REMOVE_OBJECT_ID, GHOST_VIS_ID, INVULNERABILITY_ID)) ..setAttack1DamageBase(1000) ..setAttack1CooldownTime(0.2) ..setAttack1Range(3500) ..setAttack1TargetsAllowed("air") ..setAttack1AreaofEffectFullDamage(92) ..setAttack1AreaofEffectMediumDamage(0) ..setAttack1AreaofEffectSmallDamage(0) ..setAttack1AreaofEffectTargets("air,alive,allies,debris,enemies,friend,ground,hero,notself,vulnerable") ..setAttack1DamageFactorMedium(0) ..setAttack1DamageFactorSmall(0) ..setAttack1DamageSidesperDie(1) ..setAttacksEnabled(1) ..setAcquisitionRange(3500) ..setDefenseBase(0) ..setDefenseUpgradeBonus(0) ..setButtonPositionX(1) ..setButtonPositionY(0) ..setGroundTexture("") ..setPlacementRequires("") ..setCollisionSize(0) ..setRequirements("") ..setUpgradesUsed("") ..setBuildTime(2) ..setHitPointsMaximumBase(1000) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setLumberCost(0) ..setGoldCost(0) ..setUnitClassification("ancient,standon") ..setHideMinimapDisplay(true)