FreeOrion

Forums for the FreeOrion project
It is currently Thu Dec 14, 2017 5:59 am

All times are UTC




Post new topic Reply to topic  [ 50 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
PostPosted: Mon Sep 26, 2016 12:13 pm 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
Geoff the Medio wrote:
Hmm. I suspect that there's some code that is set up to only execute SetMeter effects but isn't recognizing that the If effect might contain SetMeter effects, so is skipping over them when updating meters.


You know worse yet i tried and tried to get number of to work in sequence with activation to no avail. kept getting script errors or it just failed to work at all, otherwise maybe i could work around it in that way but.

Humm well im stumped ?


Last edited by xlightwavex on Mon Sep 26, 2016 12:23 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 12:17 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
To clarify, it's not an issue with your script; it's an issue with the code that executes your script.

For now, you probably can't use If/else effects with SetMeter in them. Hopefully I can fix it soon, though.


Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 12:24 pm 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
Geoff the Medio wrote:
To clarify, it's not an issue with your script; it's an issue with the code that executes your script.

For now, you probably can't use If/else effects with SetMeter in them. Hopefully I can fix it soon, though.


Is there a example for SetMeter ?.

I have a partial solution but i would have to drop being able to fire on cloaks with a 1 in 4 chance to hit completely. That is just to have the messages in if else and destroy in one or the other and always do damage.

Well the next attempt may have to wait for a bit but ill try it.


Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 1:12 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
xlightwavex wrote:
Is there a example for SetMeter ?
Probably in mines techs.
Quote:
That is just to have the messages in if else and destroy in one or the other and always do damage.
You only really need the GenerateSitrep and Destroy effects in the If/else effect; you could just have the SetMeter effect always execute (not with an If effect), and then also destroy the ship and generate the destroy message if its structure is low enough, and just generate a damaged sitrep if its structure is high enough.


Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 9:50 pm 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
Geoff the Medio wrote:
xlightwavex wrote:
Is there a example for SetMeter ?
Probably in mines techs.
Quote:
That is just to have the messages in if else and destroy in one or the other and always do damage.
You only really need the GenerateSitrep and Destroy effects in the If/else effect; you could just have the SetMeter effect always execute (not with an If effect), and then also destroy the ship and generate the destroy message if its structure is low enough, and just generate a damaged sitrep if its structure is high enough.


Ah sorry i misread what you said, i saw cant as can lol. I thought you were referring to SetMeter as a different way to achieve it like it was a separate keyword, i see though.

Yes i can get a partial resolution for the moment but it is a bit disappointing. Have you taken a look to see how hard of a fix that is ?


Last edited by xlightwavex on Mon Sep 26, 2016 9:59 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 9:59 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
Until people start actually using scriptable functions, issues such as this don't pop up. Fixing it isn't trivial, either.


Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 10:00 pm 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
Geoff the Medio wrote:
Fixing it isn't trivial, either.
Ackkkkk !!!!

Well it looks like my first contribution to fo is in giving you a headache/bug to solve. :)

New question how do planetary shields work vs bombardment or to stop damage ?


Here is the temporary version for now.
The tech remains the same as displayed in the very first post.
As well as the full code that should work but cant due to the bug.

Code:
BuildingType
name = "BLD_PLANETARY_GUN"
description = "BLD_PLANETARY_GUN_DESC"
buildcost = 10
buildtime = 1
location = And
[
    Planet
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
EnqueueLocation = And
[
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Enqueued type = Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
effectsgroups =
[
    EffectsGroup
    scope = NumberOf number = 1 condition = And   
    [
        Ship
        InSystem id = Source.SystemID
        OwnedBy affiliation = EnemyOf empire = Source.Owner         
    ]
    //
    // Non cloaked ships
    //
    effects =
    [
       
        SetStructure value = Value -((CurrentTurn / 14 + Target.MaxStructure / 6) +4 - Target.Shield)
        SetFuel value = Value -(.5+ Target.MaxFuel / 5) 
       
        If condition = and
        [
            Structure high = ((CurrentTurn / 14 + Target.MaxStructure / 6) +4 - Target.Shield)
            VisibleToEmpire empire = Source.Owner 
        ]
        effects =
        [
            Destroy
             //
            // msg to the player firing the gun
            GenerateSitrepMessage
                message = "EFFECT_PLANETARY_GUN_HIT_DESTROYED"
                label = "EFFECT_PLANETARY_GUN_LABEL"
                icon = "icons/sitrep/combat_destroyed.png"
                parameters =
                [
                    tag = "planet" data = Source.PlanetID
                    tag = "building" data = Source.ID
                    tag = "source" data = Source.Owner
                    tag = "target" data = Target.Owner
                    tag = "ship" data = Target.ID
                ]
                empire = Source.Owner
             //
            // msg to the player hit destroyed
            GenerateSitrepMessage
                message = "EFFECT_PLANETARY_GUN_DESTROYED_ME"
                label = "EFFECT_PLANETARY_GUN_LABEL"
                icon = "icons/sitrep/combat_destroyed.png"
                parameters =
                [
                    tag = "planet" data = Source.PlanetID
                    tag = "building" data = Source.ID
                    tag = "ship" data = Target.ID
                ]
                empire = Target.Owner
        ]
        else = if condition = and
        [
            Structure low = ((CurrentTurn / 14 + Target.MaxStructure / 6) +4 - Target.Shield)
            VisibleToEmpire empire = Source.Owner 
        ]
        effects =
        [
            //SetStructure value = Value -((CurrentTurn / 14 + Target.MaxStructure / 6) +4 - Target.Shield)
            //SetFuel value = Value -(.5+ Target.MaxFuel / 5) 
             //
            // msg to the player firing the gun
            GenerateSitrepMessage
                message = "EFFECT_PLANETARY_GUN_HIT"
                label = "EFFECT_PLANETARY_GUN_LABEL"
                icon = "icons/meter/damage.png"
                parameters =
                [
                    tag = "planet" data = Source.PlanetID
                    tag = "building" data = Source.ID
                    tag = "ship" data = Target.ID
                    tag = "rawtext" data = ((CurrentTurn / 14 + Target.MaxStructure / 6) +4 - Target.Shield)
                    tag = "source" data = Source.Owner
                    tag = "target" data = Target.Owner
                    //tag = "empire" data = Target.Owner
                ]
                empire = Source.Owner
             //
            // msg to the player that was hit
            GenerateSitrepMessage
                message = "EFFECT_PLANETARY_GUN_HIT_ME"
                label = "EFFECT_PLANETARY_GUN_LABEL"
                icon = "icons/meter/damage.png"
                parameters =
                [
                    tag = "planet" data = Source.PlanetID
                    tag = "building" data = Source.ID
                    tag = "rawtext" data = ((CurrentTurn / 14 + Target.MaxStructure / 6) +4 - Target.Shield)
                    tag = "ship" data = Target.ID
                ]
                empire = Target.Owner
        ]
    ]
]
icon = "icons/meter/damage.png"
#include "/scripting/common/priorities.macros"
#include "/scripting/common/base_prod.macros"


If you give me sets in nested if's, i can probably make a bunch of cool scripts.


Top
 Profile  
 
PostPosted: Tue Sep 27, 2016 8:43 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
Geoff the Medio wrote:
Fixing it isn't trivial, either.
I've pushed some changes that will hopefully (but probably not completely) fix the issues with meter modifications in if effects. If you can't compile from source, then you'll have to wait for the next text build in a week, unless Vezzra's away by then... then I'm not sure when.


Top
 Profile  
 
PostPosted: Wed Sep 28, 2016 7:14 am 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
Geoff the Medio wrote:
Geoff the Medio wrote:
Fixing it isn't trivial, either.
I've pushed some changes that will hopefully (but probably not completely) fix the issues with meter modifications in if effects. If you can't compile from source, then you'll have to wait for the next text build in a week, unless Vezzra's away by then... then I'm not sure when.


A long while ago i built this from source but im probably going to be busy for the next couple days.
If i can get it to build trivially right now ill give it a shot, but probably not as im having a slight hardware issue i think atm or did and im not sure its actually fixed yet. If not sometime in the next few days ill try out the changes and report back the results.


Top
 Profile  
 
PostPosted: Fri Sep 30, 2016 8:47 pm 
Offline
Release Manager, Design
User avatar

Joined: Wed Nov 16, 2011 12:56 pm
Posts: 4289
Location: Sol III
Geoff the Medio wrote:
...unless Vezzra's away by then...
He already is away... 8)

I will try to provide test builds even while I'm away, but can't make any promises. It all depends if and when I might have remote access to a system where I can build FO. So test builds will be a bit unpredictable for the next few weeks.


Top
 Profile  
 
PostPosted: Sat Oct 01, 2016 12:27 am 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
I got it to build and run just not sure were the installer is. I am running the version i compiled atm though right from the compiled exe.

Have to get far enough in to see how the changes went as i had to start a new game over. It seemed to be working fairly well except the sitreps.

RE: the SetMeter calls appear to be working but im not sure yet as im not sure the damage matches what i see in the sitreps. Its really hard to test when ai ship names are all the same.

Anyways my dl'ed version is from a few days ago so im not sure i got the one with the second set of fixes compiling this takes forever though and i forgot to change the ship name in c++ code thing i asked about earlier.

RE:RE:

Going to re-download everything again and recompile it, i think im seeing delayed destroyed messages but i think it is actually destroying them and the SetMeter is in general working it seems at least damage and messages for it are being displayed.

Something definitely isn't right. It seems like a if effect is executing after the turn or sometimes a msg will, something not sure yet changing my script up to narrow it down.


Last edited by xlightwavex on Sun Oct 02, 2016 11:19 am, edited 2 times in total.

Top
 Profile  
 
PostPosted: Sun Oct 02, 2016 11:16 am 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
Unless im missing something im doing, the effects are repeating and so are the messages the following turn. No matter what i do. I tried activation source and using priority just not working using if else if or even in the final test with just nesting visibility check doesn't seem to make a difference either. Its acting like there are two guns in a system with just one or something sometimes it seems to be delaying or repeating effects and messages or double executing them. So im gonna say its not working right unless you can see something fundamental that would cause that.

Code:
 //Tst 5g


BuildingType
name = "BLD_PLANETARY_GUN"
description = "BLD_PLANETARY_GUN_DESC"
buildcost = 10
buildtime = 1
location = And
[
    Planet
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
EnqueueLocation = And
[
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Enqueued type = Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
effectsgroups =
[
    EffectsGroup
    scope = NumberOf number = 1 condition = And   
    [
        Ship
        InSystem id = Source.SystemID
        OwnedBy affiliation = EnemyOf empire = Source.Owner         
    ]
    activation = Source
    priority = 76
    effects =
    [
           
        If condition = and
        [
            Structure low = 15
        ]
        effects =
        [
            if condition = and
            [
                VisibleToEmpire empire = Source.Owner 
            ]
            effects =
            [
           
             SetStructure value = Value - 15
             SetFuel value = Value -(.5+ Target.MaxFuel / 5) 
     
             //   
             // target damaged msg to the player firing the gun
             //
             GenerateSitrepMessage
                message = "EFFECT_PLANETARY_GUN_HIT"
                label = "EFFECT_PLANETARY_GUN_LABEL"
                icon = "icons/meter/damage.png"
                parameters =
                [
                   tag = "planet" data = Source.PlanetID
                   tag = "building" data = Source.ID
                   tag = "target" data = Target.Owner
                   tag = "ship" data = Target.ID
                   tag = "rawtext" data = 15
                   tag = "targethp" data = Target.Structure
                ]
                empire = Source.Owner
            ]
        ]
        else =
        [
            If condition = and
            [
                VisibleToEmpire empire = Source.Owner 
            ]
            effects =
            [
                Destroy
               
                //
                // target destroyed msg for the player firing the gun
                //
                GenerateSitrepMessage
                    message = "EFFECT_PLANETARY_GUN_HIT_DESTROYED"
                    label = "EFFECT_PLANETARY_GUN_LABEL"
                    icon = "icons/sitrep/combat_destroyed.png"
                    parameters =
                    [
                        tag = "planet" data = Source.PlanetID
                        tag = "building" data = Source.ID
                        //tag = "source" data = Source.Owner
                        tag = "target" data = Target.Owner
                        tag = "ship" data = Target.ID
                        tag = "rawtext" data = 16
                    ]
                    empire = Source.Owner
            ]
        ]
    ]
]
icon = "icons/meter/damage.png"
#include "/scripting/common/priorities.macros"
#include "/scripting/common/base_prod.macros"



Code:

EFFECT_PLANETARY_GUN_LABEL
Planetary Gun

EFFECT_PLANETARY_GUN_HIT
At %planet% the %building% fired on and Hit %empire:target% ship %ship% with %rawtext:targethp% hp causing %rawtext% damage.

EFFECT_PLANETARY_GUN_HIT_DESTROYED
At %planet% the %building% fired on and Destroyed the %empire:target% ship %ship% with a shot for %rawtext% damage.

EFFECT_PLANETARY_GUN_HIT_CLOAK
The %planet% the %building% fired a blind shot and Hit the %empire:target% cloaked ship %ship%.

EFFECT_PLANETARY_GUN_HIT_DESTROYED_CLOAK
The %planet% the %building% fired a blind shot and Destroyed the %empire:target% cloaked ship %ship%.

EFFECT_PLANETARY_GUN_MISSED_CLOAK
At %planet% the %building% fired a blind shot at a suspected cloaked target but scored no hit.

EFFECT_PLANETARY_GUN_HIT_ME
At %planet% the %building% fired on and Hit your ship %ship% causing %rawtext% damage.

EFFECT_PLANETARY_GUN_DESTROYED_ME
At %planet% the %building% fired on and Destroyed your ship %ship%.

EFFECT_PLANETARY_GUN_TARGETING
(testing assert) The %planet% the %building% has targeted the %empire:target% ship %ship% with %rawtext:texta% structure and %rawtext:textb% fuel.

EFFECT_PLANETARY_GUN_TARGET
(testing assert) pgun target %ship% %rawtext:texta% structure and %rawtext:textb% fuel.


Top
 Profile  
 
PostPosted: Sun Oct 02, 2016 5:23 pm 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
Coming together nicely xlightwavex,
Having the visibility check within the effects means a target may be selected that is not visible, resulting in no damage that turn.
I've modified it slightly, adding the ability to hit monsters, which should be easier to test against if you set them to high.

Code:
BuildingType
name = "BLD_PLANETARY_GUN"
description = "BLD_PLANETARY_GUN_DESC"
buildcost = 10
buildtime = 1
location = And [
    Planet
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
EnqueueLocation = And [
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Enqueued type = Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
effectsgroups = [
    EffectsGroup
    scope = NumberOf number = 1 condition = And [
        Ship
        InSystem id = Source.SystemID
        Or [
            OwnedBy affiliation = EnemyOf empire = Source.Owner
            Unowned
        ]
        VisibleToEmpire empire = Source.Owner
    ]
    activation = Source
    priority = 76
    effects = [
        If
            condition =
                Structure low = 15
            effects = [
                SetStructure value = Value - 15
                SetFuel value = Value -(.5+ Target.MaxFuel / 5)
                //
                // target damaged msg to the player firing the gun
                //
                GenerateSitrepMessage
                    message = "EFFECT_PLANETARY_GUN_HIT"
                    label = "EFFECT_PLANETARY_GUN_LABEL"
                    icon = "icons/meter/damage.png"
                    parameters = [
                    tag = "planet" data = Source.PlanetID
                    tag = "building" data = Source.ID
                    tag = "target" data = Target.Owner  // did not troubleshoot this, userstring tag result is ERROR
                    tag = "ship" data = Target.ID
                    tag = "rawtext" data = 15
                    tag = "targethp" data = Target.Structure
                    ]
                    //empire = Source.Owner  // may want to add a sitrep for the target owner as well
            ]
        else = [
            Destroy
            //
            // target destroyed msg for the player firing the gun
            //
            GenerateSitrepMessage
                message = "EFFECT_PLANETARY_GUN_HIT_DESTROYED"
                label = "EFFECT_PLANETARY_GUN_LABEL"
                icon = "icons/sitrep/combat_destroyed.png"
                parameters = [
                    tag = "planet" data = Source.PlanetID
                    tag = "building" data = Source.ID
                    tag = "target" data = Target.Owner
                    tag = "ship" data = Target.ID
                    tag = "rawtext" data = 16
                ]
                //empire = Source.Owner
        ]
    ]
]
icon = "icons/meter/damage.png"
#include "/scripting/common/priorities.macros"
#include "/scripting/common/base_prod.macros"


Top
 Profile  
 
PostPosted: Mon Oct 03, 2016 1:02 am 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
Quote:
Having the visibility check within the effects means a target may be selected that is not visible
Are you sure wouldn't it simply be redundant ?

Quote:
// did not troubleshoot this, userstring tag result is ERROR

strange i get no error on running in the console window.

As far as the code its still not a solution, ive marked your version test 6a.
Even though that works for a single conditional switch in the specific order the primary problem is i need to be able to switch on visible or not and low high structure. This is a 1 pick of 4 possible cases, conditional branching problem. Which is why in post #1 the design is using if, else if, else if, else and has both structure and visibile checks as well as not visible The above are all test cases or temporary solutions.

I have however identified the issue. Took forever to figure out what was happening and it will take a minute to explain it. I may have to edit this several times to make it clear.

To summarize the if[] effect[] bracket behavior is inconsistent depending on the level of the nesting.

pseudo illustration

Code:
effect
[
  if[]effect[...the set effect will fire once...]
]


will not behave the same as

Code:
effect
[
  if[]effect
  [
     if[]effect[... the set effect will be fired twice...]
  ]
]


Basically a if condition effect in a effect bracket will fire once.
but another if effect bracket nested within that will fire twice

http://i936.photobucket.com/albums/ad207/xlightwavex/miscellaneous/stillbuggy63_zpswooboufy.png~original

Unfortunately this spills over to else if conditions as well.
illustrating the problem side by side we will get 3 hits with 2 guns the if works the else acts as a 3rd level nested effect which fires twice, which is in this case milotha1 the message placement is as well inconsistent to what would be expected with mI then mII then mI messages.
http://i936.photobucket.com/albums/ad207/xlightwavex/miscellaneous/stillbuggy6c_zpsgiyvjvd6.png~original

Consider the following examples.

Ex #1

This will fire each gun one time just like his example above but without the destroy messege.
However this cannot actually make use of a second condition within the if condition[ ... bracket properly ... ]
Code:
 // tst 6f same as 5a 5c  6a single shot visibility is not the problem
 // cant nest with a inner if inconsistent behavior
 // single nesting
 
BuildingType
name = "BLD_PLANETARY_GUN"
description = "BLD_PLANETARY_GUN_DESC"
buildcost = 10
buildtime = 1
location = And [
    Planet
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
EnqueueLocation = And [
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Enqueued type = Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
effectsgroups = [
    EffectsGroup
    scope = NumberOf number = 1 condition = And [
        Ship
        InSystem id = Source.SystemID
        Or [
            OwnedBy affiliation = EnemyOf empire = Source.Owner
            Unowned
        ]
        VisibleToEmpire empire = Source.Owner
    ]
    activation = Source
    priority = 76
    effects =
    [
        //
        // tst 6f behavior is inconsistent to a switch when a third if is nested
        // second effect scope is ok
        //
        If condition = and [
                Structure low = 15
        ]
        effects = [
                SetStructure value = Value - 15
                SetFuel value = Value -(.5+ Target.MaxFuel / 5)
                //
                // target damaged msg for the player firing the gun
                //
                GenerateSitrepMessage
                    message = "EFFECT_PLANETARY_GUN_HIT"
                    label = "EFFECT_PLANETARY_GUN_LABEL"
                    icon = "icons/meter/damage.png"
                    parameters =
                    [
                    tag = "planet" data = Source.PlanetID
                    tag = "building" data = Source.ID
                    tag = "target" data = Target.Owner  // did not troubleshoot this, userstring tag result is ERROR
                    tag = "ship" data = Target.ID
                    tag = "rawtext" data = 15
                    tag = "targethp" data = Target.Structure
                    ]
                    //empire = Source.Owner  // may want to add a sitrep for the target owner as well
           
        ]
    ]
]
icon = "icons/meter/damage.png"
#include "/scripting/common/priorities.macros"
#include "/scripting/common/base_prod.macros"


Ex #2.

This will fire each gun twice on the same target
Code:
 // tst 6e double shot same as 6a 5a visibility is not the problem
 // cant nest with a inner if .. effect[] at level 3 the effect executes twice
 
BuildingType
name = "BLD_PLANETARY_GUN"
description = "BLD_PLANETARY_GUN_DESC"
buildcost = 10
buildtime = 1
location = And [
    Planet
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
EnqueueLocation = And [
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Enqueued type = Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
effectsgroups = [
    EffectsGroup
    scope = NumberOf number = 1 condition = And [
        Ship
        InSystem id = Source.SystemID
        Or [
            OwnedBy affiliation = EnemyOf empire = Source.Owner
            Unowned
        ]
        VisibleToEmpire empire = Source.Owner
    ]
    activation = Source
    priority = 76
    effects =
    [
        //
        // behavior is inconsistent with a switch
        //
        If condition = and [
                Structure low = 15
        ]
        effects = [
            //
            // tst 6e double shot same as 6a 5a nested if
            // repeated condition which should evaluate to true when the above if does
            //
            If condition = and [
                 Structure low = 15
            ]
            effects = [
                //
                // unexpected this will execute twice
                //
                SetStructure value = Value - 15
                SetFuel value = Value -(.5+ Target.MaxFuel / 5)
                //
                // target damaged msg for the player firing the gun
                //
                GenerateSitrepMessage
                    message = "EFFECT_PLANETARY_GUN_HIT"
                    label = "EFFECT_PLANETARY_GUN_LABEL"
                    icon = "icons/meter/damage.png"
                    parameters =
                    [
                    tag = "planet" data = Source.PlanetID
                    tag = "building" data = Source.ID
                    tag = "target" data = Target.Owner  // did not troubleshoot this, userstring tag result is ERROR
                    tag = "ship" data = Target.ID
                    tag = "rawtext" data = 15
                    tag = "targethp" data = Target.Structure
                    ]
                    //empire = Source.Owner  // may want to add a sitrep for the target owner as well
            ]
        ]
    ]
]
icon = "icons/meter/damage.png"
#include "/scripting/common/priorities.macros"
#include "/scripting/common/base_prod.macros"


http://i936.photobucket.com/albums/ad207/xlightwavex/miscellaneous/stillbuggy63_zpswooboufy.png~original

Ex#3

The if which works as expected because its not within a third inner nested effect[ .. call ..] is ok, the else here however is not the else[ ..] itself acts like a effects call and adds a nesting level.
Code:
 // tst 6c  no double shot same as 6a visibility is not the problem
 // cant nest this though with a inner if in the else
 
BuildingType
name = "BLD_PLANETARY_GUN"
description = "BLD_PLANETARY_GUN_DESC"
buildcost = 10
buildtime = 1
location = And [
    Planet
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
EnqueueLocation = And [
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Enqueued type = Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
effectsgroups = [
    EffectsGroup
    scope = NumberOf number = 1 condition = And
    [
        Ship
        InSystem id = Source.SystemID
        Or
        [
            OwnedBy affiliation = EnemyOf empire = Source.Owner
            Unowned
        ]
    ]
    activation = Source
    priority = 76
    effects =
    [
        If
            condition = and
            [
                Structure low = 15
                Not VisibleToEmpire empire = Source.Owner
            ]
            effects =
            [
                SetStructure value = Value - 15
                SetFuel value = Value -(.5+ Target.MaxFuel / 5)
                //
                // target damaged msg for the player firing the gun
                //
                GenerateSitrepMessage
                    message = "EFFECT_PLANETARY_GUN_HIT"
                    label = "EFFECT_PLANETARY_GUN_LABEL"
                    icon = "icons/meter/damage.png"
                    parameters =
                    [
                    tag = "planet" data = Source.PlanetID
                    tag = "building" data = Source.ID
                    tag = "target" data = Target.Owner  // did not troubleshoot this, userstring tag result is ERROR
                    tag = "ship" data = Target.ID
                    tag = "rawtext" data = 15
                    tag = "targethp" data = Target.Structure
                    ]
                    //empire = Source.Owner  // may want to add a sitrep for the target owner as well
            ]
        else =
        [
            If
            condition = and
            [
                Structure low = 15
            ]
            effects = [
                SetStructure value = Value - 15
                SetFuel value = Value -(.5+ Target.MaxFuel / 5)
                //
                // target damaged msg for the player firing the gun
                //
                GenerateSitrepMessage
                    message = "EFFECT_PLANETARY_GUN_HIT"
                    label = "EFFECT_PLANETARY_GUN_LABEL"
                    icon = "icons/meter/damage.png"
                    parameters =
                    [
                    tag = "planet" data = Source.PlanetID
                    tag = "building" data = Source.ID
                    tag = "target" data = Target.Owner  // did not troubleshoot this, userstring tag result is ERROR
                    tag = "ship" data = Target.ID
                    tag = "rawtext" data = 15
                    tag = "targethp" data = Target.Structure
                    ]
                    //empire = Source.Owner  // may want to add a sitrep for the target owner as well
            ]
        ]
    ]
]
icon = "icons/meter/damage.png"
#include "/scripting/common/priorities.macros"
#include "/scripting/common/base_prod.macros"

http://i936.photobucket.com/albums/ad207/xlightwavex/miscellaneous/stillbuggy6c_zpsgiyvjvd6.png~original

Code:
 // tst 7c bypass attempt
 // cant nest this though with a inner if
 
BuildingType
name = "BLD_PLANETARY_GUN"
description = "BLD_PLANETARY_GUN_DESC"
buildcost = 10
buildtime = 1
location = And [
    Planet
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
EnqueueLocation = And [
    Not Contains Building name = "BLD_PLANETARY_GUN"
    Not Enqueued type = Building name = "BLD_PLANETARY_GUN"
    Not Planet type = [GasGiant]
    OwnedBy empire = Source.Owner
]
effectsgroups = [
    EffectsGroup
    scope = NumberOf number = 1 condition = And [
        Ship
        InSystem id = Source.SystemID
        Or [
            OwnedBy affiliation = EnemyOf empire = Source.Owner
            Unowned
        ]
        VisibleToEmpire empire = Source.Owner
    ]
    activation = Source
    priority = 76
    effects =
    [
        //
        // behavior is inconsistent with a switch
        //
        If condition = and [
                Structure high = 15
        ]
        effects = [
            Destroy
            //
            // target destroyed msg for the player firing the gun
            //
            GenerateSitrepMessage
                message = "EFFECT_PLANETARY_GUN_HIT_DESTROYED"
                label = "EFFECT_PLANETARY_GUN_LABEL"
                icon = "icons/sitrep/combat_destroyed.png"
                parameters = [
                    tag = "planet" data = Source.PlanetID
                    tag = "building" data = Source.ID
                    tag = "target" data = Target.Owner
                    tag = "ship" data = Target.ID
                    tag = "rawtext" data = 16
                ]
                //empire = Source.Owner
        ]
        else =
        [
            If condition = and [
                Structure low = 15
            ]
            effects = [
               
                //
                // tst 7c bypass if[]effect[] syntax required
                // if[][] if[] ... else[] not possible
                //
                    SetStructure value = Value - 15
                    SetFuel value = Value -(.5+ Target.MaxFuel / 5)
                    //
                    // target damaged msg for the player firing the gun
                    //
                    GenerateSitrepMessage
                        message = "EFFECT_PLANETARY_GUN_HIT"
                        label = "EFFECT_PLANETARY_GUN_LABEL"
                        icon = "icons/meter/damage.png"
                        parameters =
                        [
                        tag = "planet" data = Source.PlanetID
                        tag = "building" data = Source.ID
                        tag = "target" data = Target.Owner  // did not troubleshoot this, userstring tag result is ERROR
                        tag = "ship" data = Target.ID
                        tag = "rawtext" data = 15
                        tag = "targethp" data = Target.Structure
                        ]
                        //empire = Source.Owner  // may want to add a sitrep for the target owner as well
            ]
        ]
    ]
]
icon = "icons/meter/damage.png"
#include "/scripting/common/priorities.macros"
#include "/scripting/common/base_prod.macros"


7c effect consistency tests
http://i936.photobucket.com/albums/ad207/xlightwavex/miscellaneous/stillbuggy7c_zpsawnx7yhd.png~original


Last edited by xlightwavex on Mon Oct 03, 2016 5:50 am, edited 2 times in total.

Top
 Profile  
 
PostPosted: Mon Oct 03, 2016 2:46 am 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
xlightwavex wrote:
Quote:
Having the visibility check within the effects means a target may be selected that is not visible
Are you sure wouldn't it simply be redundant ?

It may be working off a copy of the universe with only objects that are visible to the source empire, so I am not certain.
If it is working on the full universe: without the VisibleToEmpire check in scope, the target candidates would include any non-visible enemy ships in the system.
In that event, the ship selected as the Target may not be visible to the source owner.

Quote:
Quote:
// did not troubleshoot this, userstring tag result is ERROR

strange i get no error on running in the console window.

Erm, my test was vs a monster...which is unowned, my mistake ;)
There was not a console emitted error, the resulting parameter/tag within the string read "ERROR", which is expected in this case.

Quote:
To summarize the if[] effect[] bracket behavior is inconsistent depending on the level of the nesting.
Good catch. Could you create and test a very simple example for a bug report?
I can do it later this week if you don't find the time.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 50 posts ]  Go to page Previous  1, 2, 3, 4  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® Forum Software © phpBB Group