[SDK MODCOMP] Unit Fuel Mod (includes Global Fuel)

Well the AI don't know their units got fuel. Except when it comes to building the units.
 
Yeah, atm. For now I leave it to you modders to solve that problem in your mod.
 
Great idea!

Well first of all by moding it i discovered that CvEnums.h file did not have
CHAR_FUEL, CHAR_FOREVER. I got VC++ 2005 compiling errors.

I inserted these two char types and all is OK now.

New ideas:
To make it clear for AI this mod has to be little modified.

Algorithm should be something like this:
If fueltank is empty use mission "Logistics" to supply new fuel (this was used in Axis and Allies) or make this option avalibe for AI only? Because the idea is to make himan game interresting and harder :)

Logistics should provide certain amount of new fuel per turn.
for example:
25 units of 70 in your territory per turn if not stationed in city
10 units of 70 in neutral territory per turn
5 units of 70 in enemy territory per turn

Aircrafts should consume fuel instead of use this as moves. Every mission should take certain amount of fuel. If you lack fuel you lack air missions.

I tested your mod. I don't know what is the real problem but the game turn rate time increased dramatically ca 50%. I guess this mod nees some serious optimization.
 
New ideas:

To make it clear for AI this mod has to be little modified.


Algorithm should be something like this:

If fueltank is empty use mission "Logistics" to supply new fuel (this was used in Axis and Allies) or make this option avalibe for AI only? Because the idea is to make himan game interresting and harder


No offense, but I really wouldn't want to see this in the game. Adding a new mission type that the player is just going to have to run 100 times for his units in the field is the worst sort of repetitive micromanagement, what we want to avoid at all costs. Worse yet, it's going to make the AI turns even longer, since it'd have to run the same thing PLUS you'd have to tell it when to run it.

Now, what I'd suggest is an entirely automated process. It'll be a bit tricky to figure out how to do it. Basically, if a unit is within your borders, you ought to assume it's in supply. (Big assumption, I know, but it makes things simpler without having to invoke local storage.) Outside is where the problems come in. This is why I would simply advocate having a global storage and if your supply hits zero, then all mechanized units stop moving. Not the best solution, but simple enough for now.



Aircrafts should consume fuel instead of use this as moves. Every mission should take certain amount of fuel. If you lack fuel you lack air missions.


I agree with this and will be implementing that when I do a modified version for Q.R. :)


I tested your mod. I don't know what is the real problem but the game turn rate time increased dramatically ca 50%. I guess this mod nees some serious optimization.


Yikes! I hope we can cut down on that! :eek: Is it just the AI turn time or also the time it takes to move a unit to a distant tile?
 
I've tested the mod in-game now and have a few observations:

1) When you send a ship to a city if it's running low on fuel, it won't refuel unless it's one of your own cities. Makes sense, as you couldn't refuel in just any city, but only the ones that have your oil. However, in cases of teams, open borders, and alliances, I suppose this could get tricky.

2) If you lose access to oil, you still can't build anything that requires fuel even if your stockpiles are absurdly high, like 5000. I realize this gets into Quantitative Resources a bit, but it makes no sense to me that you cannot train anything that requires fuel if you have 5000 fuel already stored. The fact that you don't presently have an operational oil well would be irrelevant - oil would be all around you! :crazyeye:

3) The fuel stockpile is not saved with the game! :eek: This is an absolute necessity, since if you were very low on oil and had, say, only one raw source but 10000 fuel already stockpiled, once you reloaded you'd be very limited in your production capability.

EDIT: When you resupply at a city, the fuel also doesn't seem to be deducted from the global counter. It's got to come from somewhere. :hmm:
 
is the cvenumsinterface.h the same as the last version because if not, you need to repost it.
 
Haven't read the entire thread, so forgive me if I'm repeating something already said. it occurs to me that, if you have an iFuel attribute, then you could have an iFood attribute too. This way, the pre-industrial eras can also feature logistics, and long sailing journeys and scouting missions become a LOT more interesting ;).

Aussie_Lurker.
 
Haven't read the entire thread, so forgive me if I'm repeating something already said. it occurs to me that, if you have an iFuel attribute, then you could have an iFood attribute too. This way, the pre-industrial eras can also feature logistics, and long sailing journeys and scouting missions become a LOT more interesting ;).

Aussie_Lurker.

I am actually thinking about adapting this to use an extra "supply" feature as well, but there are several questions on how it would be implemented.

How do you simulate resupplying apart from docking in a port (or driving to a city)? In the real world, modern ships don't necessarily have to land to take on supplies - other ships (or planes) can ferry out resources to them. In ancient times, ships could land on islands and forage for fruit and food.

I would think you'd need to automatically resupply any unit within your cultural borders, so long as the global supply is above zero, since presumably you'd have available transport capacity within your own cities. Once you step outside, however, things get tricky very fast. This is partly what stopped my idea for naval unit ranges.
 
I am actually thinking about adapting this to use an extra "supply" feature as well, but there are several questions on how it would be implemented.

How do you simulate resupplying apart from docking in a port (or driving to a city)? In the real world, modern ships don't necessarily have to land to take on supplies - other ships (or planes) can ferry out resources to them. In ancient times, ships could land on islands and forage for fruit and food.

I would think you'd need to automatically resupply any unit within your cultural borders, so long as the global supply is above zero, since presumably you'd have available transport capacity within your own cities. Once you step outside, however, things get tricky very fast. This is partly what stopped my idea for naval unit ranges.

The problem with autmatic supply I find is that you have no control. So, let's say you have enough supplies to feed 75% of your troops... you would think that you'd want to feed those that are most important (location, strength, promotions, etc.) first and then feed whatever's left next. But if you're just cycling through the units, it's going to just resupply whatever's first in the index.

