Resource icon

Unit Fuel Mod 2016-10-05

Unit Fuel Mod
By: Grey Fox

Version: 1.1 - Last Updated 04/08/2008
Patch Compatibility: BTS v3.13
NOTICE: This mod is not intended as a standalone mod, but as a system for other mods to incorporate into theirs and to further modify it to their wishes. But example changes have been made and a new building have been added, so it can be played as a mod. I will hopefully add more features to this mod in the future, but as I do not have an internet connection at home, the updates can be sporadic.



What Is the Unit Fuel Mod?
This mod adds the attribute iFuel to units. If you set the attribute to above 0 the unit will require fuel to move and operate. If a land unit runs out of fuel it can't move. If a sea unit runs out of fuel it will sink. I chose not to add any fuel value for Air units in this example mod, since they are always situated in a location where they would be refueled.
But if you want to use the Global Fuel part of this mod giving Air units fuel might be a good idea.
(Currently only Gunships require fuel).

This mod consists of two parts. The Unit Fuel attribute, and the Global Fuel attribute which is a Player attribute and just like Gold tells you how much money you have. The player's Fuel determines how much fuel your units have access to.

Example with Global Fuel activated:
- if your civilization has 60 Fuel and a fuel income of 100 per turn, you can't build a destroyer which requires 300 Fuel
- if a tank that has been out in the field comes to a city to refuel and you have a total of 1400 Fuel, and your Tank has 35 Fuel, the next turn (you need to rest the unit in the city one turn to refuel) your total fuel will be 1365 (+any fuel income).

New Global Defines have been added to enable/disable the two systems:
- FUEL_SYSTEM_ACTIVE to enable or disable the entire mod
- GLOBAL_FUEL_SYSTEM_ACTIVE to enable or disable the Global Fuel system

There are also Global Defines to control fuel spending.

NEW!(v.1.1)
Fuel income is now determined in the Civ4BonusInfos.xml, this means that multiple types of bonuses can now give fuel.

On the main interface, next to the Gold display, you can see how much fuel your civilization has atm. As well as your fuel income per turn.

XML (All New Tags Are Optional)

Spoiler :

All changes marked with:
<!-- UnitFuel: Added by GreyFox xx/xx/200x -->
(where xx/xx/200x is the date, it should be 03/28/2008 on all currently)
<!-- UnitFuel: End Add ->

CIV4UnitInfos.xml
- iFuel

CIV4PromotionInfos.xml
- bUnlimitedFuel

CIV4BuildingInfos.xml
- iGlobalFuelModifier

NEW!(v.1.1)
CIV4BonusInfos.xml
- iFuelPerTurn

Supplied with the mod is two modules;
- FuelUnits: Tank, Modern Armor, etc with fuel attribute
- Refinery: A new example building to test the iGlobalFuelModifier


Python
Spoiler :

All changes marked with:
# UnitFuel: Added by Grey Fox
# UnitFUel: End Add

MainInterface.py
- To display fuel on units and for the player.
CvUnitFuelEvents.py (custom event manager)
- onUnitBuilt(): To set promotions on build
CvUnitFuelUtils.py
- doFuel(): Used to update how much fuel you get from various sources
You can use this to override the SDK function run every turn
- cannotTrain(): Guess what this does


SDK (following methods exposed to python)
Spoiler :

The Changed SDK Files have been supplied with the mod in the
"Changed SDK Files"-folder located in the root folder of the mod.

All changes in the SDK marked with:
//UnitFuel: Added by Grey Fox xx/xx/200x (filename.cpp/h)
//UnitFuel: End Add

Functions exposed to python:

CyUnitInfo
- int getFuel()

CyPromotionInfo
- bool isUnlimitedFuel()

CyBuildingInfo
-int getTileSpaceChange()

CyCultureLevelInfo
-int getTileSpaceChange()

CyUnit
- int getFuel()
- int getFuelLeft()
- void setFuel(int iNewValue)
- void changeFuel(int iChange)
- void setFuelLeft(int iNewValue)
- void changeFuelLeft(int iChange)
- bool isUnlimitedFuel()

CyPlayer
- int getFuel()
- int getFuelPerTurn()
- void setFuel(int iNewValue)
- void changeFuel(int iChange)

"Terms" of Use:
All I ask if you do use this mod, is the following:
• Give credit where credit is due (to the author).

• Let me know personally of any major enhancements you may give to this mod (I promise to give you credit if I use it/them in future versions!)​
Credits and Thanks
Programmed by GreyFox
Includes graphics made by Sevo.

Spoiler Changelog :

----------------
Version 1.1
----------------

Fixes:
- Fixed a bug where units who started with 0 fuel couldn't move.
- Added CvEnums.h in the Changed SDK Folder. Sorry for forgetting that last version.

Additions
- Added iFuelPerTurn to Civ4BonusInfos.xml
- Added the FUEL_RESTORED_IN_CITIES Define, which defines whether or not fuel should be restored to units in cities.

Removed
- The Defines that determined what Bonus gave Fuel and how much it gave.
This is now done through Civ4BonusInfos instead.
Author
Grey Fox
Downloads
488
Views
488
First release
Last update
Rating
4.00 star(s) 3 ratings

More resources from Grey Fox

Top Bottom