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 ?
// 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: Select all
effect
[
if[]effect[...the set effect will fire once...]
]
will not behave the same as
Code: Select all
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/ad20 ... g~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/ad20 ... g~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: Select all
// 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: Select all
// 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/ad20 ... g~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: Select all
// 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/ad20 ... g~original
Code: Select all
// 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/ad20 ... g~original