Multiple build pads possible?
Moderator: Moderators
Re: Multiple build pads possible?
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.
But when StartBuilding() was just called, it returns nil. I guess it needs 1 frame to update.
Re: Multiple build pads possible?
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.
Re: Multiple build pads possible?
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.
- SanadaUjiosan
- Conflict Terra Developer
- Posts: 907
- Joined: 21 Jan 2010, 06:21
Re: Multiple build pads possible?
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:
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?
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
Input, O' gracious wizards of lua?
Re: Multiple build pads possible?
For a start, you are needlessly calling Spring.GetUnitIsBuilding twice.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?
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
Re: Multiple build pads possible?
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.
- SanadaUjiosan
- Conflict Terra Developer
- Posts: 907
- Joined: 21 Jan 2010, 06:21
Re: Multiple build pads possible?
Got it! I am slowly grinding my ways towards barely understanding lua!
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.
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
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.
Re: Multiple build pads possible?
Set the max speed to 0 (or rather, to a tiny value, I heard 0 doesn't work) until it's down?
Re: Multiple build pads possible?
0 works, it just gives a warning. (kloot fixed it)zwzsg wrote:Set the max speed to 0 (or rather, to a tiny value, I heard 0 doesn't work) until it's down?
http://springrts.com/mantis/view.php?id=2950
if you cancel the buildorder at 90% the cruiser would disappear a few meters above ground...Knorke, why would you rather do it that way? It sounds like a more complicated version of just moving the build pad down.
- SanadaUjiosan
- Conflict Terra Developer
- Posts: 907
- Joined: 21 Jan 2010, 06:21
Re: Multiple build pads possible?
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?
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?
Re: Multiple build pads possible?
side note:
could just be
Code: Select all
if (UnitDefs[bdefID].canFly == true) then
Code: Select all
if UnitDefs[bdefID].canFly then
- SanadaUjiosan
- Conflict Terra Developer
- Posts: 907
- Joined: 21 Jan 2010, 06:21
Re: Multiple build pads possible?
ah, awesome! Always glad to make things more simple!