AI Land Transport Usage

TheLadiesOgre

Aspiring Codesmith
Joined
Jan 16, 2009
Messages
505
****Important-- It has been brought to my attention that while this does work, it is not working as intended. This thread is henceforth to be considered a development thread. The download will remain, though you have been notified. "The AI is not yet choosing to utilize land transport capabilities by design, it is merely coincidence that occurs when a land transport and a potential cargo unit cross paths". My apologies for the cruel joke, I am currently trying to make this happen by design instead of coincidence.

AI Land Transport Usage Mod v0.1
By: TheLadiesOgre

Patch Compatibility: v3.19
MP Compatible: ? (though I see no reason why not)

Description:
Teaches the AI how to use Land Transport Units (which in the DLL/XML version are Gunships and Mech Infantry).
I think that troop mobility is an integral part of modern warfare and
to have it not be a part of such a great game seems to me to be a crime.

Installation Instructions:

Place the AI Land Transport Usage folder which contains this readme and the Assets folder in "C:\Program Files\Firaxis Games\Sid Meier's
Civilization 4\Beyond the Sword\Mods\" or "C:\Program Files\2K Games\Firaxis Games\Sid Meier's Civilization 4 Complete\Beyond the Sword\Mods\". You can
then load AI Land Transport Usage as a mod in the normal way or set BTS to autoload AI Land Transport Usage in "\My Games\Beyond the Sword\CivilizationIV.ini".

The source code for the changes (changed files only) are also included in a zip. If you are not a modder, you do not need those files and there is no need to extract them from the zip file.

-----Notes to Modmakers-----

If you want to use AI Land Transport Usage in your mod I have tried to make things as
easy as possible for you. In the XML files I have added <!-- AI Land Transport Usage Start -->
and <!-- AI Land Transport Usage End --> in all of the places that I have made changes to the
original files.

In the SDK files I have added //TLO: AI Land Transport Usage Start and
//TLO: AI Land Transport Usage End or //TLO: AI Land Transport Usage Change
in all of the places that I have made changes to the original files. My
recommendation is to search "TLO:" (without the quotes of course) as in some
places the comment is far off to the right.

-----Version Information-----

-----v0.1----- (18.08.2009)

- Added UNITAI_ASSAULT_LAND which is essentially just a clone of
UNITAI_ASSAULT_SEA that has been tweaked for usage on land plots.

- Tweaked Gunships and Mech Infantry to be land transports (I changed
their default AI to UNITAI_ASSAULT_LAND, gave them both a cargo space
of 4 and added SPECIALUNIT_PEOPLE_GUN (Anti-Tank Infantry, Infantry,
Machine Gun, Marine and SAM Infantry) as their cargo type)

-----To Do & Ideas-----

-Potentially add UNITAI_TRANSPORT_AIR (load the transport plane and
rebase it is the idea) which would require that a suitable transport
plane be added (snafusmith made a C-130 Hercules iirc, which would do
nicely). This idea depends upon how it is recieved by the community.

-Potentially add UNITAI_MISSILE_CARRIER_LAND (for use with units like
the Missile Launcher from the Nuclear Arsenal mod). This idea also depends
upon how it is recieved by the community.

-----===Credits & Thanks===-----

- TheLopez, JDog5000
readme.txt format

- Seasnake
For getting me thinking about it

-JDog5000
For tips and pointers

Feel free to download and test for yourselves, questions and comments are welcome.

I Killed the Download

So, how do you all feel about the potential additions? Let me know if you want them and (if there is enough demand) I'll do it. I'm thinking that the UNITAI_MISSILE_CARRIER_LAND would be the easier of the two.
 
This is amazing :worship:
You've done a great job :goodjob:
I never could figure out how to make the ai understand it.
 
Nice to see you got this to work!

Can we (Star Wars Mod team) use this modcomp? You see, the Star Wars Mod went with 3x3 planets surrounded by space tiles. However we chose to make everything a land tile, and then simply blocked planetary units from moving into space tiles (so space units can move over planets, thus allowing cities in the center of a planet to build space units). However, this means then that transport units wouldn't work since the AI wouldn't understand how to use them. So the AI would (unless I missed something) be unable to go to other planets, either to build cities or attack them.

We aren't using a custom SDK, so can we simply take your DLL (and applicable XML) and add it to the mod? Or would some other changes be needed?
 
Nice to see you got this to work!

Can we (Star Wars Mod team) use this modcomp?

There is no need to ask my permission to use this ModComp. I uploaded it to be used by the community. All I ask is that if you do use it, please give credit where it is due.

We aren't using a custom SDK, so can we simply take your DLL (and applicable XML) and add it to the mod? Or would some other changes be needed?

I doubt much would need to be changed (other than units it was applied to). You could even break it up more if you wanted, make several specific SPECIALUNIT_BLAH_BLAH's and apply them to different units you want to be transportable and then plug them into the units you want to use as transports for those units (thinking CIS Units can't use a Republic ship and vice versa so on and so forth).
 
Great stuff :goodjob:
Has it been tested??

I played three quick games last night and in all three the AI brought troops against me in gunships. It's kinda scary, you can't tell that they have units in the gunship, so the gunship comes up to your city all alone and attacks and then BAM, the gunship is joined by it's buddies (a stack of 4 infantry/SAM infantry). The next thing you know, you see a stack of six gunships and you're left wondering if all of those gunships are carrying similar stacks:eek:
 
In Dune Wars, we have made all terrain transports, which are related to land transports. We have found several problems. With a land transport and a land unit, it is possible to drive up with the transport, unload the unit, have the unit attack or pillage, load the unit back into the transport, and drive away, all in the same turn. Since a transport has a high movement rate, it may be possible to do this multiple times on the same turn. This is especially a problem for pillaging. You can ransack the entire BFC with little effort, and the defender cannot respond.

