Page 1 of 2
Multiple build pads possible?
Posted: 07 Feb 2012, 05:00
by SanadaUjiosan
Is it possible for a single factory to have two separate build "pads"? Like certain units have, say, a particular custom parameter which dictates if they use build pad A or B.
What I'm wanting to do: Flagship Base has two separate build pads, one used to build engineers and miners (normal ground units), and another one used to build the cruisers (which descend from the sky).
I feel like if this was possible it'd be common knowledge, but I figure it is worth a shot.
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 05:07
by Anarchid
On quick thought:
On unit created (includes the build being started) move the nanoframe (if you use these) to target position. If you want a cruiser that descends, hide the unit until completed and descend from the iron sky once complete. If land unit, display on target pad and draw whatever construction effects you want.
Possibly more efficient solutions possible.
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 05:20
by SanadaUjiosan
That sounds like what I'm wanting to attempt with how cruisers are brought into the game. But I'm wanting two different pads, both for the factory model and for the function of not having land units descend from the sky.
The problem I see with your suggestion is that the footprint and hitsphere are still there, just the visible model isn't. Then again, it is being built so it can't move anyways.
I'd still like some other input :)
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 05:43
by Niobium
Check out the tactical missile launcher in ZeroK, it has multiple launch pads that each get a missile built on them (one after the other).
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 06:16
by SanadaUjiosan
Isn't that for a weapon? I'm looking for doing this with a factory.
I looked at the Tactical Nuclear Missile Launcher and it isn't a builder. A search of Zero K didn't yield any other units that could be what you described
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 06:17
by Google_Frog
Yes, Lua it.
You can move the construction piece around in the unit script so if you were a masochist you could also Cob it.
Tactical Nuclear Missile Launcher is a factory. It has no weapons.
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 06:42
by Anarchid
Tactical Nuclear Missile Launcher is a factory. It has no weapons.
Moreover, tacnukes are (at least until launch) units as well. So to fire them, you need to select them and order to attack, which confuses many a noob.
On topic: you can lua-disable the hitsphere!
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 07:02
by FLOZi
Look at S44 barracks for a (somewhat clunky) way to do this - barracks build infantry inside and trucks outside. Would be easier with LUS.
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 07:43
by knorke
what unit/script name and which units should be build at what pieces?
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 07:44
by PicassoCT
I do something similar in the condepot, the units build starts on the standardpad (you cant get a unitDefID before the building starts, if you dont want to parse the buildqueue on start).. once the build units id is determinated i return the buildspot i desire.
You even can go disco, having the unit flicker from on buildspot to the next, dont know if that is any good (looks like four units beeing build near simultanously for our slow eyes).
Long Story short, yes.
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 15:30
by SanadaUjiosan
So comforting to not get a ton of resounding "no"'s for once
knorke wrote:what unit/script name and which units should be build at what pieces?
This is for a unit I haven't even modeled, I was more of checking the water before I go all willy nilly with plans that can't be realized.
I could slap another point onto the bflagshipbase and try it out to make sure it is what I want.
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 15:52
by PicassoCT
Do it..
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 20:52
by SanadaUjiosan
I tracked down the gadget in S44 to game_hqBuildSpot and I've started playing with it. I think I understand it, but there is one hangup.
Code: Select all
function gadget:GetInfo()
return {
name = "HQ unit ID informer",
desc = "Tells HQ scripts which build platter to use",
author = "Nemo/B.Tyler",
date = "14th April, 2009",
license = "PD",
layer = -5,
enabled = true -- loaded by default?
}
end
if (gadgetHandler:IsSyncedCode()) then
function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID)
local ud = UnitDefs[unitDefID]
if builderID then
local builderDefID = Spring.GetUnitDefID(builderID)
local bud = UnitDefs[builderDefID]
local buildPlace
if (bud.customParams.separatebuildspot) then
if (ud.customParams.buildoutside) then
buildPlace = 1
else
buildPlace = 0
end
--> Spring.CallCOBScript(builderID, "pickPlace", 0, buildPlace)
end
else
return
end
end
else
end
The "Spring.CallCOBSript blah blah blah" (with the arrow above) is giving me errors, because I'm using a Lua script and not Cob. This is where my knowledge runs out, as I don't know how to make it read a lua script.
Also, this is what I put into my factory's script:
Code: Select all
function script.pickPlace(buildPlace)
if (buildPlace == 1) then
Move(pad, z_axis, -20)
else
Move(pad, z_axis, 20)
end
end
I'm not sure if that is how it is supposed to look, but I can't get the actual gadget to work so I haven't gotten that far.
Help?
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 21:00
by knorke
http://answers.springlobby.info/questio ... munication
But I think with lua unit scripts you can merge the gadget into the unit script.
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 21:26
by SanadaUjiosan
I followed the page best I can but it keeps giving me errors.
Code: Select all
function gadget:GetInfo()
return {
name = "HQ unit ID informer",
desc = "Tells HQ scripts which build platter to use",
author = "Nemo/B.Tyler",
date = "14th April, 2009",
license = "PD",
layer = -5,
enabled = true -- loaded by default?
}
end
if (gadgetHandler:IsSyncedCode()) then
function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID)
local ud = UnitDefs[unitDefID]
if builderID then
local env = Spring.Unitscript.GetScriptEnv(unitID)
local builderDefID = Spring.GetUnitDefID(builderID)
local bud = UnitDefs[builderDefID]
local buildPlace
if (bud.customParams.separatebuildspot) then
if (ud.customParams.buildoutside) then
buildPlace = 1
else
buildPlace = 0
end
Spring.UnitScript.CallAsUnit(builderID, env.pickPlace,
'buildPlace')
end
else
return
end
end
else
end
Code: Select all
[f=0000133] Error: LuaRules::RunCallIn: error = 2, UnitCreated, [string "LuaRules/Gadgets/game_hqbuildspot.lua"]:16: attempt to index field 'Unitscript' (a nil value)
stack traceback:
[string "LuaRules/Gadgets/game_hqbuildspot.lua"]:16: in function 'UnitCreated'
[string "LuaGadgets/gadgets.lua"]:1264: in function <[string "LuaGadgets/gadgets.lua"]:1262>
(tail call): ?
Frustrating.
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 21:28
by knorke
Spring.UnitScript...
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 22:21
by SanadaUjiosan
Code: Select all
[f=0000219] Error: LuaRules::RunCallIn: error = 2, UnitCreated, [string "LuaRules/Gadgets/game_hqbuildspot.lua"]:28: attempt to index global 'env' (a nil value)
stack traceback:
[string "LuaRules/Gadgets/game_hqbuildspot.lua"]:28: in function 'UnitCreated'
[string "LuaGadgets/gadgets.lua"]:1264: in function <[string "LuaGadgets/gadgets.lua"]:1262>
(tail call): ?
fixed what knorke pointed out, does this.
I'm done with this for today. I'll come back to this another time.
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 22:35
by knorke
local env = Spring.Unitscript.GetScriptEnv(unitID)
vs
Spring.UnitScript.CallAsUnit(builderID, env.pickPlace,'buildPlace')
among other things
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 22:57
by knorke
as unit script:
Code: Select all
--special buildspots for some units
local buildSpots = {
[UnitDefNames["supertank"].id] = piece "tankbuildspot",
[UnitDefNames["horse"].id] = piece "horsebuildspot",
}
local pad = piece "pad" --used for all other units
bdefID = -1 --unitDefID that the factory is currently building
function script.QueryBuildInfo()
Spring.Echo (bdefID)
return buildSpots [bdefID] or pad
end
function script.StartBuilding()
Sleep (10) --otherwise GetUnitIsBuilding returns nil
local bums = Spring.GetUnitIsBuilding (unitID)
bdefID = Spring.GetUnitDefID (bums)
end
Not really clean with the Sleep() but w/e
Re: Multiple build pads possible?
Posted: 07 Feb 2012, 23:16
by SanadaUjiosan
That is what I'm talking about. Again, Knorke saves the day.
Why is that sleep needed in StartBuilding? Does it just need something to do (aka, could some animation commands take its place?)