Engine will stop spawning start units and resources

Engine will stop spawning start units and resources

Resources to get you going on your new project, or to help you over some emergent problems during your development cycle.

Moderator: Moderators

Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Engine will stop spawning start units and resources

Post 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.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Engine will stop spawning start units

Post 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.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Engine will stop spawning start units and resources

Post 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.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Engine will stop spawning start units and resources

Post by zwzsg »

Will the replacment gadget be included in base?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Engine will stop spawning start units and resources

Post by Tobi »

It is included, but not enabled. (i.e. it's in LuaGadgets, like the other example gadgets)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Engine will stop spawning start units and resources

Post by Argh »

Is that change committed to the main branch yet?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Engine will stop spawning start units and resources

Post by Tobi »

Yes.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Engine will stop spawning start units and resources

Post by Argh »

OK, will test it later then.
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: Engine will stop spawning start units and resources

Post by Jazcash »

Will this fix units spawning to a slight angle to the side when just being built by a lab?
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: Engine will stop spawning start units and resources

Post 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.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Engine will stop spawning start units and resources

Post by smoth »

you might have to update a widget or gadget or two
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Engine will stop spawning start units and resources

Post 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
  },
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Engine will stop spawning start units and resources

Post 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.)
R-TEAM
Posts: 177
Joined: 22 Jan 2009, 19:25

Re: Engine will stop spawning start units and resources

Post 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 )
User avatar
Noruas
XTA Developer
Posts: 1269
Joined: 24 Feb 2005, 02:58

Re: Engine will stop spawning start units and resources

Post by Noruas »

thank you... will get to updating xta this weekend...
Kerr
Posts: 37
Joined: 27 Feb 2010, 03:18

Re: Engine will stop spawning start units and resources

Post by Kerr »

what starts the game then.

Every game engine spawns starting units!
SeanHeron
Engines Of War Developer
Posts: 614
Joined: 09 Jun 2005, 23:39

Re: Engine will stop spawning start units and resources

Post 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.
Kerr
Posts: 37
Joined: 27 Feb 2010, 03:18

Re: Engine will stop spawning start units and resources

Post 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?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Engine will stop spawning start units and resources

Post 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.)
Kerr
Posts: 37
Joined: 27 Feb 2010, 03:18

Re: Engine will stop spawning start units and resources

Post 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?
Post Reply

Return to “Game Development Tutorials & Resources”