Does the same problem occur in your modcomp?

EDIT: when I say "we" have made all terrain transports, I mean the original work was by Maniac, added/merged into Dune Wars by koma13 and keldath. I personally did not write any of this code. My apologies for omitting the credit in this reference.
 
In Dune Wars, we have made all terrain transports, which are related to land transports. We have found several problems. With a land transport and a land unit, it is possible to drive up with the transport, unload the unit, have the unit attack or pillage, load the unit back into the transport, and drive away, all in the same turn. Since a transport has a high movement rate, it may be possible to do this multiple times on the same turn. This is especially a problem for pillaging. You can ransack the entire BFC with little effort, and the defender cannot respond.

Does the same problem occur in your modcomp?

If it does, I haven't noticed it yet, thanks for the heads up though, I will keep an eye on it, shouldn't be too very hard to fix if it does rear it's ugly pillaging head. Might even be an idea to allow it to happen, but give the defender some way of responding. Not sure how I'd handle this, I'll cross that bridge if it comes.
 
Why did you name it 'UNITAI_ASSAULT_LAND'?
Wouldn't 'UNITAI_CARRIER_LAND' be more appropriate?

Personally, I feel it is a matter of semantics. IMHO, carrier implies a passive unit that does nothing but ferry units along, while assault implies an active participant in the attack.
 
OK, but there's 'UNITAI_ASSAULT_SEA'. Does that AI allow ships to land units on shore or is it 'UNITAI_CARRIER_SEA' that does this job?

UNITAI_ASSAULT_SEA is the one that takes units to the shore or allows an amphibious assault on a city.

UNITAI_CARRIER_SEA is aircraft carriers
 
Judging from a, granted, short look at the code, I don't really understand how you got the land transports to work. Or at least they may not work for the reasons you hoped they would work.

Could you please elaborate a little on what changes you made and why?

1) I see you often use parts of the ASSAULT_SEA code, for instance telling land transports to pick up units with an assault mission. However units with an assault mission are designated for transport to another continent.

2) You have also made a change to CvUnit::shouldLoadOnMove. I don't remember exactly what the function does, but either the land transport will automatically pick up units on the plots the transport moves on, or potential cargo will automatically be loaded when they move on a plot with a land transport.

Not only would this be annoying for a human player (there might be times when you don't want a unit to be loaded on a land transport - city defenders for instance), but together with point 1, I fear that with this automatic loading, the AI's land transports are dragging off units to locations where they didn't want to go.
 
In Dune Wars, we have made all terrain transports

No, you haven't...
I obviously don't care if people use my code, but you always make it seem like you wrote it, which is starting to annoy me.

And no, that problem/feature/depends-on-perspective hasn't been changed here.
 
Judging from an, admittedly, short look at the code, I don't really understand how you got the land transports to work. Or at least they may not work for the reasons you hoped they would work.

Could you please elaborate a little on what changes you made and why?

1) I see you often use parts of the ASSAULT_SEA code, for instance telling land transports to pick up units with an assault mission. However units with an assault mission are designated for transport to another continent.

2) You have also made a change to CvUnit::shouldLoadOnMove. I don't remember exactly what the function does, but either the land transport will automatically pick up units on the plots the transport moves on, or potential cargo will automatically be loaded when they move on a plot with a land transport.

Not only would this be annoying for a human player (there might be times when you don't want a unit to be loaded on a land transport - city defenders for instance), but together with point 1, I fear that with this automatic loading, the AI's land transports is dragging off units to locations where they didn't want to go.

As I stated above, I essentially cloned UNITAI_ASSAULT_SEA (at least that is my understanding of it). As such, I figured the thing to do would be to plug UNITAI_ASSAULT_LAND into anywhere that UNITAI_ASSAULT_SEA was. What I get from your first point is that I need to make a second assault mission and attach it to UNITAI_ASSAULT_LAND the way that the original assault mission is attached to UNITAI_ASSAULT_SEA. After which, I need to actually code out the UNITAI_ASSAULT_LAND stuff in its entirity instead of just plugging it into the UNITAI_ASSAULT_SEA code.

As for the ::shouldLoadOnMove, if what you say it true that absolutely sucks and I'll have to look into this a little deeper than I did previously. As it stand now though, it is out in the community and I will tackle things as they are brought to me. After all, I released it to be used so that any bugs may become readily apparent more quickly than they would if it were just me playing with it. I guess I really should have added alpha to the name. Sorry.
 
No, you haven't...
I obviously don't care if people use my code, but you always make it seem like you wrote it, which is starting to annoy me.

I agree you invented this. I have mentioned this capability a number of times, and I have tried very hard to mention that you personally developed this originally. If I have left off this original credit in some places, I apologize.
 
I don't want to come across as hostile by the way. I'd very much love working land transports, as that would make the all terrain dropships in Planetfall even more useful for the AI.

An easy way to test if it's the ::shouldLoadOnMove or the unitAI code that puts units in the cargo, would be to remove the change in ::shouldLoadOnMove, and see if the AI still uses land transports as well as before.

It would also be interesting to see if the AIs still does overseas invasions as well. Hard to test of course.
 
Regarding the unload/attack/load problem, it seems clear that land transports work differently from ocean transports. If an ocean transport unloads, the unloaded unit cannot attack or move unless it has the amphibious promotion. I am not sure exactly how this works, but it does not work this way in the existing all terrain transport implementation (... by Maniac, did I mention that? ...).

Is it possible to use up all remaining movement points and also set the isHasAttacked flag, upon unloading from a land transport? The interaction of the amphibious promotion could be copied into a "mobile assault" promotion, which would allow unload and attack the same way amphibious allows.
 
Top Bottom