package SetupBox import PlayerData import initlater Builder import ChannelAbilityPreset import SoundUtils import Preloader public constant SETUP_BOX_ID = compiletime(UNIT_ID_GEN.next()) constant HM = compiletime(ABIL_ID_GEN.next()) constant EASY_ENABLE = compiletime(ABIL_ID_GEN.next()) constant EASY_DISABLE = compiletime(ABIL_ID_GEN.next()) constant ICEI_ID = 'A057' constant ICED_ID = 'A006' constant PI_ID = 'A011' constant PD_ID = 'A059' constant LI_ID = 'A058' constant LD_ID = 'A05A' constant TURND_ID = 'A086' constant TURNI_ID = 'A087' constant ALLOW_ID = 'A01X' constant CLEAR_ID = 'A020' constant BOSS_MODE_ID = 'A03E' constant JUMP_TOGGLE_ID = 'A07S' public constant JUMP_SPELL_ID = 'A062' constant FIRST_PAGE = 'A07B' constant SECOND_PAGE = 'A07A' constant INC_GRAVITY = 'A07X' constant DEC_GRAVITY = 'A07W' constant ABIL_WIZARD = 'A06O' constant ORB_TOGGLE_ID = 'A08B' public constant ORB_SPELL_ID = 'A08A' constant CANCEL_TOGGLE_ID = 'A08C' constant CUT_ALLOW = 'A08F' constant CUT_DISABLE = 'A08G' constant MAX_SLIDESPEED = 15. constant MAX_DOT_DMG = 20. constant BOSS_SOUND = new SoundDefinition("Sound\\Dialogue\\Extra\\MuradinTaunt1.mp3", false) public class SetupBox extends UnitEntity private RegionData rdata construct(vec2 pos, player owner, RegionData data) super(createUnit(owner, SETUP_BOX_ID, pos, angle(0))) this.setCurrentRegion() rdata = data actor..addAbility(ALLOW_ID)..addAbility(CLEAR_ID)..addAbility(SECOND_PAGE) ..addAbility(INC_GRAVITY)..addAbility(DEC_GRAVITY)..addAbility(TURND_ID)..addAbility(TURNI_ID)..addAbility(ABIL_WIZARD) ..addAbility(CUT_ALLOW)..addAbility(EASY_ENABLE) EventListener.add(actor, EVENT_PLAYER_UNIT_SPELL_EFFECT, () -> onCast()) function addBossSwitch() actor.addAbility(BOSS_MODE_ID) function onCast() let id = GetSpellAbilityId() let owner = actor.getOwner() switch id case ICEI_ID if rdata.slidespeed >= MAX_SLIDESPEED DisplayTextToPlayer(owner, 0, 0, "Slidespeed is on Maximum") else rdata.slidespeed += .25 DisplayTextToPlayer(owner, 0, 0, "Slidespeed: " + rdata.slidespeed.toString()) case ICED_ID if rdata.slidespeed <= -MAX_SLIDESPEED DisplayTextToPlayer(owner, 0, 0, "Slidespeed is on Minimum") else rdata.slidespeed -= .25 DisplayTextToPlayer(owner, 0, 0, "Slidespeed: " + rdata.slidespeed.toString()) case PI_ID if rdata.poisonDmg >= MAX_DOT_DMG DisplayTextToPlayer(owner, 0, 0, "Poisondamage is on Maximum") else rdata.poisonDmg += .25 DisplayTextToPlayer(owner, 0, 0, "Poisondamage: " + rdata.poisonDmg.toString()) case PD_ID if rdata.poisonDmg <= .25 DisplayTextToPlayer(owner, 0, 0, "Poisondamage is on Minimum") else rdata.poisonDmg -= .25 DisplayTextToPlayer(owner, 0, 0, "Poisondamage: " + rdata.poisonDmg.toString()) case LI_ID if rdata.lavaDmg >= MAX_DOT_DMG DisplayTextToPlayer(owner, 0, 0, "Lavadmg is on Maximum") else rdata.lavaDmg += .25 DisplayTextToPlayer(owner, 0, 0, "Lavadmg: " + rdata.lavaDmg.toString()) case LD_ID if rdata.lavaDmg <= .25 DisplayTextToPlayer(owner, 0, 0, "Lavadmg is on Minimum") else rdata.lavaDmg -= .25 DisplayTextToPlayer(owner, 0, 0, "Lavadmg: " + rdata.lavaDmg.toString()) case ALLOW_ID let u = GetSpellTargetUnit() let p = u.getOwner() if isBuilderPlayer(p) and p != owner addEffect("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", u.getPos()).destr() if rdata.canBuild(p) and not pData[p.getId()].title == Title.ADMIN rdata.disallow(p) printTimedToPlayer("|cff9C0808Disallowed|r " + p.getNameColored() + " |cffffcc00to build in your region.", 25, owner) printTimedToPlayer(owner.getNameColored() + " |cff9C0808disallowed|r|cffffcc00 you to build in his region.", 25, p) if GetLocalPlayer() == p PingMinimapEx((GetRectMinX(rdata.theRect)+GetRectMaxX(rdata.theRect))/2, (GetRectMinY(rdata.theRect)+GetRectMaxY(rdata.theRect))/2, 3, 156, 8, 8, false) else rdata.allow(p) printTimedToPlayer("|cff08B552Allowed|r " + p.getNameColored() + " |cffffcc00to build in your region.", 25, owner) printTimedToPlayer(owner.getNameColored() + " |cff08B552allowed|r|cffffcc00 you to build in his region.", 25, p) if GetLocalPlayer() == p PingMinimapEx((GetRectMaxX(rdata.theRect)+GetRectMinX(rdata.theRect))/2, (GetRectMaxY(rdata.theRect)+GetRectMinY(rdata.theRect))/2, 3, 8, 181, 82, false) else printTimedToPlayer("|cffC51019Why would you do this!", 15, owner) case CLEAR_ID forUnitsInRect(rdata.theRect) u -> let data = u.getEntity() if data != null and not data instanceof Escaper and not data instanceof Builder and u != actor Log.debug("SetupBox Terminate") data.terminate() rdata.resetTiles() case JUMP_TOGGLE_ID let rdata = getRegionData(pos) if rdata.specialAbil > 0 for escaper from rdata.getEscapers() escaper.actor.removeAbility(rdata.specialAbil) rdata.specialAbil = JUMP_SPELL_ID printTimedToPlayer("|cffFF8C29Escapers can now jump in this region!", 25, owner) for escaper from rdata.getEscapers() escaper.actor.addAbility(rdata.specialAbil) case ORB_TOGGLE_ID let rdata = getRegionData(pos) if rdata.specialAbil > 0 for escaper from rdata.getEscapers() escaper.actor.removeAbility(rdata.specialAbil) rdata.specialAbil = ORB_SPELL_ID printTimedToPlayer("|cffFF8C29Escapers can now use the orb in this region!", 25, owner) for escaper from rdata.getEscapers() escaper.actor.addAbility(rdata.specialAbil) case CANCEL_TOGGLE_ID let rdata = getRegionData(pos) if rdata.specialAbil > 0 for escaper from rdata.getEscapers() escaper.actor.removeAbility(rdata.specialAbil) rdata.specialAbil = 0 printTimedToPlayer("|cffFF8C29Removed all abilities!", 25, owner) case BOSS_MODE_ID if pData[owner.getId()].XP >= 0 //500 BOSS_SOUND.play() actor.removeAbility(BOSS_MODE_ID) rdata.setBossRegion() printTimedToPlayer("|cff63BD4AYou converted your area to a |cff086BBDB|r|cff0C5CB0o|r|cff104DA3s|r|cff143E96s|r|cff182F89r|r|cff1C207Ce|r|cff590E4Fg|r|cff750D41i|r|cff910C33o|r|cffAD0B25n|r", 15, owner) addEffect("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl",actor.getPos()).destr() let builder = pData[owner.getId()].builder SelectUnitForPlayerSingle(builder.actor, owner) builder.setBossMenu() else DisplayTextToPlayer(owner, 0, 0, "|cffFFD621[Info]|r - You need to have at least the |cffFFE6AD3:Novice|r Rank to be able to make a BossRegion.\nYou accumulate Rank-XP over time by playing.") case SECOND_PAGE actor..removeAbility(ALLOW_ID)..removeAbility(ABIL_WIZARD)..removeAbility(CLEAR_ID)..removeAbility(SECOND_PAGE) ..removeAbility(INC_GRAVITY)..removeAbility(DEC_GRAVITY)..removeAbility(TURND_ID)..removeAbility(TURNI_ID) ..removeAbility(CUT_ALLOW)..removeAbility(CUT_DISABLE)..removeAbility(EASY_DISABLE)..removeAbility(EASY_ENABLE) actor..addAbility(ICEI_ID)..addAbility(ICED_ID)..addAbility(PI_ID)..addAbility(PD_ID) ..addAbility(LI_ID)..addAbility(LD_ID)..addAbility(FIRST_PAGE) case FIRST_PAGE actor..removeAbility(ICEI_ID)..removeAbility(ICED_ID)..removeAbility(PI_ID)..removeAbility(PD_ID) ..removeAbility(LI_ID)..removeAbility(LD_ID)..removeAbility(FIRST_PAGE) actor..addAbility(ALLOW_ID)..addAbility(ABIL_WIZARD)..addAbility(CLEAR_ID)..addAbility(SECOND_PAGE) ..addAbility(INC_GRAVITY)..addAbility(DEC_GRAVITY)..addAbility(TURND_ID)..addAbility(TURNI_ID) if rdata.allowCut actor.addAbility(CUT_DISABLE) else actor.addAbility(CUT_ALLOW) if rdata.easyMode actor.addAbility(EASY_DISABLE) else actor.addAbility(EASY_ENABLE) case INC_GRAVITY if rdata.gravity > -10 rdata.gravity -= 0.1 printTimedToPlayer("Gravity: " + rdata.gravity.toString(), 10, owner) case DEC_GRAVITY if rdata.gravity < -.2 rdata.gravity += 0.1 printTimedToPlayer("Gravity: " + rdata.gravity.toString(), 10, owner) case TURND_ID if rdata.turnSpeed > 0. rdata.turnSpeed -= .25 if rdata.turnSpeed <= 0.01 rdata.turnSpeed = 0.01 printTimedToPlayer("Turnspeed: " + rdata.turnSpeed.toString(), 10, owner) for escaper from rdata.getEscapers() escaper.actor.setTurnSpeed(rdata.turnSpeed) case TURNI_ID if rdata.turnSpeed < 5.0 if rdata.turnSpeed <= 0.01 rdata.turnSpeed = 0 rdata.turnSpeed += .25 printTimedToPlayer("Turnspeed: " + rdata.turnSpeed.toString(), 10, owner) for escaper from rdata.getEscapers() escaper.actor.setTurnSpeed(rdata.turnSpeed) case CUT_ALLOW rdata.allowCut = true actor..removeAbility(CUT_ALLOW)..addAbility(CUT_DISABLE) printTimedToPlayer("|cffFF9C29Escapers can now cut diagonal tiles", 15, owner) case CUT_DISABLE rdata.allowCut = false actor..removeAbility(CUT_DISABLE)..addAbility(CUT_ALLOW) printTimedToPlayer("|cffFF9C29Escapers can no longer cut diagonal tiles.", 15, owner) case EASY_ENABLE rdata.easyMode = true actor..removeAbility(EASY_ENABLE)..addAbility(EASY_DISABLE) printTimedToPlayer("|cffFF9C29Activated easy mode", 15, owner) case EASY_DISABLE rdata.easyMode = false actor..removeAbility(EASY_DISABLE)..addAbility(EASY_ENABLE) printTimedToPlayer("|cffFF9C29Deactivated easy mode", 15, owner) function claimRegion() let seller = GetTriggerUnit() let buyer = GetBuyingUnit() let itm = GetSoldItem() let id = GetItemTypeId(itm) let entity = buyer.getEntity() let rdata = getRegionData(seller.getPos()) let rtype = getRegionTypeFromItem(id) if entity instanceof Builder itm.remove() if rdata.rtype == RegionType.UNKNOWN and rtype != RegionType.UNKNOWN var builder = entity castTo Builder if builder.regionCount > 0 builder.regionCount-- rdata.setType(rtype, true) rdata.setOwner(builder.owner) GetManipulatedItem().remove() addEffect("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl", seller.getPos()).destr() seller.remove() DisplayTextToPlayer(builder.owner, 0, 0, "|cff6BC54AYou claimed this region!\nA |cffFFCC00Setupunit|cff6BC54A has been created at the |cffFFCC00left top corner|cff6BC54A of your region.") new SetupBox(vec2(GetRectMinX(rdata.theRect) + 192., GetRectMaxY(rdata.theRect) - 192.), builder.owner, rdata) if GetLocalPlayer() == builder.owner SelectUnit(builder.actor, true) else printTimedToPlayer("|cff3187CBYou have used up all your regions. Leave some for the other builders", 15, builder.owner) init registerPlayerUnitEvent(EVENT_PLAYER_UNIT_SELL_ITEM, () -> claimRegion()) preloadAbility(ICEI_ID) preloadAbility(ICED_ID) preloadAbility(PI_ID) preloadAbility(PD_ID) preloadAbility(LI_ID) preloadAbility(LD_ID) preloadAbility(TURND_ID) preloadAbility(TURNI_ID) preloadAbility(ALLOW_ID) preloadAbility(CLEAR_ID) preloadAbility(BOSS_MODE_ID) preloadAbility(JUMP_TOGGLE_ID) preloadAbility(JUMP_SPELL_ID) preloadAbility(FIRST_PAGE) preloadAbility(SECOND_PAGE) preloadAbility(INC_GRAVITY) preloadAbility(DEC_GRAVITY) preloadAbility(ABIL_WIZARD) preloadAbility(ORB_TOGGLE_ID) preloadAbility(ORB_SPELL_ID) preloadAbility(CANCEL_TOGGLE_ID) preloadAbility(CUT_ALLOW) preloadAbility(CUT_DISABLE) @objectgen function genSetupBox() new ChannelAbilityPreset(EASY_ENABLE, 1, true) ..setName("Enable Easy Mode") ..presetTooltipNormal((int levle) -> "Currently in |cffFF9C29normal |rmode.") ..presetTooltipNormalExtended((int levle) -> "Click to enable easy mode.\nIn Easy mode escapers don't instantly die when they normally would but instead receive damage and knockback.") ..presetIcon("BTNSacrifice.blp") ..presetButtonPosNormal(1, 0) ..presetHotkey("W") ..presetTargetTypes(Targettype.NONE) ..setHeroAbility(FALSE) new ChannelAbilityPreset(EASY_DISABLE, 1, true) ..setName("Disable Easy Mode") ..presetTooltipNormal((int levle) -> "Currently in |cff0884BDeasy |rmode.") ..presetTooltipNormalExtended((int levle) -> "Click to disable easy mode.\nEscapers will die normally again.") ..presetIcon("BTNShockWave.blp") ..presetButtonPosNormal(1, 0) ..presetHotkey("W") ..presetTargetTypes(Targettype.NONE) ..setHeroAbility(FALSE) new BuildingDefinition(SETUP_BOX_ID, 'nbse') ..setName("|cffFFCC00Setup") ..setIconGameInterface("ReplaceableTextures\\CommandButtons\\BTNMagicVault.blp") ..setNormalAbilities(commaList(GHOST_INVIS_ID, INVULNERABILITY_ID)) ..setGroundTexture("") ..setShadowTextureBuilding("") ..setModelFile("buildings\\other\\MagicVault\\MagicVault.mdl") ..setScalingValue(0.4) ..setSelectionScale(1.6) ..setSightRadiusDay(100) ..setSightRadiusNight(100) ..setPathingMap("") ..setCollisionSize(0) ..setUnitClassification("Mechanical") ..setHideMinimapDisplay(true)