modding city defense bonus
Posted: Sat Mar 25, 2017 4:12 am
Is it possible to mod the city defense bonus in rulesets, for example eliminating the 50% bonus land units get while stationed in cities?
Freeciv - because civilization should be free!
https://forum.freeciv.org/f/
Code: Select all
type = "Defend_Bonus"
value = 50
reqs =
{ "type", "name", "range"
"CityTile", "Center", "Local"
}
I believe Fortify/City defense bonus is still pretty hardcoded. A fact that makes me terribly, terribly sad. That, along with being unable to mess around with whether terrain bonuses should add or multiply with other defense bonus factors, WHICH units get terrain bonuses, and how much (ie x1, x2, etc.) are what is holding me back.bard wrote:There are rulesets with extra bonuses to defense in city that do can be modded. Open the file effects.ruleset (placed in a folder with the same name than the ruleset). Then search for "Defend_Bonus", until you find an effect like this:
Code: Select all
type = "Defend_Bonus" value = 50 reqs = { "type", "name", "range" "CityTile", "Center", "Local" }
Code: Select all
if ((pcity || fortified)
&& uclass_has_flag(utype_class(def_type), UCF_CAN_FORTIFY)
&& !utype_has_flag(def_type, UTYF_CANT_FORTIFY)) {
defensepower = (defensepower * 3) / 2; }
You can change the bonus of the wall in the ruleset, by changing the file effects.ruleset. But is not exactly the same, because the bonus will be reduced for all units, not only the ones that can fortify. (Note that all unit requisites like UnitClass must match the attacker, not the defender).NotAnyoneSpecial wrote: While this is trivial to fix ie making the wall bonus only be double: city wall [2.0x] not city wall [3.0x], I was still trying to find a way to remove the bonus for ruleset purposes.
Code: Select all
[effect_city_walls]
type = "Defend_Bonus"
value = 100
reqs =
{ "type", "name", "range"
"Building", "City Walls", "City"
"UnitClass", "Land", "Local"
}
I subscribe that.GriffonSpade wrote: I believe Fortify/City defense bonus is still pretty hardcoded. A fact that makes me terribly, terribly sad. That, along with being unable to mess around with whether terrain bonuses should add or multiply with other defense bonus factors, WHICH units get terrain bonuses, and how much (ie x1, x2, etc.) are what is holding me back.
You can try to work around it, but it's a pain and it'll never be /just right/.
Code: Select all
[effect_city_walls]
type = "Defend_Bonus"
value = 50
reqs =
{ "type", "name", "range"
"Building", "City Walls", "City"
"CityTile", "Center", "Adjacent"
}
Those reqs mean that there needs to be cities in adjacent tiles (like is possible in civ1) and one in current tile has City Walls.bard wrote:Code: Select all
[effect_city_walls] type = "Defend_Bonus" value = 50 reqs = { "type", "name", "range" "Building", "City Walls", "City" "CityTile", "Center", "Adjacent" }
"City" means that the building must be in the city. "Local" would mean that the effect is to that building only (I don't think there's any effects where this would be realized at the moment - we don't have building targeting effects) Similar to output bonuses that target one kind of output only; "Science" "Local"bard wrote:Btw, whats the difference between City and Local range for a building?
Sometimes things like these are somewhat arbitrary. The effects system gives the general framework, but the code implementing the details has still something to say case-by-case.bard wrote:(someday I'll try to understand the code related to ruleset effects and to stop making these kind of questions...