Accessing source from within effects

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

Moderators: Oberlus, Committer

Post Reply
Message
Author
jhalfast
Space Krill
Posts: 5
Joined: Fri Sep 28, 2018 7:59 pm

Accessing source from within effects

#1 Post by jhalfast »

Hey - brand new to FOCS. I've read the preliminary content, and have a few ships, parts, and buildings functioning. But I've run into a problem that I cannot find the correct solution.

I've got a building that modifies the industry of all targets - supply line connected planets with population centers. That, I can do fine. What I'd like do is to measure that effect against the size of the source planet, so the bigger the source planet, the bigger the effect on the targets.

For instance - see how I'm trying to reference the planet size of the source's planet, which fails:

Code: Select all

effects = And [
	If condition = Source.PlanetSize = value = Huge
		effects = SetTargetIndustry value = Value + 5
		else =
			If condition = Source.PlanetSize = Large
				effects = SetTargetIndustry value = Value + 2
				else =
					If condition = Source.PlanetSize = Medium
						effects = SetTargetIndustry value = Value + 1
						else = 
							If condition = Source.PlanetSize = Small
								effects = SetTargetIndustry value = Value + .5
								else = Source.PlanetSize = Tiny
									effects = SetTargetIndustry value = Value + .25
]
...numbers are for coding purposes only, not actual gameplay

I think I've got nested if statements working to differentiate the sizes, but for the life of me, I cannot reference the source planet size. Source.PlanetSize and the like break the building. The only thing I have successfully done is to use "Planet Size" in the If statement, but since it's referring to the target (defined by the "scope" of the effects group), that makes the adjustment according to the target.

Anyone care to point me to how to point to the source in an effectsgroup effects? ...or otherwise make the effect contingent on the source's planet size?

By the way - if there's a clean breakdown of programming objects - classes, properties, and nesting structure (exposed to FOCS... I'm not a C++ guy) - I'd sure love to have it.

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

Re: Accessing source from within effects

#2 Post by Geoff the Medio »

For this purpose, I suggest using several effectsgroups with appropriate activation conditions, which turn effectsgroups on or off based on whether the source object matches the condition...

Code: Select all

EffectsGroup
    scope = [???]
    activation = Planet size = Huge
    effects = SetTargetIndustry value = Value + 5
    
EffectsGroup
    scope = [???]
    activation = Planet size = Large
    effects = SetTargetIndustry value = Value + 2

[etc...]
But if you want to do it the way you were, I think this part might be causing problems with the extra "= value", and the lack of brackets, which are needed around comparisons like that, for them to be recognized as a condition:

Code: Select all

If condition = Source.PlanetSize = value = Huge
but rather something like this

Code: Select all

(0 == Source.TurnsSinceFocusChange)
And additionally, I suspect that such comparison operator conditions aren't implemented for non-number and non-string values... so PlanetSize might not be recognized, though I'm not sure about that.

jhalfast
Space Krill
Posts: 5
Joined: Fri Sep 28, 2018 7:59 pm

Re: Accessing source from within effects

#3 Post by jhalfast »

Thanks Geoff - I took your advice and used different effectsgroups. I had the wrong understanding of activation, though in hindsight it should have been obvious.

Thank you again!

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Accessing source from within effects

#4 Post by Vezzra »

Geoff the Medio wrote: Fri Sep 28, 2018 8:58 pmAnd additionally, I suspect that such comparison operator conditions aren't implemented for non-number and non-string values... so PlanetSize might not be recognized, though I'm not sure about that.
Um, just curious, couldn't you use PlanetSizeAsInt for that...?

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

Re: Accessing source from within effects

#5 Post by Geoff the Medio »

In that particular case, yes, but not for other enum types and PlanetSizeInt isnt guaranteed to have all unique values for all possible sizes.

Post Reply