Page 1 of 4

Engine will stop spawning start units and resources

Posted: 27 Jan 2010, 16:49
by Tobi
In the next major version the engine will not bother with start units or start metal/energy anymore.

This change has been made to clean up an ugly deprecated piece of engine code, and because spawning start units the way the engine did was not flexible, leading to many games writing gadgets to actually remove the engine spawned start unit only to replace it with a new one.

More reasons and details about the changes can be found in the three related commits: I've made an example gadget that should be pretty much a drop in replacement for the removed engine functionality for many games. (It honours startmetal/startenergy mod options, custom team keys, honours sidedata, shouldn't error if sidedata doesn't specify a start unit, etc.)

Modify it as desired (different way to determine start resources/storage, spawn multiple units, calculate optimal build facing for the start unit, etc.), in particular try to get rid of ugly hacks like re-spawning start units. :-)

If I've missed an important feature someone relied upon please let us know.

EDIT: Link to example gadget updated and added the commit containing zwzsg's improvements to the list of commits above.

Re: Engine will stop spawning start units

Posted: 27 Jan 2010, 16:52
by Argh
What about GameEnd being triggered, if there aren't any Units? What about Commander Ends behavior?

Personally, I'd like to see Commander Ends removed and replaced with a Gadget; it's another hardcoded TA-ism that's seen it's day go by.

Re: Engine will stop spawning start units and resources

Posted: 27 Jan 2010, 17:00
by Tobi
Yes there are many more TA-isms. Who knows, maybe I or someone else gets around to those too sometime ;-)

For now these remained unchanged.

Re: Engine will stop spawning start units and resources

Posted: 27 Jan 2010, 17:11
by zwzsg
Will the replacment gadget be included in base?

Re: Engine will stop spawning start units and resources

