Help needed to implement strategic resources

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Post Reply
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Help needed to implement strategic resources

Post by bard »

I want to introduce in my earth scenario the idea of strategic resources, so some units can be cheaper when your city have access to certan resource. For example, knights being cheaper to upgrade or upkeep if there is Iron within the city radius.

There is a new requirement in v2.5 that seems to make it possible:

Code: Select all

reqs    =
    { "type", "name", "range"
      "Resource", "Iron", "City"
    }
However, I'm unable to find any effect where this condition actually works. I have tried:

Code: Select all

type    = "Upgrade_Unit"
value   = 1
reqs    =
    { "type", "name", "range"
      "Resource", "Iron", "City"
    }

type    = "Upgrade_Price_Pct"
value   = -50
reqs    =
    { "type", "name", "range"
      "Resource", "Iron", "City"
    }

type    = "Upkeep_Factor"
value   = 1
nreqs    =
    { "type", "name", "range"
      "Resource", "Iron", "City"
    }
The only effect I found that seems to work is Unit_Upkeep_Free_Per_City, but since it affects only the city where the resource is placed, in practice it is the same as if the Iron simply produces some extra shield.
Any suggestion?
cazfi
Elite
Posts: 3093
Joined: Tue Jan 29, 2013 6:54 pm

Re: Help needed to implement strategic resources

Post by cazfi »

bard wrote:However, I'm unable to find any effect where this condition actually works. I have tried:

Code: Select all

type    = "Upgrade_Unit"
value   = 1
reqs    =
    { "type", "name", "range"
      "Resource", "Iron", "City"
    }

type    = "Upgrade_Price_Pct"
value   = -50
reqs    =
    { "type", "name", "range"
      "Resource", "Iron", "City"
    }

type    = "Upkeep_Factor"
value   = 1
nreqs    =
    { "type", "name", "range"
      "Resource", "Iron", "City"
    }
Of those Upgrade_Price_Pct is already documented (in README.effects) like: "This effect works at player level. You cannot adjust upgrade costs for certain unit type or for units upgraded in certain city."
City limitation applies to others, I think (you usually can't have city to affect units supported/present). We should improve the documentation.
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: Help needed to implement strategic resources

Post by bard »

I found a effect that seems to work: Veteran_Build.
I'm testing to use these strategic resources as requirements to recruit certain units as veterans.

Code: Select all

type    = "Veteran_Build"
value   = 1
reqs    =
    { "type", "name", "range"
      "Resource", "Iron", "City"
    }
But I think the best way to introduce strategic resources in a ruleset is to allow the construction of certain building in the city with the resource (for example Iron mine), and then to use this building as requisite for any effect you want.
User avatar
GriffonSpade
Elite
Posts: 578
Joined: Mon Apr 29, 2013 4:41 pm

Re: Help needed to implement strategic resources

Post by GriffonSpade »

bard wrote:I found a effect that seems to work: Veteran_Build.
I'm testing to use these strategic resources as requirements to recruit certain units as veterans.
...
But I think the best way to introduce strategic resources in a ruleset is to allow the construction of certain building in the city with the resource (for example Iron mine), and then to use this building as requisite for any effect you want.
Yes, it works just fine in effects and buildings, it's specifically allowing troops to be built that it doesn't work with yet.

Also, Blacksmith in a city rather than Iron Mine :)

The biggest obstacle to having units requiring buildings is actually getting art for them. It's actually pretty easy on the ruleset side.

I know I'd like to have a set of buildings for almost every unit.
Post Reply