Page 1 of 1
Check if unit is mine
Posted: 21 Nov 2010, 16:32
by Pithikos
How do I check if a unit is mine?
I have this so far to get my ID:
Then what can I use to check if a unit belongs to me? Searched a bit and didn't find anything.
Is there some function I can call to give me the unit's owner?
Re: Check if unit is mine
Posted: 21 Nov 2010, 16:38
by SirMaverick
Re: Check if unit is mine
Posted: 21 Nov 2010, 16:44
by knorke
There are playerIDs, teamIDs and allyteamIDs.
Lets say there is a 2v2 game and one team has 3 players but to make it fair 2 players controll one team together.
playerIDs - every player one has, even specs.
ie
Bob = 0
mastakilla = 1
powernoob = 2
[LOL]superrusher = 3
panzermann = 4
teamIDs - each team ("color") has one, ie two players can controll one team together
bob & mastakilla = 0
powernoob = 1
[LOL]superrusher = 2
panzermann = 2
AllyIDs - the allied teams.
bob & mastakilla & powernoob = 0
[LOL]superrusher & panzermann = 1
http://springrts.com/wiki/Lua_UnsyncedR ... eam.2CAlly
You want to compare: Spring.GetLocalTeamID (playerID)
and
Spring.GetUnitTeam (unitID)
Re: Check if unit is mine
Posted: 22 Nov 2010, 02:37
by aegis
if you're co-oping with someone, every unit on your team is yours (you can control it), there's no very good way to differentiate...
sure, children of your commander, but there's no point in co-op if you're not going to share things.
Re: Check if unit is mine
Posted: 22 Nov 2010, 03:00
by Pithikos
Yes I just got everything messed up in my head for a moment.
I guess what I really was looking for was Spring.GetUnitTeam (unitID)
Else if I really want my widget to effect ONLY my own units then I suppose I have to record the whole tech tree beginning from my commander. But that's an overkill so I will stick with the TeamID :D
Re: Check if unit is mine
Posted: 22 Nov 2010, 04:03
by aegis
curious what kind of widget you're making ^_^
Re: Check if unit is mine
Posted: 22 Nov 2010, 12:46
by Pithikos
aegis wrote:curious what kind of widget you're making ^_^
Well I saw there are many "auto repair" gadgets but none "auto reclaim" so I thought of making one. Though in the end it became a hybrid.. I use the fight command for idle builders so builders both repair damaged units and reclaim metal if the metal is under the limitbar
