Spawn Ship

Spawn Ship

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

Post Reply
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Spawn Ship

Post by Von66341 »

Hey! does any one know how do I get a ship to spawn in a map at the begining of the game?

My land units are able to spawn at the game, but not my ships.

Thanks.
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Spawn Ship

Post by oksnoop2 »

Set it as your starting unit.

http://code.google.com/p/conflictterra/ ... dedata.lua

Example ^^^^^^^^^
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Spawn Ship

Post by Von66341 »

Do we need to change anything in spawn.lua?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Spawn Ship

Post by knorke »

the file oksnoop2 posted is just a config file for a gadget that reads the config and then spawns those units.
spawner gadget would be this:
http://code.google.com/p/conflictterra/ ... _spawn.lua

gadget comes from this thread:
http://springrts.com/phpbb/viewtopic.php?f=67&t=21883

I dont see why ships should be any different than land units. Does your ship work when you do
/cheat
/give unitname
?
Maybe give infolog.txt or upload your game.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Spawn Ship

Post by zwzsg »

Make sure your ship is a valid unit by typing in the console:
/cheat
/give yourshipname
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Spawn Ship

Post by Von66341 »

Sorry am little new to spring and lua.

what do you all meant by console?
cause in gameplay i couldn't type anything.

I did following to add a ship unit:
Under hq_spawn.lua, I added the ship I want to spawn.

For e.g part of the code:

ushq={
spread= 200,
units={
"ship1",
"ship2",
},
},

will this work?

In the gadget spawn.lua,

Part of the code is like this:

local function IsPositionValid(unitDefID, x, z)
-- Don't place units underwater. (this is also checked by TestBuildOrder
-- but that needs proper maxWaterDepth/floater/etc. in the UnitDef.)
local y = GetGroundHeight(x, z)
if (y <= 0) then
return false
end
-- Don't place units where it isn't be possible to build them normally.
local test = TestBuildOrder(unitDefID, x, y, z, 0)
if (test ~= 2) then
return false
end
-- Don't place units too close together.
local ud = UnitDefs[unitDefID]
local units = GetUnitsInCylinder(x, z, CLEARANCE)
if (units[1] ~= nil) then
return false
end
return true
end

Do i need to change anything?

Thanks lots for the help! =)
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Spawn Ship

Post by knorke »

console = the chat ;)
http://answers.springlobby.info/questio ... est-my-mod

reading the comments, there seems to be some code that only spawns the unit if the position is a) on land and b) the position is not blocked.

Probally be best to start making your game from the example game:
http://springrts.com/wiki/The_Complete_ ... pring_Game
I think that is the "cleanest" example game there is.
if you start with modifying other games, you will always have left over things like this.
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Spawn Ship

Post by Von66341 »

hey! i manage to test my units and they work when I key into the console.
When I key /give yourship name, the ship spawn on land, how can i let it spawn on water?

Any idea how I can edit the gadget: spawn.lua to allow my ship to spawn on water?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Spawn Ship

Post by knorke »

When I key /give yourship name, the ship spawn on land, how can i let it spawn on water?
/give spawns the unit at your mouse pointer. so point it at water.
Any idea how I can edit the gadget: spawn.lua to allow my ship to spawn on water?
remove the part that checks for valid position or modify it. or use the gadget from the "complete guide to.." game that does not do such checks at all.

where did you find this spawn.lua?
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Spawn Ship

Post by Von66341 »

Thanks all for the help! my ships are working! =)

knorke the spawn.lua found from spring1944.
Thanks alot for your help!
Post Reply

Return to “Game Development”