Advertisement
Civilization Fanatics' Center  

Go Back   Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization

Reply
 
Thread Tools
Old May 05, 2012, 03:55 AM   #1
zez
Chieftain
 
Join Date: Oct 2010
Posts: 4
Restricting unit to road/railroad

Working on some mod ideas but as my knowledge of CiV lua etc is quite limited I thought to ask around if anyone would know.

Would it be possible to make a unit only be able to move on roads and/or railroads?

And if so would you any hints how to do this?

Thank you in advance.
zez is offline   Reply With Quote
Old May 05, 2012, 04:02 AM   #2
ww2commander
Proud father and civ-nut!
 
ww2commander's Avatar
 
Join Date: Aug 2003
Location: Eastern Front
Posts: 1,137
Others might correct me if wrong, but the closest way that comes to mind is to trigger a check event via the GameEvents.UnitSetXY function.

The only limitation to this is that the event triggers once the unit has moved to another tile which might not contain a road/rail and thus you would need to 'teleport' it back to its original location and then adjust its movement via SetMoves.

Hope this makes sense! I have thought about this many times myself but have put it on the low priority list of things to figure out via LUA.
__________________
“The Pope? How many divisions has he got?”
Josef Stalin

Current Project: The Great Patriotic War - WWII on the Eastern Front
ww2commander is offline   Reply With Quote
Old May 05, 2012, 04:13 AM   #3
Gedemon
Modder
 
Gedemon's Avatar
 
Join Date: Oct 2004
Location: France
Posts: 4,692
Can't be done without a new game events like Unit:CanEnterPlot(pPlot) or the DLL access. And I'd like a Unit:CanAttackPlot(pPlot) too.
Gedemon is offline   Reply With Quote
Old May 05, 2012, 05:26 AM   #4
whoward69
Deity
 
Join Date: May 2011
Location: Near Portsmouth, UK
Posts: 4,260
You could do it by re-writing the INTERFACEMODE_MOVE_TO handlers in InGame.lua, but
1) it would be a LOT of work
2) it would break almost every other mod out there
3) get it wrong and you'd break the game big time!
__________________
All my mods (.civ5mod files) can be downloaded from http://www.picknmixmods.com/. If you want to incorporate (parts of) my mods into your own mod(s), please read this first

Logging Attach mod File attributes UI Tutorials My Changes Mod DDS Basics Custom Game DLL Tutorials My DLL Source Unit Art Files Civ XML Files
whoward69 is online now   Reply With Quote
Old May 05, 2012, 07:26 PM   #5
Spatzimaus
Mad Scientist
 
Spatzimaus's Avatar
 
Join Date: Sep 2005
Location: Los Angeles, CA
Posts: 3,063
Quote:
Originally Posted by whoward69 View Post
You could do it by re-writing the INTERFACEMODE_MOVE_TO handlers in InGame.lua, but...
Also, the AI wouldn't be bound by that, as it doesn't use the interface. So any interface override would be restricted solely to the active player.

Honestly, this sort of thing would just be asking for trouble, even if we COULD do it easily. All you'd have to do is pillage one railroad tile (or even just park your unit on the rails) and suddenly your opponent's units can't go anywhere; besides the fact that the AI wouldn't do that to the player, the player could build a few redundant rail spurs to compensate for those rare situations when the AI would sit on the rail lines. AI limitations are the single biggest hurdle for major modding, and this one's especially bad for that as so much of the AI's behavior when creating road networks is handled internally.

Now, if you want it to be less absolute, there's a really easy XML solution: increase the movement costs for all terrain types (so instead of 1/2 MP per hex, it could be soemthing more like 1/5/20), but then go into the Routes table and make roads/railroads give a larger movement discount. This'd allow units to move respectable distances with roads/railroads, but across unimproved land they'd go very slowly.
The downside to this is that it'd be very hard to have it apply only to a small number of units; your only real way around this is to give units that aren't limited to roads the "all terrain costs 1 MP" promotion. And forests/hills would lose their ability to impede early-era movement if you did this.
__________________
Once upon a time there was the Ages of Man mod set. Then Firaxis broke it. But thanks to the DLL efforts of the community, the mods shall rise again!
Spatzimaus is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization > Restricting unit to road/railroad

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Advertisement

All times are GMT -6. The time now is 12:40 AM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
This site is copyright © Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR