package Unitcreator import BaseObject import EscaperKillers import Pointer import Knockbacker constant INFO_UNIT_CREATOR_ID = compiletime(ABIL_ID_GEN.next()) constant INCREASE_INTERVAL_ID = compiletime(ABIL_ID_GEN.next()) constant DECREASE_INTERVAL_ID = compiletime(ABIL_ID_GEN.next()) constant FIXED_ID = compiletime(ABIL_ID_GEN.next()) constant RANDOM_ID = compiletime(ABIL_ID_GEN.next()) constant UTYPE_TANK = compiletime(ABIL_ID_GEN.next()) constant UTYPE_SK = compiletime(ABIL_ID_GEN.next()) constant UTYPE_BK = compiletime(ABIL_ID_GEN.next()) constant UTYPE_SRK = compiletime(ABIL_ID_GEN.next()) constant UTYPE_BRK = compiletime(ABIL_ID_GEN.next()) constant UTYPE_POINTER = compiletime(ABIL_ID_GEN.next()) constant UTYPE_KNOCKER = compiletime(ABIL_ID_GEN.next()) constant UTYPE_GLAIVE = compiletime(ABIL_ID_GEN.next()) constant UTYPE_SPELLBOOK = compiletime(ABIL_ID_GEN.next()) constant KEY_RTYPE = "r" constant KEY_SPAWN = "s" constant KEY_INTERVAL = "i" public enum TimerMode FIXED RANDOM public class UnitCreator extends StaticBaseObject real interval = 5. real timerreal = .5 int spawnUnitType = TANK_KILLER_ID let delays = new LinkedList TimerMode tmode = TimerMode.FIXED construct(unit existing) super(existing.getPos(), existing, 0., null , null) setEnabled(false) construct(vec2 pos, player owner) super(pos, createUnit(owner, UNIT_CREATOR_ID, pos, angle(0)), 0., null , null) actor.addAbility(FIXED_ID) setEnabled(false) override function update() if timerreal <= 0.0 if noRally == null create() if tmode == TimerMode.FIXED timerreal = interval else if tmode == TimerMode.RANDOM timerreal = delays.pop() if delays.isEmpty() refreshDelays() else timerreal -= ANIMATION_PERIOD function create() let rPos = getRallyPoint().toVec2() + vec2(0.001,0.001) let cpos = pos.toVec2() + vec2(0.001,0.001) EscaperSensorSetup ek = null switch spawnUnitType case 'BIGK' ek = new BigKiller(cpos, owner, getRallyAngle()) case 'SMAL' ek = new SmallKiller(cpos, owner, getRallyAngle()) case GLAIVE_KILLER_ID ek = new GlaiveKiller(cpos, owner, getRallyAngle()) case TANK_KILLER_ID ek = new TankKiller(cpos, owner, getRallyAngle()) case BIG_RANDOM_KILLER_ID ek = new BigRandomKiller(cpos, owner, getRallyAngle()) case SMALL_RANDOM_KILLER_ID ek = new SmallRandomKiller(cpos, owner, getRallyAngle()) case POINTER_ID ek = new Pointer(cpos, owner, getRallyAngle()) case KNOCKBACKER_ID ek = new Knockbacker(cpos, owner, getRallyAngle()) ek.setup.issuePointOrder("move", rPos) function refreshDelays() if tmode == tmode.RANDOM delays.clear() for i = 2 + (GetRandomInt(0, 1)) to interval.toInt() * 4 delays.add(i * 0.25) delays.shuffle() delays.shuffle() override function onCast() super.onCast() let id = GetSpellAbilityId() switch id case INCREASE_INTERVAL_ID if interval >= 15 createFText(pos, vec2(0,0.05), "|cffC51019Max", 10, 2., colorA(255,255,255,0), owner) else interval += 0.25 createFText(pos, vec2(0,0.05), "|cffC51019Intervall "+ R2SW(interval,1,2), 10, 2., colorA(255,255,255,0), owner) refreshDelays() case DECREASE_INTERVAL_ID if interval < 0.75 createFText(pos, vec2(0,0.05), "|cffC51019Min", 10, 2., colorA(255,255,255,0), owner) else interval -= 0.25 createFText(pos, vec2(0,0.05), "|cffC51019Intervall "+ R2SW(interval,1,2), 10, 2., colorA(255,255,255,0), owner) refreshDelays() case UTYPE_BK // Big killer spawnUnitType = 'BIGK' case UTYPE_SK // Small killer spawnUnitType = 'SMAL' case UTYPE_BRK // Big Random killer spawnUnitType = BIG_RANDOM_KILLER_ID case UTYPE_POINTER // Pointer spawnUnitType = POINTER_ID case UTYPE_GLAIVE // Glaive spawnUnitType = GLAIVE_KILLER_ID case UTYPE_TANK // Tank spawnUnitType = TANK_KILLER_ID case UTYPE_SRK // Chicken spawnUnitType = SMALL_RANDOM_KILLER_ID case UTYPE_KNOCKER spawnUnitType = KNOCKBACKER_ID case FIXED_ID actor..removeAbility(FIXED_ID)..addAbility(RANDOM_ID) tmode = TimerMode.RANDOM refreshDelays() case RANDOM_ID actor..removeAbility(RANDOM_ID)..addAbility(FIXED_ID) tmode = TimerMode.FIXED override function serialize() returns Json let json = super.serialize() json..addProperty(new Property(KEY_TYPE, UNITCREATOR_INDEX.toString())) json..addProperty(new Property(KEY_SPAWN, spawnUnitType.toString())) return json override function deserialize(Json json) spawnUnitType = json.getInt(KEY_SPAWN) ondestroy destroy delays @objectgen function genUnitCreator() new ChannelAbilityPreset(INFO_UNIT_CREATOR_ID, 1, TRUE) ..setName("Information: Unit Creator") ..presetTooltipNormal(lvl -> "|cff7B94E6Information: |rUnit Creator") ..presetTooltipNormalExtended(lvl -> "If you activcate the creator (Play Button) units of the selected type will be created periodically and walk to the rallypoint.") ..presetIcon("ReplaceableTextures\\CommandButtons\\PASInfo.blp") ..presetButtonPosNormal(0, 0) ..presetTargetTypes(Targettype.PASSIVE) ..setHeroAbility(FALSE) new ChannelAbilityPreset(DECREASE_INTERVAL_ID, 1, TRUE) ..setName("UC: Decrease Interval") ..presetTooltipNormal(lvl -> "|cffFF8421Decrease|r the Spawninterval by 0.25 [|cffFFCC00X|r]") ..presetTooltipNormalExtended(lvl -> "(more units)") ..presetIcon("ReplaceableTextures\\CommandButtons\\BTNReplay-Speeddown.blp") ..presetButtonPosNormal(1, 2) ..presetHotkey("X") ..presetTargetTypes(Targettype.NONE) ..setHeroAbility(FALSE) new ChannelAbilityPreset(INCREASE_INTERVAL_ID, 1, TRUE) ..setName("UC: Increase Interval") ..presetTooltipNormal(lvl -> "|cff3ABD52Increase|r the Spawninterval by 0.25 [|cffFFCC00C|r]") ..presetTooltipNormalExtended(lvl -> "(less units)") ..presetIcon("ReplaceableTextures\\CommandButtons\\BTNReplay-Speedup.blp") ..presetButtonPosNormal(2, 2) ..presetHotkey("C") ..presetTargetTypes(Targettype.NONE) ..setHeroAbility(FALSE) new ChannelAbilityPreset(FIXED_ID, 1, true) ..presetManaCost(lvl -> 0) ..setHeroAbility(false) ..presetCooldown(lvl -> 0) ..setName("Fixed Timer") ..presetIcon("BTNUCModeFixed") ..presetHotkey("D") ..presetTooltipNormal(lvl -> "Fixed Timer [|cffFFCC00D|r]") ..presetTooltipNormalExtended(lvl -> "At fixed mode, the monsters will always be spawned in the fixed interval you set." + "|nClick to change to random mode.") ..presetButtonPosNormal(1, 1) new ChannelAbilityPreset(RANDOM_ID, 1, true) ..presetManaCost(lvl -> 0) ..setHeroAbility(false) ..presetCooldown(lvl -> 0) ..setName("Random Timer") ..presetIcon("BTNUCModeRandom") ..presetHotkey("D") ..presetTooltipNormal(lvl -> "Random Timer [|cffFFCC00D|r]") ..presetTooltipNormalExtended(lvl -> "Chooses a random interval between all monsters spawned. The configured interval is the highest possible interval." + "|nClick to change to fixed mode.") ..presetButtonPosNormal(1, 1) new BuildingDefinition(UNIT_CREATOR_ID, 'ncop') ..setName("|cff4A943AUnitcreator") ..setHotkey("W") ..setTooltipBasic("|cffFFCC00Build |cff4A943AUnitcreator [W]") ..setTooltipExtended("Periodically creates a unit of the selected type." + "\nThe created unit walks to the rallypoint.") ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNTank Creator.blp") ..setNormalAbilities(commaList(INFO_UNIT_CREATOR_ID, DECREASE_INTERVAL_ID, INCREASE_INTERVAL_ID, UTYPE_SPELLBOOK, TURN_ON_ID, REMOVE_OBJECT_ID, RALLY_POINT, GHOST_INVIS_ID, INVULNERABILITY_ID)) ..setButtonPositionX(1) ..setButtonPositionY(0) ..setTintingColorRed(0) ..setTintingColorGreen(100) ..setTintingColorBlue(0) ..setSightRadiusDay(0) ..setSightRadiusNight(0) ..setBuildTime(1) ..setCollisionSize(0) ..setScalingValue(0.8) ..setSelectionScale(2.2) ..setUnitClassification("ancient,standon") ..setHideMinimapDisplay(true) createObjectDefinition("w3a", UTYPE_BK, 'ANcl') ..setLvlDataString("anam", 0, 0, "UC: Big Killer") ..setLvlDataString("aani", 0, 0, "spell") ..setLvlDataString("aeat", 0, 0, "") ..setLvlDataString("atat", 0, 0, "") ..setLvlDataInt("achd", 0, 0, 0) ..setLvlDataInt("aher", 0, 0, 0) ..setLvlDataInt("alev", 0, 0, 1) ..setLvlDataString("arac", 0, 0, "unknown") ..setLvlDataUnreal("aran", 1, 0, 0.0) ..setLvlDataUnreal("Ncl4", 1, 4, 0.0) ..setLvlDataString("atp1", 1, 0, "Change |cffffcc00Unittype |rto Big Escaper Killer [|cffffd700E|r]") ..setLvlDataString("aub1", 1, 0, "") ..setLvlDataUnreal("Ncl1", 1, 1, 0.0) ..setLvlDataInt("Ncl5", 1, 5, 0) ..setLvlDataInt("Ncl3", 1, 3, 1) ..setLvlDataString("Ncl6", 1, 6, "windwalk") ..setLvlDataUnreal("acdn", 1, 0, 0.5) ..setLvlDataString("aart", 0, 0, "ReplaceableTextures\\CommandButtons\\BTNAbomination.blp") ..setLvlDataString("acat", 0, 0, "") ..setLvlDataString("ahky", 0, 0, "E") createObjectDefinition("w3a", UTYPE_SK, 'ANcl') ..setLvlDataString("anam", 0, 0, "UC: Small Killer") ..setLvlDataString("aani", 0, 0, "spell") ..setLvlDataString("aeat", 0, 0, "") ..setLvlDataString("atat", 0, 0, "") ..setLvlDataInt("achd", 0, 0, 0) ..setLvlDataInt("aher", 0, 0, 0) ..setLvlDataInt("alev", 0, 0, 1) ..setLvlDataString("arac", 0, 0, "unknown") ..setLvlDataUnreal("aran", 1, 0, 0.0) ..setLvlDataUnreal("Ncl4", 1, 4, 0.0) ..setLvlDataString("atp1", 1, 0, "Change |cffFFCC00Unittype |rto |cff0894E6Small Escaper Killer") ..setLvlDataString("aub1", 1, 0, "") ..setLvlDataUnreal("Ncl1", 1, 1, 0.0) ..setLvlDataInt("Ncl5", 1, 5, 0) ..setLvlDataInt("Ncl3", 1, 3, 1) ..setLvlDataString("Ncl6", 1, 6, "whirlwind") ..setLvlDataUnreal("acdn", 1, 0, 0.5) ..setLvlDataString("aart", 0, 0, "ReplaceableTextures\\CommandButtons\\BTNDalaranMutant.blp") ..setLvlDataString("acat", 0, 0, "") createObjectDefinition("w3a", UTYPE_SRK, 'ANcl') ..setLvlDataString("anam", 0, 0, "UC: Random killer") ..setLvlDataString("aani", 0, 0, "spell") ..setLvlDataString("aeat", 0, 0, "") ..setLvlDataString("atat", 0, 0, "") ..setLvlDataInt("achd", 0, 0, 0) ..setLvlDataInt("aher", 0, 0, 0) ..setLvlDataInt("alev", 0, 0, 1) ..setLvlDataString("arac", 0, 0, "unknown") ..setLvlDataUnreal("aran", 1, 0, 0.0) ..setLvlDataUnreal("Ncl4", 1, 4, 0.0) ..setLvlDataString("atp1", 1, 0, "Change |cffFFCC00Unittype |rto |cff0894E6Small Random Escaper Killer") ..setLvlDataString("aub1", 1, 0, "") ..setLvlDataUnreal("Ncl1", 1, 1, 0.0) ..setLvlDataInt("Ncl5", 1, 5, 0) ..setLvlDataInt("Ncl3", 1, 3, 1) ..setLvlDataString("Ncl6", 1, 6, "web") ..setLvlDataUnreal("acdn", 1, 0, 0.5) ..setLvlDataString("aart", 0, 0, "ReplaceableTextures\\CommandButtons\\BTNCritterChicken.blp") ..setLvlDataString("acat", 0, 0, "") createObjectDefinition("w3a", UTYPE_BRK, 'ANcl') ..setLvlDataString("anam", 0, 0, "UC: Big Random Killer") ..setLvlDataString("aani", 0, 0, "spell") ..setLvlDataString("aeat", 0, 0, "") ..setLvlDataString("atat", 0, 0, "") ..setLvlDataInt("achd", 0, 0, 0) ..setLvlDataInt("aher", 0, 0, 0) ..setLvlDataInt("alev", 0, 0, 1) ..setLvlDataString("arac", 0, 0, "unknown") ..setLvlDataUnreal("aran", 1, 0, 0.0) ..setLvlDataUnreal("Ncl4", 1, 4, 0.0) ..setLvlDataString("atp1", 1, 0, "Change |cffFFCC00Unittype |rto |cff0894E6Big Random Escaper Killer") ..setLvlDataString("aub1", 1, 0, "") ..setLvlDataUnreal("Ncl1", 1, 1, 0.0) ..setLvlDataInt("Ncl5", 1, 5, 0) ..setLvlDataInt("Ncl3", 1, 3, 1) ..setLvlDataString("Ncl6", 1, 6, "acidbomb") ..setLvlDataUnreal("acdn", 1, 0, 0.5) ..setLvlDataString("aart", 0, 0, "ReplaceableTextures\\CommandButtons\\BTNCritterRabbit.blp") ..setLvlDataString("acat", 0, 0, "") createObjectDefinition("w3a", UTYPE_TANK, 'ANcl') ..setLvlDataString("anam", 0, 0, "UC: Tank") ..setLvlDataString("aani", 0, 0, "spell") ..setLvlDataString("aeat", 0, 0, "") ..setLvlDataString("atat", 0, 0, "") ..setLvlDataInt("achd", 0, 0, 0) ..setLvlDataInt("aher", 0, 0, 0) ..setLvlDataInt("alev", 0, 0, 1) ..setLvlDataString("arac", 0, 0, "unknown") ..setLvlDataUnreal("aran", 1, 0, 0.0) ..setLvlDataUnreal("Ncl4", 1, 4, 0.0) ..setLvlDataString("atp1", 1, 0, "Change |cffFFCC00Unittype |rto |cff0894E6Tank") ..setLvlDataString("aub1", 1, 0, "") ..setLvlDataUnreal("Ncl1", 1, 1, 0.0) ..setLvlDataInt("Ncl5", 1, 5, 0) ..setLvlDataInt("Ncl3", 1, 3, 1) ..setLvlDataString("Ncl6", 1, 6, "webon") ..setLvlDataUnreal("acdn", 1, 0, 0.5) ..setLvlDataString("aart", 0, 0, "ReplaceableTextures\\CommandButtons\\BTNSeigeEngine.blp") ..setLvlDataString("acat", 0, 0, "") createObjectDefinition("w3a", UTYPE_POINTER, 'ANcl') ..setLvlDataString("anam", 0, 0, "UC: Pointer") ..setLvlDataString("aani", 0, 0, "spell") ..setLvlDataString("aeat", 0, 0, "") ..setLvlDataString("atat", 0, 0, "") ..setLvlDataInt("achd", 0, 0, 0) ..setLvlDataInt("aher", 0, 0, 0) ..setLvlDataInt("alev", 0, 0, 1) ..setLvlDataString("arac", 0, 0, "unknown") ..setLvlDataUnreal("aran", 1, 0, 0.0) ..setLvlDataUnreal("Ncl4", 1, 4, 0.0) ..setLvlDataString("atp1", 1, 0, "Change |cffFFCC00Unittype |rto |cff0894E6Pointer") ..setLvlDataString("aub1", 1, 0, "") ..setLvlDataUnreal("Ncl1", 1, 1, 0.0) ..setLvlDataInt("Ncl5", 1, 5, 0) ..setLvlDataInt("Ncl3", 1, 3, 1) ..setLvlDataString("Ncl6", 1, 6, "voodoo") ..setLvlDataUnreal("acdn", 1, 0, 0.5) ..setLvlDataString("aart", 0, 0, "ReplaceableTextures\\CommandButtons\\BTNFlamingArrows.blp") ..setLvlDataString("acat", 0, 0, "") createObjectDefinition("w3a", UTYPE_GLAIVE, 'ANcl') ..setLvlDataString("anam", 0, 0, "UC: Glaive") ..setLvlDataString("aani", 0, 0, "spell") ..setLvlDataString("aeat", 0, 0, "") ..setLvlDataString("atat", 0, 0, "") ..setLvlDataInt("achd", 0, 0, 0) ..setLvlDataInt("aher", 0, 0, 0) ..setLvlDataInt("alev", 0, 0, 1) ..setLvlDataString("arac", 0, 0, "unknown") ..setLvlDataUnreal("aran", 1, 0, 0.0) ..setLvlDataUnreal("Ncl4", 1, 4, 0.0) ..setLvlDataString("atp1", 1, 0, "Change |cffFFCC00Unittype |rto |cff0894E6Glaive") ..setLvlDataString("aub1", 1, 0, "") ..setLvlDataUnreal("Ncl1", 1, 1, 0.0) ..setLvlDataInt("Ncl5", 1, 5, 0) ..setLvlDataInt("Ncl3", 1, 3, 1) ..setLvlDataString("Ncl6", 1, 6, "darkconversion") ..setLvlDataUnreal("acdn", 1, 0, 0.5) ..setLvlDataString("aart", 0, 0, "ReplaceableTextures\\CommandButtons\\BTNHowlOfTerror.blp") ..setLvlDataString("acat", 0, 0, "") ..setLvlDataString("aord", 0, 0, "cannibalize") createObjectDefinition("w3a", UTYPE_KNOCKER, 'ANcl') ..setLvlDataString("anam", 0, 0, "UC: Knockbacker") ..setLvlDataString("aani", 0, 0, "spell") ..setLvlDataString("aeat", 0, 0, "") ..setLvlDataString("atat", 0, 0, "") ..setLvlDataInt("achd", 0, 0, 0) ..setLvlDataInt("aher", 0, 0, 0) ..setLvlDataInt("alev", 0, 0, 1) ..setLvlDataString("arac", 0, 0, "unknown") ..setLvlDataUnreal("aran", 1, 0, 0.0) ..setLvlDataUnreal("Ncl4", 1, 4, 0.0) ..setLvlDataString("atp1", 1, 0, "Change |cffFFCC00Unittype |rto |cff0894E6Knockbacker") ..setLvlDataString("aub1", 1, 0, "") ..setLvlDataUnreal("Ncl1", 1, 1, 0.0) ..setLvlDataInt("Ncl5", 1, 5, 0) ..setLvlDataInt("Ncl3", 1, 3, 1) ..setLvlDataString("Ncl6", 1, 6, "locustswarm") ..setLvlDataUnreal("acdn", 1, 0, 0.5) ..setLvlDataString("aart", 0, 0, "ReplaceableTextures\\CommandButtons\\BTNTauren.blp") ..setLvlDataString("acat", 0, 0, "") ..setLvlDataString("aord", 0, 0, "creepthunderbolt") createObjectDefinition("w3a", UTYPE_SPELLBOOK, 'Aspb') ..setLvlDataInt("spb4", 1, 4, 11) ..setLvlDataInt("spb4", 2, 4, 11) ..setLvlDataInt("spb4", 3, 4, 11) ..setLvlDataInt("spb4", 4, 4, 11) ..setLvlDataInt("spb4", 5, 4, 11) ..setLvlDataInt("spb4", 6, 4, 11) ..setLvlDataInt("spb4", 7, 4, 11) ..setLvlDataInt("spb4", 8, 4, 11) ..setLvlDataInt("spb4", 9, 4, 11) ..setLvlDataInt("spb4", 10, 4, 11) ..setLvlDataInt("spb3", 1, 3, 11) ..setLvlDataInt("spb3", 2, 3, 11) ..setLvlDataInt("spb3", 3, 3, 11) ..setLvlDataInt("spb3", 4, 3, 11) ..setLvlDataInt("spb3", 5, 3, 11) ..setLvlDataInt("spb3", 6, 3, 11) ..setLvlDataInt("spb3", 7, 3, 11) ..setLvlDataInt("spb3", 8, 3, 11) ..setLvlDataInt("spb3", 9, 3, 11) ..setLvlDataInt("spb3", 10, 3, 11) ..setLvlDataString("spb5", 2, 5, "spellbook") ..setLvlDataString("spb1", 1, 1, commaList(UTYPE_SK, UTYPE_BK, UTYPE_SRK, UTYPE_BRK, UTYPE_GLAIVE, UTYPE_TANK, UTYPE_POINTER, UTYPE_KNOCKER)) ..setLvlDataInt("spb2", 4, 2, 1) ..setLvlDataInt("spb2", 5, 2, 1) ..setLvlDataInt("spb2", 6, 2, 1) ..setLvlDataInt("spb2", 7, 2, 1) ..setLvlDataInt("spb2", 8, 2, 1) ..setLvlDataInt("spb2", 9, 2, 1) ..setLvlDataInt("spb2", 10, 2, 1) ..setLvlDataString("aart", 0, 0, "ReplaceableTextures\\CommandButtons\\BTNRedDragon.blp") ..setLvlDataString("atp1", 1, 0, "Set the |cffFFCC00Unittype [|cffFFCC00R|r]") ..setLvlDataString("aub1", 1, 0, "Change the Type of the spawned Unit.") ..setLvlDataString("ahky", 0, 0, "R") ..setLvlDataInt("abpx", 0, 0, 3) ..setLvlDataInt("spb2", 1, 2, 0) ..setLvlDataString("ansf", 0, 0, "(Wizard)") ..setLvlDataString("anam", 0, 0, "UC: Select Type") ..setLvlDataInt("aite", 0, 0, 0)