How does transportcapacity work?

How does transportcapacity work?

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

How does transportcapacity work?

Post by Jools »

I've run into some problems regarding the amount limitation of transports. From the wiki:
http://springrts.com/wiki/Units-UnitDefs#Transports wrote: int transportCapacity Default: 0
The total number of units that the transport can pick up, with each unit multiplied by it's footprintX size. If this tag is not present, then any AttachUnit and DropUnit call in the animation script will be ignored (See Animation-LuaCallouts#Other)
So according to this, the transportCapacity is simply the sum of footprintx, or xsize in lua-unitdef. However, in xta:

arm ornith: transportcapacity=8; (t2 transporter)
arm atlas: transportcapacity=1;
arm bear: transportcapacity=15; (hovercraft transport)

Yet, in reality, ornith can pick up 3 bulldogs (each bulldog has footprintx=3 => 9)

Ornith can also pick up 4 spiders (4*2), or 2 bulldogs and a spider (2*3+2=8).

Bear can pick up 5 bulldogs (5*3 = 15), so that checks.

But atlas can also pick up one spider, one bulldog etc, so here the tag doesn't compute: all these footprints exceed 1.

I read that this is complicated, but I would be happy if someone could clarify the formula.

The mass isnt the limiting factor in any of these cases. For reference:
Atlas wrote: transmaxunits=1;
transportcapacity=1;
transportmass=70001;
transportsize=3;
Bear wrote: transportcapacity=15;
transportmaxunits=16;
transportsize=3;
(mass not defined, default = 100 000)
Ornith wrote: transmaxunits=3;
transportcapacity=8;
transportmass=7000;
transportsize=3;
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: How does transportcapacity work?

Post by FLOZi »

transportCapacity should just be total of units, the current logic is an ugly hangover from the days prior to transportMass et al.

back on topic;

https://github.com/spring/spring/blob/d ... t.cpp#L331

Code: Select all

transportCapacityUsed += tu.size;
Where
https://github.com/spring/spring/blob/d ... t.cpp#L328

Code: Select all

tu.size = unit->xsize / 2;
And
https://github.com/spring/spring/blob/d ... f.cpp#L612

Code: Select all

xsize = std::max(1 * SPRING_FOOTPRINT_SCALE, (udTable.GetInt("footprintX", 1) * SPRING_FOOTPRINT_SCALE));
Where:
https://github.com/spring/spring/blob/d ... ants.h#L21

Code: Select all

const int SPRING_FOOTPRINT_SCALE = 2;
So wiki is essentially correct in what it says, however;

https://github.com/spring/spring/blob/d ... t.cpp#L222

Code: Select all

if (transportCapacityUsed >= unitDef->transportCapacity)
		return false;
'Transport is full' logic is rather flawed; instead of checking 'is the next unit too big to fit?' it checks 'Am I already over-stuffed'?
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: How does transportcapacity work?

Post by Jools »

Thanks, that explained it.
Post Reply

Return to “Lua Scripts”