package Door import SetupObject import Key import PlayerData import ChannelAbilityPreset public constant DOORPATH = compiletime(UNIT_ID_GEN.next()) constant DOORPATH_O = compiletime(UNIT_ID_GEN.next()) constant DOOROPEN_ABILITY_ID = 'A00J' constant DOORTURN_ABILITY_ID = 'A01W' constant DOORPLACEKEY_ABILITY_ID = 'Av42' constant EVENT_RADIUS = 192. let KEY_COLOR_ID = ['I009', //white 'I00C', //red 'I004', //blue 'I008', //teal 'I00J', //purple 'I005', //yellow 'I00O', //orange 'I00B', //green 'I006'] //pink constant KEY_COLOR = "c" constant KEY_ROTATION = "d" public class Door extends StaticSetupObject unit pathing var col = EBRColor.WHITE var vertical = false var opened = false construct(unit existing) super(createUnit(existing.getOwner(), DOORDUMMY_ID, existing.getPos(), (270).asAngleDegrees()), existing, EVENT_RADIUS, function Door.keyopen) pathing = createUnit(this.owner, DOORPATH, pos, 270 .fromDeg()) construct(vec2 pos, player owner) super(createUnit(owner,DOORDUMMY_ID, pos, (270).asAngleDegrees()), createUnit(owner,DOORORDER_ID, pos, 0 .fromDeg()), EVENT_RADIUS, function Door.keyopen) pathing = createUnit(this.owner, DOORPATH, pos, 270 .fromDeg()) EventListener.add(setup, EVENT_PLAYER_UNIT_SPELL_CAST, () -> onCast()) static function keyopen() let source = GetTriggeringTrigger().getSource() let u = GetTriggerUnit() let e = u.getEntity() let door = source.getEntity() castTo Door if not door.opened and e instanceof Escaper let es = e castTo Escaper if es.pos.z < 64 if u.hasItemById(KEY_COLOR_ID[door.col castTo int]) let kdata = u.getItemById(KEY_COLOR_ID[door.col castTo int]).getEntity() castTo Key if kdata != null Log.debug("kdata Terminate") kdata.terminate() door.openDoor() let pd = pData[e.owner.getId()] pd.addXp(10, false) function changeColor(int id) for i = 0 to 8 if id == colorSpells[i] col = i castTo EBRColor actor.setVertexColor(col.toColor()) function toggleOpen() if opened closeDoor() else openDoor() function closeDoor() actor.setAnimation("stand") pathing.remove() opened = false if vertical pathing = createUnit(owner, DOORPATH, pos.toVec2(), 0 .fromDeg()) else pathing = createUnit(owner, DOORPATH, pos.toVec2(), 270 .fromDeg()) function openDoor() actor.setAnimation("Death Alternate") pathing.remove() opened = true if vertical pathing = createUnit(owner, DOORPATH_O, pos.toVec2(), 0 .fromDeg()) else pathing = createUnit(owner, DOORPATH_O, pos.toVec2(), 270 .fromDeg()) function turn() if vertical pathing.remove() vertical = false if opened setNewActor(createUnit(owner, DOORDUMMY_ID , pos.toVec2(), 270 .fromDeg())) actor.setAnimation("Death Alternate") pathing = createUnit(owner, DOORPATH_O, pos.toVec2(), 270 .fromDeg()) else setNewActor(createUnit(owner, DOORDUMMY_ID , pos.toVec2(), 270 .fromDeg())) pathing = createUnit(owner, DOORPATH, pos.toVec2(), 270 .fromDeg()) else pathing.remove() vertical = true if opened setNewActor(createUnit(owner, DOORDUMMY_ID , pos.toVec2(), 0 .fromDeg())) actor.setAnimation("Death Alternate") pathing = createUnit(owner, DOORPATH_O, pos.toVec2(), 0 .fromDeg()) else setNewActor(createUnit(owner, DOORDUMMY_ID , pos.toVec2(), 0 .fromDeg())) pathing = createUnit(owner, DOORPATH, pos.toVec2(), 0 .fromDeg()) actor.setVertexColor(col.toColor()) ondestroy pathing.remove() function onCast() let id = GetSpellAbilityId() switch id case DOOROPEN_ABILITY_ID toggleOpen() case DOORTURN_ABILITY_ID turn() default changeColor(id) override function serialize() returns Json let json = super.serialize() json.addProperty(new Property(KEY_TYPE, DOOR_INDEX.toString())) json.addProperty(new Property(KEY_COLOR, (col castTo int).toString())) json.addProperty(new Property(KEY_ROTATION, (vertical.toInt()).toString())) return json override function deserialize(Json json) super.deserialize(json) col = json.getInt(KEY_COLOR) castTo EBRColor actor.setVertexColor(col.toColor()) if json.getInt(KEY_ROTATION) == 1 turn() @objectgen function genDoor() new BuildingDefinition(DOORPATH, 'hhou') ..setScalingValue(0.55) ..setRequiredAnimationNames("second") ..setButtonPositionX(0) ..setButtonPositionY(0) ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNGateDoor.blp") ..setGroundTexture("") ..setShadowTextureBuilding("") ..setModelFile(".mdl") ..setSelectionScale(6) ..setUnitSoundSet("") ..setPathingMap("war3mapImported\\Doorpathing.tga") ..setPlacementPreventedBy("") ..setCollisionSize(140) ..setCanDropItemsOnDeath(false) ..setNormalAbilities((INVULNERABILITY_ID).toRawCode()) ..setName("Doorpathing") ..setHotkey("D") ..setTooltipBasic("|cFFFFFF00D|roor Horizontal/Vertical") ..setTooltipExtended("Can be opened by using a |cFF00FFFFKey|r") ..setBuildTime(1) ..setHitPointsMaximumBase(1000000) ..setFoodProduced(0) ..setGoldCost(0) ..setLumberCost(0) ..setHideMinimapDisplay(true) ..setPlacementRequires("") new BuildingDefinition(DOORPATH_O, 'hhou') ..setScalingValue(0.55) ..setRequiredAnimationNames("second") ..setButtonPositionX(0) ..setButtonPositionY(0) ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNGateDoor.blp") ..setGroundTexture("") ..setShadowTextureBuilding("") ..setModelFile(".mdl") ..setSelectionScale(6) ..setUnitSoundSet("") ..setPathingMap("war3mapImported\\DoorpathingOpen.tga") ..setPlacementPreventedBy("") ..setCollisionSize(140) ..setCanDropItemsOnDeath(false) ..setNormalAbilities((INVULNERABILITY_ID).toRawCode()) ..setName("DoorpathingOpen") ..setHotkey("D") ..setTooltipBasic("|cFFFFFF00D|roor Horizontal/Vertical") ..setTooltipExtended("Can be opened by using a |cFF00FFFFKey|r") ..setBuildTime(1) ..setHitPointsMaximumBase(1000000) ..setFoodProduced(0) ..setGoldCost(0) ..setLumberCost(0) ..setHideMinimapDisplay(true) ..setPlacementRequires("") new BuildingDefinition(DOORDUMMY_ID, 'hhou') ..setScalingValue(0.55) ..setRequiredAnimationNames("second") ..setButtonPositionX(0) ..setButtonPositionY(0) ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNGateDoor.blp") ..setGroundTexture("") ..setShadowTextureBuilding("") ..setModelFile("Doodads\\LordaeronSummer\\Terrain\\ElfGate\\ElfGate.mdl") ..setSelectionScale(6) ..setUnitSoundSet("") ..setPathingMap("war3mapImported\\Doorpathing.tga") ..setPlacementPreventedBy("") ..setCollisionSize(140) ..setCanDropItemsOnDeath(false) ..setNormalAbilities(('Aloc').toRawCode()) ..setName("|cffFF9421Door") ..setHotkey("Y") ..setTooltipBasic("|cffFFCC00Build |cffFF9421Door [Y]") ..setTooltipExtended("Doors can be opened by keys and executers." + "\nThey can be rotated and recolored. Doors of a certain color can only be opened by a key with that same color." + "\nYou can drop keys using the item in your builder's inventory.") ..setBuildTime(1) ..setHitPointsMaximumBase(1000000) ..setFoodProduced(0) ..setGoldCost(0) ..setLumberCost(0) ..setHideMinimapDisplay(true) ..setUnitClassification("ancient,mechanical") ..setPlacementRequires("") new BuildingDefinition(DOORORDER_ID, 'hhou') ..setScalingValue(0.75) ..setRequiredAnimationNames("second") ..setButtonPositionX(0) ..setButtonPositionY(0) ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNGateDoor.blp") ..setGroundTexture("") ..setShadowTextureBuilding("") ..setModelFile("models\\tcBox.mdl") ..setSelectionScale(1) ..setUnitSoundSet("") ..setPathingMap("") ..setPlacementPreventedBy("") ..setPlacementRequires("") ..setCollisionSize(0) ..setCanDropItemsOnDeath(false) ..setNormalAbilities(commaList('A05R', 'A01W', 'A00J', REMOVE_OBJECT_ID, INVULNERABILITY_ID, GHOST_INVIS_ID)) ..setName("|cFFFF8000Door|r ") ..setHotkey("D") ..setNameEditorSuffix("Dummy") ..setBuildTime(1) ..setHitPointsMaximumBase(1000000) ..setFoodProduced(0) ..setGoldCost(0) ..setLumberCost(0) ..setHideMinimapDisplay(true) ..setUnitClassification("ancient,mechanical")