[BtS][Python]zRoutes

I have downloaded this and the two other similar mod components and will eventually use one or two of them. Thanks.

What I want to know is if this will help me solve my problem of creating tunneling units. My idea is as follows, please let me know if you think this is/is not possible:

1. Create a new type of route, called tunnel.

2. These new routes would be invisible to any unit without the underground promotion. The underground promotion is only available if that unit is on a tile with a tunnel or tunnel entry/exit improvement.

3. This tunnel entry/exit improvement would be created (a turn or two) by a digging unit or whatever.

4. As soon as that unit is on an entry/exit point, it can cast a spell to go "underground", making it invisible to on ground units.

Game Play/Results:

1. Units can only go underground or come above ground along the tunnels.

2. Tunnels could be dug under impassable terrain or enemy lines (give them invisibility/hidden nationality when underground) simulating Viet Cong type units.

3. Tunnels could collapse from random events or after a while or if enough explosions/bombing from air units.

4. Units underground without tunnel access to entry/exit points have to dig themselves out or remain trapped until rescue.
 
Sorry about the multiples, I figured I would maximize the chances that each various authors would read it. Next time, I will make the one.

Is it relatively easy to make a new route? Charlemagne has the Roman Roads in the scenario, but perhaps those are just renamed and reskinned railways. I am guessing that adding a new route would involve the Plotsquare thingy, and other complicated things.

Alternatively, it could rely totally on the improvements the unit is on, except for the idea of digging to an adjacent tile. Hmmm.
 
XML wise there's no real problem, if you copy the existing entries and just use new graphics. The graphics themselves are another thing.
There are several mods, which add the "roads" from Final Frontier as futuristic roads, so technical it's doable.
 
Just to help debugging:

Version: Civ4 BTS 3.19
Path: mods/zRoutes (/Assets/Python...)

Downloaded from http://forums.civfanatics.com/downloads.php?do=file&id=7867 and installed without any changes. Loaded the mod. Warriors's movement is unrestricted. Archers' movement is unrestricted.

The unedited zRoutes Config.ini is:
Code:
;It is very easy to use this. Here is some example code:
[UNIT_WARRIOR]		;We want to work with the warrior
ROUTE_ROAD = True	;We want the warrior to require that a road be on the plot

[UNITCLASS_ARCHER]	;We want to work with the archer, skirmisher, and bowman
ROUTE_RAILROAD = True	;They all require that a railroad be on the plot

I have no idea, really, but looking through the code I couldn't figure out what was supposed to make it work. Maybe a file is missing in the upload?
 
Python is outdated: getXmlVal() does not work anymore, maybe some other things too.
 
Since there is a request, here is a revised version updated to BtS 3.19.

I didn't try to change the logic of this ModComp, but be aware that, as such, when there is no route on the plot, your units cannot move into it. I'm surprised that nobody made the remark in this thread before! Note that this could be adjusted in Python.

Also, be aware that a unit configured to move only into plots with roads will not be able to enter your cities as soon as the tech for railroads has been researched!

Have fun (or not!...) :p

PS: as Zebra 9 said, if you want to incorporate this into your mod, you will have to change the mod's name inside the Python/Utils/CvModName.py file.
 
Since there is a request, here is a revised version updated to BtS 3.19.

I didn't try to change the logic of this ModComp, but be aware that, as such, when there is no route on the plot, your units cannot move into it. I'm surprised that nobody made the remark in this thread before! Note that this could be adjusted in Python.

Also, be aware that a unit configured to move only into plots with roads will not be able to enter your cities as soon as the tech for railroads has been researched!

Thank you! I can confirm that the zRoutes now works with BTS 3.19 but there's a bug. I mean, it loads and restricts movement, just not quite in the way intended.

I wonder if you'd be willing to consider maybe possibly giving it another look? :goodjob: I've tested the mod several ways and I'm pretty sure it's not user error.

You're right, of course, that if you set a route to TRUE in the zRoutes Config.ini that you won't be able to move that unit type into plots without the route type. This warrior will only be able to travel roads, will only be able to board ships in cities, and won't be able to enter cities after railroads are researched. That's a feature.

Code:
[UNIT_WARRIOR]    ;We want to work with the warrior unit
ROUTE_ROAD = True    ;the warrior is only allowed to move along roads

