I am wanting to experiment with custom meters for trade and infrastructure (and probably population later on).
I would like to get some help with where/what to modify.
It looks like I should create something like PopCenter for both trade, infrastructure to do custom calculations for the meter targets and growth values.
Not seeing how target_meter_value is set/determined ATM. Where would I find that? Having trouble back tracking: float target_meter_value = target->Current(); That is, where is population taking specials and tech into consideration?
For trade I want to iterate over all colonies/planets of current empire( and trade allied empires).
Info I want to use: distance as uu, distance as jumps(supply limit), pop size, species, planet type, planet focus
Where is good example that I can copy+modify?
In ResourceCenter.h I see METER_CONSTRUCTION but no infrastructure, is METER_CONSTRUCTION === infrastructure?
How do I do custom trade, infrastructure meters?
Moderator: Committer
-
- Space Floater
- Posts: 40
- Joined: Sat Jul 01, 2017 4:54 am
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: How do I do custom trade, infrastructure meters?
Not sure exactly what you're asking. Are you aware that scripted effects are used to set meter values? Are you asking in what functions effects are executed? Or where / when those functions are run? Or where the API for effects scripting is defined? Or how meter-setting effects work internally when executed?Gault.Drakkor wrote:Not seeing how target_meter_value is set/determined ATM. Where would I find that? Having trouble back tracking: float target_meter_value = target->Current(); That is, where is population taking specials and tech into consideration?
Most of that is accessible in scripted effects. There are lots of examples in the scripting directory, eg. https://github.com/freeorion/freeorion/ ... D.focs.txt or https://github.com/freeorion/freeorion/ ... H.focs.txt and https://github.com/freeorion/freeorion/ ... macros#L57For trade I want to iterate over all colonies/planets of current empire( and trade allied empires).
Info I want to use: distance as uu, distance as jumps(supply limit), pop size, species, planet type, planet focus
I'm not sure whether you want / need to add new meters to something, or just change / add effects that determine existing meters' values.
If you can be more clear / specific about what you're trying to do, a relevant example can probably be found. I'm not yet sure if you want / need to modify C++ code, or just effect scripting.Where is good example that I can copy+modify?
Yes.is METER_CONSTRUCTION === infrastructure?
-
- Space Floater
- Posts: 40
- Joined: Sat Jul 01, 2017 4:54 am
Re: How do I do custom trade, infrastructure meters?
Thank you for your reply.Geoff the Medio wrote: I'm not sure whether you want / need to add new meters to something, or just change / add effects that determine existing meters' values.If you can be more clear / specific about what you're trying to do, a relevant example can probably be found. I'm not yet sure if you want / need to modify C++ code, or just effect scripting.Where is good example that I can copy+modify?
I'll describe what I want to try doing. Hopefully it will be clear enough for you to point me in the right direction.
Trade:
I want to implement something along the lines of an inverse square law:
Code: Select all
def update_planet_trade(current_planet):
trade = 0
for planets in empire:
if planet in supply_range:
trade += empire_trade_bonus * current_planet.pop * planet.pop/
(distance_in_uu(current_planet, planet)**2)
current_planet.target_trade = trade
- The supply of current planet and other planet.
- The infrastructure of current planet and other planet.
- If trade is current focus of either planet.
- Species of current planet and other planet, (and their trade bonus/malus).
- Planet type, different types would be a small bonus.
I don't believe I can do this in the FOCS.
Infrastructure:
I haven't firmed up my formulas yet.
So far:
- Cost of each point of infrastructure to be exponential.
- Production multiplier for each unit of infrastructure to have diminishing returns.
- Perhaps a capacity factor like what moo3 had. (will probably not include this)
- Maintenance cost.
- Current infrastructure to be used for current trade, current trade to be used to determine next/increment of infrastructure.
- Planning to siphon off 10% of trade /production every turn.
Control population not by determining population cap, but by determining population growth. So probably a creation of an additional meter: population growth. With one unit of the growth meter being 0.1% growth to apply to the population meter. I would also need to modify techs, specials too affect growth not population cap, but that I know how to do If there is a separate growth meter.
I am pretty sure I can figure out creation of an additional meter, not sure how to display that in the UI though, but haven't looked into that at all.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: How do I do custom trade, infrastructure meters?
An effect like SetTargetTrade value = [stuff] can have arbitrarily complicated [stuff], which can (or can be made to on request) reference all of those properties.Gault.Drakkor wrote:Trade:
I want to implement something along the lines of an inverse square law:With additional values going into it. such as:Code: Select all
def update_planet_trade(current_planet): trade = 0 for planets in empire: if planet in supply_range: trade += empire_trade_bonus * current_planet.pop * planet.pop/ (distance_in_uu(current_planet, planet)**2) current_planet.target_trade = trade
- The supply of current planet and other planet.
- The infrastructure of current planet and other planet.
- If trade is current focus of either planet.
- Species of current planet and other planet, (and their trade bonus/malus).
- Planet type, different types would be a small bonus.
That would require C++. Doing it in a sitrep message might be possible just in FOCS.I would want to keep track of, say top 5, trade partners and display that in the tool tip.
A SetTargetIndustry effect could refer to infrastructure (construction meter) with an arbitrary function to determine how to change the meter value. Similarly, SetConstruction (to increment construction meter) can refer to arbitrary combinations of meters. The rest are unclear / vague.Infrastructure:
- Cost of each point of infrastructure to be exponential.
- Production multiplier for each unit of infrastructure to have diminishing returns.
- Perhaps a capacity factor like what moo3 had. (will probably not include this)
- Maintenance cost.
- Current infrastructure to be used for current trade, current trade to be used to determine next/increment of infrastructure.
- Planning to siphon off 10% of trade /production every turn.
If you want a separate growth meter to appear in the UI, it would require C++ modifications. The actual population changes are currently implemented in C++ code, https://github.com/freeorion/freeorion/ ... r.cpp#L102 although this should probably be moved into an effect regardless of your plans.Population:
Control population not by determining population cap, but by determining population growth. So probably a creation of an additional meter: population growth. With one unit of the growth meter being 0.1% growth to apply to the population meter. I would also need to modify techs, specials too affect growth not population cap, but that I know how to do If there is a separate growth meter.
I am pretty sure I can figure out creation of an additional meter, not sure how to display that in the UI though, but haven't looked into that at all.
-
- Space Floater
- Posts: 40
- Joined: Sat Jul 01, 2017 4:54 am
Re: How do I do custom trade, infrastructure meters?
Ok, underestimated what you can do in FOCS.Geoff the Medio wrote:An effect like SetTargetTrade value = [stuff] can have arbitrarily complicated [stuff], which can (or can be made to on request) reference all of those properties.
So something like this?Geoff the Medio wrote: If you want a separate growth meter to appear in the UI, it would require C++ modifications. The actual population changes are currently implemented in C++ code, https://github.com/freeorion/freeorion/ ... r.cpp#L102 although this should probably be moved into an effect regardless of your plans.
Code: Select all
POPULATION_CHANGE
'''EffectsGroup
scope = Source
activation = Planet
effects = SetPopulation value = min(Value * ( Target.Population + 1 - Value) / 100, Target.Population - Value)
'''
I believe I have enough info to write up what I want to do and try some of them(infrastructure and population growth) In game. I'll come back later with a more complete writeup of what I want to do with trade, and better understanding of FOCS.
Thank you for your help.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: How do I do custom trade, infrastructure meters?
That would set the population equal to what is currently the change in population each turn.Gault.Drakkor wrote:[So something like this?Code: Select all
POPULATION_CHANGE '''EffectsGroup scope = Source activation = Planet effects = SetPopulation value = min(Value * ( Target.Population + 1 - Value) / 100, Target.Population - Value) '''
You don't need to loop; you need to sum, which is a statistic, eg. https://github.com/freeorion/freeorion/ ... ocs.txt#L2I see via orbital drydock how to do functions. Not sure about looping.