FreeOrion

Forums for the FreeOrion project
It is currently Sat May 18, 2013 8:21 pm

All times are UTC




Post new topic Reply to topic  [ 115 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 8  Next
Author Message
 Post subject: Re: Help with EffectsGroups
PostPosted: Wed Sep 14, 2011 1:00 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7885
Location: Vancouver, BC
eleazar wrote:
OK, when you get a chance, i'm apparently not guessing how to use "RootCandidate" properly.
Say there's an scope condition:
Code:
scope = WithinDistance distance = 5 condition = And [
    Planet
    OwnedBy TheEmpire RootCandidate.Owner
    Construction low = 0 high = LocalCandidate.TargetConstruction / 2
]
Here there are two sets of objects being matched:
1) The objects actually being matched for the scope. These are objects within distance 5 of an object matched by the subcondition.
2) The objects matched by the subcondition, which are used to evaluate the outer condition. These are planets that are owned by the same empire that owns the object matched in the outer condition, and that have less than half their own target construction.

RootCandidate refers to the object being matched in the outer-most condition - WithinDistance in this case. This gives a way to refer to the object actually being matched by a big multi-part condition from one of the inner condition definitions, where the object being matched by a subcondition is likely not the same object being matched by the outer condition.

LocalCandidate refers to the object being matched in whatever condition it is directly in - the Construction meter condition in this case. This gives a way to refer to the object being matched by the current condition, regardless of what other conditions are matching outside or inside the current condition.

Also available is Target when writing an effect. For example
Code:
SetFarming Target.MaxFarming
Target only works within an effect, not within a scope or activation condition or building location condition, as those are not within an effect, so there is no "Target" object to refer to. Target is the object being acted on by an effect, be it meter-setting, moving, destroy, setting destination for a monster, etc.

And Source is also available. For example
Code:
SetFarming Source.Farming


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Sat Mar 03, 2012 8:01 pm 
Offline
Designer and Programmer
User avatar

Joined: Tue Aug 14, 2007 6:33 pm
Posts: 1770
Location: Orion
Will the following:
Code:
And [
    Not Stationary
    ContainedBy System
]

match objects which were stopped at a system due to combat, but still have a move order, as well as objects such as space monsters that have just had their destination set with an effect?

_________________
Warning: Antarans in dimensional portal are closer than they appear.


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Sat Mar 03, 2012 8:22 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7885
Location: Vancouver, BC
Bigjoe5 wrote:
Will the following:
Code:
And [
    Not Stationary
    ContainedBy System
]

match objects which were stopped at a system due to combat, but still have a move order, as well as objects such as space monsters that have just had their destination set with an effect?

Not sure about the stopped by combat. Probably not for the space monsters since the code that determines which effects act on which objects runs before effects are executed, so an effect that acts on an object can't change which other effects will act on that object in the same turns.


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Fri Mar 09, 2012 7:51 pm 
Offline
Design & Graphics Lead
User avatar

Joined: Sat Sep 23, 2006 7:09 pm
Posts: 3693
Location: USA — midwest
I'd like to add specials that activate once an empire enters a system. Stuff like "you've found an abandoned hulk, from which you scavenge 10 minerals". The kind of rewards for exploration that don't require colonizing a planet. See here for other ideas.

I think the effects system can do everything, except i can't figure how to trigger (activation) it when an imperial ship enters the system.

Thoughts?

Here's what i got so far:
Code:
Special
    name = "SCAVENGE_MINERALS_SPECIAL"
    description = "SCAVENGE_MINERALS_SPECIAL_DESC"
    spawnrate = 5.0
    spawnlimit = 9999
    location = And [
        System
        Not ContainedBy Contains Homeworld
    ]
    EffectsGroup
        activation = ??????
        effects = [
            SetOwnerMineralStockpile +20
            GenerateSitRepMessage
                message = "EFFECT_SCAVENGE_MINERALS"
                parameters = [
                    tag = "system" data = Source.ID
                ]
       
            RemoveSpecial "SCAVENGE_MINERALS_SPECIAL"
        ]
    graphic = ""

