Page 1 of 1

Do units use these tag for movment or just construction?

Posted: 18 Dec 2010, 08:05
by smoth
minwaterdepth
maxwaterdepth
maxslope

The same tags exist both in movdefs and unit defs. Do they actually effect the unit's movement when in the unit def or are they JUST used for construction?

Re: Do units use these tag for movment or just construction?

Posted: 18 Dec 2010, 12:24
by slogic
maxWaterDepth & minWaterDepth of unitdef are used in GetAllowedTerrainHeight() only. For static units they are not tweaked. For mobile units (units with movedef):
1) with ship movement minWaterDepth is adjusted based on "depth" key
2) without ship movement maxWaterDepth is adjusted based on "depth" key

Note, that they are adjusted within GetAllowedTerrainHeight(), self properties left the same.

Of cause as they are exposed to lua layer i can't predict their usage from mod/game developer point of view.

EDIT. GetAllowedTerrainHeight() is used (directly or indirectly) in CUnitHandler::TestBuildSquare() and CTransportUnit::GetLoadUnloadHeight(), and also in CTransportUnit::KillUnit() to prevent some lua hacks (according to sourcecode comments).

Re: Do units use these tag for movment or just construction?

Posted: 18 Dec 2010, 21:29
by smoth
what is this "depth" key?

Re: Do units use these tag for movment or just construction?

Posted: 20 Dec 2010, 12:38
by slogic
It is defined in movedef.

Re: Do units use these tag for movment or just construction?

Posted: 20 Dec 2010, 18:19
by FLOZi
smoth wrote:what is this "depth" key?
Somehow the other day my find function failed hard; depth is set to minWaterDepth for boats, maxWaterDepth for ground units.

Re: Do units use these tag for movment or just construction?

Posted: 20 Dec 2010, 18:41
by smoth
interesting. So that means my code needs to check min and max waterdepth then?

Re: Do units use these tag for movment or just construction?

Posted: 21 Dec 2010, 05:35
by FLOZi

Code: Select all

00967: float UnitDef::GetAllowedTerrainHeight(float height) const {
00968: float maxwd = maxWaterDepth;
00969: float minwd = minWaterDepth;
00970:
00971: if (movedata) {
00972: if (movedata->moveType == MoveData::Ship_Move)
00973: minwd = movedata->depth;
00974: else
00975: maxwd = movedata->depth;
00976: }
If that is indeed the only function where they are used, then it is quite clear that for any unit which has an assigned movedef, they are effectively ignored.