View topic - Announcement: game end condition moved to Lua



All times are UTC + 1 hour


Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 09 Sep 2010, 22:37 
Lobby Developer
User avatar

Joined: 25 Sep 2006, 12:56
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:
   {
      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.
unsticky, http://springrts.com/wiki/EngineChangelogForContentDevs


Top
 Offline Profile  
 
PostPosted: 10 Sep 2010, 00:38 

Joined: 19 Apr 2005, 18:23
imo this should go above the topics section under "announcements", like the starting units one...


Top
 Offline Profile  
 
PostPosted: 10 Sep 2010, 10:12 
User avatar

Joined: 01 Apr 2010, 20:05
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:


Top
 Offline Profile  
 
PostPosted: 10 Sep 2010, 13:28 
Moderator
User avatar

Joined: 26 Oct 2007, 15:21
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.


Top
 Offline Profile  
 
PostPosted: 10 Sep 2010, 13:37 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
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?


Top
 Offline Profile  
 
PostPosted: 10 Sep 2010, 13:50 
Lobby Developer
User avatar

Joined: 25 Sep 2006, 12:56
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, 14:19, edited 2 times in total.

Top
 Offline Profile  
 
PostPosted: 10 Sep 2010, 14:18 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
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.


Quote:
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


Top
 Offline Profile  
 
PostPosted: 10 Sep 2010, 18:12 
Lobby Developer
User avatar

Joined: 25 Sep 2006, 12:56
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


Top
 Offline Profile  
 
PostPosted: 10 Sep 2010, 18:41 
Balanced Annihilation Maintainer
User avatar

Joined: 10 Dec 2006, 18:46
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.


Top
 Offline Profile  
 
PostPosted: 14 Sep 2010, 16:14 
Game Developer
User avatar

Joined: 25 Jun 2006, 07:44
Location: Germany
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.


Top
 Offline Profile  
 
PostPosted: 27 Jun 2011, 20:41 
Evolution RTS Developer
User avatar

Joined: 17 Nov 2005, 02:43
Location: Raegquitting Spring on 04/24/12
lolbump, maek resticky.


Top
 Offline Profile  
 
PostPosted: 29 Jun 2011, 15:32 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
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.


Top
 Offline Profile  
 
PostPosted: 29 Jun 2011, 16:29 
Lobby Developer
User avatar

Joined: 25 Sep 2006, 12:56
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


Top
 Offline Profile  
 
PostPosted: 04 Jul 2011, 14:49 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
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


Top
 Offline Profile  
 
PostPosted: 04 Jul 2011, 16:37 
Spring Developer
User avatar

Joined: 22 Sep 2007, 08:51
thanks knorke, will do! :-)


Top
 Offline Profile  
 
PostPosted: 09 Jul 2011, 15:22 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
When I perform a Spring.GameOver(WinningAllies)

Are the widget:GameOver() callin of every widget executed?


Top
 Offline Profile  
 
PostPosted: 29 Jul 2011, 18:28 
User avatar

Joined: 23 Feb 2009, 16:29
Location: Finland
I would assume they are.


Top
 Offline Profile  
 
PostPosted: 29 Jul 2011, 19:56 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
So would I have, except that I tried and ....


Top
 Offline Profile  
 
PostPosted: 29 Jul 2011, 21:03 
Content Developer
User avatar

Joined: 13 Jan 2005, 00:46
Location: ModalitÃ
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?


Top
 Offline Profile  
 
PostPosted: 11 Dec 2011, 07:59 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
https://github.com/spring/spring/blob/m ... me_end.lua
comment at top is wrong:
Quote:
-- 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:
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)


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.