FreeOrion

Forums for the FreeOrion project
It is currently Wed Dec 13, 2017 10:34 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Jun 07, 2017 9:04 am 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 213
Hi I got a problem with FOCS with an effectsgroup for a building.

I am having a building and one of it effects is that it should add some happiness to all the empires planets with the same kind of species.


This didnt work, I think buildings match no species condition:
Code:
EffectsGroup /* add happiness for species */
            scope = And [
                PopulationCenter
                Species name = Source.Species
                OwnedBy empire = Source.Owner
            ]
            activation = Source
            effects = [
                    SetTargetHappiness value = Value + [[GOVERNMENT_FUNCTION_HAPPINESS_FOR_SPECIES]]
            ]


This doesnt work as well:
Code:
EffectsGroup /* add happiness for species */
            scope = And [
                PopulationCenter
                OwnedBy empire = Source.Owner
            ]
            activation = Source
            effects = [
                If condition = And [
                    Object id = Source.PlanetID
                    Planet
                    Species name = Target.Species
                ] effects = [
                    SetTargetHappiness value = Value + [[GOVERNMENT_FUNCTION_HAPPINESS_FOR_SPECIES]]
                ]
            ]

Current code is in EFFECTS_GROUPS_GOVERNMENT_FUNCTION_HAPPINESS macro.

Any help greatly appreciated. I was bumping my head against this one last night.

Also, shouldnt buildings "have" a species (there is a one-to-one-relationship) for the Species condition to match?

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Last edited by Ophiuchus on Fri Jun 09, 2017 8:43 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 9:26 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
Ophiuchus wrote:
Any help greatly appreciated. I was bumping my head against this one last night.

Also, shouldnt buildings "have" a species (there is a one-to-one-relationship) for the Species condition to match?
No; Planets or ships have a species. Buildings are on a planet, which can have a species, but don't themselves have a species. So use Source.Planet.Species rather than Source.Species for a building source object.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 10:58 am 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 213
Geoff the Medio wrote:
Ophiuchus wrote:
Any help greatly appreciated. I was bumping my head against this one last night.

Also, shouldnt buildings "have" a species (there is a one-to-one-relationship) for the Species condition to match?
No; Planets or ships have a species. Buildings are on a planet, which can have a species, but don't themselves have a species. So use Source.Planet.Species rather than Source.Species for a building source object.

Thats even better. Somehow missed (or forgot) that you could chain those references.

Works great now. Thaaanks for your help again :)

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 12:39 pm 
Offline
Creative Contributor
User avatar

Joined: Fri Jun 28, 2013 11:45 pm
Posts: 3291
Hint ;-) Always look at similar effects that already work freeorion/IMPERIAL_PALACE.focs.txt at master · freeorion/freeorion

It's the only way I can get anything done at all, this rolling your own from scratch understanding the actual code is way too complex for me ;-)

_________________
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 4:39 pm 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 213
MatGB wrote:
Hint ;-) Always look at similar effects that already work freeorion/IMPERIAL_PALACE.focs.txt at master · freeorion/freeorion

It's the only way I can get anything done at all, this rolling your own from scratch understanding the actual code is way too complex for me ;-)

Oh. I didnt know about that happyness bonus... Thanks.

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group