Game control gadget (proof of concept)

Game control gadget (proof of concept)

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
eyu100
Posts: 182
Joined: 05 Jul 2008, 04:10

Game control gadget (proof of concept)

Post by eyu100 »

I wrote a gadget that lets authenticated users (so far only me, I haven't made a password option yet) kill all units on the map, kill all units belonging to a specific team, kill themselves if they are a player and kill all of a particular type of unit and prevent more from being created for the rest of the game (this is currently the most useful control).

Anyone, not just the host (even spectators!) can use the gadget if they know the password or can come up with a password that hashes to the same value. (I got a pure Lua version of CRC32 from the Internet, so the hash function isn't very secure :|. Their version didn't work, so I modified it, but now the hash function isn't even a correct version of CRC32. It does, however, give different hashes for different passwords). As an example of what you can do with the gadget (if it is integrated into a map), suppose that the players are lagging because there are too many fighters on the screen. You could fix this using the following sequence of commands:

Code: Select all

/luarules ctrl_authenticate [password]
/luarules ctrl_genocide armap
/luarules ctrl_genocide armaap
/luarules ctrl_genocide corap
/luarules ctrl_genocide coraap
/luarules ctrl_genocide armfig
/luarules ctrl_genocide armhawk
/luarules ctrl_genocide corveng
/luarules ctrl_genocide corvamp
Lines 2 through 5 are not strictly necessary, but you don't want teams to build other air units when fighters are disabled.

I plan to add:
  • A way to authenticate other users without giving them the password
  • Forced unit transfer
  • And more
EDIT: fixed gadget (before, I left ctrl_authenticate as _authenticate)
Attachments
gamectrl.lua
(9.18 KiB) Downloaded 111 times
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Game control gadget (proof of concept)

Post by Forboding Angel »

./facepalm

Lobby -> Disabled units tab
eyu100
Posts: 182
Joined: 05 Jul 2008, 04:10

Re: Game control gadget (proof of concept)

Post by eyu100 »

Updated the gadget.
  • New features:
  • Authentication by name (certain users won't need a password)
  • Forced give all to let you deal with afk players without kicking them
Attachments
gamectrl.lua
(11.86 KiB) Downloaded 107 times
eyu100
Posts: 182
Joined: 05 Jul 2008, 04:10

Re: Game control gadget (proof of concept)

Post by eyu100 »

Forboding Angel wrote:./facepalm

Lobby -> Disabled units tab
This gadget can be extended to let authorized users do almost anything. Combined with a widget, an extended gadget could let spectators:
  • Teleport units (I don't know if the current version of Spring has MoveCtrl)
  • Give certain players resource bonuses
  • Gift resources to players
  • Kill individual units
  • Paralyze individual units
  • Declare one allyteam the winner by using the gadget to kill all their enemies
  • Make certain units invincible (air transports, for example)
Etc., etc., etc.
eyu100
Posts: 182
Joined: 05 Jul 2008, 04:10

Re: Game control gadget (proof of concept)

Post by eyu100 »

Command list:

Code: Select all

/luarules ctrl_password
The password hash is computed using an incorrect implementation of CRC32.

Code: Select all

/luarules ctrl_killall

Code: Select all

/luarules ctrl_kill [team]

Code: Select all

/luarules ctrl_suicide
Internally, this is interpreted as /luarules ctrl_kill [teamOfThePlayerSendingTheCommand]

Code: Select all

/luarules ctrl_genocide [unit]

Code: Select all

/luarules ctrl_give [team1] [team2]
Completely wipes out team1, giving all their units to team2.

Other important things:
The privilegedPlayers table gives the list of players that do not need the password to run commands. The unsynced part of the gadget calls the synced part every 10 seconds (per player, so if you have 10 players the synced part is called on average once every second). This is to make cheating more difficult.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Game control gadget (proof of concept)

Post by aegis »

you can find crc32 collisions in a reasonable amount of time by *hand*
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Game control gadget (proof of concept)

Post by zwzsg »

Forboding Angel wrote:./facepalm

Lobby -> Disabled units tab
Lobby cannot kill units already built in a running game.

/facepalm
eyu100
Posts: 182
Joined: 05 Jul 2008, 04:10

Re: Game control gadget (proof of concept)

Post by eyu100 »

Ok, I updated the gadget again. This time, the password hash is computed with an incorrect version of SHA1, so it should be more secure (it is now probably infeasible to find collisions by hand). The hash is computed using pure Lua (credit goes to http://luaforge.net/projects/sha1-rsa/); I put the files in a separate folder which should go in LuaRules/Gadgets. Also, I made the synced part send a secret number to the unsynced part:

Code: Select all

local allUnits = Spring.GetAllUnits()
for i,unitID in ipairs(allUnits) do
   synced_secretNumber = synced_secretNumber + math.sin(i)*unitID
end
SendToUnsynced("ctrl_secretNumber", synced_secretNumber)
Does someone know if SendToUnsynced messages are private? Or can they be read by widgets?
Attachments
gamectrl.zip
(20.96 KiB) Downloaded 13 times
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Game control gadget (proof of concept)

Post by CarRepairer »

Hey, I say this with all sincerity. If you had a really interesting reason for doing this I'd be totally motivated to help you. I don't mean to sound mean, I just want to know what you could use this for. Maybe if you told me your reasons (I don't believe it's just "lulz") I could help you come up with simpler ways to do it.

Do you intend for a modder to be able to join any battle of his game and have a prefix code like in Wrath of Khan so he can flaunt his mighty powers? Come on, gimme something interesting! You have like three threads in the lua forum and have piqued my curiosity. I must know.
eyu100
Posts: 182
Joined: 05 Jul 2008, 04:10

Re: Game control gadget (proof of concept)

Post by eyu100 »

Another update. Now you can use the ctrl_super command to make a team invincible and the ctrl_fragile command to make a team's units fragile (if they are damaged at all, they immediately die, leaving no wreck).

EDIT: forgot attachment
Attachments
gamectrl.zip
(16.05 KiB) Downloaded 17 times
Pako
Posts: 174
Joined: 12 Jul 2009, 18:57

Re: Game control gadget (proof of concept)

Post by Pako »

This seems a very promising gadget and I would have several uses for it but I'm not a game developer.
eyu100
Posts: 182
Joined: 05 Jul 2008, 04:10

Re: Game control gadget (proof of concept)

Post by eyu100 »

Major update. I put the gadget (now actually two gadgets spread over 7 files) in DSD and called it "DeltaSiegeDry Hacked". Version 0.1.0 is on jobjol.
Post Reply

Return to “Lua Scripts”