Find commander unit independent of mod
Moderator: Moderators
Find commander unit independent of mod
Hi,
I'm trying to find a way to find the commander unit that is independent of the mod (or at least works for mods with commander as starting unit).
Would UnitDefs[ud].isCommander work? Or is there a better way to find out?
Thanks for your help, qray.
I'm trying to find a way to find the commander unit that is independent of the mod (or at least works for mods with commander as starting unit).
Would UnitDefs[ud].isCommander work? Or is there a better way to find out?
Thanks for your help, qray.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Find commander unit independent of mod
Afaik it's not possible to do it absolutely independently of the mod since, in theory, mods can spawn any starting unit they like and may have no units tagged as (or even similar to) commanders.
I think the traditional solution for this has been to include a unit list for each mod and use the appropriate one. Within BA you can use uDef.customParams.iscommander, but you might need to wait for our next release before it works. I think with 94.0 and before you are safe with uDef.isCommander but with 95.0 I think maybe that's deprecated.
I think the traditional solution for this has been to include a unit list for each mod and use the appropriate one. Within BA you can use uDef.customParams.iscommander, but you might need to wait for our next release before it works. I think with 94.0 and before you are safe with uDef.isCommander but with 95.0 I think maybe that's deprecated.
Re: Find commander unit independent of mod
Catch first unitID of a unit created for this team?
Re: Find commander unit independent of mod
I kinda hoped I would get around the catching of the first spawned unit per team (if there is more than once race, there could be more than a single com id)... but it seems that this will be the only reliable way to find com in mods that use com.
Thanks for the answers
Thanks for the answers
Re: Find commander unit independent of mod
Silly Idea... ask the user... have your gui ask the user to confirm a unit is their com or click on the one they want to be treated as their com.
Re: Find commander unit independent of mod
The com finding is to make a king of hill script work with more mods than just BA.
Asking the user would be a sure invitation to cheat
Asking the user would be a sure invitation to cheat
Re: Find commander unit independent of mod
Best option atm. I'm skeptic of any standardization in regards to that.include a unit list for each mod
Re: Find commander unit independent of mod
not
every
spring
game
has
a
commander
every
spring
game
has
a
commander
Re: Find commander unit independent of mod
He knows that, see first post.
Still many have a commander-like unit and he wants his thing (map I think?) to work in a specific way for those mods that do, for whatever reason.
It's not a bad thing.
Still many have a commander-like unit and he wants his thing (map I think?) to work in a specific way for those mods that do, for whatever reason.
It's not a bad thing.
- CarRepairer
- Cursed Zero-K Developer
- Posts: 3359
- Joined: 07 Nov 2007, 21:48
Re: Find commander unit independent of mod
Why do you need a commander for koth?
Re: Find commander unit independent of mod
Maybe that's the unit that needs to be in the scoring zone to earn points?CarRepairer wrote:Why do you need a commander for koth?
Re: Find commander unit independent of mod
what if not every game has that setup for KOTH.
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Re: Find commander unit independent of mod
Then this map isn't for those games, if it's what you assume it is. Can't you just let him do his thing? Or at least make suggestions/advice if thats what you're getting at.
Re: Find commander unit independent of mod
Point is much of the thread ends at that point.
"I'm trying to find a way to find the commander unit that is independent of the mod"
most of the rest of the thread is discussion about how to find said unit. In many cases said unit doesn't exist.
Many things, KOTH included are project specific. Sinbad posted a point. I posted a counter point.
There is no sort of generic way to assume this sort of thing. Best bet is to ask the *A(because in these cases that is who it is) guys what their KOTH setup is and then go to them about it.
When we get into MODES of gameplay we are talking specific to certain projects. Not everything is going to work for all projects.
"I'm trying to find a way to find the commander unit that is independent of the mod"
most of the rest of the thread is discussion about how to find said unit. In many cases said unit doesn't exist.
Many things, KOTH included are project specific. Sinbad posted a point. I posted a counter point.
There is no sort of generic way to assume this sort of thing. Best bet is to ask the *A(because in these cases that is who it is) guys what their KOTH setup is and then go to them about it.
When we get into MODES of gameplay we are talking specific to certain projects. Not everything is going to work for all projects.
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Re: Find commander unit independent of mod
smoth wrote:not
every
spring
game
has
a
commander
smoth wrote: most of the rest of the thread is discussion about how to find said unit. In many cases said unit doesn't exist.
He already mentions not every game has a commander. Why repeat it in a long dramatic fashion, then again multiple times?smoth wrote:what if not every game has that setup for KOTH.
From that I can only assume he isn't worried about the games that don't have commanders, or at least knows of them. Why bring them up and use them in counter arguments?qray wrote: (or at least works for mods with commander as starting unit).
This is his project, and yes it is specific to the way he wants it. Which probably includes a commander (*when there is one).smoth wrote: Many things, KOTH included are project specific. Sinbad posted a point. I posted a counter point.
There is no sort of generic way to assume this sort of thing. Best bet is to ask the *A(because in these cases that is who it is) guys what their KOTH setup is and then go to them about it.
When we get into MODES of gameplay we are talking specific to certain projects. Not everything is going to work for all projects.
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Re: Find commander unit independent of mod
I think this would be the most reliable, for sure.gajop wrote:Best option atm. I'm skeptic of any standardization in regards to that.include a unit list for each mod
As far as unit spawning goes..
I've noticed many games have a widget that auto-selects their commander units at gamestart and that could be useful in some way.
Here's the widget that does it in BA/BAR, it could probably be recycled in some fashion.
Code: Select all
function widget:GetInfo()
return {
name = "Select n Center!",
desc = "Selects and centers the Commander at the start of the game.",
author = "quantum and Evil4Zerggin and zwzsg",
date = "19 April 2008",
license = "GNU GPL, v2 or later",
layer = 5,
enabled = true -- loaded by default?
}
end
--bug with usage of "Spring.GetPlayerInfo" fixed by [teh]decay 27 may 2012
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function widget:Update()
local t = Spring.GetGameSeconds()
_, _, spectator = Spring.GetPlayerInfo(Spring.GetMyPlayerID())
if (spectator or t > 10) then
widgetHandler:RemoveWidget()
return
end
if (t > 0) then
local x, y, z = Spring.GetTeamStartPosition(Spring.GetMyTeamID())
local unitArray = Spring.GetTeamUnits(Spring.GetMyTeamID())
if (unitArray and #unitArray==1) then
Spring.SelectUnitArray{unitArray[1]}
x, y, z = Spring.GetUnitPosition(unitArray[1])
end
if x and y and z then
Spring.SetCameraTarget(x, y, z)
end
widgetHandler:RemoveWidget()
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Re: Find commander unit independent of mod
agree that including list of all known commanders is probally best.
For XTA a list is here:
http://code.google.com/p/xta-springrts/ ... ion.lua#43
For zK the com unitdefs are generated based on what modules players put on their commanders, might have to look at it to see what names it uses.
BA only has 2 coms I think?
Imo do not save com names "by mod", might just bring more problems than it solves. Just a list.
That way forks of mods that keep comnames will work, too.Think unlikely that a unit "arm_com" will be something totally game breaking different in another mod.
"First spawned unit" maybe not so good, because during game commander might become a different unit. By rezzing, capture (also of different faction) sharing, morphing,...
For XTA a list is here:
http://code.google.com/p/xta-springrts/ ... ion.lua#43
For zK the com unitdefs are generated based on what modules players put on their commanders, might have to look at it to see what names it uses.
BA only has 2 coms I think?
Imo do not save com names "by mod", might just bring more problems than it solves. Just a list.
That way forks of mods that keep comnames will work, too.Think unlikely that a unit "arm_com" will be something totally game breaking different in another mod.
"First spawned unit" maybe not so good, because during game commander might become a different unit. By rezzing, capture (also of different faction) sharing, morphing,...
- KingRaptor
- Zero-K Developer
- Posts: 838
- Joined: 14 Mar 2007, 03:44
Re: Find commander unit independent of mod
For ZK look for customParam "commtype" or "level"
Re: Find commander unit independent of mod
For XTA, you can also use unitDef.customparams.iscommander, but that will also return the decoy commanders. Which may or may not be what you want to do.qray wrote:Hi,
I'm trying to find a way to find the commander unit that is independent of the mod (or at least works for mods with commander as starting unit).
Would UnitDefs[ud].isCommander work? Or is there a better way to find out?
Catching the first unit created for a team may not be fool proof. At least XTA has a mod option to begin with decoys (then that is your commander in every meaningful way), and there is a mission where you begin with a decoy and the real commander gets teleported to you later.
I think there is a loose consensus nowadays to put the iscommander field in customparams and in that way standardise the field between games.
Re: Find commander unit independent of mod
In that case it's even better to use:FLOZi wrote:Catch first unitID of a unit created for this team?
Code: Select all
local startunit = Spring.GetTeamRulesParam(teamID, 'startUnit')