modding city defense bonus

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Post Reply
NotAnyoneSpecial
Posts: 19
Joined: Wed Feb 27, 2013 10:08 am

modding city defense bonus

Post by NotAnyoneSpecial »

Is it possible to mod the city defense bonus in rulesets, for example eliminating the 50% bonus land units get while stationed in cities?
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: modding city defense bonus

Post by bard »

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"
    }
User avatar
GriffonSpade
Elite
Posts: 578
Joined: Mon Apr 29, 2013 4:41 pm

Re: modding city defense bonus

Post by GriffonSpade »

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"
    }
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/.
NotAnyoneSpecial
Posts: 19
Joined: Wed Feb 27, 2013 10:08 am

Re: modding city defense bonus

Post by NotAnyoneSpecial »

After managing to find the source code (it's actually really easy to find, i was just stupid), I confirmed that much like fortified bonus. The city bonus is hardcoded:

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; 	}
source: line 543 http://svn.gna.org/viewcvs/freeciv/trun ... iew=markup

This is a problem because one of the pecuilarites of the Freeciv ruleset is that it difers from the civ2 one in that the city walls SHOULDN'T apply with the fortified bonus. That is not defense * fortified [1.5x] * citywall [3x] but actually defense * fortified [1.5x] OR defense * citywall [3x].
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.
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: modding city defense bonus

Post by bard »

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.
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).

Code: Select all

[effect_city_walls]
type    = "Defend_Bonus"
value	= 100
reqs	=
    { "type", "name", "range"
      "Building", "City Walls", "City"
      "UnitClass", "Land", "Local"
    }
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/.
I subscribe that.
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: modding city defense bonus

Post by bard »

I have a related question...
Is it possible to give a bonus to defense to all units adjacent to a city with walls? I tested this with no success:

Code: Select all

[effect_city_walls]
type    = "Defend_Bonus"
value   = 50
reqs   =
    { "type", "name", "range"
      "Building", "City Walls", "City"
      "CityTile", "Center", "Adjacent"
    }
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: modding city defense bonus

Post by cazfi »

bard wrote:

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.

As for your question; no, unfortunately "Building" requirement is not supported at "Adjacent" range (See doc/README.effects)
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: modding city defense bonus

Post by bard »

Ok, thanks.
Btw, whats the difference between City and Local range for a building?
(someday I'll try to understand the code related to ruleset effects and to stop making these kind of questions... :)
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: modding city defense bonus

Post by cazfi »

bard wrote:Btw, whats the difference between City and Local range for a building?
"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:(someday I'll try to understand the code related to ruleset effects and to stop making these kind of questions... :)
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.
Post Reply