Modding questions

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
SMACX2
Posts: 16
Joined: Mon Oct 12, 2015 6:47 pm

Modding questions

Postby SMACX2 » Thu May 18, 2017 5:59 pm

1. Is it possible to give a building a fixed output bonus instead of a percentage?
For example I want a building that gives "+ 5 science bulbs" per turn independent of the cities science output.

2. How can I change the prefered "game settings" via ruleset?
For example how many starting units each player gets.

cazfi
Elite
Posts: 1510
Joined: Tue Jan 29, 2013 6:54 pm

Re: Modding questions

Postby cazfi » Thu May 18, 2017 6:50 pm

SMACX2 wrote:1. Is it possible to give a building a fixed output bonus instead of a percentage?
For example I want a building that gives "+ 5 science bulbs" per turn independent of the cities science output.

One thing you can do is to make central tile of the city to produce +5 shields when the city has specific building. But that is then subject to government tile output bonuses / penalties, Railroad bonus, and likes of Factories.

SMACX2 wrote:2. How can I change the prefered "game settings" via ruleset?
For example how many starting units each player gets.

Game.ruleset has [settings] section where you can define values that server settings get when ruleset is loaded. You can also 'lock' the setting to that value so that user cannot change it afterwards (meant to be used in situations where the ruleset is built for specific value and wouldn't behave sensibly with different value)

SMACX2
Posts: 16
Joined: Mon Oct 12, 2015 6:47 pm

Re: Modding questions

Postby SMACX2 » Sun May 21, 2017 9:31 am

cazfi wrote:
SMACX2 wrote:2. How can I change the prefered "game settings" via ruleset?
For example how many starting units each player gets.

Game.ruleset has [settings] section where you can define values that server settings get when ruleset is loaded. You can also 'lock' the setting to that value so that user cannot change it afterwards (meant to be used in situations where the ruleset is built for specific value and wouldn't behave sensibly with different value)


Found it, thank you. For all options it works.

User avatar
Corbeau
Elite
Posts: 789
Joined: Mon Jan 13, 2014 11:13 pm

Re: Modding questions

Postby Corbeau » Fri Dec 08, 2017 4:23 pm

I have a few questions, if I may.

Where is it defined what kind of upkeep does a government have? All I found was, for example:

"Monarchy pays 3 less gold"
"Republic pays 1 less shield"
"Democracy pays 2 less gold"

But I can't find where it says: "Monarchy pays ONLY gold, Republic pays ONLY shield" etc.

Because I want to define that units require upkeep in both gold and shields AND independent of the government.

Next: I want to have University increase military unhapiness by 1 (per unit, of course) in Republic and Democracy, in the city where it is built. Would this do? (If I got it right, the value here adds up?)

Code: Select all

[effect_student_protests]
type    = "Unhappy_Factor"
value   = 1
reqs    =
    { "type", "name", "range"
      "Building", "University", "City"
    }
nreqs   =
    { "type", "name", "range"
      "Gov", "Anarchy", "Player"
      "Gov", "Tribal", "Player"
      "Gov", "Communism", "Player"
      "Gov", "Despotism", "Player"
      "Gov", "Monarchy", "Player"
      "Gov", "Fundamentalism", "Player"
      "Gov", "Federation", "Player"
;      "Gov", "Republic", "Player"
;      "Gov", "Democracy", "Player"
    }

User avatar
GriffonSpade
Elite
Posts: 578
Joined: Mon Apr 29, 2013 4:41 pm

Re: Modding questions

Postby GriffonSpade » Fri Dec 08, 2017 4:53 pm

Corbeau wrote:I have a few questions, if I may.

Where is it defined what kind of upkeep does a government have? All I found was, for example:

"Monarchy pays 3 less gold"
"Republic pays 1 less shield"
"Democracy pays 2 less gold"

But I can't find where it says: "Monarchy pays ONLY gold, Republic pays ONLY shield" etc.


There's Upkeep_Factor in effects.ruleset. Individual Output_Type can be specified. That's how democracy and republic get multiplied food costs. Assumably it has to be zero or an integer.

There's also a Shield2Gold flag that allows shield upkeep to be converted to gold upkeep.

Relevant Effects wrote:Shield2Gold_Factor
Factor in percent for the conversion of unit shield upkeep to gold upkeep.
A value of 200 would transfer 1 shield upkeep to 2 gold upkeep. The range
of this effect must be player or world. Note that only units with the
"Shield2Gold" flag will be affected by this.

Unhappy_Factor
Multiply unhappy unit upkeep by amount.

Upkeep_Factor
Multiply unit upkeep by amount.

Unit_Upkeep_Free_Per_City
In each city unit upkeep is deducted by this amount. As usual, you can use
with OutputType requirement to specify which kind of upkeep this should be.


Unfortunately, a great many effects lack the ability to outright increment or decrement the base value with integers.

Corbeau wrote:Next: I want to have University increase military unhapiness by 1 (per unit, of course) in Republic and Democracy, in the city where it is built. Would this do? (If I got it right, the value here adds up?)


Yes, that should work, though I'd make two effects without all those NREQs instead. Just copy the existing Democracy and Republic effects and add the University requirement. (And Change the unhappy factor from Democracy + University to 1. Don't want them to go from 2 to 4 unhappy, after all)

Code: Select all

[effect_student_protests]
type    = "Unhappy_Factor"
value   = 1
reqs    =
    { "type", "name", "range"
      "Building", "University", "City"
      "Gov", "Republic", "Player"
    }

[effect_student_protests_2]
type    = "Unhappy_Factor"
value   = 1
reqs    =
    { "type", "name", "range"
      "Building", "University", "City"
      "Gov", "Democracy", "Player"
    }

User avatar
Corbeau
Elite
Posts: 789
Joined: Mon Jan 13, 2014 11:13 pm

Re: Modding questions

Postby Corbeau » Fri Dec 08, 2017 5:50 pm

Thanks. So, basically, the "default" upkeep_factor is 0 (zero) and only after it is changed in the ruleset it becomes non-zero, correct? So I can simply use this

Code: Select all

[...]
type    = "Upkeep_Factor"
value   = 1
reqs    =
    { "type", "name", "range"
     "OutputType", "Gold", "Local"
    }
   
[...]
type    = "Upkeep_Factor"
value   = 1
reqs    =
    { "type", "name", "range"
     "OutputType", "Shields", "Local"
    }
   


to have all units require both shields and gold across all governments, and have the game simply copy/use the values from the units.ruleset for each unit?

User avatar
Caedo
Elite
Posts: 457
Joined: Sun Feb 10, 2013 10:21 pm
Location: Stuttgart, Germany

Re: Modding questions

Postby Caedo » Fri Dec 08, 2017 6:55 pm

Corbeau wrote:Thanks. So, basically, the "default" upkeep_factor is 0 (zero) and only after it is changed in the ruleset it becomes non-zero, correct? So I can simply use this

Code: Select all

[...]


to have all units require both shields and gold across all governments, and have the game simply copy/use the values from the units.ruleset for each unit?

Precisely so. The way the Longturn.org rulesets work, each unit has one point of each basic upkeep type (gold, shield, food, unhappy) and the different governments are used as requirements for the Upkeep_Factor effects. However, I do believe it should be possible to use technologies, wonders, and possibly even unit types as requirements for these effects.
~S.C. L.

User avatar
GriffonSpade
Elite
Posts: 578
Joined: Mon Apr 29, 2013 4:41 pm

Re: Modding questions

Postby GriffonSpade » Sat Dec 09, 2017 5:09 am

Corbeau wrote:Thanks. So, basically, the "default" upkeep_factor is 0 (zero) and only after it is changed in the ruleset it becomes non-zero, correct? So I can simply use this to have all units require both shields and gold across all governments, and have the game simply copy/use the values from the units.ruleset for each unit?


Yes, but note that rulesets normally have this code to have it use 1x of prod/gold/food already.

Code: Select all

[effect_base_unit_upkeep]
type    = "Upkeep_Factor"
value   = 1

User avatar
Corbeau
Elite
Posts: 789
Joined: Mon Jan 13, 2014 11:13 pm

Re: Modding questions

Postby Corbeau » Sat Dec 09, 2017 9:35 am

Ok, I thought I got it, but now I'm lost again. So, this effectively sets all upkeep_factors for all resources (food, shields, gold, unhappy) to 1 (one). Then how come that Monarchy doesn't pay upkeep in gold (which it should, if upkeep_factor for gold is *not* zero)? Or it does and I simply haven't checked that ruleset properly? (The code you copied exists in Multiplayer ruleset, but not in civ2civ3.)

User avatar
Caedo
Elite
Posts: 457
Joined: Sun Feb 10, 2013 10:21 pm
Location: Stuttgart, Germany

Re: Modding questions

Postby Caedo » Sat Dec 09, 2017 1:15 pm

Corbeau wrote:Ok, I thought I got it, but now I'm lost again. So, this effectively sets all upkeep_factors for all resources (food, shields, gold, unhappy) to 1 (one). Then how come that Monarchy doesn't pay upkeep in gold (which it should, if upkeep_factor for gold is *not* zero)? Or it does and I simply haven't checked that ruleset properly? (The code you copied exists in Multiplayer ruleset, but not in civ2civ3.)

Again, this depends on the ruleset. In classic and multiplayer rulesets (and some others), gold upkeep for unit isn't a thing, that is, for every unit type, that unit type's specific gold upkeep is set to 0. So you could set the upkeep factor to an arbitrarily high value, and gold upkeep would still be 0, since the unit doesn't have gold upkeep.

In civ2civ3 (and all derived rulesets, such as the previously mentioned LT rulesets), most unit types have one of every upkeep type, and what upkeep is actually being paid is based on the type-specific Upkeep_Factor. So for example, Despotism sets Upkeep_Factor to 1 only for gold upkeep, whereas Monarchy does to only for shield upkeep. An effect like the one GriffonSpade mentioned would (in that ruleset) make every unit cost gold, shield and food.

Tl;dr: The specific upkeep depends not only on Upkeep_Factor-effects, but also on the upkeep set in the unit type declaration.

EDIT: Also, I'm pretty sure military unhappiness is not affected by Upkeep_Factor, but a seperate effect, Unhappy_Factor.
~S.C. L.