package Teleporter import BaseObject import PlayerData constant INFO_TELEPORTER_ID = compiletime(ABIL_ID_GEN.next()) constant EFFECT_STRING = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl" constant EVENT_RADIUS = 38. enum TeleportMode ESCAPER KILLER BOTH public class Teleporter extends StaticBaseObject boolean teleportWisps = false TeleportMode mode = TeleportMode.ESCAPER construct(vec2 pos, player owner) super(pos, createUnit(owner, TELEPORTER_ID, pos, angle(0)), EVENT_RADIUS, function Teleporter.teleport, null) actor.addAbility(TURN_OFF_ID) construct(unit existing) super(existing.getPos(), existing, EVENT_RADIUS, function Teleporter.teleport, null) actor.addAbility(TURN_OFF_ID) static function teleport() let source = GetTriggeringTrigger().getSource() let u = GetTriggerUnit() let e = u.getEntity() let obj = source.getEntity() castTo Teleporter let rallyPos = obj.getRallyPoint() let rdata = getRegionData(rallyPos) SetupObject dyn switch obj.mode case TeleportMode.ESCAPER if e instanceof Escaper e.setPos(rallyPos) addEffect(EFFECT_STRING, obj.pos).destr() addEffect(EFFECT_STRING, rallyPos).destr() if not (e castTo Escaper).camlock e.owner.panCameraToTimed(rallyPos, 0.03) case TeleportMode.KILLER if e instanceof SetupObject and rdata.canBuild(obj.owner) dyn = e castTo SetupObject dyn.setPos(rallyPos) addEffect(EFFECT_STRING, obj.pos).destr() addEffect(EFFECT_STRING, rallyPos).destr() case TeleportMode.BOTH if e instanceof SetupObject and rdata.canBuild(obj.owner) dyn = e castTo SetupObject dyn.setPos(rallyPos) addEffect(EFFECT_STRING, obj.pos).destr() addEffect(EFFECT_STRING, rallyPos).destr() else if e instanceof Escaper u.setPos(rallyPos.x, rallyPos.y) addEffect(EFFECT_STRING, obj.pos).destr() addEffect(EFFECT_STRING, rallyPos).destr() if not (e castTo Escaper).camlock e.owner.panCameraToTimed(rallyPos, 0.03) if e instanceof Escaper and isEscaperPlayer(e.owner) and obj.owner == STAFF_PLAYER and not obj.actor.hasAbility(REMOVE_OBJECT_ID) Log.debug("Teleport term") obj.terminate() override function onCast() super.onCast() let id = GetSpellAbilityId() switch id case MODE_BOTH_ID actor..removeAbility(MODE_BOTH_ID)..addAbility(MODE_ESCAPERS_ID) mode = TeleportMode.ESCAPER case MODE_ESCAPERS_ID actor..removeAbility(MODE_ESCAPERS_ID)..addAbility(MODE_KILLERS_ID) mode = TeleportMode.KILLER case MODE_KILLERS_ID actor..removeAbility(MODE_KILLERS_ID)..addAbility(MODE_BOTH_ID) mode = TeleportMode.BOTH override function serialize() returns Json let json = super.serialize() json.addProperty(new Property("t", TELEPORTER_INDEX.toString())) return json @objectgen function genTeleporter() new ChannelAbilityPreset(INFO_TELEPORTER_ID, 1, TRUE) ..setName("Information: Teleporter") ..presetTooltipNormal(lvl -> "Information: Teleporter") ..presetTooltipNormalExtended(lvl -> "The Teleporter teleports the entering Unit to the Rallypoint." + "\nYou can define if Escapers or Escape Killers should be teleporting by clicking on the 'Teleport escapers only' Spell") ..presetIcon("ReplaceableTextures\\CommandButtons\\PASInfo.blp") ..presetButtonPosNormal(0, 0) ..presetTargetTypes(Targettype.PASSIVE) ..setHeroAbility(FALSE) new BuildingDefinition(TELEPORTER_ID, 'ncop') ..setName("|cffFFFF08Teleporter") ..setHotkey("A") ..setTooltipBasic("|cffFFCC00Build |cffFFFF08Teleporter [A]") ..setTooltipExtended("Teleports Escaperkillers/Escapers to the selected destination.") ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNTeleporter.blp") ..setNormalAbilities(commaList(INFO_TELEPORTER_ID, MODE_ESCAPERS_ID, REMOVE_OBJECT_ID, MAKE_UNIT_INVISIBLE_ID, RALLY_POINT, INVULNERABILITY_ID)) ..setButtonPositionX(0) ..setButtonPositionY(1) ..setTintingColorBlue(0) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setBuildTime(1) ..setCollisionSize(0) ..setScalingValue(0.8) ..setSelectionScale(2.2) ..setUnitClassification("ancient,standon") ..setHideMinimapDisplay(true)