Using improvements to make other improvements obsolete

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Post Reply
FriendAtArms
Posts: 34
Joined: Thu Apr 16, 2026 9:35 pm

Using improvements to make other improvements obsolete

Post by FriendAtArms »

I've currently got an improvement called a "Sanctuary", with a small anti-disease effect. Eventually you can build another improvement called a "Hospital", with a big anti-disease effect. My intention is, if you've got a Sanctuary in your city, it keeps working until you build a Hospital, and then becomes obsolete and disappears.

Right now, the Sanctuary's obsolete_by entry says:
obsolete_by =
{ "type", "name", "range"
"Building", "Hospital", "City"
}
I run a test game and build a Hospital in one of my cities. The Sanctuary's name in that city is crossed out and "(O)" is tacked on, so I know it's considered obsolete. Sanctuaries in other cities are unaffected. But then the obsolete Sanctuary sticks around for several turns before the automatic deletion kicks in.

Is that how it's supposed to work? I know that in standard rulesets, Barracks I gets instantly deleted when you research Gunpowder, and I'm not sure why using a technology as the obsolescence condition would be different from using an improvement.

(Of course if worse comes to worst, I can just solve this like I did the "standard Temple vs. Temple of Artemis" problem I posted about earlier. The Sanctuary just loses its effect, rather than being properly "obsolete", leaving its deletion to the player's discretion. But I am curious about whether Freeciv distinguishes between improvement-obsolescence and technology-obsolescence somehow.)
John Campbell
Posts: 20
Joined: Wed Jan 18, 2023 6:57 pm

Re: Using improvements to make other improvements obsolete

Post by John Campbell »

I have something similar with walls, where I have a series of progressively more advanced walls that take progressively more advanced Artillery units to bypass, so there's an arms race between offensive and defensive technology. But I don't want walls to just vanish when the tech to build better ones is developed and leave cities vulnerable even to things that the older walls would protect against. So I have them set up so that you can no longer build obsolete walls after the tech for the newer ones is developed, but the walls don't actually disappear until a newer one is actually built in the city.

So my entry for City Walls, which are the earliest iteration, looks like this:

Code: Select all

[building_city_walls]
name            = _("City Walls")
genus           = "Improvement"
flags           = "VisibleByOthers"
reqs    =
    { "type", "name", "range", "present"
      "Tech", "Masonry", "Player", TRUE
      "Tech", "Construction", "Player", FALSE
    }
graphic = "b.citywalls"
graphic_alt     = "-"
obsolete_by     =
    { "type", "name", "range"
        "Building", "Curtain Walls", "City"
        "Building", "Bastions", "City"
        "Building", "Fortifications", "City"
    }
build_cost      = 60
upkeep          = 1
sabotage        = 50
sound           = "b_city_walls"
sound_alt       = "b_generic"
helptext        = _("\
City Walls make it easier to defend a city.  They give a +200% bonus to the\
 defense strength of units within the city against Land and Wheeled units.  They are\
 ineffective against airborne and sea units as well as artillery units and\
 armored vehicles.\
 City Walls also prevent the loss of population which occurs when a\
 defending unit is destroyed by a ground unit.\
 They are made obsolete by Construction and the development of more\
 effective Curtain Walls; however, old walls remain standing until new ones\
 are built.\
")
Curtain Walls, which are the next iteration up, look like so:

Code: Select all

[building_curtain_walls]
name            = _("Curtain Walls")
genus           = "Improvement"
flags           = "VisibleByOthers"
reqs    =
    { "type", "name", "range", "present"
      "Tech", "Construction", "Player", TRUE
      "Tech", "Military Architecture", "Player", FALSE
    }
graphic = "b.city_walls"
graphic_alt     = "-"
obsolete_by     =
    { "type", "name", "range"
        "Building", "Bastions", "City"
        "Building", "Fortifications", "City"
    }
build_cost      = 60
upkeep          = 1
sabotage        = 50
sound           = "b_city_walls"
sound_alt       = "b_generic"
helptext        = _("\
Curtain Walls make it easier to defend a city.  They give a +200% bonus to\
 the defense strength of units within the city against Land and Wheeled\
 units, as well as Catapults.  They are ineffective against airborne and\
 sea units as well as gunpowder Artillery units and armored vehicles.\
 Curtain Walls also prevent the loss of population which occurs when a\
 defending unit is destroyed by a ground unit.\
 They are made obsolete by Military Architecture and the development of more\
 effective Bastions; however, old walls remain standing until newer ones\
 are built.\
")
And so on.

The practical effect of this is that, when you develop Masonry, you can build City Walls (which I'm thinking about renaming "Palisades", because the City/Curtain Wall distinction keeps confusing even me), which protect against most ground units, but can be bypassed by Catapults or any other Artillery unit. When you develop Construction, you gain the ability to build Curtain Walls, which protect against Catapults, but can still be bypassed by Cannons or better, but lose the ability to build City Walls. However City Walls that were already built don't immediately get sold off like Barracks did. They remain, and remain effective, until you actually build Curtain Walls (or Bastions or Fortifications, which are the next iterations, enabled by Military Architecture and Ferroconcrete Construction, respectively) in the city. Even then, it's not until the turn after the new walls are built that the old ones get sold off. I think the obsolescence check happens before the production check, so on the turn the new walls are built, the old ones aren't yet obsolete when it's checked. You can go in and manually sell them off if you want the cash faster, or just wait until the next turn when they're sold automatically.

I have the wall effects set up to explicitly exclude older walls when there's a newer wall in the city, so they don't double up on the turn between the new ones being built and the old ones being sold off, like so:

Code: Select all

[effect_city_walls]
type    = "Defend_Bonus"
value   = 200
reqs    =
    { "type", "name", "range", "present"
      "Building", "City Walls", "City", TRUE
      "Building", "Great Wall", "Player", FALSE
      "Building", "Curtain Walls", "City", FALSE
      "Building", "Bastions", "City", FALSE
      "Building", "Fortifications", "City", FALSE
      "UnitClass", "Artillery", "Local", FALSE 
      "UnitClass", "Armor", "Local", FALSE 
      "UnitClass", "LTA", "Local", FALSE 
      "UnitClass", "Light Air", "Local", FALSE 
      "UnitClass", "Air", "Local", FALSE 
      "UnitClass", "Helicopter", "Local", FALSE 
      "UnitClass", "Missile", "Local", FALSE 
      "UnitClass", "Sail", "Local", FALSE 
      "UnitClass", "Sea", "Local", FALSE 
      "UnitClass", "Brown Water", "Local", FALSE 
      "UnitClass", "Green Water", "Local", FALSE 
    }
(The Great Wall acts as Curtain Walls in all cities, so it overrides local City Walls, but it doesn't force the sell-off of local City Walls like building actual Curtain Walls or better in the city would. It also never goes obsolete, which is my policy for Wonders that are still extant, but it gets a lot less effective as technology improves and more and more of what the enemy's fielding bypasses it.)

Also, annoyingly, the tech-tree skein generator for the Research tab apparently doesn't distinguish between positive and negative tech requirements, so City Walls appear on the tech tree under both Masonry and Construction, with no indication that the latter makes it so you can't build them. and likewise for the more advanced walls.
FriendAtArms
Posts: 34
Joined: Thu Apr 16, 2026 9:35 pm

Re: Using improvements to make other improvements obsolete

Post by FriendAtArms »

However City Walls that were already built don't immediately get sold off like Barracks did. They remain, and remain effective, until you actually build Curtain Walls
Okay yeah, this is what I'm going for with my Sanctuaries! And it looks like your obsolete_by format is the same as mine, so at least I can be sure I got that part right.
Even then, it's not until the turn after the new walls are built that the old ones get sold off.
This is my main problem. For some reason the older building doesn't get sold off on the turn after, or even the turn after that.

I see you've got True/False entries in the requirements for effect_city_walls. I'll add those to my effect_sanctuary, and see if it helps. Thank you very much!
User avatar
Corbeau
Elite
Posts: 1320
Joined: Mon Jan 13, 2014 11:13 pm

Re: Using improvements to make other improvements obsolete

Post by Corbeau »

What I have in my Sim ruleset is that you can build (medieval) Workshop/Manufaktur, but once you build a Factory in the city, the Manufaktur becomes a museum and gives you 2 Gold instead of 2 Production. You may want to think about what would be the effect of the older walls once the new ones are built. Do they make the new ones' upkeep cheaper? Do they add to defence? Are they actually in the way? Are they a tourist attraction?
--
* Freeciv LongTurn, a community of one-turn-per-day players and developers
* LongTurn Blog - information nexus with stuff and stuff and stuff
* Longturn Discord server; real-time chatting, discussing, quarrelling, trolling, gaslighting...
Dino the Dinosore
Hardened
Posts: 231
Joined: Sun Dec 31, 2017 3:41 am

Re: Using improvements to make other improvements obsolete

Post by Dino the Dinosore »

Also, annoyingly, the tech-tree skein generator for the Research tab apparently doesn't distinguish between positive and negative tech requirements, so City Walls appear on the tech tree under both Masonry and Construction, with no indication that the latter makes it so you can't build them. and likewise for the more advanced walls.
That looks like a bug to me, maybe start a ticket for it.

Related - if you have > 1 tech as a positive req for a unit (maybe for buildings also), that unit shows up in multiple techs. Which I think is the right thing to do.

And speaking of obsolete_by, civ2civ3 buildings.ruleset has this for Barracks, which I don't understand -

Code: Select all

obsolete_by	=
    { "type", "name", "range"
      "Tech", "Gunpowder", "Player"
      "Building", "Barracks II", "City"
      "Building", "Barracks III", "City"
    }
Since you can't build Barracks II without having Gunpowder, isn't that redundant?
cazfi
Elite
Posts: 3488
Joined: Tue Jan 29, 2013 6:54 pm

Re: Using improvements to make other improvements obsolete

Post by cazfi »

Dino the Dinosore wrote: Thu Jun 11, 2026 8:36 pmSince you can't build Barracks II without having Gunpowder, isn't that redundant?
Even when you cannot build Barracks II by yourself, you may conquer a city with one.
Post Reply