Posted: 27 Jan 2010, 17:14
by Tobi
It is included, but not enabled. (i.e. it's in LuaGadgets, like the other example gadgets)

Re: Engine will stop spawning start units and resources

Posted: 27 Jan 2010, 17:16
by Argh
Is that change committed to the main branch yet?

Re: Engine will stop spawning start units and resources

Posted: 27 Jan 2010, 17:16
by Tobi
Yes.

Re: Engine will stop spawning start units and resources

Posted: 27 Jan 2010, 17:22
by Argh
OK, will test it later then.

Re: Engine will stop spawning start units and resources

Posted: 27 Jan 2010, 18:05
by Jazcash
Will this fix units spawning to a slight angle to the side when just being built by a lab?

Re: Engine will stop spawning start units and resources

Posted: 27 Jan 2010, 18:08
by Gota
will this break spawning random commanders?
When u pick the random side in the lobby,ingame,It replaces your initial commander with a random one,core or arm.

Re: Engine will stop spawning start units and resources

Posted: 27 Jan 2010, 18:12
by smoth
you might have to update a widget or gadget or two

Re: Engine will stop spawning start units and resources

Posted: 28 Jan 2010, 20:26
by Tobi
Oh, btw, one other thing.

The fact that this gadget now handles StartMetal and StartEnergy, also means I have removed StartMetal and StartEnergy from EngineOptions.lua (since it isn't an engine option anymore...)

So please copy the relevant parts of EngineOptions.lua to ModOptions.lua (if desired). If you already override EngineOptions.lua or override the options in ModOptions.lua then this is irrelevant of course.

The relevant part of EngineOptions.lua, right before I removed it:

Code: Select all

  {
    key    = 'StartingResources',
    name   = 'Starting Resources',
    desc   = 'Sets storage and amount of resources that players will start with',
    type   = 'section',
  },

  {
    key    = 'StartMetal',
    name   = 'Starting metal',
    desc   = 'Determines amount of metal and metal storage that each player will start with',
    type   = 'number',
    section= 'StartingResources',
    def    = 1000,
    min    = 0,
    max    = 10000,
    step   = 1,  -- quantization is aligned to the def value
                    -- (step <= 0) means that there is no quantization
  },
  {
   key    = 'StartMetal',
   scope  = 'team',
   name   = 'Team Starting metal',
   desc   = 'Determines amount of metal and metal storage this team will start with',
   type   = 'number',
   section= 'StartingResources',
   def    = 1000,
   min    = 0,
   max    = 10000,
   step   = 1,  -- quantization is aligned to the def value
   -- (step <= 0) means that there is no quantization
  },
  {
    key    = 'StartEnergy',
    name   = 'Starting energy',
    desc   = 'Determines amount of energy and energy storage that each player will start with',
    type   = 'number',
    section= 'StartingResources',
    def    = 1000,
    min    = 0,
    max    = 10000,
    step   = 1,  -- quantization is aligned to the def value
                    -- (step <= 0) means that there is no quantization
  },
  {
   key    = 'StartEnergy',
   scope  = 'team',
   name   = 'Team Starting energy',
   desc   = 'Determines amount of energy and energy storage that this team will start with',
   type   = 'number',
   section= 'StartingResources',
   def    = 1000,
   min    = 0,
   max    = 10000,
   step   = 1,  -- quantization is aligned to the def value
   -- (step <= 0) means that there is no quantization
  },

Re: Engine will stop spawning start units and resources

Posted: 04 Feb 2010, 17:13
by Tobi
For developers, to temporarily make Spring sort-of compatible with mods that don't have the gadget yet, do:

Code: Select all

mkdir -p installer/builddata/springcontent/LuaRules/Gadgets
cp installer/builddata/springcontent/LuaGadgets/Gadgets/game_spawn.lua \
   installer/builddata/springcontent/LuaRules/Gadgets/game_spawn.lua
(This works unless the mod itself has a gadget / file with that name.)

Re: Engine will stop spawning start units and resources

Posted: 17 Feb 2010, 02:59
by R-TEAM
Hi,

mhh .. have without problems managed the migration from modinfo.tdf
to .lua on different old mods that not more maintained....

But this change i cant handle easy ;)
Have as a example depacked BA7.11 to BA711.SSD dir and on a test the
game starts - but without units/resources.
This was expectet ...
Now i copyed the game_spawn.lua to Luarules/gadgets/ ...
Now the units (the commander) apear - but still no resources .........?
and i know the BA mod WILL updatet to work flawles, but i need to understand this to fix a couple of old mods to work with the new system.
(if its not TO MUCH work - still like primary to PLAY spring and dont code it ... :P )

Re: Engine will stop spawning start units and resources

Posted: 24 Feb 2010, 22:42
by Noruas
thank you... will get to updating xta this weekend...

Re: Engine will stop spawning start units and resources

Posted: 27 Feb 2010, 21:21
by Kerr
what starts the game then.

Every game engine spawns starting units!

Re: Engine will stop spawning start units and resources

Posted: 27 Feb 2010, 21:46
by SeanHeron
Kerr wrote:what starts the game then.

Every game engine spawns starting units!
Wrong - almost every RTS game spawns start units. What starts the game would be eg the following gadget http://github.com/spring/spring/blob/ma ... _spawn.lua. No worries if you're not a game dev - they'll be sorting it out.

Re: Engine will stop spawning start units and resources

Posted: 28 Feb 2010, 20:13
by Kerr
But why remove starting units?

I don't get it.

:?

And no, Every rts game engine, in most cases the game and game engine are the same thing, since spring is only an engine though it's going to remove functionality in and of itself for spawning starting units, and people will have to use a gadget to spawn starting units?

Re: Engine will stop spawning start units and resources

Posted: 28 Feb 2010, 20:18
by Tobi
Because the way engine spawned starting units was less flexible than having some gadget spawn starting units.

For example: in many games engine spawned starting unit was immediately removed after it was spawned only to spawn a new starting unit facing another direction.

Another example: random faction is usually implemented by removing engine spawned starting unit, picking a random faction and then spawning the startunit of that faction at the same place.

If the game would respawn anyway then it isn't really needed for engine to spawn units in the first place. (Besides, the code that did this was in a very confusing part of the loading procedure, which could use a cleanup or removal.)

Re: Engine will stop spawning start units and resources

Posted: 28 Feb 2010, 20:21
by Kerr
but you are making it more complicated on mods that don't want random starting units...

If I did not want any lua gadgets in my mod, would my mod run in any capacity?