Last clicked object as Source/Target for named value refs?

Creation, discussion, and balancing of game content such as techs, buildings, ship parts.

Moderators: Oberlus, Committer

Post Reply
Message
Author
Ophiuchus
Programmer
Posts: 3495
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Last clicked object as Source/Target for named value refs?

#1 Post by Ophiuchus »

wobbly wrote: Wed Apr 10, 2024 8:52 am
Oberlus wrote: Thu Feb 01, 2024 5:24 pm I would do this for most effects gated by stability.
Minimum stability for the effect to kick in should be 0 or 5 by default (or the baseline stability value). I would use higher minimum values only for policies with effects not compatible with the scaling or policies strong enough and with a fluff for which having happy/compliant populations seems necessary (can't think of examples now).
So having played with this on centralism I can say that mechanically it works, but there's a price in clarity/simplicity. There's more small decimals and it's harder for the player to calculate a ballpoint figure in their head.
I am still trying to think up a system for good UI for giving info to players in complex situations involving named valuerefs.

One idea would be to remember a last selected object (like we currently do for rendering ship designs in the pedia) and expose that as Source/Target when rendering/calculating named values in the pedia
This might be too simplistic, but it should work for some cases and should not be too hard to implement.

E.g. stringtable text could look like

Code: Select all

EXAMPLE_BLD_INDUSTRY_CENTER_DESC
As an example an [[buildingtype BLD_INDUSTRY_CENTER]] would produce [[namedvalue BLD_INDUSTRY_CENTER_PP]]PP on planet %planet:currenttarget%
Which would render like 'As an example an industry center(link to industry center pedia page) would produce 12PP on planet Wurrrza 3 alpha(link to example pedia page for EXAMPLE_BLD_INDUSTRY_CENTER)'
and in case of failure like 'As an example an industry center(link to industry center pedia page) would produce ?(link to generic pedia page explaining about failing to calculate values/choosing valid targets for namedvalues)' on planet please select a planet as current target(link to generic pedia page explaining about examples/choosing valid current targets for examples)'


Or we could expose the last clicked objects to FOCS and introduce a way to declare a namedexample which allows to pick objects for Source/Target (via conditions) and calculate a value (via valuerefs). Such a namedexample would render the value and also the chosen objects in some way.
E.g. stringtable text could look like

Code: Select all

BLD_INDUSTRY_CENTER_DESC
'''Initially provides a bonus to ...
For example: [[namedexample EXAMPLE_BLD_INDUSTRY_CENTER_PP]].
'''

EXAMPLE_BLD_INDUSTRY_CENTER_PP_DESC
On planet %planet:target% the [[buildingtype BLD_INDUSTRY_CENTER]] would produce %rawtext:value%
e.g. python code (where BLD_INDUSTRY_CENTER_1_TARGET_INDUSTRY would be defined in the effectsgroups, using the target stability and population)

Code: Select all

Building(...
    enqueuelocation=ENQUEUE_BUILD_ONE_PER_PLANET,
    examples=[
        Example(
            name = "EXAMPLE_BLD_INDUSTRY_CENTER_PP",
            target=LatestClicked()
            & Planet()
            & OwnedBy(empire=Source.Owner),
            value=OwnerHasTech(name="PRO_INDUSTRY_CENTER_I")  * NamedRealLookup(name="BLD_INDUSTRY_CENTER_1_TARGET_INDUSTRY")
            ...OwnerHasTech(name=""PRO_INDUSTRY_CENTER_II") ... OwnerHasTech(name=""PRO_INDUSTRY_CENTER_III") ...
        )
    ]
    effectsgroups=[
)
edit: another option: make the select object a parameter to the value ref definition

Code: Select all

effects = SetTargetIndustry value = Value + (NamedReal name = "BLD_INDUSTRY_CENTER_3_INDUSTRY_BUFF" 
                                               exampleTarget = SelectedPlanet() 
                                               value = Target.Population 
                                                       * (NamedReal name = "BLD_INDUSTRY_CENTER_3_TARGET_INDUSTRY_PERPOP"
                                                            value = 0.75 * [[INDUSTRY_PER_POP]]) )
Last edited by Ophiuchus on Sun Apr 28, 2024 8:40 pm, edited 2 times in total.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13612
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Last clicked object as Source/Target for named value refs?

#2 Post by Geoff the Medio »

You can access the IDs of the selected system and fleet, like used in the objects list distance to columns:
Attachments
screenshot with objects list with distance to columns selected
screenshot with objects list with distance to columns selected
dist to selected.png (704.42 KiB) Viewed 183 times

Ophiuchus
Programmer
Posts: 3495
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Last clicked object as Source/Target for named value refs?

#3 Post by Ophiuchus »

Geoff the Medio wrote: Wed Apr 10, 2024 1:42 pm You can access the IDs of the selected system and fleet, like used in the objects list distance to columns:
thank you! it looks these are available :mrgreen: (with implementations in UI/MapWnd.cpp delegated via client/human/GGHumanClientApp.cpp)

Code: Select all

std::make_unique<ValueRef::Variable<int>>(ValueRef::ReferenceType::NON_OBJECT_REFERENCE, "SelectedFleetID"); // from MapWnd
std::make_unique<ValueRef::Variable<int>>(ValueRef::ReferenceType::NON_OBJECT_REFERENCE, "SelectedPlanetID"); // from ProductionWnd
std::make_unique<ValueRef::Variable<int>>(ValueRef::ReferenceType::NON_OBJECT_REFERENCE, "SelectedShipID"); // from MapWnd
std::make_unique<ValueRef::Variable<int>>(ValueRef::ReferenceType::NON_OBJECT_REFERENCE, "SelectedSystemID"); // from SidePanel
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

Post Reply