package Pointer import EscaperSensor import Escaper import Preloader import ChannelAbilityPreset import StringUtils public constant POINTER_ID = 'pntr' constant INFO_POINTER_ID = compiletime(ABIL_ID_GEN.next()) constant POINTER_RADIUS = 64. constant INC_ID = 'A01F' constant DEC_ID = 'A01G' constant START_ID = 'A031' constant STOP_ID = 'A032' public class Pointer extends EscaperSensorSetup var turnspeed = 2. var angl = 0 .fromDeg() var turning = false construct(vec2 pos, player owner, angle facing) super(pos.toVec3(), owner, POINTER_ID, facing, POINTER_RADIUS, 16.) angl = facing EventListener.add(setup, EVENT_PLAYER_UNIT_SPELL_CAST, () -> onCast()) override function update() if turning angl += turnspeed.asAngleDegrees() angl = (angl.degrees() % 360).asAngleDegrees() actor..setXY(setup.getPos()) ..setFacing(angl) else super.update() function onCast() let id = GetSpellAbilityId() switch id case INC_ID if turnspeed < 6. turnspeed += 0.5 createFText(pos, vec2(0,0.05), "Turnspeed: "+ R2SW(turnspeed,1,2), 10, 2., COLOR_WHITE, owner) else createFText(pos, vec2(0,0.05), "Maximum Speed", 10, 2., COLOR_WHITE, owner) case DEC_ID if turnspeed > -6. turnspeed -= 0.5 createFText(pos, vec2(0,0.05), "Turnspeed: "+ R2SW(turnspeed,1,2), 10, 2., COLOR_WHITE, owner) else createFText(pos, vec2(0,0.05), "Minimum Speed", 10, 2., COLOR_WHITE, owner) case START_ID turning = true angl = actor.getFacingAngle() activate() setup..removeAbility(START_ID)..addAbility(STOP_ID) case STOP_ID turning = false deactivate() setup..removeAbility(STOP_ID)..addAbility(START_ID) override function onSensor(UnitEntity source, UnitEntity target) let edata = target var data = source castTo Pointer if edata instanceof Escaper let es = edata castTo Escaper if not data.active data.angl = data.actor.getFacingAngle() es.actor.setFacing(data.angl) function setfacing(angle amount) angl = amount setup.setFacing(angl) actor.setFacing(angl) createFText(pos, vec2(0,0.05), amount.degrees().toString(), 10, 2., colorA(255,175,75,0), owner) override function serialize() returns Json let json = super.serialize() json ..addProperty(new Property(KEY_TYPE, POINTER_INDEX.toString())) return json init EventListener.add(EVENT_PLAYER_CHAT_FILTER) -> let text = GetEventPlayerChatString() let tokens = text.split(" ") let cmd = tokens.dequeue() if cmd == "-setangle" or cmd == "-sa" let angle = tokens.dequeue().toReal().fromDeg() forUnitsSelected(GetTriggerPlayer()) u -> if u.getEntity() instanceof Pointer let pointer = u.getEntity() castTo Pointer pointer.setFacing(angle) preloadAbility(START_ID) preloadAbility(STOP_ID) preloadAbility(INC_ID) preloadAbility(DEC_ID) @objectgen function genPointer() new ChannelAbilityPreset(INFO_POINTER_ID, 1, TRUE) ..setName("Information: Pointer") ..presetTooltipNormal(lvl -> "Information: Pointer") ..presetTooltipNormalExtended(lvl -> "Only on Ice!" + "\nFaces and Escaper in the direction the Pointer is facing." + "\nYou can set facing by moving pointer or by the command: -setangle 0-360" + "\nTo let it autorotate click the Ability once.") ..presetIcon("ReplaceableTextures\\CommandButtons\\PASInfo.blp") ..presetButtonPosNormal(0, 0) ..presetTargetTypes(Targettype.PASSIVE) ..setHeroAbility(FALSE) new UnitDefinition(POINTER_ID, 'hmtt') ..setAttacksEnabled(0) ..setTargetedAs("air") ..setAnimationBlendTimeseconds(0) ..setAnimationCastBackswing(0) ..setAnimationCastPoint(0) ..setDeathTimeseconds(0.1) ..setElevationSamplePoints(0) ..setElevationSampleRadius(0) ..setShadowImageCenterX(0) ..setShadowImageCenterY(0) ..setShadowImageHeight(0) ..setShadowImageUnit("") ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNFlamingArrows.blp") ..setModelFile("Abilities\\Weapons\\BallistaMissile\\BallistaMissile.mdl") ..setSelectionScale(1.5) ..setUnitSoundSet("") ..setCollisionSize(0) ..setSpeedBase(180) ..setMovementHeight(10) ..setTurnRate(99) ..setMovementType(MovementType.Fly) ..setNormalAbilities(commaList('A031', 'A01F', 'A01G', REMOVE_OBJECT_ID, GHOST_VIS_ID, INVULNERABILITY_ID)) ..setHotkey("X") ..setName("|cff0894E6Pointer") ..setTooltipBasic("|cffFFCC00Train |cff0894E6Pointer [X]") ..setTooltipExtended("Changes the Angle of a escaper where it points to") ..setUpgradesUsed("") ..setRequirements("") ..setHitPointsMaximumBase(100000000) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setGoldCost(0) ..setFoodCost(0) ..setHideMinimapDisplay(true)