Food Supply

You could tie this to the "avoid growth" button, so whenever the food bar fills, a caravan unit is created with the excess. Or if that's not possible, perhaps a buildable caravan unit that has a spell that just drains all of the stored food and adds it to the unit (to reduce micro).

Could the amount of food be tracked by a promotion? I'm no modder, but I think I remember reading that FF has the ability to have N-unlimited stacking promos. Would it be a drain on the computing time if you had a unit that has 30+ copies of the same promo?
 
I know how to solve this.

How do we link two units intrisically, so that they can't work without each other?

COMMANDERS!

Or more specifically, the commander system.

Assign one unit as the commander ('Exporter' unit).
He would have a "Trade Food" spell. This would grant him a stackable promotion, which could only be cast when in a city, and when that city has surplus food (python needed probably). It's effects:

Increases Command Limit by 1
gives -2 Food in the city
Gives the "Food Importer" promotion to Followers.
Held

And on the other hand, we'd have an "Importer" unit, which could be joined to the Exporter. He would have no purpose except to join the exporter unit. Doing so would grant him the Food Importer promotion, which gives +1.5 (or maybe just +1) food, in the city he's standing in.

Essentially, the exporter would be able to cast Trade Food as many times as the city's food supply can support. Each casting would increase his drain on the city's food, but also increase the number of exporters he can have following him, thusly redistributing food across the empire. You could put multiple exporters in one city to transport a lot of food.

There would be a minor period of waste, between the importer joining an exporter, then moving to where he's supposed to be, but once that's over, you'd be able to use floodplain farm metropolises to fund your outer mining colonies. Using units also gives a supply line that can be targeted by enemies. If someone assassinates the Exporter, it could do a lot of damage to your empire. Adding more tactical depth.

The only problems I can forsee:

How to prevent normal units from joining the Exporter?
Maybe have the Food Importer promotion apply only to null unitcombat, and assign the importers that.
 
Don't even need to cast spells. Just use CityBonus tags to add/remove food.

To prevent the joining of normal units, don't use CommandLimit, just use a python check for a spell which allows Importers to join Exporters, but only if the Exporter has more "I eat your food" promotions than he has attached Importers.
 
The problem with that solution, is that python and modules are incompatible things. Modules are all the rage for modmods these days :)

Notably, they don't require maintenance, and can easily be ported between versions. If python is added, it requires the author to include and maintain their own spellinterface, unless we incorporate their code into a patch.
But I don't really think it'd be necessary to involve python. If it were done how I suggested, the only python part would be figuring out if the city has surplus food. Is there any way to accomplish this via xml. Or would it even need to be done?

Perhaps it could be allowed, to starve a city by taking food when it has no surplus. The only thing I'd worry about then is a possible exploit where you could continually drain infinite food from a throwaway size 1 city that feeds the rest of your empire, since a city can't shrink below size 1 through starvation.
 
just use a python check

I thought python was cheating. (ie, it needs to be modular.)

I think WarKirby's scheme needs to be tweaked. I haven't actually used the master/minion/slave promos, so maybe I'm wrong, but I think this would work better:

Exporter unit has spell that summons an Importer. The Importer starts with the "Importing Food" Promotion and gives the stackable "MasterPromotion" "Export Food" to the Exporter. "Export Food" still makes exporter immobile.

Master/Slave relationship rather than Commander/Follower, so no messing about with command limits or others trying to join up.

So, if I'm reading this correctly, any lost Importer will Cost the Exporter 1 "Export Food" promo. A lost Exporter will eliminate all the connected Importers. I suggest a gold cost for casting the spell, btw, and/or a gold cost for the promotion.
 
I thought python was cheating. (ie, it needs to be modular.)

I think WarKirby's scheme needs to be tweaked. I haven't actually used the master/minion/slave promos, so maybe I'm wrong, but I think this would work better:

Exporter unit has spell that summons an Importer. The Importer starts with the "Importing Food" Promotion and gives the stackable "MasterPromotion" "Export Food" to the Exporter. "Export Food" still makes exporter immobile.

Master/Slave relationship rather than Commander/Follower, so no messing about with command limits or others trying to join up.

So, if I'm reading this correctly, any lost Importer will Cost the Exporter 1 "Export Food" promo. A lost Exporter will eliminate all the connected Importers. I suggest a gold cost for casting the spell, btw, and/or a gold cost for the promotion.

This was actually my first thought, but I seem to remember hearing that master/slave and commander/follower relationships are different. So I assumed that wouldn't work. Do commander promotions work with summoned minions as well ?

