how can ""stranded"" unit request pickup?

davidlallen

Deity
Joined
Apr 28, 2008
Messages
4,743
Location
California
(Not a Dune Wars question)

So, I have a different mod where a unit may suddenly have a need to cross water. For some background, see this thread. The idea is that a magic item may become available, but it is on a different island, and a unit is dispatched to pick it up. I have gotten the effect I want when the unit and item are on the same continent. I know in general there is some code for picking up stranded units, for example after a failed amphibious assault.

Can some kind person please suggest a specific starting point to help understand the logic of BBAI for units to request pickup by a transport?
 
I was hoping this post hadn't gotten lost. Thanks for the pointers. My goal is for a land unit to request transport *to* someplace. These pointers give two parts of the problem. I can write new code in calculateIsStranded so the land unit can set itself to stranded. This will cause an ocean transport to maybe be dispatched without any new code.

One part still remains; upon being loaded, the land unit has a destination in mind, and it wants to make the transport go there. What is a good way for the transport to realize, upon loading, that it has to go to a certain place?
 
That you'll have to create some new logic for, and also worry about whether it's an ASSAULT_SEA or SETTLER_SEA transport that picks up the unit.

If there's some distinguishing characteristic of this unit, then in CvUnitAI::AI_assaultSeaMove you could check if the loaded unit is of the special type. In fact, if you do this already to have the unit dropped off in the first place, it should work the same now.

Right now SETTLER_SEA will also do stranded pickups, but since they aren't supposed to be doing military transport they just take the units back to the closest city. You probably want to either avoid having a settler sea unit do the pickup, or change how they act when not carrying workers or settlers (you should be able to pick out the section of CvUnitAI::AI_settlerSeaMove where this is handled).
 
Thanks. Looks like I will have to do some work for this. I have a unitai called "Pick me up" which causes a land unit to go to a plot to pick up a dropped item. I can have the unit call for transport. But, when the transport arrives, I guess the land unit will have to "infect" the transport with the "pick me up" unitai. That way the transport will also be directed to the dropped item. I will leave that for later, but at least I can see the general form of the solution.
 
Top Bottom