Joined: 22 Feb 2006, 01:02 Location: cheap kitchen
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.
Joined: 24 Jan 2006, 21:12 Location: There is no god - and reality is his prophetess
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.
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.
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:
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.
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:
-- 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
Joined: 22 Feb 2006, 01:02 Location: cheap kitchen
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.
Got it! I am slowly grinding my ways towards barely understanding lua!
Code:
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.
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?
Users browsing this forum: No registered users and 2 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum