From 93b22c5f8677aae0bc9d133d67981aaea612fa7c Mon Sep 17 00:00:00 2001 From: Freagarach Date: Wed, 9 Feb 2022 15:49:26 +0000 Subject: [PATCH] Allow cheats to convert units to arbitrary players. This allows the "wololo" cheat to switch units to an arbitrarily defined player. If no player is specified, it defaults to the player entering the cheat. The player manager will warn when using a wrong player number. Patch by: @Nullus Differential revision: https://code.wildfiregames.com/D4479 Comments by: @Stan This was SVN commit r26328. --- binaries/data/mods/public/gui/credits/texts/programming.json | 1 + .../data/mods/public/simulation/data/cheats/convertUnit.json | 4 +++- binaries/data/mods/public/simulation/helpers/Cheat.js | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/binaries/data/mods/public/gui/credits/texts/programming.json b/binaries/data/mods/public/gui/credits/texts/programming.json index 333f9b2b38..0acc9f57ba 100644 --- a/binaries/data/mods/public/gui/credits/texts/programming.json +++ b/binaries/data/mods/public/gui/credits/texts/programming.json @@ -194,6 +194,7 @@ { "nick": "NoMonkey", "name": "John Mena" }, { "nick": "norsnor" }, { "nick": "notpete", "name": "Rich Cross" }, + { "nick": "Nullus" }, { "nick": "nwtour" }, { "nick": "odoaker", "name": "Ágoston Sipos" }, { "nick": "Offensive ePeen", "name": "Jared Ryan Bills" }, diff --git a/binaries/data/mods/public/simulation/data/cheats/convertUnit.json b/binaries/data/mods/public/simulation/data/cheats/convertUnit.json index c58b4c4b21..59d3cbd6f6 100644 --- a/binaries/data/mods/public/simulation/data/cheats/convertUnit.json +++ b/binaries/data/mods/public/simulation/data/cheats/convertUnit.json @@ -1,6 +1,8 @@ { "Name": "wololo", "Data": { - "Action": "convertunit" + "Action": "convertunit", + "DefaultParameter": -1, + "isNumeric": true } } diff --git a/binaries/data/mods/public/simulation/helpers/Cheat.js b/binaries/data/mods/public/simulation/helpers/Cheat.js index 18c6cd1ede..10eae37948 100644 --- a/binaries/data/mods/public/simulation/helpers/Cheat.js +++ b/binaries/data/mods/public/simulation/helpers/Cheat.js @@ -35,11 +35,12 @@ function Cheat(input) return; } case "convertunit": + const playerID = (input.parameter > 1 && QueryPlayerIDInterface(input.parameter) || cmpPlayer).GetPlayerID(); for (let ent of input.selected) { let cmpOwnership = Engine.QueryInterface(ent, IID_Ownership); if (cmpOwnership) - cmpOwnership.SetOwner(cmpPlayer.GetPlayerID()); + cmpOwnership.SetOwner(playerID); } return; case "killunits":