View topic - Multiple build pads possible?



All times are UTC + 1 hour


Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: 07 Feb 2012, 23:21 
Moderator
User avatar

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.


Top
 Offline Profile  
 
PostPosted: 08 Feb 2012, 09:25 
Journeywar Developer & Mapper
User avatar

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.


Top
 Offline Profile  
 
PostPosted: 08 Feb 2012, 15:35 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
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.


Top
 Offline Profile  
 
PostPosted: 15 Feb 2012, 20:55 
Conflict Terra Developer
User avatar

Joined: 21 Jan 2010, 06:21
Location: Tucson
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.

Input, O' gracious wizards of lua?


Top
 Offline Profile  
 
PostPosted: 15 Feb 2012, 21:33 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
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:
-- 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


Top
 Offline Profile  
 
PostPosted: 15 Feb 2012, 21:59 
Moderator
User avatar

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.


Top
 Offline Profile  
 
PostPosted: 15 Feb 2012, 23:42 
Conflict Terra Developer
User avatar

Joined: 21 Jan 2010, 06:21
Location: Tucson
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.


Top
 Offline Profile  
 
PostPosted: 16 Feb 2012, 00:19 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
Set the max speed to 0 (or rather, to a tiny value, I heard 0 doesn't work) until it's down?


Top
 Offline Profile  
 
PostPosted: 16 Feb 2012, 00:27 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
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
Quote:
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...


Top
 Offline Profile  
 
PostPosted: 16 Feb 2012, 00:46 
Conflict Terra Developer
User avatar

Joined: 21 Jan 2010, 06:21
Location: Tucson
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?


Top
 Offline Profile  
 
PostPosted: 16 Feb 2012, 01:33 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
side note:

Code:
  if (UnitDefs[bdefID].canFly == true) then


could just be

Code:
  if UnitDefs[bdefID].canFly then


Top
 Offline Profile  
 
PostPosted: 16 Feb 2012, 02:00 
Conflict Terra Developer
User avatar

Joined: 21 Jan 2010, 06:21
Location: Tucson
ah, awesome! Always glad to make things more simple!


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.