How to add a variable to ships/parts?

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

Moderators: Oberlus, Committer, Oberlus, Committer

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

Re: How to add a variable to ships/parts?

#16 Post by Ophiuchus » Fri Jan 18, 2019 9:25 pm

Code: Select all

$ grep -i capac parse/Tokens.h 
    (Capacity)                                  \
    (HasSpecialCapacity)                        \
    (MaxCapacity)                               \
    (NoDefaultCapacityEffect)                   \
    (PartCapacity)                              \
    (SetCapacity)                               \
    (SetMaxCapacity)                            \
    (SetSpecialCapacity)                        \
    (SpecialCapacity)                           \
$ grep -i secon parse/Tokens.h 
    (PartSecondaryStat)
    (SetMaxSecondaryStat)                       \
    (SetSecondaryStat)                          \
Does the Capacity condition work for querying the value from a ship part? If so is only SecondaryStat missing?
... No. I tried and Capacity does not work querying the value from a ship part. @geoff What is needed there - a ValueRef?

Hm I remember there were some issues because you can have the same part multiple times in your ship so asking/modifying capacity of a part is actually not really defined if you are in the general context of a ship. You dont have that problem with a special.. it can be there only once.


edit1: mention multiple-times-the-same-part issues

edit2: there is no way to query the (Max)Capacity values explicitly
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Furthermore, I propse... we should default to four combat rounds instead of three ...for the good of playerkind.

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

Re: How to add a variable to ships/parts?

#17 Post by Geoff the Medio » Sat Jan 19, 2019 10:52 am

Ophiuchus wrote:
Fri Jan 18, 2019 9:25 pm
Does the Capacity condition work for querying the value from a ship part? If so is only SecondaryStat missing?
... No. I tried and Capacity does not work querying the value from a ship part. @geoff What is needed there - a ValueRef?
There is a separate ShipPartMeter condition:

https://github.com/freeorion/freeorion/ ... r4.cpp#L54
Hm I remember there were some issues because you can have the same part multiple times in your ship so asking/modifying capacity of a part is actually not really defined if you are in the general context of a ship.
Ships have only one instance of a meter for each unique part type. You specify the part name and meter type for the condition. Doesn't matter if there are 1 or 10 mass drivers in a design; there will be just one ShipPartMeter with part name "SHP_WEAPON_1" and meter type Capacity.
edit2: there is no way to query the (Max)Capacity values explicitly
Yes; that's what I wrote earlier: "...lack of a way to access ship part meter values in FOCS..."

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

Re: How to add a variable to ships/parts?

#18 Post by Ophiuchus » Sat Jan 19, 2019 2:09 pm

Geoff the Medio wrote:
Sat Jan 19, 2019 10:52 am
Ophiuchus wrote:
Fri Jan 18, 2019 9:25 pm
Does the Capacity condition work for querying the value from a ship part? If so is only SecondaryStat missing?
... No. I tried and Capacity does not work querying the value from a ship part. @geoff What is needed there - a ValueRef?
There is a separate ShipPartMeter condition:

https://github.com/freeorion/freeorion/ ... r4.cpp#L54
I am not sure how the condition actually helps (besides activating effects depending on value ranges). The request was to have access to the value, right? Is DoubleValueRefParser the place to look at?

I can not find any use or documentation for ShipPartMeter. Reading the parser code I came up with following (which looks a bit unusual):

Code: Select all

            activation = And [ Source  ShipPartMeter part = ThisPart Capacity low = 6 high = 999] 
Dumping the data for a ship i see meters for the weapons but not for the armour part. Is this different for different part types?
It could also be a bug in the dumping of the ship part information; the ship has 3 parts, but only one weapon. No it is different for armour and weapon part. I could successfully trigger ShipPartMeter for the weapon but not the armour part.

Code: Select all

part meters: SR_WEAPON_1_1 METER_MAX_CAPACITY: 3  SR_WEAPON_1_1 METER_MAX_SECONDARY_STAT: 1  SR_WEAPON_1_1 METER_CAPACITY: 3  SR_WEAPON_1_1 METER_SECONDARY_STAT: 1  
Also setting

Code: Select all

parse/ConditionParserImpl.h:#define DEBUG_CONDITION_PARSERS 1
leads to a compile errors. Sigh.
Geoff the Medio wrote:
Sat Jan 19, 2019 10:52 am
Yes; that's what I wrote earlier: "...lack of a way to access ship part meter values in FOCS..."
You wrote "apparently". So i thought there is some degree of uncertainty.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Furthermore, I propse... we should default to four combat rounds instead of three ...for the good of playerkind.

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

Re: How to add a variable to ships/parts?

#19 Post by Ophiuchus » Sat Jan 19, 2019 2:28 pm

Ah I think I found the part class differences in Ship.cpp#L59
  • troops, colony,: Capacity meter
  • weapons and hangars: (Max)Capacity and (Max)SecondaryStat meters
  • launch bay: (Max)Capacity meters
  • armour and everything else: no meter
As some of these values have some derived semantics (launch bay capacity indicates if there are fighters in the launch bay and thus the ship may be considered dangerous).

Maybe we should give the general part class a (Max)Capacity and a SecondaryStat to allow for meters avoid this confusion?
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Furthermore, I propse... we should default to four combat rounds instead of three ...for the good of playerkind.

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

Re: How to add a variable to ships/parts?

#20 Post by Geoff the Medio » Sun Jan 20, 2019 8:54 pm

Ophiuchus wrote:
Sat Jan 19, 2019 2:28 pm
Maybe we should give the general part class a (Max)Capacity and a SecondaryStat to allow for meters avoid this confusion?
I'm reluctant to do that because it would mean that every ship with a design that has a General class part would then be carrying around two or four extra meter per (unique) General part in the design. Also, any general part will be put in the general class filter on the design screen, which isn't really suitable if it's intended to be an armour part.

I'd be more inclined to give armour parts capacity meters... though as with shields, the purpose of these would be a bit muddled given that they currently have effects that modify the single ship meter. The reason weapons are different (ie. have their own meter) is that this is necessary for how they function. With shield and armour parts, the stats of the individual parts aren't important; just the net effect on the ship meter. But on the plus side, they'd be filtered correctly.

I guess there could also be a ComplicatedGeneral part type that also has a capacity meter... Seems like not the best solution, though...

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

Re: How to add a variable to ships/parts?

#21 Post by Ophiuchus » Mon Jan 21, 2019 7:41 am

How about adding meter types on setting a meter value if it does not exist dynamically? So only parts which need it would have it.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Furthermore, I propse... we should default to four combat rounds instead of three ...for the good of playerkind.

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

Re: How to add a variable to ships/parts?

#22 Post by Geoff the Medio » Mon Jan 21, 2019 1:59 pm

That's pretty much what adding a special would do...

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

Re: How to add a variable to ships/parts?

#23 Post by Ophiuchus » Mon Jan 21, 2019 4:55 pm

Telos wrote:
Thu Jan 17, 2019 11:54 pm
what are the best practices for where I would script the specials? Do they need to be defined in their own file(s) in the Specials directory? Or could (and if so *should*) they be scripted in the very same file as the shippart for which they serve as a capacity?
Basic directory layout is explained in default/scripting/README.md

All specials go into default/scripting/specials/
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Furthermore, I propse... we should default to four combat rounds instead of three ...for the good of playerkind.

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

Re: How to add a variable to ships/parts?

#24 Post by Ophiuchus » Fri Jan 25, 2019 1:26 am

Also note that I added "all" the info for using specials in FOCS in https://freeorion.org/index.php/FOCS_Scripting_Details and I am working on giving access to ship part meters in PR#2363 (just needs some input, then i can finish the implementation).

Note that besides code-diving, dumping the values of a ship to the chat window using the objects filter window is the biggest help.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Furthermore, I propse... we should default to four combat rounds instead of three ...for the good of playerkind.

Post Reply