Advertisement
Civilization Fanatics' Center  

Welcome to Civilization Fanatics' Center.

You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support.

Go Back   Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Mod Components

Notices

Reply
 
Thread Tools
Old Mar 29, 2008, 08:27 PM   #1
Grey Fox
Master of Points
 
Grey Fox's Avatar
 
Join Date: Dec 2001
Location: Sweden
Posts: 8,727
Images: 1
Civ4 BTS [SDK MODCOMP] Unit Fuel Mod (includes Global Fuel)

Unit Fuel Mod
By: Grey Fox

Version: 1.1 - Last Updated 04/08/2008
Patch Compatibility: BTS v3.13
Download Mod v1.1
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.
Spoiler for Interface:

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 for 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.
Attached Thumbnails
Click image for larger version

Name:	UnitFuel_Interface.jpg
Views:	2559
Size:	367.4 KB
ID:	172756  
__________________
GreyFox.ME - a blog about Gaming and Me | Latest Article | Latest Comic | Latest Image | Latest Video
@GreyFoxMe
| ~SolidDread | Read Welcome To China! | My Mods | Chat about FfH stuff @ #erebus

Member of the R i f E team. | Rise from Erebus - R i f E | Blog| Wiki | Forum

Last edited by Grey Fox; Apr 08, 2008 at 07:46 AM.
Grey Fox is offline   Reply With Quote
Old Mar 29, 2008, 08:36 PM   #2
Shqype
Shqyptar
 
Shqype's Avatar
 
Join Date: Nov 2005
Location: New York + Shqypni
Posts: 2,466
Images: 2
Seems interesting, and useful for World War mods.

I know Gaius Octavius was working on something along these lines.

Good work, nonetheless
__________________
BtS Rallying Call: Renaissance Mod of Eastern European Battles against the Ottoman Turks!
Chechen Republic: Chechnya civilization! - Euzkadi: Basque civilization

Ancient Illyria and Ethnic Albania BTS 3.13 compatible! - Kosova Republik Modular for BTS
[BTS SDK MODCOMPS]: Route Restricter (Restrict a unit's movement to roads, railroads, or both!), BuildingCitySizePrereq (Assign city size requirements before cities can construct buildings), Vicinity Bonus (Set units/buildings to only be constructed if resources are in a city's workable radius)
How to pronounce my username (with audio samples)
Shqype is offline   Reply With Quote
Old Mar 29, 2008, 09:40 PM   #3
Gaius Octavius
Deity
 
Gaius Octavius's Avatar
 
Join Date: Jul 2006
Posts: 4,016
Bravo, Grey Fox, this will make it much easier for me to generalize for Quantified Resources.

I must admit I'm not too crazy about the ships sinking or the need to move into a city to get refueled, but that shouldn't be too hard to change. You've undoubtedly simplified my work by a factor of ten.

Quick question: is the cannot train portion of it handled exclusively in SDK, or did you invoke the Python check? (Might be an issue on big maps as far as slowdown goes.)
Gaius Octavius is offline   Reply With Quote
Old Mar 29, 2008, 09:47 PM   #4
Grey Fox
Master of Points
 
Grey Fox's Avatar
 
Join Date: Dec 2001
Location: Sweden
Posts: 8,727
Images: 1
I used the python cannotTrain for simplicity, (simpler to remove and change for the user of the mod) but it can easily be moved to the SDK.

Yeah the ships sinking is easily removed. The need for a city to refuel is a one-line change. You could change it so that the unit needs to be in your territory, or whatever. Maybe write a function to check how far from home the unit is etc.
__________________
GreyFox.ME - a blog about Gaming and Me | Latest Article | Latest Comic | Latest Image | Latest Video
@GreyFoxMe
| ~SolidDread | Read Welcome To China! | My Mods | Chat about FfH stuff @ #erebus

Member of the R i f E team. | Rise from Erebus - R i f E | Blog| Wiki | Forum
Grey Fox is offline   Reply With Quote
Old Mar 29, 2008, 09:53 PM   #5
Gaius Octavius
Deity
 
