[SDK MODCOMP] Mech Route

Shqype

Shqyptar
Joined
Nov 15, 2005
Messages
2,468
Location
New York + Shqypni
This modcomp has been improved, updated, and expanded. It is now called Route Restricter. The development thread is: http://forums.civfanatics.com/showthread.php?t=267632
Spoiler :
Mech Route SDK Mod Component

This was requested by Snafusmith for his upcoming WWI mod, Blood and Iron, but I'm sure others in the community have use for it.

What it does: if a unit is bMechanized, then that unit can only move on plots with existing routes, ie roads or railroads. Zebra 9 has created a similar modcomp in Python which allows an .ini configuration file to set which units can only travel on which routes, but this is simpler and done in C++, effectively eliminating any lag that might ensue from the Python route.

I have enclosed both the source code and the mod itself, which includes the DLL I compiled and the proper XML to make it work: the text file for the new tag I created, and the CIV4UnitInfos.xml file. Note that I have made sure no unit besides the Mech Infantry is Mechanized. This is solely for testing purposes: just keep in mind that no units should have <bMechanized> set to "1" unless you plan on restricting that unit's movement to routes alone (roads and railroads).

To see what I changed in the source code, just search for "Shqype," as I have commented all my additions with either "Shqype Start" and "Shqype End" for multi-line additions, or "Shqype Add" for one-line additions. The <bMechanized> tag is not used by Firaxis, so it shouldn't cause any trouble. This way is convenient because you don't have to alter the schema at all :)

I'd like to give special thanks to Kael, because his extremely useful tutorial gave me insight and instruction on completing this modcomp, my first ever standalone SDK mod component.

Enjoy, and let me know if there are any problems or criticisms that you may have.

 
Very interesting! However it sounds like it could create problems for units which are technically mechanized but which should still be able to cross empty terrain, like the open desert or seas. (I can think of tanks and battleships to start...) Would you consider creating an entirely new tag such as <bRoutesReq> for this purpose?

Either way, it sounds like a great job in coding. :thumbsup:

EDIT: Yes, I know that bMechanized is not used by default, but I am working on adapting the oil counter to BtS, which does use it, so I guess what I'm saying is that the two will be incompatible. :lol: Anyway, good show. :D
 
Very interesting! However it sounds like it could create problems for units which are technically mechanized but which should still be able to cross empty terrain, like the open desert or seas. (I can think of tanks and battleships to start...) Would you consider creating an entirely new tag such as <bRoutesReq> for this purpose?

Either way, it sounds like a great job in coding. :thumbsup:

EDIT: Yes, I know that bMechanized is not used by default, but I am working on adapting the oil counter to BtS, which does use it, so I guess what I'm saying is that the two will be incompatible. :lol: Anyway, good show. :D

Thanks for the kind words, Gaius. :)

As for a new tag, that would probably be the best option if one wanted to use bMechanized for something else; nor would it be too difficult, especially with Kael's tutorial and all. But I aimed for simplicity. I saw a simple fix, and made it for the desired effect. Planes and Tanks and Ships might be bMechanized in the vanilla game, but we both know that tag isn't used, so you do a simple replace all like I have done and set that tag to 0 if you want them to be allowed to traverse any terrain and not just plots with routes present.

I realize it would not be compatible outright with your mod if you use bMechanized, but if I were you I would (instead of using bMechanized) create a new int tag that determines how many units of oil each unit needs to move. The default can be 0 if the unit requires no oil, 1 if it requires 1 unit, 2 if it requires 2 units, etc. I'd say the bMechanized would be only 1 of 2 tags needed if you were to do it that way ... so 1 tag which does everything would be a better solution in my opinion. :)
 
I realize it would not be compatible outright with your mod if you use bMechanized, but if I were you I would (instead of using bMechanized) create a new int tag that determines how many units of oil each unit needs to move. The default can be 0 if the unit requires no oil, 1 if it requires 1 unit, 2 if it requires 2 units, etc. I'd say the bMechanized would be only 1 of 2 tags needed if you were to do it that way ... so 1 tag which does everything would be a better solution in my opinion. :)

Yep, that's the way Duke176 tried to do it, and that's essentially what I'll be doing. He's got a pretty good tutorial on how to do that though he ran into some SDK problems toward the end.

Where is Kael's tutorial on this? :mischief:
 
Linked in the first post: http://forums.civfanatics.com/showthread.php?t=166935

Here's something a bit "crazy" (which I'd eventually like to be able to do) ... instead of restricting it to oil, make it so that each unit has a "Resource Needed" branch (much like UnitCombat Attack Bonuses) that will allow you to set which resource a unit needs, and how many. That's pretty crazy though, :lol:
 
