More flexible Attack_Bonus (and Range)

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Post Reply
User avatar
soundnfury
Posts: 28
Joined: Sat Apr 11, 2020 12:09 pm

More flexible Attack_Bonus (and Range)

Post by soundnfury »

In my Aviation ruleset I want to be able to have a building Sector Control, whose effect is "50% attack bonus to friendly units attacking Air units within the city's borders (i.e. City_Radius_Sq)". There are two things I would need to make that possible:
  1. Defender unit reqs for Attack_Bonus (currently the reqs use the attacking unit only)
  2. A Range value of City_Radius to specify "defender is within city borders" (rather than the current City range, which AIUI applies only to a city containing the defending unit)
For (1) it might make sense to have separate AttackerType and DefenderType (and AttackerClass and AttackerFlag, etc.) requirement types, with the existing Unit ones being kept as aliases for whichever they currently mean on any given effect.
As an alternative to (2), City_Adjacent (search any city adjacent to the defender's tile) could also work.
In either case, the range would need to only count cities belonging to the attacking player — the bonus shouldn't be given to enemies!

Stretch goal: I also want a Great Wonder, Dowding System, which acts as a Sector Control in every city. range=Player wouldn't quite do what I want, as it'd apply over the whole map rather than just "within borders of any friendly city", so I'd need yet another new Range value, Player_City_Radius, to mean "within City_Radius of any Player city" (and for symmetry one could also implement Alliance_City_Radius and World_City_Radius with the obvious semantics).

I realise this is all pretty complex and not very generic, so it's unlikely to happen. But hey, the board is called Wishlist ;)
Creator of the Aviation ruleset. Try it out today!
cazfi
Elite
Posts: 3103
Joined: Tue Jan 29, 2013 6:54 pm

Re: More flexible Attack_Bonus (and Range)

Post by cazfi »

soundnfury wrote:City_Adjacent (search any city adjacent to the defender's tile) could also work.
"CityTile", "Center", "Adjacent" ?
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: More flexible Attack_Bonus (and Range)

Post by Ignatus »

soundnfury wrote:In my Aviation ruleset I want to be able to have a building Sector Control, whose effect is "50% attack bonus to friendly units attacking Air units within the city's borders (i.e. City_Radius_Sq)". There are two things I would need to make that possible:
  1. Defender unit reqs for Attack_Bonus (currently the reqs use the attacking unit only)
  2. A Range value of City_Radius to specify "defender is within city borders" (rather than the current City range, which AIUI applies only to a city containing the defending unit)
(1) - in v.3.1 we likely shall have defender-related defense bonus HRM#867744
(2) - a Lua kludge could place some extra on tiles within city radii if the building is built in a city and add/remove it on radius changes (building_built, build_lost, city_size_change signals).
User avatar
soundnfury
Posts: 28
Joined: Sat Apr 11, 2020 12:09 pm

Re: More flexible Attack_Bonus (and Range)

Post by soundnfury »

cazfi wrote:
soundnfury wrote:City_Adjacent (search any city adjacent to the defender's tile) could also work.
"CityTile", "Center", "Adjacent" ?
AIUI that just tests that you are adjacent to a city; I don't see how to combine it with "and that city contains building X". Unless having both in the same reqs vector forces them to apply to the same city, but I'd expect not.
Ignatus wrote:(1) - in v.3.1 we likely shall have defender-related defense bonus HRM#867744
Intriguing. I guess "33% defence malus" accomplishes the same effect as I'm after.
Ignatus wrote:(2) - a Lua kludge could place some extra on tiles within city radii if the building is built in a city and add/remove it on radius changes (building_built, build_lost, city_size_change signals).
Sounds plausible; guess I'll have to learn some Lua then ;)

Thanks for the help, and I look forward to using this when the time comes to port my ruleset to 3.1 :)
Creator of the Aviation ruleset. Try it out today!
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: More flexible Attack_Bonus (and Range)

Post by Ignatus »

soundnfury wrote: AIUI that just tests that you are adjacent to a city; I don't see how to combine it with "and that city contains building X". Unless having both in the same reqs vector forces them to apply to the same city, but I'd expect not.
Yes, alas, almost all unit-ranged effects consider a city only when a unit is on its center.
Post Reply