Gaius Octavius's Avatar
 
Join Date: Jul 2006
Posts: 4,016
Yeah, I was even thinking about combining this with a dynamic supply line, so that naval units have specific ranges beyond which they cannot travel without starting to lose supplies. There's lots of possibilities here.
Gaius Octavius is offline   Reply With Quote
Old Mar 29, 2008, 10:22 PM   #6
keldath
LivE LonG AnD PrOsPeR
 
keldath's Avatar
 
Join Date: Dec 2005
Location: israel
Posts: 4,855
wow,

incredible mod and idea, juust what i needed to spice things up.

just perfect,

one quastion, does the ai will know how to manipulate this feature? is it aware not to spend all of his fual and avoid reaching zeor fual?

bravo indeed.
__________________
keldath is offline   Reply With Quote
Old Mar 29, 2008, 10:26 PM   #7
Gaius Octavius
Deity
 
Gaius Octavius's Avatar
 
Join Date: Jul 2006
Posts: 4,016
Quote:
Originally Posted by keldath View Post
one quastion, does the ai will know how to manipulate this feature? is it aware not to spend all of his fual and avoid reaching zeor fual?
I would think a more important feature would be to train the AI to seek as much fuel as possible, so that it tries to avoid getting down to zero, if possible. I guess that's essentially what you were saying.
Gaius Octavius is offline   Reply With Quote
Old Mar 29, 2008, 10:43 PM   #8
Grey Fox
Master of Points
 
Grey Fox's Avatar
 
Join Date: Dec 2001
Location: Sweden
Posts: 8,727
Images: 1
No changes to the AI has been made so far.
__________________
GreyFox.ME - a blog about Gaming and Me | Latest Article | Latest Comic | Latest Image | Latest Video
@GreyFoxMe
| ~SolidDread | Read Welcome To China! | My Mods | Chat about FfH stuff @ #erebus

Member of the R i f E team. | Rise from Erebus - R i f E | Blog| Wiki | Forum
Grey Fox is offline   Reply With Quote
Old Mar 29, 2008, 11:00 PM   #9
Gaius Octavius
Deity
 
Gaius Octavius's Avatar
 
Join Date: Jul 2006
Posts: 4,016
Quote:
Originally Posted by Grey Fox View Post
No changes to the AI has been made so far.
No worries, it may not even be an issue.

I nominate this mod for discussion in the next Apolyton ModCast.
Gaius Octavius is offline   Reply With Quote
Old Mar 29, 2008, 11:37 PM   #10
Shqype
Shqyptar
 
Shqype's Avatar
 
Join Date: Nov 2005
Location: New York + Shqypni
Posts: 2,466
Images: 2
Quote:
Originally Posted by Gaius Octavius View Post
No worries, it may not even be an issue.

I nominate this mod for discussion in the next Apolyton ModCast.
I think it will be an issue. The AI will not understand that it's running low on fuel and has to "rebase" in order to resupply. Even if you implement code when the unit is running low on fuel that it should make its way back to the nearest city when it reaches a certain fuel level, the AI still will not have the human understanding that it might not need to refuel because it's on a suicide mission or may conquer an enemy city and rebase there instead.


But, this mod is better than I thought on my initial first glance. I love what you've done with the interface: it looks great!

Very nice job
__________________
BtS Rallying Call: Renaissance Mod of Eastern European Battles against the Ottoman Turks!
Chechen Republic: Chechnya civilization! - Euzkadi: Basque civilization

Ancient Illyria and Ethnic Albania BTS 3.13 compatible! - Kosova Republik Modular for BTS
[BTS SDK MODCOMPS]: Route Restricter (Restrict a unit's movement to roads, railroads, or both!), BuildingCitySizePrereq (Assign city size requirements before cities can construct buildings), Vicinity Bonus (Set units/buildings to only be constructed if resources are in a city's workable radius)
How to pronounce my username (with audio samples)
Shqype is offline   Reply With Quote
Old Mar 30, 2008, 12:16 AM   #11
keldath
LivE LonG AnD PrOsPeR
 
