Multiple build pads possible?

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
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Multiple build pads possible?

Post 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.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Multiple build pads possible?

Post 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.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Multiple build pads possible?

Post 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 :)
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: Multiple build pads possible?

Post 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).
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Multiple build pads possible?

Post 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 :(
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Multiple build pads possible?

Post 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.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Multiple build pads possible?

Post 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!
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Multiple build pads possible?

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

Re: Multiple build pads possible?

Post by knorke »

what unit/script name and which units should be build at what pieces?
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Multiple build pads possible?

Post 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.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Multiple build pads possible?

Post 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.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Multiple build pads possible?

Post by PicassoCT »

Do it..
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Multiple build pads possible?

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

Re: Multiple build pads possible?

Post by knorke »

http://answers.springlobby.info/questio ... munication

But I think with lua unit scripts you can merge the gadget into the unit script.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Multiple build pads possible?

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

Re: Multiple build pads possible?

Post by knorke »

Spring.UnitScript...
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Multiple build pads possible?

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

Re: Multiple build pads possible?

Post by knorke »

local env = Spring.Unitscript.GetScriptEnv(unitID)
vs
Spring.UnitScript.CallAsUnit(builderID, env.pickPlace,'buildPlace')

among other things
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Multiple build pads possible?

Post 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
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Multiple build pads possible?

Post 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?)
Post Reply

Return to “Game Development”