Ticket #3477: ticket3477_metacheat_3.diff
File ticket3477_metacheat_3.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 … … 20 20 switch(input.action) 21 21 { 22 22 case "addresource": 23 // force input.text to be an array 24 input.text = [].concat(input.text); 25 for each (var type in input.text) 26 cmpPlayer.AddResource(type, input.parameter); 27 break; 23 cmpPlayer.AddResource(input.text, input.parameter); 24 return; 28 25 case "revealmap": 29 26 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 30 27 cmpRangeManager.SetLosRevealAll(-1, true); 31 break;28 return; 32 29 case "maxpopulation": 33 30 cmpPlayer.SetPopulationBonuses(500); 34 break;31 return; 35 32 case "changemaxpopulation": 36 33 cmpPlayer.SetMaxPopulation(500); 37 break;34 return; 38 35 case "convertunit": 39 36 for (let ent of input.selected) 40 37 { … … 42 39 if (cmpOwnership) 43 40 cmpOwnership.SetOwner(cmpPlayer.GetPlayerID()); 44 41 } 45 break;42 return; 46 43 case "killunits": 47 44 for (let ent of input.selected) 48 45 { … … 52 49 else 53 50 Engine.DestroyEntity(ent); 54 51 } 55 break;52 return; 56 53 case "defeatplayer": 57 54 var playerEnt = cmpPlayerManager.GetPlayerByID(input.parameter); 58 55 if (playerEnt == INVALID_ENTITY) 59 56 return; 60 Engine.PostMessage(playerEnt, MT_PlayerDefeated, { "playerId": input.parameter } 61 break;57 Engine.PostMessage(playerEnt, MT_PlayerDefeated, { "playerId": input.parameter }); 58 return; 62 59 case "createunits": 63 60 if (!input.selected[0]) 64 61 { 65 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You need to select a building that trains units."});62 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You need to select a building that trains units." }); 66 63 return; 67 64 } 68 65 … … 69 66 var cmpProductionQueue = Engine.QueryInterface(input.selected[0], IID_ProductionQueue); 70 67 if (!cmpProductionQueue) 71 68 { 72 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You need to select a building that trains units."});69 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You need to select a building that trains units." }); 73 70 return; 74 71 } 75 72 for (let i = 0; i < input.parameter; ++i) 76 73 cmpProductionQueue.SpawnUnits(input.templates[i % input.templates.length], 1, null); 77 break;74 return; 78 75 case "fastactions": 79 76 cmpPlayer.SetCheatTimeMultiplier((cmpPlayer.GetCheatTimeMultiplier() == 1) ? 0.01 : 1); 80 break;77 return; 81 78 case "changespeed": 82 79 cmpPlayer.SetCheatTimeMultiplier(input.parameter); 83 break;80 return; 84 81 case "changephase": 85 82 var cmpTechnologyManager = Engine.QueryInterface(playerEnt, IID_TechnologyManager); 86 83 if (!cmpTechnologyManager) … … 102 99 103 100 // rewrite input and call function 104 101 input.action = "researchTechnology"; 105 Cheat( input);106 break;102 Cheat({ "player": input.player, "action": "researchTechnology", "parameter": input.parameter, "selected": input.selected }); 103 return; 107 104 case "researchTechnology": 108 105 // check, if name of technology is given 109 106 if (input.parameter.length == 0) 110 107 { 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].)"});108 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 109 return; 113 110 } 114 111 var techname = input.parameter; … … 137 134 var tech = techs[number-1]; 138 135 if (!tech) 139 136 { 140 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You have already researched this technology."});137 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "You have already researched this technology." }); 141 138 return; 142 139 } 143 140 // get name of tech … … 148 145 } 149 146 else 150 147 { 151 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "This building only has " + techs.length + " technologies."});148 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "This building only has " + techs.length + " technologies." }); 152 149 return; 153 150 } 154 151 } … … 159 156 var template = cmpTechnologyManager.GetTechnologyTemplate(techname); 160 157 if (!template) 161 158 { 162 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "Technology \"" + techname + "\" does not exist"});159 cmpGuiInterface.PushNotification({ "type": "notification", "players": [input.player], "message": "Technology \"" + techname + "\" does not exist" }); 163 160 return; 164 161 } 165 162 … … 166 163 // check, if technology is already researched 167 164 if (!cmpTechnologyManager.IsTechnologyResearched(techname)) 168 165 cmpTechnologyManager.ResearchTechnology(techname); 169 break; 166 return; 167 case "metaCheat": 168 // resources 169 Cheat({ "player": input.player, "action": "addresource", "text": "food", "parameter": input.parameter }); 170 Cheat({ "player": input.player, "action": "addresource", "text": "wood", "parameter": input.parameter }); 171 Cheat({ "player": input.player, "action": "addresource", "text": "stone", "parameter": input.parameter }); 172 Cheat({ "player": input.player, "action": "addresource", "text": "metal", "parameter": input.parameter }); 173 174 // max population "the hive master" 175 Cheat({ "player": input.player, "action": "maxpopulation" }); 176 177 // change max pupulation "TARDIS" 178 Cheat({ "player": input.player, "action": "changemaxpopulation" }); 179 180 // fast actions "i am too busy" 181 Cheat({ "player": input.player, "action": "fastactions" }); 182 183 // change phase "back to the future" * 2 184 Cheat({ "player": input.player, "action": "changephase", "selected": input.selected }); 185 Cheat({ "player": input.player, "action": "changephase", "selected": input.selected }); 186 return; 170 187 default: 171 188 warn("Cheat '" + input.action + "' is not implemented"); 172 break;189 return; 173 190 } 174 191 } 175 192