However, you can't designate two route types. If you do, neither will work. This archer, for example, can't move into plots with roads, railroads, or no routes at all. That's a bug (because he should be able to enter roads and railroads).

Code:
[UNITCLASS_ARCHER]    ;we want to work with the archer unit class
ROUTE_ROAD = True
ROUTE_RAILROAD = True    ;the archer unit class can only move along roads and railroads

I can come up with an XML hack to get around this for my purposes (I'm getting good at those), but it's not nearly as good as zRoutes.
 
You're right, it does not work when two routes are set as True in the Config file.

At first, I thought that there was a problem with this Config file or how it was read, but it isn't the case (I had to learn about ConfigParser and Config files :think:): the problem lies with the Python code and was there since the beginning.

The for loop is problematic: it loops through the routes (in BtS, there is only Road & Railroad), without looking at the plot(s). Since there are two entries in the Config file, one for each route, the condition is met twice and the code goes on to the next step, twice, to check if the plot has the same route as the loop. Automatically, once it is correct and once it is not, which makes the code declare that the unit cannot enter the plot, whether it has a road or a railroad! :crazyeye:

I can change the code one way or another but first, I would like to know what you want to achieve with this. As such, this mod comp is not very practical. Imagine that you have 200 units, adding some each week, if you want them to be allowed to use roads, you would have to add them all in the Config file and updating it regularly.

Some people were mentioning a mobile artillery only available on trains/railroads: it would be easier then to set the road as False than set the railroad as true and even more, a Config file is useless, you might as well insert a list in your code.

The pros of the Config file are that people will feel more comfortable using them and that you have to fill it once only and the code for the Civilopedia (CvPediaUnit.py) reads the same Config file.

Still, no unit can enter a plot without routes and only units with the corresponding route ability can enter a city. Is that needed and interesting?

Not to say that the mixture in the same file of UNIT types and UNITCLASS types complicates the whole thing.
 
For what it's worth, this is the ModComp so far, updated to BtS 3.19 and reviewed according to the two posts above.

Important modification: the Config file now supports the option of NO_ROUTE, in the same format (NO_ROUTE = True).

To be edited now: the CvPediaUnit.py file. Writing this, I realise that it should be adapted as well.

(after a while)... still the Pedia works, it just does not show what happens with the new option NO_ROUTE... and I don't feel like changing it!
 

Attachments

  • zRoutes.rar
    12.6 KB · Views: 348
I can change the code one way or another but first, I would like to know what you want to achieve with this. As such, this mod comp is not very practical. Imagine that you have 200 units, adding some each week, if you want them to be allowed to use roads, you would have to add them all in the Config file and updating it regularly.

Some people were mentioning a mobile artillery only available on trains/railroads: it would be easier then to set the road as False than set the railroad as true and even more, a Config file is useless, you might as well insert a list in your code.

I'm not sure I understand what you're saying. As it works now, only the units listed with routes are restricted. As is any unit not listed is unaffected, and any unit listed without a route specified is unrestricted. The logic is "Cannot enter tile" = TRUE or NULL (FALSE = double TRUE).

Code:
[UNIT_WARRIOR]    ;Unrestricted

[UNIT_SCOUT]    ;Roads only
ROUTE_ROAD = True

[UNIT_ARCHER]    ;Can't move anywhere
ROUTE_ROAD = True
ROUTE_RAILROAD = True

What am I trying to do? Well, I've got this Caravans II modcom, and I'd like to restrict caravans to roads & railroads (and to loading on vessels only at cities/forts).

Still, no unit can enter a plot without routes and only units with the corresponding route ability can enter a city. Is that needed and interesting?

I don't see a use for ROAD+NOT RAILROAD (I've got gypsy horse carts going past my house every day), but I suppose RAILROAD+NOT ROAD would open the possibility for a FREIGHT unit. (Not that interesting, IMO.) My goal is just ROUTE/NO ROUTE, to make the utility of caravans dependent upon the connectivity of the transportation network. Absent an rewrite of zRoutes, I'll just obsolete caravans with railroad.

Not to say that the mixture in the same file of UNIT types and UNITCLASS types complicates the whole thing.