keldath's Avatar
 
Join Date: Dec 2005
Location: israel
Posts: 4,855
Quote:
Originally Posted by Shqype View Post
I think it will be an issue. The AI will not understand that it's running low on fuel and has to "rebase" in order to resupply. Even if you implement code when the unit is running low on fuel that it should make its way back to the nearest city when it reaches a certain fuel level, the AI still will not have the human understanding that it might not need to refuel because it's on a suicide mission or may conquer an enemy city and rebase there instead.
:
i agree,

this mod is crucial to ai use, they ai will max out his fual, and wouldnt know how to raise the amount of fual.

also ships will surly sink.

i love this mod idea it gives a whole different strategy tactics,
indeed i would rather wait until some upadatewill be made to the ai prior i integrate this modcomp to my overlord2,

another suggestion grey,

pehaps to aircrafts you can come up with some system that will make airmissions to "cost" fual? this will be some answer to the fual with aircrafts

also,
does helicopters , counts as air? meaning can the current version can be applied to heli's aswell?


i will watch closely on this thread , it gives a suitble answer to everyone who talked about quantetive resuorse system ...

keep up the develomment and this great promissing addition.

***edit***

oh two more thing, i think it would be proper to create a refuling unit, some unit that can affect fueled units and refill them, maybe in a system , with a small area of effect, say like you have a tank needs refueling, you fortify or make it rest in the vacinity of the refueling unit .

second,
i would also suggest,
making fuel , tradble between nations, fuel agreements and such - wow so much possibilities with this mod
__________________

Last edited by keldath; Mar 30, 2008 at 12:32 AM.
keldath is offline   Reply With Quote
Old Mar 30, 2008, 12:21 AM   #12
Grey Fox
Master of Points
 
Grey Fox's Avatar
 