Also, incorporating gold costs sounds like a nice idea, but perhaps a bit too balanced in combination with the inefficiency. I do like that idea better though. So perhaps this would work best with full food efficiency. Lose 2, gain 2. just with gold costs associated for moving it around. Each importer could have extra maintenance costs, and a 25-50 one off cost on the Commission Food Trader spell (I think that's a better name)
 
Actually the Master/Slave relationship is different in almost exactly the way you want it to be different. You can still only have 1 Master, but now there isn't a limitation on the range at which you apply promotions to one another And if the Master dies, it auto-cleans the slaves for you. You could even have the Summoned Slave units be capable of Rebasing so that they can instantly move to any city you own, but can never be anywhere EXCEPT in a city.

And personally I don't think Modules tend to be an ideal method to implement something which is a completely new mechanic. You run into too many walls. But you might be able to pull off most of this by module.


Exporter = Unit who can summon Importers. Held, but can Rebase?

Importer = Summoned unit who starts with the "Sending Food" promotion that is CityBonus = -1 Food, and applies a Stack Effect "Getting Food" promotion to their Master which is CityBonus +1 food.

Summon Importer would be an Ability (damn Amurites) which ignores HasCasted, and summons a TEMPORARY Importer (if Permanent, you can only have 1), but the "Sending Food" promotion also grants +1 Duration Per Turn (effectively making the summon permanent)

Importer can Rebase, but cannot move.
 
So you will begin managing food this way in FF for patch c perhaps? or is it a module? I know nothing about modulating :)
 
It would need some playtesting in practice, first. It's a new mechanic so more of a significant addition than just a new unit, for example. Expect to see it in a module before it's an official part of FF. The good thing about modules, even if made by teammembers, is that we can throw caution and balance to the wind and experiment with cool stuff. Safe in the knowledge that it can just be easily turned off, or is otherwise optional to the end user. See Bannor chain of Command as an example :)

Also, as mentioned before, modules require almost no maintenance efforts, so it's make once and then just copy it into the folder for future versions. As opposed to a more traditional modmod like FFPlus, which valk has to maintain and update with each new FF version. But as mentioned also, modules have limitations, like the inability to add any python code, and certainly can't modify the dll. Xienwolf has lifted a lot of the xml restrictions though. I'm not sure if there's anything now in xml that can't be done modularly. Or at least anything you'd ever want to do.




Rebasing: Seems like a good idea, but perhaps too good. For example, if we used an importer unit that has to actually move to the target city, then it would mean that.

1. Sending food to cities across the sea would be impossible unless you have ships to transport it

2. Enemies would be able to cut off the supply to a city, by assassinating the importer, and blockading the road to the city so that another one can't get in. Effectively cutting off the food supply of a city during a siege.

3. A safe route from export to destination would be required in order to initiate the trade route.

I think these weaknesses, would add a bit more immersion and fun to the concept, rather than ust making the unit instantly able to teleport between cities.
 
This is pretty much exactly how I was doing it. :D Now I don't have to. Good. I'm going to continue slacking off and being generally retired. :D
 
If it were done how I suggested, the only python part would be figuring out if the city has surplus food. Is there any way to accomplish this via xml.

Yes, but it requires python.:)

The PyRequirement tag of SpellInfos.xml is really just python code that is "compiled" and evaluated each time it is needed.

So using a PyRequirement along the lines of
Code:
<PyRequirement>pPlot.getPlotCity().foodDifference(True) > 0</PyRequirement>
should have the same effects as adding a python function to CvSpellInterface.py that does the same thing.

The downside is a small performance hit, though I doubt it is large enough to notice in this case. Just don't add another four hundred lines of code.
 
Yes, but it requires python.:)

The PyRequirement tag of SpellInfos.xml is really just python code that is "compiled" and evaluated each time it is needed.

So using a PyRequirement along the lines of
Code:
<PyRequirement>pPlot.getPlotCity().foodDifference(True) > 0</PyRequirement>
should have the same effects as adding a python function to CvSpellInterface.py that does the same thing.

The downside is a small performance hit, though I doubt it is large enough to notice in this case. Just don't add another four hundred lines of code.

Does this seriously work? I've never heard it mentioned before.
 