_________________
—• Read this First before posting Game Design Ideas!
—• Design Philosophy

—•— My Ideas, Organized —•— Get an Avatar —•— Acronyms —•—


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Fri Mar 09, 2012 8:06 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7885
Location: Vancouver, BC
eleazar wrote:
I think the effects system can do everything, except i can't figure how to trigger (activation) it when an imperial ship enters the system.
The activation condition is tested on the source object only, so you'd need to phrase things in terms of the source object if you want to use an activation condition.

Regardless, you probably want something like
Code:
activation = ContainedBy And [
    System
    Contains And [
        Ship
        OwnedBy AnyEmpire
    ]
]
That should match the source object (presumably a planet with an attached special that is providing this effectsgroup) when the source object is in a system that (also) contains a ship owned by any empire.

Edit: Also, you'll probably want two separate effectsgroups, one of which acts on the planet and removes the special, the other which acts on the ship and gives its owner some minerals. Since the planet has no owner, giving its owner minerals won't do much, and the ship doesn't have the special on it.

Or, you might be able to have a single scope that includes both the ship and the planet using an And condition to combine both... This would probably work, as the ship won't have the special and the planet won't have an owner, so removing the special from both and adding minerals to the owner of both will probably just work as intended.

You also need a "Value" before the +20.


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Fri Mar 09, 2012 11:21 pm 
Offline
Design & Graphics Lead
User avatar

Joined: Sat Sep 23, 2006 7:09 pm
Posts: 3693
Location: USA — midwest
This:
Code:
Special
    name = "SCAVENGE_MINERALS_SPECIAL"
    description = "SCAVENGE_MINERALS_SPECIAL_DESC"
    spawnrate = 5.0
    spawnlimit = 9999
    location = And [
        Planet
        Not ContainedBy Contains Homeworld
    ]
    EffectsGroup
        activation = ContainedBy And [
            System
            Contains And [
                Ship
                OwnedBy AnyEmpire
            ]
        ]
        effects = [
            scope = And [
                Planet
                Ship
            ]
            SetOwnerMineralStockpile Value +20
            RemoveSpecial "SCAVENGE_MINERALS_SPECIAL"
            GenerateSitRepMessage
                message = "EFFECT_SCAVENGE_MINERALS"
                parameters = [
                    tag = "system" data = Source.ID
                ]
        ]
    graphic = ""


gives me this error:

Code:
2012-03-09 17:11:02,323 ERROR Client : /Users/jbjerk/Desktop/FreeOrion.app/Contents/Resources/default/specials.txt:1145:8: Parse error.  Expected Condition here:
          activation = ContainedBy And [
          ^

_________________
—• Read this First before posting Game Design Ideas!
—• Design Philosophy

—•— My Ideas, Organized —•— Get an Avatar —•— Acronyms —•—


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Fri Mar 09, 2012 11:56 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7885
Location: Vancouver, BC
scope needs to be before activation at the top level, not within the effects list (which can only contain effects, not a scope condition).

The error somewhat misleadingly means that it's expecting a condition (the scope, which is not optional) before the activation label (which is optional).


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Sat Mar 10, 2012 12:21 am 
Offline
Design & Graphics Lead
User avatar

Joined: Sat Sep 23, 2006 7:09 pm
Posts: 3693
Location: USA — midwest
OK, i should have caught that. But i'm immediately stuck again:

Code:
Special
    name = "SCAVENGE_MINERALS_SPECIAL"
    description = "SCAVENGE_MINERALS_SPECIAL_DESC"
    spawnrate = 5.0
    spawnlimit = 9999
    location = And [
        Planet
        Not ContainedBy Contains Homeworld
    ]
    EffectsGroup
        scope = And [
            Planet
            Ship
        ]
        activation = ContainedBy And [
            System
            Contains And [
                Ship
                OwnedBy AnyEmpire
            ]
        ]
        effects = [
            SetOwnerMineralStockpile Value + 20
            RemoveSpecial "SCAVENGE_MINERALS_SPECIAL"
            GenerateSitRepMessage
                message = "EFFECT_SCAVENGE_MINERALS"
                parameters = [
                    tag = "system" data = Source.ID
                ]
        ]
    graphic = ""


Code:
2012-03-09 18:19:26,946 ERROR Client : /Users/jbjerk/Desktop/FreeOrion.app/Contents/Resources/default/specials.txt:1157:37: Parse error.  Expected integer expression here:
              SetOwnerMineralStockpile Value + 20
                                       ^

_________________
—• Read this First before posting Game Design Ideas!
—• Design Philosophy

—•— My Ideas, Organized —•— Get an Avatar —•— Acronyms —•—


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Sat Mar 10, 2012 1:04 am 
Offline
Designer and Programmer
User avatar

Joined: Tue Aug 14, 2007 6:33 pm
Posts: 1770
Location: Orion
eleazar wrote:
OK, i should have caught that. But i'm immediately stuck again:

Code:
Special
    name = "SCAVENGE_MINERALS_SPECIAL"
    description = "SCAVENGE_MINERALS_SPECIAL_DESC"
    spawnrate = 5.0
    spawnlimit = 9999
    location = And [
        Planet
        Not ContainedBy Contains Homeworld
    ]
    EffectsGroup
        scope = And [
            Planet
            Ship
        ]
        activation = ContainedBy And [
            System
            Contains And [
                Ship
                OwnedBy AnyEmpire
            ]
        ]
        effects = [
            SetOwnerMineralStockpile Value + 20
            RemoveSpecial "SCAVENGE_MINERALS_SPECIAL"
            GenerateSitRepMessage
                message = "EFFECT_SCAVENGE_MINERALS"
                parameters = [
                    tag = "system" data = Source.ID
                ]
        ]
    graphic = ""


Code:
2012-03-09 18:19:26,946 ERROR Client : /Users/jbjerk/Desktop/FreeOrion.app/Contents/Resources/default/specials.txt:1157:37: Parse error.  Expected integer expression here:
              SetOwnerMineralStockpile Value + 20
                                       ^

The mineral stockpile isn't a meter, so you can't use "Value + whatever" like for SetMeter effects. You'll need to reference the empire's stockpile (which I'm almost positive you can do because I distinctly remember adding with a similar effect somewhere).

edit: I think this is it. Something like
Code:
SetOwnerMineralStockpile Target.Mineralstockpile + 20
or perhaps without the Target. should work.

_________________
Warning: Antarans in dimensional portal are closer than they appear.


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Sat Mar 10, 2012 1:20 am 
Offline
Design & Graphics Lead
User avatar

Joined: Sat Sep 23, 2006 7:09 pm
Posts: 3693
Location: USA — midwest
Bigjoe5 wrote:
The mineral stockpile isn't a meter, so you can't use "Value + whatever" like for SetMeter effects. You'll need to reference the empire's stockpile (which I'm almost positive you can do because I distinctly remember adding with a similar effect somewhere).

edit: I think this is it. Something like
Code:
SetOwnerMineralStockpile Target.Mineralstockpile + 20
or perhaps without the Target. should work.

Thanks, but neither that nor several semi-plausible variations changed the error. It really wants an integer there.

_________________
—• Read this First before posting Game Design Ideas!
—• Design Philosophy

—•— My Ideas, Organized —•— Get an Avatar —•— Acronyms —•—


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Sat Mar 10, 2012 2:54 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7885
Location: Vancouver, BC
Bigjoe5 wrote:
The mineral stockpile isn't a meter, so you can't use "Value + whatever" like for SetMeter effects.
There are actually quite a few parameters for which "Value" can be used that aren't meters. Even non-number things like planet size or type can work, though there's probably not much use for that in practice...
eleazar wrote:
Thanks, but neither that nor several semi-plausible variations changed the error. It really wants an integer there.
I think the problem is that SetOwnerMineralStockpile isn't a valid effect. I don't know why it's complaining about the lack of an integer rather than the nonrecognized effect name label, but try "SetEmpireMineralStockpile empire = Target.EmpireID value = Value + 20" or omit the "empire = Target.EmpireID" part.


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Sun Mar 11, 2012 8:21 pm 
Offline
Design & Graphics Lead
User avatar

Joined: Sat Sep 23, 2006 7:09 pm
Posts: 3693
Location: USA — midwest
Code:
Special
    name = "SCAVENGE_MINERALS_SPECIAL"
    description = "SCAVENGE_MINERALS_SPECIAL_DESC"
    spawnrate = 5.0
    spawnlimit = 9999
    location = And [
        Planet
        Not ContainedBy Contains Homeworld
    ]
    EffectsGroup
        scope = And [
            Planet
            Ship
        ]
        activation = ContainedBy And [
            System
            Contains And [
                Ship
                OwnedBy AnyEmpire
            ]
        ]
        effects = [
            SetEmpireMineralStockpile value = Value + 20
            RemoveSpecial "SCAVENGE_MINERALS_SPECIAL"
            GenerateSitRepMessage
                message = "EFFECT_SCAVENGE_MINERALS"
                parameters = [
                    tag = "system" data = Source.ID
                ]
        ]
    graphic = "icons/specials_huge/abandoned-colony.png"


The above doesn't cause any errors. But it doesn't do anything either. If somebody more script-savvy wants to try to make this work i'd appreciate it. Maybe somebody in the community that's not a regular dev?

_________________
—• Read this First before posting Game Design Ideas!
—• Design Philosophy

—•— My Ideas, Organized —•— Get an Avatar —•— Acronyms —•—


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Sun Mar 11, 2012 8:54 pm 
Offline
Designer and Programmer
User avatar

Joined: Tue Aug 14, 2007 6:33 pm
Posts: 1770
Location: Orion
eleazar wrote:
Code:
        scope = And [
            Planet
            Ship
        ]

This is the problem. The special does stuff when that And is changed to Or. However, if you want to generate only one sitrep message, you should probably have two effects groups, one that acts on Source, and one that acts on the ship (with a stackinggroup).

_________________
Warning: Antarans in dimensional portal are closer than they appear.


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Sun Mar 11, 2012 10:41 pm 
Offline
Design & Graphics Lead
User avatar

Joined: Sat Sep 23, 2006 7:09 pm
Posts: 3693
Location: USA — midwest
Bigjoe5 wrote:
eleazar wrote:
Code:
        scope = And [
            Planet
            Ship
        ]

This is the problem. The special does stuff when that And is changed to Or. However, if you want to generate only one sitrep message, you should probably have two effects groups, one that acts on Source, and one that acts on the ship (with a stackinggroup).

That makes all the specials in the galaxy fire at the same time-- and i think give every empire 20 minerals per special.

_________________
—• Read this First before posting Game Design Ideas!
—• Design Philosophy

—•— My Ideas, Organized —•— Get an Avatar —•— Acronyms —•—


Top
 Profile  
 
 Post subject: Re: Help with EffectsGroups
PostPosted: Sun Mar 11, 2012 10:47 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7885
Location: Vancouver, BC
eleazar wrote:
That makes all the specials in the galaxy fire at the same time-- and i think give every empire 20 minerals per special.
Or [ Ship Planet ] matches every ship and every planet in the universe, so each empire would receive +20 per ship or per planet, per copy of the special that is active that turn. If you want it to only act on a particular ship or planet, you'll need to be more specific in the scope.

Note that the activation just determines if the effectsgroup is active; it doesn't affect the scope at all.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 115 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 8  Next

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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group