package RegionData import initlater Builder import initlater Boss import public GameConstants import public BuilderConstants import public TerrainData import HashMap import PlayerData import TerrainModder import UnitProducer import DummyRecycler import PickSystem import ObstacleObjects import Execute import MGSpacey import MGWarlock public constant LOUNGE = gg_unit_revp_0322.getPos() constant regionMap = new HashMap() public enum RegionType UNKNOWN CITADEL SAND CITY SNOW SUNKEN public function RegionType.getTypeSet() returns regionTypeSet switch this case UNKNOWN return regionTypeSet(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) case CITADEL return regionTypeSet('I00H', 'Idtr', 'Ibkb', SMALL_CITADEL_KILLER_ID, BIG_CITADEL_KILLER_ID, 'KTtw', SOBS_CITADEL_ID, BOBS_CITADEL_ID, 'h00G', 'u00K', HOBS_CITADEL_ID) case SAND return regionTypeSet('I00G', 'Bdsd', GetTerrainType(2670,-7090), SMALL_SAND_KILLER_ID, BIG_SAND_KILLER_ID, 'BTtw', SOBS_DESERT_ID, BOBS_DESERT_ID, 'h00M', 'u00N', HOBS_DESERT_ID) case CITY return regionTypeSet('I00E', 'Ywmb', 'Ygsb', SMALL_GRASS_KILLER_ID, BIG_GRASS_KILLER_ID, 'LTlt', SOBS_GRASS_ID, BOBS_GRASS_ID, 'h00L', 'u00M', HOBS_GRASS_ID) case SNOW return regionTypeSet('I00D', 'Itbk', 'Isnw', SMALL_ICE_KILLER_ID, BIG_ICE_KILLER_ID, 'WTst', SOBS_ICE_ID, BOBS_ICE_ID, 'h00O', 'u00L', HOBS_ICE_ID) case SUNKEN return regionTypeSet('I00N', 'Zbks', 'Zdrg', SMALL_SUNKEN_KILLER_ID, BIG_SUNKEN_KILLER_ID, 'ZTtw', SOBS_SUNKEN_ID, BOBS_SUNKEN_ID, 'h00N', 'u00O', HOBS_SUNKEN_ID) public function getRegionTypeFromItem(int itemId) returns RegionType for i = 1 to 5 let reg = i castTo RegionType if reg.getTypeSet().regionItemId == itemId return reg return RegionType.UNKNOWN public tuple regionTypeSet(int regionItemId, int walkableId, int unwalkableId, int smallKillerId, int bigKillerId, int treeId, int smallObstacleId, int bigObstacleId, int bossId, int minionId, int highObstacleId) public enum Permission GUEST CONTRIBUTOR OWNER class FogData fogmodifier modifier fogstate state boolean visible rect r player p construct(player p, rect r) this.r = r this.p = p visible = isBuilderPlayer(p) if visible changeFog(FOG_OF_WAR_VISIBLE) else changeFog(FOG_OF_WAR_MASKED) function changeFog(fogstate fstate) if state != fstate state = fstate if modifier != null DestroyFogModifier(modifier) modifier = CreateFogModifierRect(p, state, r, false, false) FogModifierStart(modifier) // The "Area" RegionData a builder has to claim in order to build public class RegionData static RegionData EMPTY_REGION = new RegionData(null) private trigger visTrig LinkedList escapers = new LinkedList() private HashMap permissions = new HashMap() private FogData array[12] fmods RegionType rtype = RegionType.UNKNOWN rect theRect real slidespeed = 3. real poisonDmg = 1. real lavaDmg = 1. real turnSpeed = 2.55 real gravity = -0.8 boolean easyMode = false boolean visible = false int specialAbil = 0 boolean bossRegion = false boolean allowCut = false Boss boss = null construct(rect r) theRect = r if r != null visTrig = CreateTrigger() ..registerRectEnterEventSource(r) ..addAction(() -> enterRect()) regionMap.put(r, this) setBossRegion() function getEscapers() returns LLIterator return escapers.staticItr() function addEscaper(Escaper e) escapers.add(e) function removeEscaper(Escaper e) escapers.remove(e) function setBossRegion() bossRegion = true function resetTiles() if rtype != RegionType.UNKNOWN theRect.changeTerrain(rtype.getTypeSet().unwalkableId) function setType(RegionType rtype, boolean changeTerrain) this.rtype = rtype if rtype != RegionType.UNKNOWN and changeTerrain theRect.changeTerrain(rtype.getTypeSet().unwalkableId) function getTypeSet() returns regionTypeSet return rtype.getTypeSet() function setOwner(player p) permissions.put(p, Permission.OWNER) function allow(player p) permissions.put(p, Permission.CONTRIBUTOR) function disallow(player p) permissions.put(p, Permission.GUEST) function getPermission(player p) returns Permission if permissions.has(p) return permissions.get(p) return Permission.GUEST function canBuild(player p) returns boolean return (permissions.has(p) and (permissions.get(p) castTo int) > 0) or pData[p.getId()].title == Title.ADMIN function createSetup() createUnit(STAFF_PLAYER, REGION_ADMIN_ID, theRect.getCenter(), (270).asAngleDegrees()) function revealRegion(player p) let id = p.getId() if fmods[id] == null fmods[id] = new FogData(p, theRect) fmods[id].changeFog(FOG_OF_WAR_VISIBLE) function hideRegion(player p) let id = p.getId() if fmods[id] == null fmods[id] = new FogData(p, theRect) fmods[id].changeFog(FOG_OF_WAR_MASKED) static function enterRect() let u = GetTriggerUnit() let data = u.getEntity() let rdata = regionMap.get(GetTriggeringTrigger().getSourceRect()) if data != null if data instanceof Escaper let edata = data castTo Escaper if rdata.getTypeSet() == RegionType.UNKNOWN.getTypeSet() edata.setPos(edata.getPos()-edata.getRealVel()) edata.stop() edata.kill(null) edata.setCurrentRegion() else if isEscaperPlayer(data.owner) rdata.revealRegion(data.owner) edata.updateRegionData() else if not rdata.canBuild(data.owner) and not data instanceof Builder and not data instanceof Selector and not data instanceof Spaceship and not data instanceof Warlock and not data instanceof TerrainModder and not data instanceof UnitProducer printTimedToPlayer("|cffC51019You have no permission to move units into this region", 15, data.owner) Log.debug("no permission") if data == null u.kill() else data.terminate() real x = 0 real y = 0 public function rect.changeTerrain(integer ttype) let xmax = this.getMaxX() - 32 let xmin = this.getMinX() + 32 let ymax = this.getMaxY() - 32 let ymin = this.getMinY() + 32 x = xmin y = ymin while y <= ymax execute() -> while x <= xmax vec2(x,y).getEBRTile().setType(ttype) x = x + 128 x = xmin y = y + 128 RegionData array currentRegion public function Entity.setCurrentRegion() returns RegionData currentRegion[this castTo int] = getRegionData(this.getPos()) return currentRegion[this castTo int] public function Entity.getCurrentRegion() returns RegionData if currentRegion[this castTo int] == null currentRegion[this castTo int] = getRegionData(this.getPos()) return currentRegion[this castTo int] public function getRegionData(vec3 pos) returns RegionData return getRegionData(pos.toVec2()) public function getRegionData(vec2 pos) returns RegionData var i = 0 while regions[i] != null if regions[i].theRect.contains(pos) return regions[i] i++ return RegionData.EMPTY_REGION public RegionData array regions init regions[0] = new RegionData(gg_rct_Region_024) regions[0].setType(getRegionTypeFromItem('I00D'), false) regions[0].setOwner(STAFF_PLAYER) regions[1] = new RegionData(gg_rct_Region_018) regions[1].setType(getRegionTypeFromItem('I00G'), false) regions[1].setOwner(STAFF_PLAYER) regions[2] = new RegionData(gg_rct_Region_000) regions[2].setType(getRegionTypeFromItem('I00E'), false) regions[2].setOwner(STAFF_PLAYER) regions[3] = new RegionData(gg_rct_Region_001) regions[3].setType(getRegionTypeFromItem('I00H'), false) regions[3].setOwner(STAFF_PLAYER) regions[4] = new RegionData(gg_rct_Region_004)..createSetup() regions[5] = new RegionData(gg_rct_Region_005)..createSetup() regions[6] = new RegionData(gg_rct_Region_006)..createSetup() regions[7] = new RegionData(gg_rct_Region_007)..createSetup() regions[8] = new RegionData(gg_rct_Region_008)..createSetup() regions[9] = new RegionData(gg_rct_Region_009)..createSetup() regions[10] = new RegionData(gg_rct_Region_010)..createSetup() regions[11] = new RegionData(gg_rct_Region_011)..createSetup() regions[12] = new RegionData(gg_rct_Region_012)..createSetup() regions[13] = new RegionData(gg_rct_Region_013)..createSetup() regions[14] = new RegionData(gg_rct_Region_014)..createSetup() regions[15] = new RegionData(gg_rct_Region_015)..createSetup() regions[16] = new RegionData(gg_rct_Region_016)..createSetup() regions[17] = new RegionData(gg_rct_Region_017)..createSetup() regions[18] = new RegionData(gg_rct_Region_002)..createSetup() regions[19] = new RegionData(gg_rct_Region_003)..createSetup() regions[20] = new RegionData(gg_rct_Region_026)..createSetup() regions[21] = new RegionData(gg_rct_Start) regions[21].setOwner(STAFF_PLAYER) regions[21].setType(getRegionTypeFromItem('I00D'), false) regions[22] = new RegionData(gg_rct_Choose) regions[22].setType(getRegionTypeFromItem('I00D'), false) regions[22].setOwner(STAFF_PLAYER) regions[23] = new RegionData(gg_rct_coingamearea) regions[23].setType(getRegionTypeFromItem('I00G'), false) regions[23].setOwner(STAFF_PLAYER) regions[23].easyMode = true regions[24] = new RegionData(gg_rct_spaceygamearea) regions[24].setType(getRegionTypeFromItem('I00G'), false) regions[24].setOwner(STAFF_PLAYER) regions[25] = new RegionData(gg_rct_slidegamearea) regions[25].setType(getRegionTypeFromItem('I00D'), false) regions[25].setOwner(STAFF_PLAYER) regions[26] = new RegionData(gg_rct_Region_027)..createSetup() regions[27] = new RegionData(gg_rct_agargamearea) regions[27].setType(getRegionTypeFromItem('I00E'), false) regions[27].setOwner(STAFF_PLAYER) regions[28] = new RegionData(gg_rct_warlockgamearea) regions[28].setType(getRegionTypeFromItem('I00E'), false) regions[28].setOwner(STAFF_PLAYER) CreateTrigger()..registerRectLeaveEventSource(gg_rct_Region_023) ..addAction() -> let entity = GetTriggerUnit().getEntity() if entity instanceof Escaper (entity castTo Escaper).stop() (entity castTo Escaper).kill(null) else if entity != null and GetTriggerUnit().getTypeId() != DUMMY_UNIT_ID print(entity.actor.getName()) Log.debug("RegionDataDelete") entity.terminate()