package TrooperTower import Tower import public Entity import Heightmap constant DUMMY_DIST = 15. public constant TOWER_TROOPER_ID = 'h01E' constant TROOP_ID = 'h01F' constant TROOPG_ID = 'h02D' trigger tupgradestart trigger tupgradecancel public class TroopGround extends UnitEntity construct (vec3 pos, player owner) super(createUnitZ(owner, TROOPG_ID, pos, angle(0))) setXY(pos) public class Troop extends UnitEntity construct (vec3 pos, player owner) super(createUnitZ(owner, TROOP_ID, pos, angle(0))) deactivate() actor.addAbility(LOCUST_ID) actor.setPropWindow(0 .fromDeg()) ondestroy if not IsUnitHidden(actor) SetUnitExploded(actor, true) actor.setEntity(null) KillUnit(actor) actor.remove() public class TrooperTower extends Tower let troops = new LinkedList() int level = 0 construct (Tower t) super(t) addTrooper() addTrooper() addTrooper() EventListener.add(actor, EVENT_PLAYER_UNIT_UPGRADE_START) -> onUpgradeStart() EventListener.add(actor, EVENT_PLAYER_UNIT_UPGRADE_CANCEL) -> onUpgradeCancel() override function onUpgrade() level++ addTrooper() actor.issueImmediateOrder("stop") override function onAttack(UnitEntity target) for troop in troops troop.actor.issueTargetOrder("smart", target.actor) function onUpgradeStart() for troop in troops troop.actor.setVertexColor(COLOR_BLACK) troop.actor.pause() function onUpgradeCancel() for troop in troops troop.actor.setVertexColor(COLOR_WHITE) troop.actor.unpause() troop.setXY(troop.pos) function addTrooper() troops.add(new Troop(pos, owner)) // Make into circle let angleV = 360. / troops.size() var angleD = 0. for troop in troops let tpos = getPos().toVec2().polarOffset(angleD.asAngleDegrees(), DUMMY_DIST).withZ(pos.getHeightMap() + 160.) troop.actor..setVertexColor(COLOR_WHITE) ..unpause() ..setFacing(angleD.asAngleDegrees()) ..addAbility(LOCUST_ID) troop.setXY(tpos) angleD += angleV override function pause() super.pause() for troop in this.troops troop.actor.pause() override function unpause() super.unpause() for troop in this.troops troop.actor.unpause() ondestroy for trooper in troops new TroopGround(trooper.pos, trooper.owner) trooper.terminate() destroy troops