Page 1 of 1

Unit requirements on Upkeep_Factor effect

Posted: Thu May 20, 2021 12:50 am
by soundnfury
Currently the Upkeep_Factor effect can only have requirements on Player and Output_Type. Since upkeep is always being calculated for a specific unit, it should be possible to condition on details of the unit (e.g. unit flags).

Ideally, the unit's homecity should also be available to requirements, so that e.g. buildings can do more interesting things with upkeep than just Unit_Upkeep_Free_Per_City.

Re: Unit requirements on Upkeep_Factor effect

Posted: Mon May 24, 2021 9:41 am
by nef
The homecity requirement raises the issue concerning Civ I compliance for unhappy uk. (The unit must be IN the homecity to avoid the unhappy uk.)

Re: Unit requirements on Upkeep_Factor effect

Posted: Mon May 24, 2021 7:18 pm
by Ignatus
nef wrote:The homecity requirement raises the issue concerning Civ I compliance for unhappy uk. (The unit must be IN the homecity to avoid the unhappy uk.)
Well, we just don't have this CivI feature, wether we do have any reqs on Upkeep_Factor or not (this effect is not about happiness any way). Neither do we have a requirement that tells us if a unit is in its own home city (may be a variant of "UnitState"). (Also, CivI has its own way of determining the home city of a bribed unit - it takes not the home city of the diplo but the closest bribing player's city, and looks for one only in some area and thus sometimes makes the bribed unit free.)

Re: Unit requirements on Upkeep_Factor effect

Posted: Mon May 31, 2021 10:03 am
by nef
Ignatus wrote: (Also, CivI has its own way of determining the home city of a bribed unit - it takes not the home city of the diplo but the closest bribing player's city, and looks for one only in some area and thus sometimes makes the bribed unit free.)
I believe this is exactly the same as the hut enter algorithm - in my version published for civ1 ruleset. I have tried some code to do this for bribed units but have run foul of problems with tolua facilities. Avoiding a server crash makes for ugly code. (edit.unit_kill causes the crash, but in part due to bad design of the callbacks unit_built, unit_killed. I have on my TODO list some workaround using extra unit types, but this too has some problems.)