Examples for area checks during unit spawn?
Moderator: Moderators
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Examples for area checks during unit spawn?
Say I want to spawn a unit near another unit (as if it were built from it) and I want to check the positions in the potential spawning area, to prevent placing on top of feature/ units, or off the map's edge. Are there any good examples of a gadgets using checks like this?
Last edited by bobthedinosaur on 05 Dec 2010, 16:42, edited 1 time in total.
-
- Moderator
- Posts: 2464
- Joined: 12 Oct 2007, 09:24
Re: Examples for area checks during unit spawn?
For the other checks just check your position against the map sizes and 0.wiki wrote:Spring.TestBuildOrder
( number unitDefID, number x, number y, number z, number facing)
-> number blocking [,number featureID]
blocking can be:
0 - blocked
1 - mobile unit in the way
2 - free (or if featureID is != 0 then with a blocking feature that can be reclaimed)
facing can be:
0, "s", "south"
1, "e", "east"
2, "n", "north"
3, "w", "west"
Re: Examples for area checks during unit spawn?
I used
Code: Select all
local bt1,bt2=Spring.TestBuildOrder(UnitDefNames.yourunit.id,x,0,z,0)
if bt1==2 and not bt2 then
-- okay area is free
end
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Examples for area checks during unit spawn?
I am confused. what is the 2nd local for?
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Examples for area checks during unit spawn?
Okay. New kind of related question:
If I wanted a certain air pad like unit to spawn another unit on top (attached to air pad), how would I go about this?
edit: Not possible? okay. nvm
If I wanted a certain air pad like unit to spawn another unit on top (attached to air pad), how would I go about this?
edit: Not possible? okay. nvm