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 » 27 Jan 2010, 16:49

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.
0 x

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

Re: Engine will stop spawning start units

Post by Argh » 27 Jan 2010, 16:52

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.
0 x

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

Re: Engine will stop spawning start units and resources

Post by Tobi » 27 Jan 2010, 17:00

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.
0 x

User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7017
Joined: 16 Nov 2004, 13:08

Re: Engine will stop spawning start units and resources

Post by zwzsg » 27 Jan 2010, 17:11

Will the replacment gadget be included in base?
0 x

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

Re: Engine will stop spawning start units and resources

Post by Tobi » 27 Jan 2010, 17:14

It is included, but not enabled. (i.e. it's in LuaGadgets, like the other example gadgets)
0 x

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

Re: Engine will stop spawning start units and resources

Post by Argh » 27 Jan 2010, 17:16

Is that change committed to the main branch yet?
0 x

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

Re: Engine will stop spawning start units and resources

Post by Tobi » 27 Jan 2010, 17:16

Yes.
0 x

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

Re: Engine will stop spawning start units and resources

Post by Argh » 27 Jan 2010, 17:22

OK, will test it later then.
0 x

User avatar
Jazcash
Posts: 5302
Joined: 08 Dec 2007, 17:39

Re: Engine will stop spawning start units and resources

Post by Jazcash » 27 Jan 2010, 18:05

Will this fix units spawning to a slight angle to the side when just being built by a lab?
0 x

User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: Engine will stop spawning start units and resources

Post by Gota » 27 Jan 2010, 18:08

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.
0 x

User avatar
smoth
Posts: 22298
Joined: 13 Jan 2005, 00:46

Re: Engine will stop spawning start units and resources

Post by smoth » 27 Jan 2010, 18:12

you might have to update a widget or gadget or two
0 x

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

Re: Engine will stop spawning start units and resources

Post by Tobi » 28 Jan 2010, 20:26

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
  },
0 x

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

Re: Engine will stop spawning start units and resources

Post by Tobi » 04 Feb 2010, 17:13

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.)
0 x

R-TEAM
Posts: 177
Joined: 22 Jan 2009, 19:25

Re: Engine will stop spawning start units and resources

Post by R-TEAM » 17 Feb 2010, 02:59

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 )
0 x

User avatar
Noruas
XTA Developer
Posts: 1267
Joined: 24 Feb 2005, 02:58

Re: Engine will stop spawning start units and resources

Post by Noruas » 24 Feb 2010, 22:42

thank you... will get to updating xta this weekend...
0 x

Kerr
Posts: 37
Joined: 27 Feb 2010, 03:18

Re: Engine will stop spawning start units and resources

Post by Kerr » 27 Feb 2010, 21:21

what starts the game then.

Every game engine spawns starting units!
0 x

SeanHeron
Engines Of War Developer
Posts: 583
Joined: 09 Jun 2005, 23:39

Re: Engine will stop spawning start units and resources

Post by SeanHeron » 27 Feb 2010, 21:46

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.
0 x

Kerr
Posts: 37
Joined: 27 Feb 2010, 03:18

Re: Engine will stop spawning start units and resources

Post by Kerr » 28 Feb 2010, 20:13

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?
0 x

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

Re: Engine will stop spawning start units and resources

Post by Tobi » 28 Feb 2010, 20:18

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.)
0 x

Kerr
Posts: 37
Joined: 27 Feb 2010, 03:18

Re: Engine will stop spawning start units and resources

Post by Kerr » 28 Feb 2010, 20:21

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?
0 x

Post Reply

Return to “Game Development Tutorials & Resources”