package PlayerData import MultiboardClass import public Escaper import public BuilderConstants import public GameConstants import public ClosureForGroups import initlater CodeGenerator import initlater TerrainModder import Builder import UnitProducer import RevivePointModifier import EscaperClasses import ClosureTimers import Players import PlayerMemoryData import SoundUtils import Assets import PickSystem public Board playerboard public PlayerData array pData public let allPlayers = new LinkedList() public let escaperPlayers = new LinkedList() public let builderPlayers = new LinkedList() let questFailedSound = new SoundDefinition(Sounds.questFailed, false) public function player.getData() returns PlayerData return pData[this.getId()] public var minutes = 0 public var seconds = 0 public enum Role BUILDER ESCAPER public enum Title PLAYER MOD ADMIN public class PlayerData player p int id string hash string name string mbname string icon = Icons.bTNSelectHeroOn string rank = "Newbie" Role role Title title Escaper escaper Builder builder TerrainModder array[4] tmods UnitProducer prod int XP = 40 effect lvlfx = null effect tagfx = null boolean localFilesEnabled = false int lastExpGain = 0 int lastSave = -1 real zCam = 1600. var smooth = 10. RevivePointModifier revmod PMData pmdata = null Selector selector = null construct (player p) pData[p.getId()] = this this.p = p id = p.getId() name = p.getName() pData[id] = this hash = name.getHash().toString() mbname = name checkName() var i = 0 while names[i] != null i++ mbname = p.getNameColored() allPlayers.add(this) if id > 7 role = Role.BUILDER builderPlayers.add(this) else role = Role.ESCAPER escaperPlayers.add(this) function checkName() let cname = mbname.toLowerCase() for i = 0 to names.length if cname == names[i].toLowerCase() mbname = tags[i] + "|r" + p.getNameColored() function setMBRow(int row) playerboard..setNewItem(row,0,mbname,icon) ..setNewItem(row, 1, escaper == null ? "-" : escaper.deaths.toString(), null) ..setNewItem(row, 2, rank, null) function addXp(int amount, boolean time) if localFilesEnabled and allPlayers.size() > 1 or title == Title.ADMIN if time XP += amount else if lastExpGain < minutes lastExpGain = minutes Log.debug("add current xp:" + XP.toString()) XP += amount Log.debug("add new xp:" + XP.toString()) updateRank() function setXp(int amount) Log.debug("set current xp:" + XP.toString()) XP = amount updateRank() Log.debug("set new xp:" + XP.toString()) function updateRank() if lvlfx != null lvlfx.destr() var i = 0 while XP >= expBounds[i] i++ rank = ranks[i] p.addGold(i * 15) if title == Title.ADMIN rank = "|cffADD642*Admin*" if tagfx == null tagfx = AddSpecialEffectTarget("war3mapImported\\HolyShield Seal_Portrait.mdx", escaper.actor, "chest") if XP > 10000 lvlfx = AddSpecialEffectTarget("war3mapImported\\Life High_Portrait.mdx", escaper.actor, "chest") else if XP > 7500 lvlfx = AddSpecialEffectTarget("war3mapImported\\Life High.mdx", escaper.actor, "chest") else if XP > 4000 lvlfx = AddSpecialEffectTarget("war3mapImported\\Life Low_Portrait.mdx", escaper.actor, "chest") else if XP > 1000 lvlfx = AddSpecialEffectTarget("war3mapImported\\Life Low.mdx", escaper.actor, "chest") if XP >= expBounds[3] and not UnitHasItemOfTypeBJ(escaper.actor, 'I002') printTimedToPlayer("You have unlocked the |cffFFCC00jukebox|r!", 25, p) escaper.actor.addItemById('I002') function validateAdmintoken() let divhash = name.getHash() - fhash(name) div 2 if pmdata != null and not title == Title.ADMIN if pmdata.adminToken != "no" if 1303565542 == pmdata.adminToken.getHash() printTimedToPlayer("You are an admin!", 10, p) title = Title.ADMIN else if divhash == pmdata.adminToken.toInt() // yarik's coin printTimedToPlayer("You are a contributor!", 10, p) escaper.actor.addItemById('I00Z') ondestroy printTimed(p.getNameColored() + "|r |cffFFCC33has left the game!", 20.) questFailedSound.play() if selector != null destroy selector if escaper != null if escaper.alive Log.debug("PD Terminate") escaper.terminate() else escaper.left = true escaper = null if prod != null prod.terminate() for i = 0 to 3 if tmods[i] != null tmods[i].legit = true tmods[i].terminate() allPlayers.remove(this) if isBuilderPlayer(p) builderPlayers.remove(this) else escaperPlayers.remove(this) // Give remaining builders control if not builderPlayers.isEmpty() and isBuilderPlayer(p) if builder != null Log.debug("isEmpty Terminate") builder.terminate() for i = 0 to 22 if regions[i].getPermission(this.p) == Permission.OWNER for j = 8 to 11 regions[i].allow(players[j]) pData[j].builder.regionCount += 2 // forUnitsOfPlayer(p) u -> // u.setOwner(builderPlayers.peek().p, true) pData[id] = null rebuildBoard() if revmod != null destroy revmod if tagfx != null tagfx.destr() pData[p.getId()] = null function rebuildBoard() playerboard = new Board(allPlayers.size()+1,3) var i = 1 for pd in allPlayers playerboard.board.getItem(i,0)..setStyle(true,true)..setWidth(0.1) playerboard.board.getItem(i,1)..setStyle(true,false)..setWidth(0.015) playerboard.board.getItem(i,2)..setStyle(true,false)..setWidth(0.05) pd.setMBRow(i) i++ CameraSetSmoothingFactor(10.) playerboard.board.getItem(0,0)..setStyle(true,false)..setWidth(0.1) playerboard.setNewItem(0,0,"Player",null) playerboard.board.getItem(0,1)..setStyle(false,true)..setWidth(0.02) playerboard.setNewItem(0,1,null,Icons.bTNAnkh) playerboard.board.getItem(0,2)..setWidth(0.05)..setStyle(true,false) playerboard.setNewItem(0,2,"Rank",null) playerboard.board.display(true) EnableUserControl(true) EnableOcclusion(true) function setTime() seconds++ var secs = "|cffffffff" var mins = "|cffffffff" // Preceding zeros secs += seconds < 10 ? "0" + seconds.toString() : seconds.toString() mins += minutes < 10 ? "0" + minutes.toString() : minutes.toString() secs += "|r" mins += "|r" if seconds >= 60 seconds = 0 minutes++ if minutes % 10 == 0 printTimed("|cffFFCC00Visit our discord server |r- |cff217BD6discord.gg/yr3ZyYQ", 45.) if minutes % 5 == 0 allPlayers.forEach(p -> p.addXp(10, true)) playerboard.board.setTitle(MAP_VER + " [ " + mins + " : " + secs +" ]") int i = 1 for pd in allPlayers pd.setMBRow(i) if pd.escaper != null SetCameraFieldForPlayer(pd.p, CAMERA_FIELD_TARGET_DISTANCE, pd.zCam, 1.) i++ public function startTestmode(PlayerData pd) if (allPlayers.size() == 1 or pd.title == Title.ADMIN) and pd.builder == null Log.debug("testmode terminate") pd.escaper.terminate() builderPlayers.add(pd) for i = 0 to 28 regions[i].revealRegion(pd.p) pd.tmods[0] = new TerrainModder(createUnit(pd.p, WALKABLE_ID, hidden, angle(0))) pd.tmods[1] = new TerrainModder(createUnit(pd.p, UNWALKABLE_ID, hidden, angle(0))) pd.tmods[2] = new TerrainModder(createUnit(pd.p, SLIDEABLE_ICE_ID, hidden, angle(0))) pd.tmods[3] = new TerrainModder(createUnit(pd.p, SLIDEABLE_UNC_ICE_ID, hidden, angle(0))) pd.prod = new UnitProducer(hidden, pd.p) let e1 = new HolyEscaper(currentRevivepoint.toVec3(), pd.p) pd.escaper = e1 e1.actor..addAbility('A001')..addAbility(CREATE_REV_MOD_ID) let e2 = new FastEscaper(currentRevivepoint.toVec3(), pd.p) e2.actor.addAbility('A001') let e3 = new StrongEscaper(currentRevivepoint.toVec3(), pd.p) e3.actor.addAbility('A001') let e4 = new IceEscaper(currentRevivepoint.toVec3(), pd.p) e4.actor.addAbility('A001') pd.builder = new Builder(pd.p) pd.builder.actor..addItemById('I001') ..addItemById('I002') ..addItemById('I003') pd.builder.regionCount = 17 pd.escaper.actor.addAbility('A001') printTimed("|cff949494SinglePlayer |cffFFCC00test mode |cff949494enabled!", 45) public function initPlayers() ALL_PLAYERS.forEach() p -> new PlayerData(p) onPlayerLeave() p -> destroy p.getData() doAfter(.1, () -> rebuildBoard()) doPeriodically(1., cb -> setTime()) for pd in builderPlayers pd.tmods[0] = new TerrainModder(createUnit(pd.p, WALKABLE_ID, hidden, angle(0))) pd.tmods[1] = new TerrainModder(createUnit(pd.p, UNWALKABLE_ID, hidden, angle(0))) pd.tmods[2] = new TerrainModder(createUnit(pd.p, SLIDEABLE_ICE_ID, hidden, angle(0))) pd.tmods[3] = new TerrainModder(createUnit(pd.p, SLIDEABLE_UNC_ICE_ID, hidden, angle(0))) pd.prod = new UnitProducer(hidden, pd.p) pd.builder = new Builder(pd.p) pd.builder.actor..addItemById('I001') ..addItemById('I002')..addItemById('I003') pd.builder.regionCount = (17. / builderPlayers.size()).round() for i = 0 to 28 regions[i].revealRegion(pd.p)