Ticket #3477: ticket3477_metacheat_2.diff
File ticket3477_metacheat_2.diff, 7.2 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/simulation/data/cheats/metaCheat.json
1 { 2 "Name": "gift from the gods", 3 "Data": { 4 "Action": "metacheat", 5 "DefaultParameter": 100000, 6 "IsNumeric": true 7 } 8 } -
binaries/data/mods/public/simulation/helpers/Cheat.js
13 13 var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 14 14 if (!cmpPlayer.GetCheatsEnabled()) 15 15 { 16 cmpGuiInterface.PushNotification({ "type": "chat", "players": [input.player], "message": "Cheats are disbaled in this match"});16 cmpGuiInterface.PushNotification({ "type": "chat", "players": [input.player], "message": "Cheats are disbaled in this match" }); 17 17 return; 18 18 } 19 19 … … 22 22 case "addresource": 23 23 // force input.text to be an array 24 24 input.text = [].concat(input.text); 25 for each ( vartype in input.text)25 for each (let type in input.text) 26 26 cmpPlayer.AddResource(type, input.parameter); 27 break;27 return; 28 28 case "revealmap": 29 29 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 30 30 cmpRangeManager.SetLosRevealAll(-1, true); 31 break;31 return; 32 32 case "maxpopulation": 33 33 cmpPlayer.SetPopulationBonuses(500); 34 break;34 return; 35 35 case "changemaxpopulation": 36 36 cmpPlayer.SetMaxPopulation(500); 37 break;37 return; 38 38 case "convertunit": 39 39 for (let ent of input.selected) 40 40 { … … 42 42 if (cmpOwnership) 43 43 cmpOwnership.SetOwner(cmpPlayer.GetPlayerID()); 44 44 } 45 break;45 return; 46 46 case "killunits": 47 47 for (let ent of input.selected) 48 48 { … … 52 52 else 53 53 Engine.DestroyEntity(ent); 54 54 } 55 break;55 return; 56 56 case "defeatplayer": 57 57 var playerEnt = cmpPlayerManager.GetPlayerByID(input.parameter); 58 58 if (playerEnt == INVALID_ENTITY) 59 59 return; 60 Engine.PostMessage(playerEnt, MT_PlayerDefeated, { "playerId": input.parameter } 61 break;60 Engine.PostMessage(playerEnt, MT_PlayerDefeated, { "playerId": input.parameter }); 61 return; 62 62 case "createunits": 63 63 if (!input.selected[0]) 64 64 { 65 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You need to select a building that trains units."});65 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You need to select a building that trains units." }); 66 66 return; 67 67 } 68 68 … … 69 69 var cmpProductionQueue = Engine.QueryInterface(input.selected[0], IID_ProductionQueue); 70 70 if (!cmpProductionQueue) 71 71 { 72 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You need to select a building that trains units."});72 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You need to select a building that trains units." }); 73 73 return; 74 74 } 75 75 for (let i = 0; i < input.parameter; ++i) 76 76 cmpProductionQueue.SpawnUnits(input.templates[i % input.templates.length], 1, null); 77 break;77 return; 78 78 case "fastactions": 79 79 cmpPlayer.SetCheatTimeMultiplier((cmpPlayer.GetCheatTimeMultiplier() == 1) ? 0.01 : 1); 80 break;80 return; 81 81 case "changespeed": 82 82 cmpPlayer.SetCheatTimeMultiplier(input.parameter); 83 break;83 return; 84 84 case "changephase": 85 85 var cmpTechnologyManager = Engine.QueryInterface(playerEnt, IID_TechnologyManager); 86 86 if (!cmpTechnologyManager) … … 102 102 103 103 // rewrite input and call function 104 104 input.action = "researchTechnology"; 105 Cheat( input);106 break;105 Cheat({ "player": input.player, "action": "researchTechnology", "parameter": input.parameter, "selected": input.selected }); 106 return; 107 107 case "researchTechnology": 108 108 // check, if name of technology is given 109 109 if (input.parameter.length == 0) 110 110 { 111 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You have to enter the name of a technology or select a building and enter the number of the technology (brainiac number [top|paired].)"});111 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You have to enter the name of a technology or select a building and enter the number of the technology (brainiac number [top|paired].)" }); 112 112 return; 113 113 } 114 114 var techname = input.parameter; … … 137 137 var tech = techs[number-1]; 138 138 if (!tech) 139 139 { 140 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You have already researched this technology."});140 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You have already researched this technology." }); 141 141 return; 142 142 } 143 143 // get name of tech … … 148 148 } 149 149 else 150 150 { 151 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "This building only has " + techs.length + " technologies."});151 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "This building only has " + techs.length + " technologies." }); 152 152 return; 153 153 } 154 154 } … … 159 159 var template = cmpTechnologyManager.GetTechnologyTemplate(techname); 160 160 if (!template) 161 161 { 162 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "Technology \"" + techname + "\" does not exist"});162 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "Technology \"" + techname + "\" does not exist" }); 163 163 return; 164 164 } 165 165 … … 166 166 // check, if technology is already researched 167 167 if (!cmpTechnologyManager.IsTechnologyResearched(techname)) 168 168 cmpTechnologyManager.ResearchTechnology(techname); 169 break; 169 return; 170 case "metacheat": 171 // resources 172 Cheat({ "player": input.player, "action": "addresource", "text": "food", "parameter": input.parameter }) 173 Cheat({ "player": input.player, "action": "addresource", "text": "wood", "parameter": input.parameter }) 174 Cheat({ "player": input.player, "action": "addresource", "text": "stone", "parameter": input.parameter }) 175 Cheat({ "player": input.player, "action": "addresource", "text": "metal", "parameter": input.parameter }) 176 177 // max population "the hive master" 178 Cheat({ "player": input.player, "action": "maxpopulation" }); 179 180 // change max pupulation "TARDIS" 181 Cheat({ "player": input.player, "action": "changemaxpopulation" }); 182 183 // fast actions "i am too busy" 184 Cheat({ "player": input.player, "action": "fastactions" }); 185 186 // change phase "back to the future" * 2 187 Cheat({ "player": input.player, "action": "changephase", "selected": input.selected }); 188 Cheat({ "player": input.player, "action": "changephase", "selected": input.selected }); 189 return; 170 190 default: 171 191 warn("Cheat '" + input.action + "' is not implemented"); 172 break;192 return; 173 193 } 174 194 } 175 195