You could code it to take certain qualities into account, but that's imperfect and will ultimately drag down system resources as well.

But at the same time, the idea of Supply Wagon/Ship units is just absolutely horrible IMO...

I've also scratched my head about how to limit (and ultimately attack) supply in the field, but I haven't come up with any kind of method that seems both logical and simple. You can't just check if a plot is connected to your capital because an enemy plot never will be. But one would think that if the defending player positions their armies between your troops and your base of supplies, that this should cut you off from supply. How do you do this? I have not found any way to reasonably determine things like this.
 
The problem with autmatic supply I find is that you have no control. So, let's say you have enough supplies to feed 75% of your troops... you would think that you'd want to feed those that are most important (location, strength, promotions, etc.) first and then feed whatever's left next. But if you're just cycling through the units, it's going to just resupply whatever's first in the index.

You could code it to take certain qualities into account, but that's imperfect and will ultimately drag down system resources as well.

But at the same time, the idea of Supply Wagon/Ship units is just absolutely horrible IMO...

I've also scratched my head about how to limit (and ultimately attack) supply in the field, but I haven't come up with any kind of method that seems both logical and simple. You can't just check if a plot is connected to your capital because an enemy plot never will be. But one would think that if the defending player positions their armies between your troops and your base of supplies, that this should cut you off from supply. How do you do this? I have not found any way to reasonably determine things like this.

Yep, that's another major drawback. :( A solution would be to resort to local supplies, like in Hearts of Iron (which is my inspiration for this system, since I wanted to use it for my WWII scenario) but then you've got two new problems: how to teach the AI to manage local supplies through automated transfer, and how to set this up with supply trains/planes so it's mostly automatic. Not to mention all the extra coding that would go into creating individual city storage in the first place. :crazyeye:

The slightly easier solution I thought of is to ditch the individual fuel altogether, and draw from one global stockpile. Until it hits zero, all mechanized units can function. Once it does, none of them functions, or else they have reduced strength and movement. Not the best solution in the world, but perhaps the better of two evils.
 
I have some specific goals for a fuel mod, for a Mad Max mod I have been working on (see my sig for the thread). This fuel modcomp does almost exactly what I want for one part of it. As you may recall, in the Mad Max setting fuel is very rare and precious, so it is important to track. This modcomp will do that. But, there are two things I don't think this modcomp does. Maybe if there is active development, these two could be added? I have not yet tried SDK level development so this is beyond me right now.

1. I would like units which are out of fuel, to have a reduced strength but not be destroyed. Ideally I would like it to be possible to capture them; but a reduced strength indicates they will at least put on a "last stand" while disabled.

2. I see there are strong opinions about this in the thread, but I would like an option to have fuel *transferred* from one unit to another. Specifically, I would like to have a building which creates a specific unit -- Fuel Truck -- which has a large fuel capacity. When you send out an army to invade somebody, you won't have enough fuel to get back, so you send along one or two of these trucks. When the fighting units get low on fuel in neutral/enemy territory, you use a "refuel" button on the fuel truck. The unit is consumed (optional) and the fuel is transferred evenly to all the other units in the stack.

I can see that the modpack plus some XML would allow creating and filling the fuel truck; the only bit missing is to transfer fuel. This is sort of like the way the Great General unit can be consumed to divide a number of XP's among all the units in the stack.
 
Has anyone done any spin-off mods on this yet? If so I'm interested in your results.

Also, sorry for any mistakes in the uploaded files. I will correct them whenever I can.
 
Yes, I have been doing a lot of work with the mod. :) I changed the resupply system to be more automatic: all units within your cultural borders, or within friendly territory, that are on a tile which is connected to your trade network automatically get resupplied each turn. The trade connection is necessary to simulate blockades. If your soldiers get trapped somewhere behind enemy lines, they can't get adequately resupplied.

That reminds me, when a unit is upgraded, the fuel is not set to the new value correctly. For example, if you upgrade a Warrior to a Mobile SAM, the new SAM starts with no fuel and just sits there because it can't move.

Also, I found a bug in CvUnit.cpp in the section that governs what to do if there is a fuel shortage when a unit tries to refuel. You had:

Code:
setFuelLeft(GET_PLAYER(getOwnerINLINE()).getFuel());

And it should be something like:

Code:
setFuelLeft(getFuelLeft()+GET_PLAYER(getOwnerINLINE()).getFuel());

Because if not, the unit in question will lose its surplus fuel. For instance, if you had 50 fuel left globally, and a carrier that had 150 fuel was trying to resupply itself in port, then instead of draining your reserves (which would leave it with 200 fuel), its new supply gets set to 50.

This mod has been very helpful for my Quantitative Resources project, and you've done a great job in adding an entirely new game mechanic to Civilization. That doesn't happen every day. Keep up the good work! :thumbsup:
 
Sounds great. Keep me updated. :)

I don't have much time to work on this mod since I have two heavy mods in progress atm. So it would be nice if you could post a link once you have something to release. (Try to release when you have something that is stable and functional rather than perfect, then you get bug testers for free :P )
 
Since you made refueling automatic within your trading network, it would then be really cool to make a modification that, during war, you take military control over your opponents square, and you don't even have to leave your unit to maintain control. In other words, once you step on a square during war it is yours until the enemy reclaims it. Once you encircle the enemy you effectively cut off his supply of oil, because he is in an exclave.

Also, maybe consider making an "ammunition" mod that works very similar except iron is the resource and it affects all modern units. I think that would be very good and wouldn't be too complicated to make and wouldn't make the game anymore confusing.
 
Back
Top Bottom