Announcement: game end condition moved to Lua

Announcement: game end condition moved to Lua

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Announcement: game end condition moved to Lua

Post by BrainDamage »

Starting from next major spring engine release ( at least 6 months from this post, version something like 0.83.x ), spring will stop handling hardcoded game end conditions

the Lua API to handle lineage and display old game end condition are removed as well

mods will need to use a gadget to implement game end/victory conditions

GameOver call-in will now return a list of winning allyteams
added new synced call-outs to declare GameOver and to kill a team
teams will be able to stay alive with 0 units by default, manually killing them will be necessary

a sample gadget that reimplements kill all units game end is being included in springcontent, LuaGadgets/LuaRules/Gadgets/game_end.lua
the gadgets has the following features:
never ending game and teams don't die even with 0 units option
teams die when they have 0 units ( same as current beaviour ) option
teams don't die when they have 0 units, but die when the whole allyteam has 0 units option
option to let dynamic alliances have shared victory

I strongly reccomend modders to set default game end condition to "allyzerounits" ( teams die when 0 units in the whole allyteam ), this because it will allow players who dropped out the game to be /take'd and when will rejoin, they'll be able to resume playing by getting their units being shared back

here's a code snippet to add the gameend's options to your modoptions file:

Code: Select all

	{
		key="teamdeathmode",
		name="Team Game End Mode",
		desc="What it takes to eliminate a Team",
		type="list",
		def="allyzerounits",
		items={
			{key="none", name="Never Die", desc="All Teams will stay alive regardless of what happends, gameover will never arrive."},
			{key="teamzerounits", name="Team Death on Zero Units", desc="The Team will die when it has 0 units."},
			{key="allyzerounits", name="AllyTeam Death on Zero units", desc="The Team will die when every Team in his AllyTeam have 0 units."},
		}
	},
	{
		key    = "shareddynamicalliancevictory",
		name   = "Dynamic Ally Victory",
		desc   = "Ingame alliance should count for game over condition.",
		type   = "bool",
		def    = false,
    },
updated the wiki accordingly

some forum moderator please make this thread stick in Game & Mod and Lua sections of the forums
Last edited by knorke on 07 Mar 2012, 02:58, edited 3 times in total.
Reason: unsticky, http://springrts.com/wiki/EngineChangelogForContentDevs
Sheekel
Posts: 1390
Joined: 19 Apr 2005, 19:23

Re: Announcement: game end condition moved to Lua

Post by Sheekel »

imo this should go above the topics section under "announcements", like the starting units one...
User avatar
Karl
Panzerstahl Developer
Posts: 746
Joined: 01 Apr 2010, 21:05

Re: Announcement: game end condition moved to Lua

Post by Karl »

Oh that is very nice to see that Spring gets more Luaified

if you are already doing that why arent you all just doing it right

and making everything Lua? :roll:
User avatar
Beherith
Moderator
Posts: 5039
Joined: 26 Oct 2007, 16:21

Re: Announcement: game end condition moved to Lua

Post by Beherith »

Thanks BD!

I really like the ability to reconnect after a crash/disconnect already, and seeing this kind of integration really pushes the engine forward.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7032
Joined: 16 Nov 2004, 13:08

Re: Announcement: game end condition moved to Lua

Post by zwzsg »

BrainDamage wrote:the Lua API to handle lineage [...] removed as well
So, any gadget using the function Spring.SetUnitLineage will now crash?


Is the commander unitDef tag getting removed too? I see no use of it in your replacment gadget. Even if it no longer means anything to the engine, I'd like the commander tag to still be part of the "main" list of unit tags, instead of having to move it to a custom unitDef tag, if only because so many widgets and gadgets rely on UnitDefs[id].isCommander

I recall hearing long time about a unitDef tag that make some unit "do not count" for gameover, such as, a mod would mark mines with these, so that player lose when all they have left are mines. But I don't see it in your gadget. Then I can't find any info about it anymore, so I'm not even sure this tag was ever implemented.

If the first thing I do is morphing my startunit, do I lose the game? (Since morphing is destroying a unit then creating a new one) Where's the couple seconds grace between losing last unit and losing the game?
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Re: Announcement: game end condition moved to Lua

Post by BrainDamage »

zwzsg wrote:So, any gadget using the function Spring.SetUnitLineage will now crash?

yes
zwzsg wrote:Is the commander unitDef tag getting removed too?

I didn't, no idea if anyone has intention about doing such
zwzsg wrote:I recall hearing long time about a unitDef tag that make some unit "do not count" for gameover, such as, a mod would mark mines with these, so that player lose when all they have left are mines. But I don't see it in your gadget. Then I can't find any info about it anymore, so I'm not even sure this tag was ever implemented.

there was no such thing in the engine's gameover logic, the only related stuff I can remember, is a gadget from KDR that selfd'ed all remaining units if they all had the "do not count tag" ( useful for mines, etc )
zwzsg wrote:If the first thing I do is morphing my startunit, do I lose the game? (Since morphing is destroying a unit then creating a new one) Where's the couple seconds grace between losing last unit and losing the game?
Probably, I didn't check so, try it?
morphing is quite mod specific btw, this is supposed to be a generic gadget, feel free to edit to fit your needs
out of curiosity, why the grace time after losing the last unit is so necessary? wouldn't be more correct instead to pass the info to the game end gadget that the unit is being morphed?
in the engine the grace was simply the effect of the check being done every slowupdate, so it could be anything between 1/30 to 16/30 fraction of a second ( at speed 1.0 ) according to the frame when the last unit died
EDIT: grammar and reference about speed 1.0
Last edited by BrainDamage on 10 Sep 2010, 15:19, edited 2 times in total.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7032
Joined: 16 Nov 2004, 13:08

Re: Announcement: game end condition moved to Lua

Post by zwzsg »

BD wrote:the only related stuff I can remember, is a gadget from KDR that selfd'ed all remaining units if they all had the "do not count tag"
Oh, so it was a custom gadget relying on a custom tag? Nevermind then!

BD wrote:out of curiosity, why the grace time after losing the last unit is so necessary? wouldn't be more correct instead to pass the info to the game end gadget that the unit is being morphed?
Well, a couple second grace is a more generic method. The standard CA morph gadget may not the only way to create a transitory period where the unit is missing. Inter gadget communication sounds nice in theory, but is iffy in practice, and would make porting gadgets from one mod to another harder. Every time a new person write a new morph-like behavior, it would be a pain to have to remember to also write special code to tell game_end to hold on for a bit, as opposed to having the game_end gadget transparently automagically handling it without even having to think about it.

Lastly, it feels much better to get to see your commander explosion death mushroom billows, than having the autohost instaquit the moment commander health reach zero.

- Sure, springie and spad code could be changed to let game run couple seconds before exiting.
- I could change my single player menu to add a couple second delay as well before it shows up.
- I could update my Lua load game gadget to workaround the transitory no unit state
- I could update the three gadget where I morph the start unit to workaround the transitory no unit state
- The gameover screen could be disabled, and new one implemented in Lua that doesn't appear before a few second.
- I'm only listing problems I can think from the top of my head in the one mod I'm familiar with, but:
- Ectera, all that multiplied by every Spring mod in existance

Or, a couple second grace, or at least delay, could be implemented once and for all where it belongs, in the default game_end logic.

so it could be anything between 1/30 to 16/30 fraction of a second ( at speed 1.0 )
LoL, so I imagined "a couple seconds" that were never there in the first place? :P
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Re: Announcement: game end condition moved to Lua

Post by BrainDamage »

zwzsg wrote: - Sure, springie and spad code could be changed to let game run couple seconds before exiting.
this already happends in spads case

anyway, now the sample gadget will take from 1 to 16 frames to detect a team died, so you can quickly replace units
gameover will be detected exactly 16 frames after the last allyteam died
User avatar
TheFatController
Balanced Annihilation Developer
Posts: 1177
Joined: 10 Dec 2006, 18:46

Re: Announcement: game end condition moved to Lua

Post by TheFatController »

