package Tracks import Escaper import ConfigValue import Collision import ChannelAbilityPreset int array TRACKS constant TRACKS_ID = compiletime(UNIT_ID_GEN.next()) constant TRACKS_1_ID = compiletime(UNIT_ID_GEN.next()) constant TRACKS_2_ID = compiletime(UNIT_ID_GEN.next()) constant TRACKS_3_ID = compiletime(UNIT_ID_GEN.next()) constant INC_ID = 'A04S' constant DEC_ID = 'A04T' constant LEFT_ID = 'A04L' constant RIGHT_ID = 'A04U' constant INCLENGTH_ID = 'A04H' constant DECLENGTH_ID = 'A050' public class Tracks extends UnitEntity let trackSpeed = new ConfigValue(4, 0.50, "Trackspeed") unit setup int tsize = 0 rectangle rct vec2 dir = UP construct(vec2 pos, player owner) super(createUnit(owner, TRACKS[0], pos, angle(0))) this.setCurrentRegion() setup = createUnit(owner, TRACKS_ID, pos, angle(0)) setup.setEntity(this) EventListener.add(setup, EVENT_PLAYER_UNIT_SPELL_CAST, () -> onCast()) updateTrack() override function update() for escaper from this.getCurrentRegion().getEscapers() if escaper.pos.z < 22 and rct.contains(escaper.pos.toVec2()) escaper.otherVel += dir * trackSpeed.get() function recreateDummy() setNewActor(createUnit(owner, TRACKS[tsize], pos, dir.getAngle()-(90).asAngleDegrees())) ondestroy setup.setEntity(null) setup.remove() destroy trackSpeed function onCast() let id = GetSpellAbilityId() switch id case INC_ID trackSpeed.increment(this, 20) case DEC_ID trackSpeed.decrement(this, 1) case INCLENGTH_ID if tsize < 2 tsize++ updateTrack() case DECLENGTH_ID if tsize > 0 tsize-- updateTrack() case LEFT_ID if dir == UP dir = LEFT else if dir == LEFT dir = DOWN else if dir == DOWN dir = RIGHT else dir = UP updateTrack() case RIGHT_ID if dir == UP dir = RIGHT else if dir == RIGHT dir = DOWN else if dir == DOWN dir = LEFT else dir = UP updateTrack() actor.setTimeScale(0.5+trackSpeed.get()/6) function updateTrack() if dir == UP or dir == DOWN rct = rectangle(vec2(pos.x - 64,pos.y - tsize * 128 - 64), vec2(pos.x + 64, pos.y + tsize * 128 + 64)) else rct = rectangle(vec2(pos.x - tsize * 128 - 64,pos.y - 64), vec2(pos.x + tsize * 128 + 64, pos.y + 64)) recreateDummy() override function serialize() returns Json let json = super.serialize() json.addProperty(new Property(KEY_TYPE, TRACKS_INDEX.toString())) return json init TRACKS[0] = TRACKS_1_ID TRACKS[1] = TRACKS_2_ID TRACKS[2] = TRACKS_3_ID @objectgen function genTracks() new BuildingDefinition(TRACKS_ID, 'ncop') ..setName("|cffE63A21Tracks") ..setNameEditorSuffix("(Setup)") ..setHotkey("B") ..setTooltipBasic("|cffFFCC00Build |cffE63A21Tracks") ..setTooltipExtended("|cFFFF0000Moves Escaper in a certain directionr|r") ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNTracks.blp") ..setModelFile("models\\tcBox.mdl") ..setUnitSoundSet("") ..setPathingMap("none") ..setNormalAbilities(commaList(INC_ID, DEC_ID, LEFT_ID, RIGHT_ID, INCLENGTH_ID, DECLENGTH_ID, GHOST_INVIS_ID, REMOVE_OBJECT_ID, INVULNERABILITY_ID)) ..setButtonPositionX(0) ..setButtonPositionY(0) ..setTintingColorRed(210) ..setTintingColorGreen(210) ..setTintingColorBlue(230) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setBuildTime(1) ..setCollisionSize(0) ..setScalingValue(0.55) ..setSelectionScale(1) ..setRace(Race.Nightelf) ..setHideMinimapDisplay(true) new BuildingDefinition(TRACKS_1_ID, 'ncop') ..setName("|cffE63A21Tracks 1") ..setHotkey("B") ..setTooltipBasic("|cffFFCC00Build |cffE63A21Tracks") ..setTooltipExtended("|cFFFF0000Moves Escaper in a certain directionr|r") ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNTracks.blp") ..setModelFile("war3mapImported\\Tracks_1x1.mdl") ..setUnitSoundSet("") ..setPathingMap("none") ..setNormalAbilities(commaList('Aloc', INVULNERABILITY_ID)) ..setButtonPositionX(0) ..setButtonPositionY(0) ..setTintingColorRed(210) ..setTintingColorGreen(210) ..setTintingColorBlue(230) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setBuildTime(1) ..setCollisionSize(0) ..setSelectionScale(1) ..setRace(Race.Nightelf) ..setHideMinimapDisplay(true) new BuildingDefinition(TRACKS_2_ID, 'ncop') ..setName("|cffE63A21Tracks 2") ..setHotkey("B") ..setTooltipBasic("|cffFFCC00Build |cffE63A21Tracks") ..setTooltipExtended("|cFFFF0000Moves Escaper in a certain directionr|r") ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNTracks.blp") ..setModelFile("war3mapImported\\Tracks_3x1.mdl") ..setUnitSoundSet("") ..setPathingMap("none") ..setNormalAbilities(commaList('Aloc', INVULNERABILITY_ID)) ..setButtonPositionX(0) ..setButtonPositionY(0) ..setTintingColorRed(210) ..setTintingColorGreen(210) ..setTintingColorBlue(230) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setBuildTime(1) ..setCollisionSize(0) ..setSelectionScale(1) ..setRace(Race.Nightelf) ..setHideMinimapDisplay(true) new BuildingDefinition(TRACKS_3_ID, 'ncop') ..setName("|cffE63A21Tracks 3") ..setHotkey("B") ..setTooltipBasic("|cffFFCC00Build |cffE63A21Tracks") ..setTooltipExtended("|cFFFF0000Moves Escaper in a certain directionr|r") ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNTracks.blp") ..setModelFile("war3mapImported\\Tracks_5x1.mdl") ..setUnitSoundSet("") ..setPathingMap("none") ..setNormalAbilities(commaList('Aloc', INVULNERABILITY_ID)) ..setButtonPositionX(0) ..setButtonPositionY(0) ..setTintingColorRed(210) ..setTintingColorGreen(210) ..setTintingColorBlue(230) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setBuildTime(1) ..setCollisionSize(0) ..setSelectionScale(1) ..setRace(Race.Nightelf) ..setHideMinimapDisplay(true) new BuildingDefinition(BUILD_TRACKS_ID, 'ncop') ..setName("|cffE63A21Tracks") ..setNameEditorSuffix("(Builddummy)") ..setHotkey("D") ..setTooltipBasic("|cffFFCC00Build |cffF721ADTracks [D]") ..setTooltipExtended("Functions like a conveyor." + "\nIt makes Escapers move in the selected direction as long as they stay ontop of it.") ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNTracks.blp") ..setModelFile("war3mapImported\\Tracks_1x1.mdl") ..setUnitSoundSet("") ..setPathingMap("PathTextures\\4x4SimpleSolid.tga") ..setNormalAbilities(commaList(GHOST_INVIS_ID, REMOVE_OBJECT_ID, INVULNERABILITY_ID)) ..setButtonPositionX(2) ..setButtonPositionY(1) ..setTintingColorRed(210) ..setTintingColorGreen(210) ..setTintingColorBlue(230) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setBuildTime(1) ..setCollisionSize(0) ..setSelectionScale(1) ..setUnitClassification("ancient,standon") ..setRace(Race.Nightelf) ..setHideMinimapDisplay(true)