Yeah, I just discovered that I released v1.0 using BUILDING_ instead of BUILDINGCLASS_ so Romans can't build caravans to feed Rome. :D

The for loop is problematic: it loops through the routes (in BtS, there is only Road & Railroad), without looking at the plot(s). Since there are two entries in the Config file, one for each route, the condition is met twice and the code goes on to the next step, twice, to check if the plot has the same route as the loop. Automatically, once it is correct and once it is not, which makes the code declare that the unit cannot enter the plot, whether it has a road or a railroad! :crazyeye:

I don't know Python (yet) but when I saw the for loop I was thinking of changing it out for something like:
1 = ROADS ONLY
2 = RAILROADS ONLY
3 = ROADS and RAILROADS ONLY

Maybe a nested IF statement: IF VAR = 1 THEN roads(TRUE), ELSE IF VAR=2 THEN railroads(TRUE), ELSE IF VAR=3 THEN roadsrailroads(TRUE), ELSE FALSE (no change).

(...was that QBasic?!? What corner of my mind did that crawl out of???)
 
I'm not sure I understand what you're saying. As it works now, only the units listed with routes are restricted. As is any unit not listed is unaffected, and any unit listed without a route specified is unrestricted. The logic is "Cannot enter tile" = TRUE or NULL (FALSE = double TRUE).

What am I trying to do? Well, I've got this Caravans II modcom, and I'd like to restrict caravans to roads & railroads (and to loading on vessels only at cities/forts).

I don't see a use for ROAD+NOT RAILROAD (I've got gypsy horse carts going past my house every day), but I suppose RAILROAD+NOT ROAD would open the possibility for a FREIGHT unit. (Not that interesting, IMO.) My goal is just ROUTE/NO ROUTE, to make the utility of caravans dependent upon the connectivity of the transportation network. Absent an rewrite of zRoutes, I'll just obsolete caravans with railroad.

In the zebra code, any unit which is not listed in the Config file is defaulted as False. His idea was that any unit/unitclass with a True statement in the file would be authorised to go along xyz routes. That's why in the first place I was thinking of reversing the logic to only include units to RESTRICT them some routes and I think that is what you want too: you only want to handle a few units, restricting their movements on roads or railroads.

Edit: True in Config for a specific unit/unitclass on a specific route is translated into False in the unitCannotMoveInto function.
 
@ Patriachica:

For you, I reversed the logic in the CvGameUtils attached.

With this file, you should now only fill the Config file with False, all True being the default.

For example, a caravan could be NO_ROUTE = False. Then the caravan will be obliged to use road or railroad. To even restrict it, for example, caravans cannot use railroad, add: ROUTE_RAILROAD = False.

For a freight train unit: NO_ROUTE = False and ROUTE_ROAD = False.

Probably the Civilopedia will be wrong but right now I'm fed up with this code! :D

Edit: added the revised Python/Screens/CvPediaUnit.py file to show "Cannot move along..." in the Civilopedia. Packed the whole new version with instructions.

Have fun!
 

Attachments

  • zRoutesII.rar
    13.4 KB · Views: 321
@ Patriachica:

I've revised the CvPediaUnit.py file too: see previous post.

Does this version works for you?
 
@ Patriachica:

I've revised the CvPediaUnit.py file too: see previous post.

Does this version works for you?

Sorry. I got knocked offline for a couple days. :mad:

The version you posted (before CvPediaUnit.py) works great. I'm attaching the working mod with instructions etc. I'll give a look at the CvPediaUnit.py in the next couple days.

You're a rock star. :goodjob:
 
You're a rock star. :goodjob:

How did you know?! :band:

But I don't understand what you packed together: it's a mismatch between two different versions, GameUtils from version II and CvPediaUnit + the Config files from version I !!! It's not up to you to do that anyway.

Please delete this attachment as it is confusing.

Edit: packed version II with instructions: see post #56 above.
 
How did you know?! :band:

But I don't understand what you packed together: it's a mismatch between two different versions, GameUtils from version II and CvPediaUnit + the Config files from version I !!! It's not up to you to do that anyway.

Please delete this attachment as it is confusing.

Edit: packed version II with instructions: see post #56 above.

Oops. Cutesy fail. I removed my attachment. Thank you.
 
Top Bottom