most excellent Shqype !

this is a very much handy mod,

this can turn gameplay to be even more stratigic, and tactical!.

well done for doing this mod with c++ rather then python.

keep developing mod packs like this one,
the mini mods like this one, really affect the entire gameplay,
keep popping this sorts more!
(i have ideas...)

well done shqype.

keldath.
 

Thanks for that. :)

Here's something a bit "crazy" (which I'd eventually like to be able to do) ... instead of restricting it to oil, make it so that each unit has a "Resource Needed" branch (much like UnitCombat Attack Bonuses) that will allow you to set which resource a unit needs, and how many. That's pretty crazy though, :lol:

You mean something like, oh, say, Quantitative Resources? :lol: :mischief:
 
Awesome work! I agree with GO though that some mechanised units should be able to drive on other terrain.

Wouldn't be hard to do as another XML tag in Civ4UnitInfos.xml
 
Great work, I really appreciate it! Does this include a way to restrict movement to specifically roads or specifically railroads, or does it just restrict them to the tile having one or the other. Basicallly, does this include a way to restrict something to just roads or just railroads?
 
Keldath, thanks for the praise, and I'm glad that you like it. :)

Thanks Dale! It feels good to hear that from someone such as you ;)

Smitty: this simply restricts movement to routes for all units set to bMechanized. I chose a simple solution for a simple modcomp. Tags can be added as needed, and for Blood and Iron we can always make exceptions to the rule (for, let's say, rail cars). Lemme know what you're gonna need and I'll do what I can to achieve it.


GO and Dale:
I can understand about some units needing to travel on all terrain (tanks, for example, are especially built to traverse all types of terrain, like sand) ... but in such an instance all you would need to do in CIV4UnitInfos.xml is set <bMechanized > to 0, and it won't be restricted only to plots with routes.

Sure, a tank is "mechanized," but since the bool tag <bMechanized> isn't used for anything else, I don't see why one would need to keep a tank (or other machine) with that tag set to true. Only make a unit <bMechanized> if you want to limit its movement to roads and railroads.

Maybe I'm not explaining myself clearly enough, or maybe there's something I'm completely missing ... but I trust you guys will enlighten me. :goodjob:
 
No, I looked through the SDK and couldn't figure out where bMechanized was ever used, so you're probably safe. :D
 
No, I looked through the SDK and couldn't figure out where bMechanized was ever used, so you're probably safe. :D

I know I am, I checked, I had to declare its use as a bool myself :p
 
I guess he mean some units should be able to only travel at flatlands, without forrest. But yea that would require another tag.

Anyway good modcomp :). :thumbsup: Mods like this keeps me from losing interest in Civ4 where most moddest just add more of same thing.
 
Zuul
hey,

well,
i think its no problem to limit some units to certain lands -
theres a tag in the xml that that serves this purpose,

like ships that cannot enter ocean,
you can define units, to be prevented access to , say grass, mountains, hills and so on.

i think this can be done easly.
 
I guess he mean some units should be able to only travel at flatlands, without forrest. But yea that would require another tag.

All I can say is... don't worry about this one ;)
 
Actually I'm fairly sure that animations make use of the bMech tag. And I'm fairly sure formations use it too. Nothing too serious though. :)

I'd still like to see it done "properly", but that's for another time maybe. ;)
 
Well, I've essentially added in the Civ3 Wheeled tag. A unit flagged as a wheeled unit cannot enter tiles with hills, certain kinds of features (Jungles & Forests) UNLESS these tiles have a route. So it's not a simple restriction to routes only. Like I said, the conditions are exactly the same as the Civ3 option.

I've included this in my upcoming modcomp release. So... Dale, save yourself the work and get something else done instead ;)
 
Actually I'm fairly sure that animations make use of the bMech tag. And I'm fairly sure formations use it too. Nothing too serious though. :)

I'd still like to see it done "properly", but that's for another time maybe. ;)

You're right Dale, I'll look into expanding the functionality. But, there's no rush for now ... I'm currently working on 2 other modcomps that are much better than this one ;)
 
Well, I've essentially added in the Civ3 Wheeled tag. A unit flagged as a wheeled unit cannot enter tiles with hills, certain kinds of features (Jungles & Forests) UNLESS these tiles have a route. So it's not a simple restriction to routes only. Like I said, the conditions are exactly the same as the Civ3 option.

I've included this in my upcoming modcomp release. So... Dale, save yourself the work and get something else done instead ;)

Sounds better. Think an XML based unit by unit method is more flexible though. Tracked vehicles have problems with hilly terrain as well as wheeled and todays 8x8 and even 10x10 are not far behind tracks in rough terrain.

Dan
 
Back
Top Bottom