Join Date: Dec 2001
Location: Sweden
Posts: 8,727
Images: 1
Helicopters are land units so they function as tanks would. (And don't crash if they run out of fuel, helicopters can land ya know)

If anyone want to give the AI update of this mod a stab, be my guest. I will probably not be able to update this for a while since I don't have a internet connection at home.
__________________
GreyFox.ME - a blog about Gaming and Me | Latest Article | Latest Comic | Latest Image | Latest Video
@GreyFoxMe
| ~SolidDread | Read Welcome To China! | My Mods | Chat about FfH stuff @ #erebus

Member of the R i f E team. | Rise from Erebus - R i f E | Blog| Wiki | Forum
Grey Fox is offline   Reply With Quote
Old Mar 30, 2008, 01:07 AM   #13
keldath
LivE LonG AnD PrOsPeR
 
keldath's Avatar
 
Join Date: Dec 2005
Location: israel
Posts: 4,855
ye heli's can land hehe...sometimes..

well, ill integate this mod comp today into overlord2, then release it to the public,
and then ill report you hows the ai doing .

well, if you dont hvae int at home,
im sending you a box through the post, return it to me in a disc, dont worry , the stamps on me.
__________________
keldath is offline   Reply With Quote
Old Mar 30, 2008, 03:37 AM   #14
Ninja2
Great Engineer
 
Ninja2's Avatar
 
Join Date: Nov 2005
Location: Denmarkia
Posts: 1,142
This is an extremely interesting mod. Thanks for the work, Grey Fox!
__________________
Merged Mod: A combination of Wolfshanze's 1850-1920 mod, Dales Combat mod, Influence Driven War and GIR's Partisan mod, all built on top of the Better AI! Download

"The memory of spectacular failure eclipses that of enduring success."
Ninja2 is offline   Reply With Quote
Old Mar 30, 2008, 03:53 AM   #15
Grey Fox
Master of Points
 
Grey Fox's Avatar
 
Join Date: Dec 2001
Location: Sweden
Posts: 8,727
Images: 1
Oh yeah, I forgot to mention. This mod is built on top of Bhruic's Unofficial patch.
__________________
GreyFox.ME - a blog about Gaming and Me | Latest Article | Latest Comic | Latest Image | Latest Video
@GreyFoxMe
| ~SolidDread | Read Welcome To China! | My Mods | Chat about FfH stuff @ #erebus

Member of the R i f E team. | Rise from Erebus - R i f E | Blog| Wiki | Forum
Grey Fox is offline   Reply With Quote
Old Mar 30, 2008, 08:06 AM   #16
keldath
LivE LonG AnD PrOsPeR
 
keldath's Avatar
 
Join Date: Dec 2005
Location: israel
Posts: 4,855
grey,
your still working on interstellar c'?
__________________
keldath is offline   Reply With Quote
Old Mar 30, 2008, 09:26 AM   #17
Gaius Octavius
Deity
 
Gaius Octavius's Avatar
 
Join Date: Jul 2006
Posts: 4,016
Quote:
Originally Posted by Shqype View Post
I think it will be an issue. The AI will not understand that it's running low on fuel and has to "rebase" in order to resupply.
Quote:
Originally Posted by keldath View Post
i agree,
this mod is crucial to ai use, they ai will max out his fual, and wouldnt know how to raise the amount of fual.
Which is why I would suggest removing the rebase micromanagement altogether...

Here's a related question: can you tie the AI thinking into resources directly? What I mean is, how does the AI judge the value of specific resources, such as oil? Does it assign an intrinsic value, or does it judge it based on the number of units currently available (by tech) that need oil in order to be trained? What I'm thinking is, if it's just a flat intrinsic value, then you could increase that value and make fuel directly proportional to the number of oil resources a player has. This way, the AI will be less likely to run out, because it would already be seeking new supplies by default.
Gaius Octavius is offline   Reply With Quote
Old Mar 30, 2008, 09:58 AM   #18
Grey Fox
Master of Points
 
Grey Fox's Avatar
 
Join Date: Dec 2001
Location: Sweden
Posts: 8,727
Images: 1
Removing the need for units to return to cities to refuel would make it a whole lot easier, yeah.

Anyways, I will be AWOL awhile again now. So I see ya all when I see ya. Hopefully with updates from both sides!
__________________
GreyFox.ME - a blog about Gaming and Me | Latest Article | Latest Comic | Latest Image | Latest Video
@GreyFoxMe
| ~SolidDread | Read Welcome To China! | My Mods | Chat about FfH stuff @ #erebus

Member of the R i f E team. | Rise from Erebus - R i f E | Blog| Wiki | Forum
Grey Fox is offline   Reply With Quote
Old Mar 30, 2008, 10:31 AM   #19
keldath
LivE LonG AnD PrOsPeR
 
keldath's Avatar
 
Join Date: Dec 2005
Location: israel
Posts: 4,855
goodluck grey,

we will be waiting.
__________________
keldath is offline   Reply With Quote
Old Apr 05, 2008, 02:49 PM   #20
lamppost4
Holder of the Light
 
lamppost4's Avatar
 
Join Date: Jan 2007
Location: Over Yonder
Posts: 286
If you remove the need to return to cities to refuel, can u keep that version up for those of us who would like it. Also, is the fuel based on a resource like oil?
lamppost4 is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Mod Components > [SDK MODCOMP] Unit Fuel Mod (includes Global Fuel)

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
The fuel for the future ?? Rik Meleet Science & Technology 36 Apr 26, 2008 11:44 AM
New Unit Storage/Fuel/Ammo Ability yoshi Civ3 Conquests - Requests, Fixes, & Changes 26 Oct 23, 2003 09:21 AM
Jet Fuel gozpel Humor & Jokes 1 Aug 31, 2003 07:58 AM
Enemy air unit having unlimited fuel? Valdy.com Civ2 - General Discussions 8 May 02, 2001 08:14 AM


Advertisement

All times are GMT -6. The time now is 09:27 PM.


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