zwzsg wrote:Is the commander unitDef tag getting removed too? I see no use of it in your replacment gadget. Even if it no longer means anything to the engine, I'd like the commander tag to still be part of the "main" list of unit tags, instead of having to move it to a custom unitDef tag, if only because so many widgets and gadgets rely on UnitDefs[id].isCommander
I would also be against removing isCommander.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Announcement: game end condition moved to Lua

Post by KDR_11k »

All mods written for the hardcoded logic will make sure that the team never falls to 0 units through morphing (always create a new unit BEFORE destroying the old one) anyway, any mod written afterthat can just adjust the game end logic anyway.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14657
Joined: 17 Nov 2005, 02:43

Re: Announcement: game end condition moved to Lua

Post by Forboding Angel »

lolbump, maek resticky.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Announcement: game end condition moved to Lua

Post by knorke »

Does this also mean the removing of the "com ends" option?
If yes, it might be worth noting that lobby devs should remove it from lobbies as well.
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Re: Announcement: game end condition moved to Lua

Post by BrainDamage »

knorke wrote:Does this also mean the removing of the "com ends" option?
yes
knorke wrote:it might be worth noting that lobby devs should remove it from lobbies as well.
not necessary since it wasn't hardcoded since several years, engine uses same interface as mods to give to the lobbies the game end condition, and I simply removed it from engine options, so lobbies will automatically get the option removed
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Announcement: game end condition moved to Lua

Post by knorke »

BrainDamage wrote:
knorke wrote:Does this also mean the removing of the "com ends" option?
yes
there is still a "com ends warning" widget in the engine test version, it should be removed?
LuaUI\Widgets\gui_comm_ends.lua
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Announcement: game end condition moved to Lua

Post by hoijui »

thanks knorke, will do! :-)
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7032
Joined: 16 Nov 2004, 13:08

Re: Announcement: game end condition moved to Lua

Post by zwzsg »

When I perform a Spring.GameOver(WinningAllies)

Are the widget:GameOver() callin of every widget executed?
User avatar
Jools
XTA Developer
Posts: 2814
Joined: 23 Feb 2009, 16:29

Re: Announcement: game end condition moved to Lua

Post by Jools »

I would assume they are.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7032
Joined: 16 Nov 2004, 13:08

Re: Announcement: game end condition moved to Lua

Post by zwzsg »

So would I have, except that I tried and ....
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Announcement: game end condition moved to Lua

Post by smoth »

I am still waiting on this to be setup. I have heard nothing of this beyond that what I am looking for may be this:
https://github.com/spring/spring/blob/m ... me_end.lua

is this what you need z? if not what is missing?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Announcement: game end condition moved to Lua

Post by knorke »

https://github.com/spring/spring/blob/m ... me_end.lua
comment at top is wrong:
-- file: game_end.lua
-- brief: spawns start unit and sets storage levels
gadget would not work for me, it did not kill playerteams with 0 alive units. I just c&p'ed it into my mod "as is."
Added echos like this:

Code: Select all

local function KillTeamsZeroUnits()
-- kill all the teams that have zero units
for teamID, unitCount in pairs(teamsUnitCount) do
Spring.Echo ("team " ..teamID .. " - " .. unitCount .. " units alive")
if unitCount == 0 then
Spring.Echo ("Team " .. teamID .. " has zero units left.")
spKillTeam( teamID )
end
end
end
And it only spammed "team 2 - 80 units alive" with 2 being gaiea team.
It did not seem to check the actual player teams.
(the 80 is correct, i have some gaiea units)
When you do /cheat /give someunit after the game has started, it will start spam "team 0 - 1 units alive", only counting the newly spawned unit and ignoring the original startunits.
I tried changing the layer=0 but no sucess.

Seems like it does not catch the UnitCreated() of the startunits (in my mod you start with 2 units) because when inserting
gadget:UnitCreated(0, 0, teamID)
gadget:UnitCreated(0, 0, teamID)

in function gadget:Initialize(), then everything works correctly.
my startunits spawn gadget

Also does the "ignore gaiea" part still make sense? I think I read something about gaiea now being unkillable by KillTeam(tID)
Post Reply

Return to “Game Development”