[Feature Request] SPADS Plugin for Lobby to Game communications

[Feature Request] SPADS Plugin for Lobby to Game communications

SpringRTS Perl Autohost for Dedicated Server

Moderators: Moderators, Lobby Developers, SPADS AutoHost

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

[Feature Request] SPADS Plugin for Lobby to Game communications

Post by Forboding Angel »

Unfortunately, this seems to be the only way to contact Bibim. So ban-dodging, against my nature for the hopeful betterment of whatever. (edit: viewtopic.php?f=10&t=36782 - Silentwings)

Now that that is out of the way. I will try to nutshell what I need.

I've been playing a lot of sc2 recently. As you may know, sc2 is a game that is laser focused on meaningless tasks, doing them fast and in the right order. I happen to be pretty skilled at the game. This causes issues when trying to introduce friends to the game as if they play vs me, even with 2 or 3 of them, they get steamrolled.

But sc2 has a feature that works REALLY well to even the gap... Handicap. You can handicap a player, and at player's units take an HP cut equal to the handicap. I.E. unitHP = unitHP * handicapAmount * 0.01 (making the handicap number a percentage). To clarify, maximum and normal handicap is 100%. 100% is the normal handicap level for every player. It cannot be increased over 100%

It works so well that I am in awe of its simplicity. The reason it works so well is because it doesn't change game balance overall in the same way that manipulating resources or weapon damage would. As a handicapped player at 50 or 60%, I play the game exactly the same way that I would as if I were at 100%, just with the knowledge that my units and buildings are significantly weaker. In the realm of sc2, this means that my 200/200 army, could break even with my opponents 100/200 army. It is an absolutely fantastic solution and it works extremely well. Better than any other handicap system that I have used in any other rts. Moreover, it allows me to play games vs my gaming group friends who aren't remotely as skilled, and they can even win sometimes (we usually do 2v1 at 50 or 60% handicap).

But how to implement in spring? How to set a handicap on a specific player? How to feed that info from the lobby to the game? Is this something that would have to be done in game? Would you have to have a gadget listening for UnitCreated per teamID and then setting maxhealth that way? Is there any feasible and simplistic way that this could be done?

Having asked that question, yes there is (thanks to sprung for helping).

Code: Select all

function gadget:UnitCreated(unitID, unitdefid, unitTeam)
    local customKeys = select(7, Spring.GetTeamInfo(unitTeam))
    local mult = customKeys.handicap or 1 -- (0; 1]
    Spring.SetUnitMaxHealth(unitID, select(2, Spring.GetUnitHealth(unitID) * mult)
end
As I see it, I am in need of a plugin that can pass parameters to the game via TeamRulesParam (GetTeamInfo?). At which point, a gadget containing the above snippet just listens, waits for unitcreated on a specific teamID (teamID vs playerID because you have to account for commsharing) and sets hp, EzPZ.

As I see it, a generic plugin that can be tailored to send info to the game from the lobby could have a myriad of uses, this only being a small example of a use case scenario. Bibim, could you add this ability to spads?

P.S. Directed at he who shall not be named: I expected that you would do something silly, and so I preemptively pastebinned it accordingly. I was hoping that I would be wrong, but sadly, I was right.

Image
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: [Feature Request] SPADS Plugin for Lobby to Game communications

Post by bibim »

If I understand correctly, you just want to be able to re-implement the existing handicap/advantage system in a different way, impacting units HP instead of resource incomes.

You don't need any new lobby/game communication mechanism for that, you can simply use the Spring startscript, as it is currently done for the existing handicap/advantage system. You just need to add a new tag for each player, for example "hpHandicap", or "hpAdvantage"...

There is already a customization callback dedicated for this purpose in SPADS plugin API, it's addStartScriptTags. This callback can used to add player-specific tags, as explained in the documentation.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: [Feature Request] SPADS Plugin for Lobby to Game communications

Post by Forboding Angel »

My purpose is to do handicap/advantage in a different way yes, but with what I described, it could easily be adapted for anything else. It seems as though startscript tags could as well, but how do you read a startscript tag with lua? Additionally, per player yes, but this specifically needs to be per teamID, because a handicap on players commsharing starts getting unnecessarily messy.

Code: Select all

addStartScriptTags(\%additionalData)
This callback is called when a Spring start script is generated, just before launching the game. It allows plugins to declare additional scrip tags which will be written in the start script.

\%additionalData is a reference to a hash which must be updated by adding the desired keys/values. For example a plugin can add a modoption named "hiddenoption" with value "test" like this: $additionalData{"game/modoptions/hiddenoption"}="test" . For tags to be added in player sections, the special key "playerData" must be used. This special key must point to a hash associating each account ID to a hash containing the tags to add in the corresponding player section.
I'm finding this documentation really hard to follow, unfortunately. I understand that this is a general description of how it works, but without specific examples of usage, it doesn't do me much good.
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: [Feature Request] SPADS Plugin for Lobby to Game communications

Post by bibim »

Forboding Angel wrote:with what I described, it could easily be adapted for anything else. It seems as though startscript tags could as well, but how do you read a startscript tag with lua?
Afaik this is exactly the purpose of the startscript mechanism: a generic system to pass game configuration chosen in lobby (and any other information) to Spring server at start. Startscript tags can be read easily with LUA of course...
Forboding Angel wrote:I'm finding this documentation really hard to follow, unfortunately.
Do you know perl basics ? Did you follow the SPADS plugin development tutorials ?
Forboding Angel wrote:I understand that this is a general description of how it works, but without specific examples of usage, it doesn't do me much good.
You can easily find an example of usage by searching "addStartScriptTags" in the plugins folder of the Github SPADS repository for instance. Searching for "addStartScriptTags" in Spring forum also give you some information.
Post Reply

Return to “SPADS AutoHost”