package Vortex import Escaper import ChannelAbilityPreset import Fx constant INC_GRAV_ID = 'A04J' constant DEC_GRAV_ID = 'A04K' constant real GRAV_RADIUS_BIG = 415.*415. constant real GRAV_RADIUS_MEDIUM = 207.*207. constant real GRAV_RADIUS_SMALL = 103.*103. constant ZMODE_NONE = compiletime(ABIL_ID_GEN.next()) constant ZMODE_CYLI = compiletime(ABIL_ID_GEN.next()) constant ZMODE_HEMI = compiletime(ABIL_ID_GEN.next()) constant SIZE_SMALL = compiletime(ABIL_ID_GEN.next()) constant SIZE_MED = compiletime(ABIL_ID_GEN.next()) constant SIZE_BIG = compiletime(ABIL_ID_GEN.next()) enum ZMode NONE CYLINDER HEMISPHERE public class Vortex extends UnitEntity real vgravity = 2. ZMode zMode = ZMode.NONE real radiusSq = GRAV_RADIUS_MEDIUM Fx vortexFx construct(vec2 pos, player owner) super(CreateUnit(owner, VORTEX_ID, pos.x, pos.y, 0)) this.setCurrentRegion() EventListener.add(actor, EVENT_PLAYER_UNIT_SPELL_CAST, () -> onCast()) actor..addAbility(ZMODE_NONE)..addAbility(ZMODE_CYLI)..addAbility(ZMODE_HEMI)..setVertexColor(colorA(255,255,255,155)) ..addAbility(SIZE_SMALL)..addAbility(SIZE_MED)..addAbility(SIZE_BIG)..addAbility(GHOST_INVIS_ID) vortexFx = new Fx(pos.withZ(12), "models\\vortex256.mdx") override function update() for e from this.getCurrentRegion().getEscapers() switch zMode case ZMode.NONE if pos.toVec2().distanceToSq(e.pos.toVec2()) < radiusSq and not e.flying let angl = e.pos.toVec2().angleTo(pos.toVec2()) e.otherVel += vec3(Cos(angl.radians) * vgravity, Sin(angl.radians) * vgravity, 0) case ZMode.CYLINDER if pos.toVec2().distanceToSq(e.pos.toVec2()) < radiusSq let angl = e.pos.toVec2().angleTo(pos.toVec2()) e.otherVel += vec3(Cos(angl.radians) * vgravity, Sin(angl.radians) * vgravity, 0) case ZMode.HEMISPHERE if pos.distanceToSq(e.pos) < radiusSq let angl = e.pos.toVec2().angleTo(pos.toVec2()) e.otherVel += vec3(Cos(angl.radians) * vgravity, Sin(angl.radians) * vgravity, 0) function onCast() let id = GetSpellAbilityId() switch id case INC_GRAV_ID if vgravity < 25. vgravity += .5 createFText(pos, vec2(0,0.06), "Gravity : " + vgravity.toString(), 12, 2., colorA(255,255,255,0), owner) case DEC_GRAV_ID if vgravity > -25. vgravity -= .5 createFText(pos, vec2(0,0.06), "Gravity : " + vgravity.toString(), 12, 2., colorA(255,255,255,0), owner) case ZMODE_NONE zMode = ZMode.NONE createFText(pos, vec2(0,0.06), "Z Mode: None", 12, 2., colorA(255,255,255,0), owner) case ZMODE_CYLI zMode = ZMode.CYLINDER createFText(pos, vec2(0,0.06), "Z Mode: Cylinder", 12, 2., colorA(255,255,255,0), owner) case ZMODE_HEMI zMode = ZMode.HEMISPHERE createFText(pos, vec2(0,0.06), "Z Mode: Hemisphere", 12, 2., colorA(255,255,255,0), owner) case SIZE_SMALL radiusSq = GRAV_RADIUS_SMALL vortexFx.hiddenDestroy() vortexFx = new Fx(pos + vec3(0,0,12), "models\\vortex128.mdx") case SIZE_MED radiusSq = GRAV_RADIUS_MEDIUM vortexFx.hiddenDestroy() vortexFx = new Fx(pos + vec3(0,0,12), "models\\vortex256.mdx") case SIZE_BIG radiusSq = GRAV_RADIUS_BIG vortexFx.hiddenDestroy() vortexFx = new Fx(pos + vec3(0,0,12), "models\\vortex512.mdx") override function serialize() returns Json let json = super.serialize() json.addProperty(new Property(KEY_TYPE, VORTEX_INDEX.toString())) return json ondestroy vortexFx.hiddenDestroy() @objectgen function genVortex() new ChannelAbilityPreset(ZMODE_NONE, 1, true) ..setName("Set no Z Mode") ..presetTooltipNormal((int levle) -> "Set to |cffFF9C29normal |rmode.") ..presetTooltipNormalExtended((int levle) -> "In this mode escapers are only affected while on ground") ..presetIcon("BTNSacrifice.blp") ..presetButtonPosNormal(0, 1) ..presetHotkey("A") new ChannelAbilityPreset(ZMODE_CYLI, 1, true) ..setName("Set Cylinder Z Mode") ..presetTooltipNormal((int levle) -> "Set to |cff0884BDcylinder |rmode.") ..presetTooltipNormalExtended((int levle) -> "In this mode escapers are affected also while flying, at any height") ..presetIcon("BTNShockWave.blp") ..presetButtonPosNormal(1, 1) ..presetHotkey("S") new ChannelAbilityPreset(ZMODE_HEMI, 1, true) ..setName("Set Hemisphere Z Mode") ..presetTooltipNormal((int levle) -> "Set to |cff0884BDhemisphere |rmode.") ..presetTooltipNormalExtended((int levle) -> "In this mode escapers are affected in a hemisphere above the center") ..presetIcon("BTNShockWave.blp") ..presetButtonPosNormal(2, 1) ..presetHotkey("D") new ChannelAbilityPreset(SIZE_SMALL, 1, true) ..setName("Size small") ..presetTooltipNormal((int levle) -> "Set size to small [Q]") ..presetTooltipNormalExtended((int levle) -> "128") ..presetIcon("BTN1x1inactive.blp") ..presetButtonPosNormal(0, 0) ..presetHotkey("Q") new ChannelAbilityPreset(SIZE_MED, 1, true) ..setName("Size medium") ..presetTooltipNormal((int levle) -> "Set size to medium [W]") ..presetTooltipNormalExtended((int levle) -> "256") ..presetIcon("BTN3x3inactive.blp") ..presetButtonPosNormal(1, 0) ..presetHotkey("W") new ChannelAbilityPreset(SIZE_BIG, 1, true) ..setName("Size big") ..presetTooltipNormal((int levle) -> "Set size to big [E]") ..presetTooltipNormalExtended((int levle) -> "128") ..presetIcon("BTN5x5inactive.blp") ..presetButtonPosNormal(2, 0) ..presetHotkey("E") new BuildingDefinition(VORTEX_ID, 'ncop') ..setName("|cff636363Vortex ") ..setHotkey("R") ..setTooltipBasic("Build |cff636363Vortex [R]") ..setTooltipExtended("Build a vortex that attracts escapers to it's center.") ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNStun.blp") ..setNormalAbilities(commaList('A04K', 'A04J', REMOVE_OBJECT_ID, INVULNERABILITY_ID)) ..setModelFile("models\\tcBox.mdl") ..setTintingColorBlue(225) ..setTintingColorGreen(25) ..setTintingColorRed(205) ..setUnitSoundSet("") ..setPathingMap("none") ..setButtonPositionX(1) ..setButtonPositionY(0) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setBuildTime(1) ..setCollisionSize(1) ..setScalingValue(0.55) ..setSelectionScale(1) ..setUnitClassification("ancient,standon") ..setHideMinimapDisplay(true)