Multiple build pads possible? - Page 2

Multiple build pads possible?

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
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Multiple build pads possible?

Post by knorke »

Spring.GetUnitIsBuilding returns what a factory is building.
But when StartBuilding() was just called, it returns nil. I guess it needs 1 frame to update.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Multiple build pads possible?

Post by PicassoCT »

Ignore what Picasso said: Have a buildspot thats out of sight Then when the buildprocess has started get unitdefid, and return buildspot. But hey, its just Picasso, what does he know.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Multiple build pads possible?

Post by FLOZi »

knorke wrote:Spring.GetUnitIsBuilding returns what a factory is building.
But when StartBuilding() was just called, it returns nil. I guess it needs 1 frame to update.

Hmm, this is ugly. Maybe mantis it though it's quite possible that it isn't avoidable.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Multiple build pads possible?

Post by SanadaUjiosan »

Knorke's code to divide up the build pads works great, but I've run into another obstacle. Part of doing this is having separate animations for each group (again, Cruisers which descend from the sky and "normal units" which come out of the factory via a little scaffolding rig)

I've blindly tried figuring this out, but the best I can do is have no script-breaking errors. Here is what I have:

Code: Select all

	function script.StartBuilding()
		Sleep (10) --otherwise GetUnitIsBuilding returns nil
		local bums = Spring.GetUnitIsBuilding (unitID)
		bdefID = Spring.GetUnitDefID (bums)
		if Spring.GetUnitIsBuilding == UnitDefNames["bmechcruiser"].id then
			StartThread(cruiser_descend)
		else
			StartThread(normal_unit)
		end
	end
I feel this hinges on using the right Spring.blah blah == blah blah unitdef, but I'm ignorant of what they should be and a little wary of my approach as a whole.

Input, O' gracious wizards of lua?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Multiple build pads possible?

Post by FLOZi »

SanadaUjiosan wrote: I feel this hinges on using the right Spring.blah blah == blah blah unitdef, but I'm ignorant of what they should be and a little wary of my approach as a whole.

Input, O' gracious wizards of lua?
For a start, you are needlessly calling Spring.GetUnitIsBuilding twice.
I would probably either give all the units you want to 'fly in from the sky' a customparam or come up with a reliable heuristic (check for canfly etc), unless there is only the one unit in which case why not use the unitdef. HOWEVER, you should localise (also your API calls) it. e.g.

Code: Select all

-- i like to keep global vars at top of file
local cruiserDefID = UnitDefNames["bmechcruiser"].id

...

	function script.StartBuilding()
		Sleep (10) --otherwise GetUnitIsBuilding returns nil
		local bums = Spring.GetUnitIsBuilding (unitID)
		bDefID = Spring.GetUnitDefID (bums)
		if bDefID == cruiserDefID then
			StartThread(cruiser_descend)
		else
			StartThread(normal_unit)
		end
	end
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Multiple build pads possible?

Post by knorke »

I would not make descending cruisers by moving their buildspot downwards. Instead make have the factory build some invisible placeholder unit and once finished, spawn the cruiser and MoveCtrl it down. Or just move the buildspot way high and see if spring's flightphysic make the cruisers descend look okayish.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Multiple build pads possible?

Post by SanadaUjiosan »

Got it! I am slowly grinding my ways towards barely understanding lua!

Code: Select all

	function script.StartBuilding()
		Sleep (10) --otherwise GetUnitIsBuilding returns nil
		local bums = Spring.GetUnitIsBuilding (unitID)
		bdefID = Spring.GetUnitDefID (bums)
		if (UnitDefs[bdefID].canFly == true) then
			StartThread(cruiser_descend)
		else
			StartThread(normal_unit)
		end
	end
Thanks Flozi for the canFly suggestion. I think that'll work just fine.

Knorke, why would you rather do it that way? It sounds like a more complicated version of just moving the build pad down.

Also, just moving the build spot really high and letting spring carry the unit down works, but if you tell the unit to go somewhere while it is being built, it'll move from the really high point to wherever you tell it to go via a diagonal trajectory. Aka, you can plant fresh units in the middle of the enemy base if the distances allow it.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Multiple build pads possible?

Post by zwzsg »

Set the max speed to 0 (or rather, to a tiny value, I heard 0 doesn't work) until it's down?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Multiple build pads possible?

Post by knorke »

zwzsg wrote:Set the max speed to 0 (or rather, to a tiny value, I heard 0 doesn't work) until it's down?
0 works, it just gives a warning. (kloot fixed it)
http://springrts.com/mantis/view.php?id=2950
Knorke, why would you rather do it that way? It sounds like a more complicated version of just moving the build pad down.
if you cancel the buildorder at 90% the cruiser would disappear a few meters above ground...
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Multiple build pads possible?

Post by SanadaUjiosan »

Ah, I see. Yes, that is a problem with the system I'm using now...

So, an invisi-unit is made, spawns a cruiser, invisi-unit is destroyed, cruiser descends down on top of the factory, and that's that? I'm guessing you could have the cruiser spawn some distance in front of the factory so it doesn't land on top of it? And perhaps even change the velocity of how fast it descends, such as having it descend rather quickly, then slow down once it reaches a certain point above the ground?

Do you think I could butcher part of spacerocks.lua to achieve this? Like the part where if bmex is destroyed, the rocks fall down?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Multiple build pads possible?

Post by FLOZi »

side note:

Code: Select all

  if (UnitDefs[bdefID].canFly == true) then
could just be

Code: Select all

  if UnitDefs[bdefID].canFly then
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Multiple build pads possible?

Post by SanadaUjiosan »

ah, awesome! Always glad to make things more simple!
Post Reply

Return to “Game Development”