Does this seriously work? I've never heard it mentioned before.
Sure. I just tested with:
Code:
		<SpellInfo>			<!-- Test spell -->
			<Type>SPELL_test_spell</Type>
			<Description>Test Spell</Description>
			<bAllowAI>0</bAllowAI>
			<bDisplayWhenDisabled>1</bDisplayWhenDisabled>
			<bHasCasted>1</bHasCasted>
			<AddPromotionType1>PROMOTION_SPIDER_TEXTUS</AddPromotionType1>
			<bBuffCasterOnly>1</bBuffCasterOnly>
			<PyRequirement>pCaster.plot().getPlotCity().foodDifference(True) > 0</PyRequirement>
			<Effect>EFFECT_SPELL1</Effect>
			<Sound>AS3D_SPELL_MUTATION</Sound>
			<Button>Art/Interface/Buttons/Promotions/Mutated.dds</Button>
		</SpellInfo>

Note that the PyRequirement is slightly different from the original version, I didn't think that one though 100%.

EDIT:
Actually, it seems like imports in the PyRequirement doesn't work, I guess import was disabled in exec to make it safer to use. Simple, one-liner reqs and results are possible though.

EDIT2:
Actually, it does work provided I write correct code, rather than random scribblings. See this post for some exposition.

Spoiler :
EDIT:Maybe it's possible somehow, but I don't have the knowledge to make it work.

Some further rambling:
It should even be possible to import a python module in the req, so you could do something along the lines of:
Code:
<PyRequirement>import foodfurther;foodfurther.enoughFoodForWhatINeedToDo(pCaster)</PyRequirement>

Essentially use the same format as all other spells, only preface the function with "import yourmodule;"
The semicolon could be replaced with a newline, only I don't know enough xml to format the string properly.

Provided Firaxis haven't done anything strange with the import statement in their python machine, only the first import will compile the module. Subsequent imports will just fetch the cached module.

Obviously, you'd need to place your module somewhere civ IV can find it.
 
This seems too good to be true. I wonder why xienwolf never mentioned this before.
Have you tested importing python from a module in 0.51 ? are you certain that works ?
 
Never mentioned it before because I bloody hate python so don't look for tricks in it :p

Also, Python is a white-space dependent language, main reason I hate it, and that is probably the reason you cannot evaluate multiple lines in the PyReq. Figure out a way to write an import and a call in a single line in a python file and it should be allowed in the PyReq
 
I find that programming is much easier if I actually read the source code, rather than look at the first character and guess what the rest is. :(

Never mentioned it before because I bloody hate python so don't look for tricks in it :p

Also, Python is a white-space dependent language, main reason I hate it, and that is probably the reason you cannot evaluate multiple lines in the PyReq. Figure out a way to write an import and a call in a single line in a python file and it should be allowed in the PyReq

No the line actually was just a single line. The reason it didn't work is because eval was used, not exec . eval evaluates and returns an expression, I tried to use statements.

Anyway, as an example, here is Vitalize from my module, modified to not need changing of CvSpellInteface.py :
Code:
<SpellInfo>			<!-- Vitalize -->
    <Type>SPELL_VITALIZE</Type>
    <Description>TXT_KEY_SPELL_VITALIZE</Description>
    <Civilopedia>TXT_KEY_SPELL_VITALIZE_PEDIA</Civilopedia>
    <Help>TXT_KEY_SPELL_VITALIZE_HELP</Help>
    <PromotionPrereq1>PROMOTION_NATURE3</PromotionPrereq1>
    <bAllowAI>1</bAllowAI>
    <bDisplayWhenDisabled>1</bDisplayWhenDisabled>
    <bHasCasted>1</bHasCasted>
    <iDelay>7</iDelay>
    <PyResult>__import__('odmod').spellVitalize(pCaster)</PyResult>
    <PyRequirement>__import__('odmod').reqVitalize(pCaster)</PyRequirement>
    <Effect>EFFECT_VITALIZE</Effect>
    <Sound>AS3D_SPELL_SANCTIFY</Sound>
    <Button>Art/Interface/Buttons/Spells/Vitalize.dds</Button>
</SpellInfo>

The relevant code is __import__('odmod').reqVitalize(pCaster). (And ditto for PyResult.)

The original was odmod.reqVitalize(pCaster), which requires an import odmod in CvSpellInterface.py.

The python module odmod, id est the file odmod.py , still needs to be somewhere civ IV looks for it of course, I stuck it in the python folder.

I don't know if this will cause horrible performance issues. Imports are normally cached by python, so the second and subsequent times the __import__('odmod') should be quick.
 
For balance issues, would this be unbroken for Kurio civ? Or are they weak enough that it would balance things out?
 
What if a dummy spell were made, only containing the import line. Surely the engine would have to run that import when it's trying to check if the spell is castable, and import the file in doing so. so that calls to future python functions within the imported file should work.
Am I on the right path of thinking here?
 
Hmm, this trick would be useful to make some python thingies (more) modular.
 
Back
Top Bottom