Page 1 of 1
Water depth && Unit type values
Posted: 28 Jul 2006, 17:39
by AF
I'm working on my unviersal build routiens for NTai and I have no way of telling the difference between submarines amphibious units, and udnerwater structures, save wether they're mobile or not.
So, based on maxWaterDepth and MinWaterDepth, what would I expect for:
A submarine
A pelican/hvoercraft
A triton/croc/Gimp
An underwater mex
A normal building.
A normal unit
Re: Water depth && Unit type values
Posted: 28 Jul 2006, 18:36
by Egarwaen
AF wrote:A pelican/hvoercraft
Don't these totally ignore water depth?
Posted: 28 Jul 2006, 20:18
by KDR_11k
I think if it has a minimum depth it can be classified as a sub, if it doesn't it can obviously move on land and is amphibious. Also I'd check more for underwater weapons as those matter more for submarine combat than the movement type. E.g. a construction sub shouldn't try to approach a torpedo-equipped amphibious unit.
Posted: 28 Jul 2006, 20:23
by AF
The problem is, regardless of wether you define the tag, when i look through the AI itnerface it always has a value, so I need to know what that value represents and how ti works.
And I think floater=1 is used for hovercraft and pelicans, but it doesnt tell me anything about how MinWaterDepth and maxWaterDepth work
Re: Water depth && Unit type values
Posted: 28 Jul 2006, 22:15
by Rafal99
AF wrote:So, based on maxWaterDepth and MinWaterDepth, what would I expect for:
Also Floater, WaterLine and CanHover tags are useful here.
Try something like this:
Code: Select all
if (ud->canhover) {
//it is a hovercraft
}
if (ud->minWaterDepth > 0) {
//it is a water-only unit or building
if (ud->floater || ud->waterline) {
if (ud->waterline > 10) {
//it is a sub
} else {
//it is a ship
}
}
else {
//it is something like underwater mex and stays at the bottom
}
}
if (ud->minWaterDepth <= 0) {
//it is a ground unit or building
if (ud->floater) {
//unit can float, like Pelican for example
}
else if (ud->maxWaterDepth > 30) {
//unit can move underwater
}
else {
//unit is ground only
}
}
Also try using min(ud->maxWaterDepth, ud->movedata->depth) instead ud->maxWaterDepth, otherwise it gives wrong results for some units.
Everything was tested and worked prefectly for AA and XTA but it was some time ago, so some values might need a little tweaking.
Btw it wasn't so hard find out with a look at mod files and some testing.
Posted: 28 Jul 2006, 22:35
by AF
wow, that wasnt just exactly what i needed it was the code too!!!!!!!!!!
*10 cookies to rafal*
Posted: 29 Jul 2006, 01:48
by bobthedinosaur
wouldnt planes become ground only then?
Posted: 29 Jul 2006, 02:52
by AF
for a plane
ud->canfly=true && ud->movedata==0
planes simply dont obey the same set of movement rules.
Posted: 29 Jul 2006, 03:11
by esteroth12
isnt there also something like, "taairmovetype" or something like that? a patch got rejected because it assumed all flying units used canfly=1
Posted: 29 Jul 2006, 03:26
by AF
hmmm I thoguht all flying untis had canfly=1;.....
I know for deffo both static buildings and aircraft have ud->movedata==0/null though
Posted: 29 Jul 2006, 04:12
by Bobcatben
does ud->canfly only work for the globalai interface? cause whenever i try with the groupai interface it always returns the same value no matter if its a building or a plane or my commander, i was trying to make my group ai only accept planes, never did get that part to work.
Posted: 29 Jul 2006, 04:19
by AF
this check should be enough
Code: Select all
if(ud->canfly && (ud->movedata==0))
also
Code: Select all
if(ud->type == string("Fighter"))
if(ud->type == string("Bomber"))
with
Code: Select all
if(ud->type == string("Fighter")){
if(ud->hoverattack == true){
//gunship
}else{
// fighter
}
}
Could this be moved to the AI forum now?
Posted: 29 Jul 2006, 06:58
by KDR_11k
So if my tags list says e.g. Gunship instead of Fighter it won't get recognized?
Posted: 29 Jul 2006, 07:14
by Gnomre
IIRC SJ said the engine handles con aircraft and air transports with the same pathfinding as gunships as well.
Posted: 29 Jul 2006, 15:03
by AF
ud->type is defined based on which Unit AI was assigned to the unit.
Gunships and fighters both have the same Unti AI and thus are assigned the Fighter value.
You need to check anythign with the Fighter value for the hoverattack value, which dictates wether a fighter circles its target like a gunship or if it atatcks like a hawk..
Factory
Builder
MetalExtractor
Ground
Fighter
Bomber
not sure about Ground and there may be another one to be added
Posted: 29 Jul 2006, 21:08
by Bobcatben
does ud->type work with groupai's? mine always return (null)

Posted: 29 Jul 2006, 21:14
by AF
in that case you are doing something wrong.
GroupAI's and the Skirmish AI's have identical itnerfaces, infact they're the same interface.
Always check for error codes.
if the unit you're trying to check is out of LOS/radar and you shouldnt be able to tell what type of unit it is then cb->getUnitDef will return a null pointer.
Thus check if(ud){do stuff}else{skip}