Ticket #2019: cheatMod.patch
File cheatMod.patch, 12.0 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/gui/session/messages.js
9 9 const MAX_NUM_NOTIFICATION_LINES = 3; 10 10 var notifications = []; 11 11 var notificationsTimers = []; 12 var cheat List = parseJSONData("simulation/data/cheats.json").Cheats;12 var cheats = getCheatsData(); 13 13 14 // Gets cheats from the cheats folder 15 function getCheatsData() 16 { 17 var cheats = new Object(); 18 var cheatFileList = getJSONFileList("simulation/data/cheats/"); 19 for each (var fileName in cheatFileList) 20 { 21 var currentCheat = parseJSONData("simulation/data/cheats/"+fileName+".json"); 22 if (Object.keys(cheats).indexOf(currentCheat.Name) !== -1) 23 warn("Cheat name '"+currentCheat.Name+"' is already present"); 24 else { 25 cheats[currentCheat.Name] = currentCheat.Data; 26 } 27 } 28 return cheats; 29 } 30 14 31 // Notifications 15 32 function handleNotifications() 16 33 { … … 219 236 var isCheat = false; 220 237 if (text.length) 221 238 { 222 for (var i = 0; i < cheatList.length; i++)239 if (g_Players[Engine.GetPlayerID()].cheatsEnabled) 223 240 { 224 var cheat = cheatList[i]; 241 for each (var cheat in Object.keys(cheats)) 242 { 225 243 226 // Line must start with the cheat. 227 if (text.indexOf(cheat.Name) == 0) 228 { 229 var number; 230 if (cheat.IsNumeric) 244 // Line must start with the cheat. 245 if (text.indexOf(cheat) == 0) 231 246 { 232 // Match the first word in the substring. 233 var match = text.substr(cheat.Name.length).match(/\S+/); 234 if (match && match[0]) 235 number = Math.floor(match[0]); 247 var number; 248 if (cheats[cheat].DefaultNumber !== undefined) 249 { 250 // Match the first word in the substring. 251 var match = text.substr(cheat.length).match(/\S+/); 252 if (match && match[0]) 253 number = Math.floor(match[0]); 236 254 237 if (number <= 0 || isNaN(number)) 238 number = cheat.DefaultNumber; 255 if (number <= 0 || isNaN(number)) 256 number = cheats[cheat].DefaultNumber; 257 } 258 259 Engine.PostNetworkCommand({ 260 "type": "cheat", 261 "action": cheats[cheat].Action, 262 "number": number, 263 "text": cheats[cheat].Type, 264 "selected": g_Selection.toList(), 265 "templates": cheats[cheat].Templates, 266 "player": Engine.GetPlayerID()}); 267 isCheat = true; 268 break; 239 269 } 240 241 Engine.PostNetworkCommand({242 "type": "cheat",243 "action": cheat.Action,244 "number": number,245 "text": cheat.Type,246 "selected": g_Selection.toList(),247 "templates": cheat.Templates,248 "player": Engine.GetPlayerID()});249 isCheat = true;250 break;251 270 } 252 271 } 253 272 … … 427 446 recurse = true; 428 447 break; 429 448 case "/team": 430 var playerData = getPlayerData();431 449 if (hasAllies(sender, playerData)) 432 450 { 433 if ( playerData[Engine.GetPlayerID()].team != playerData[sender].team)451 if (g_Players[Engine.GetPlayerID()].team != g_Players[sender].team) 434 452 msg.hide = true; 435 453 else 436 454 msg.prefix = "(Team) "; … … 440 458 recurse = true; 441 459 break; 442 460 case "/enemy": 443 var playerData = getPlayerData(); 444 if (hasAllies(sender, playerData)) 461 if (hasAllies(sender, g_Players)) 445 462 { 446 if ( playerData[Engine.GetPlayerID()].team == playerData[sender].team && sender != Engine.GetPlayerID())463 if (g_Players[Engine.GetPlayerID()].team == g_Players[sender].team && sender != Engine.GetPlayerID()) 447 464 msg.hide = true; 448 465 else 449 466 msg.prefix = "(Enemy) "; -
binaries/data/mods/public/gui/session/utility_functions.js
60 60 "color": color, 61 61 "team": playerState.team, 62 62 "teamsLocked": playerState.teamsLocked, 63 "cheatsEnabled": playerState.cheatsEnabled, 63 64 "state": playerState.state, 64 65 "isAlly": playerState.isAlly, 65 66 "isMutualAlly": playerState.isMutualAlly, -
binaries/data/mods/public/simulation/components/GuiInterface.js
87 87 "state": cmpPlayer.GetState(), 88 88 "team": cmpPlayer.GetTeam(), 89 89 "teamsLocked": cmpPlayer.GetLockTeams(), 90 "cheatsEnabled": cmpPlayer.GetCheatsEnabled(), 90 91 "phase": phase, 91 92 "isAlly": allies, 92 93 "isMutualAlly": mutualAllies, -
binaries/data/mods/public/simulation/components/Player.js
31 31 this.controlAllUnits = false; 32 32 this.isAI = false; 33 33 this.gatherRateMultiplier = 1; 34 this.cheatsEnabled = true;34 this.cheatsEnabled = false; 35 35 this.cheatTimeMultiplier = 1; 36 36 this.heroes = []; 37 37 }; … … 550 550 this.UpdateSharedLos(); 551 551 }; 552 552 553 Player.prototype.SetCheat Enabled = function(flag)553 Player.prototype.SetCheatsEnabled = function(flag) 554 554 { 555 555 this.cheatsEnabled = flag; 556 556 }; 557 557 558 Player.prototype.GetCheat Enabled = function()558 Player.prototype.GetCheatsEnabled = function() 559 559 { 560 560 return this.cheatsEnabled; 561 561 }; -
binaries/data/mods/public/simulation/data/cheats/changeMaxPopulation.json
1 { 2 "Name": "TARDIS", 3 "Data": { 4 "Action": "changemaxpopulation" 5 } 6 } -
binaries/data/mods/public/simulation/data/cheats/convertUnit.json
1 { 2 "Name": "wololo", 3 "Data": { 4 "Action": "convertunit" 5 } 6 } -
binaries/data/mods/public/simulation/data/cheats/createHeros.json
1 { 2 "Name": "iwanttopwnthem", 3 "Data": { 4 "Action": "createunits", 5 "DefaultNumber": 1, 6 "Templates": ["units/cart_hero_hamilcar", "units/cart_hero_hannibal", "units/cart_hero_maharbal", "units/rome_hero_marcellus", "units/rome_hero_maximus", "units/rome_hero_scipio", "units/pers_hero_cyrus", "units/pers_hero_darius", "units/pers_hero_xerxes"] 7 } 8 } -
binaries/data/mods/public/simulation/data/cheats/createPlane.json
1 { 2 "Name": "how do you turn this on?", 3 "Data": { 4 "Action": "createunits", 5 "DefaultNumber": 1, 6 "Templates": ["other/plane"] 7 } 8 } -
binaries/data/mods/public/simulation/data/cheats/createUnits.json
1 { 2 "Name": "salad bowl", 3 "Data": { 4 "Action": "createunits", 5 "DefaultNumber": 10, 6 "Templates": ["units/athen_infantry_spearman_b", "units/brit_infantry_spearman_b", "units/cart_infantry_spearman_b", "units/gaul_infantry_spearman_b", "units/iber_infantry_spearman_b", 7 "units/mace_infantry_spearman_b", "units/maur_infantry_spearman_b", "units/pers_infantry_spearman_b", "units/rome_infantry_spearman_b", "units/spart_infantry_spearman_b"] 8 } 9 } -
binaries/data/mods/public/simulation/data/cheats/defeatPlayer.json
1 { 2 "Name": "exodia", 3 "Data": { 4 "Action": "defeatplayer", 5 "DefaultNumber": 2 6 } 7 } -
binaries/data/mods/public/simulation/data/cheats/fastActions.json
1 { 2 "Name": "i am too busy", 3 "Data": { 4 "Action": "fastactions" 5 } 6 } -
binaries/data/mods/public/simulation/data/cheats/food.json
1 { 2 "Name": "i want pizza", 3 "Data": { 4 "Action": "addresource", 5 "Type": "food", 6 "DefaultNumber": 1000 7 } 8 } -
binaries/data/mods/public/simulation/data/cheats/killUnits.json
1 { 2 "Name": "black death", 3 "Data": { 4 "Action": "killunits" 5 } 6 } -
binaries/data/mods/public/simulation/data/cheats/maxPopulation.json
1 { 2 "Name": "the hive master", 3 "Data": { 4 "Action": "maxpopulation" 5 } 6 } -
binaries/data/mods/public/simulation/data/cheats/metal.json
1 { 2 "Name": "your money or your life", 3 "Data": { 4 "Action": "addresource", 5 "Type": "metal", 6 "DefaultNumber": 1000 7 } 8 } -
binaries/data/mods/public/simulation/data/cheats/revealMap.json
1 { 2 "Name": "jame jam", 3 "Data": { 4 "Action": "revealmap" 5 } 6 } -
binaries/data/mods/public/simulation/data/cheats/stone.json
1 { 2 "Name": "i see a mountain here", 3 "Data": { 4 "Action": "addresource", 5 "Type": "stone", 6 "DefaultNumber": 1000 7 } 8 } -
binaries/data/mods/public/simulation/data/cheats/wood.json
1 { 2 "Name": "bring me my axe", 3 "Data": { 4 "Action": "addresource", 5 "Type": "wood", 6 "DefaultNumber": 1000 7 } 8 }