Page 1 of 2
scope focussing on 2 objects: possible or not?
Posted: Tue Feb 25, 2014 12:30 pm
by StGW44
This is a question for the scripting pro's:
Is it somehow possible to set the focus for effects to where something like this produces legal results:
(example code)
Code: Select all
scope = And [
Ship
DesignHasPart "some_part"
ContainedBy And [
System
Contains And [
Planet
OwnedBy EnemyOf Source.Owner
]
]
]
effects = [
Target.AddSpecial "Special=Planet-manipulation"
Source.AddSpecial "Special=Ship-manipulation"
]
I am looking for a way to make a ship part manipulate a planet ONCE and then to turn itself off (as to the part being depleted). My problem is that the scope of the ship part is allways ALL the ships having the same part installed while resting in same system AND that the one part causes multiple effects íf there are more then one legal "effects candidates" present...
Any help would be greatly appreciated!
Re: scope focussing on 2 objects: possible or not?
Posted: Tue Feb 25, 2014 5:41 pm
by Geoff the Medio
The "Source" condition will select just the source object.
You can Or two conditions, one of which is the Source to select the source and other objects.
You can select a specific number of objects that match another condition using the NumberOf condition. Examples of this are used in MoveTo effects such as
Code: Select all
MoveTo NumberOf 1 And [
System And [
WithinStarlaneJumps 1 Target
WithinStarlaneJumps 1 And [
Planet
OwnedBy TheEmpire Source.Owner
TargetPopulation low = 1
]
]
]
Re: scope focussing on 2 objects: possible or not?
Posted: Tue Feb 25, 2014 6:56 pm
by StGW44
Thanks for your answer!
I have tried to get the clue but did not succeed!
You, I think, have been referring to the Psycho-Domination effect and looking at it, I understand that the effect can be a choice of several possibilities (different legal destinations, I guess here is where the "NumberOf" comes into play??). This effect is, however, still referring to only one target, here the dominated ship (or multiple ships, as this makes no difference to the effect beings the ships are in the same scope).
I was trying to delegate effects to 2 different entities, not actually 1 entity with multiple instances (in my example the planet and the ship part are suppose to be altered by adding a special to both at the same time)
However, I fear this actually is not possible as I cannot, for the effect, get the planet in scope without loosing the scope to the ship part or vice versa...
Re: scope focussing on 2 objects: possible or not?
Posted: Tue Feb 25, 2014 7:10 pm
by Geoff the Medio
Geoff the Medio wrote:You can Or two conditions, one of which is the Source to select the source and other objects.
Re: scope focussing on 2 objects: possible or not?
Posted: Tue Feb 25, 2014 10:32 pm
by StGW44
Sorry, I cant relate your answer to my question. In
using the command "SetStructure " will reduce "structure" by halve for whatever object was in focus in the scope section, right?
How do I do this for a ship "InSystem" with the planet in scope? Can it be done within one and the same EffectsGroup structure? If yes, please provide a short example!
Best regards,
Robert
Re: scope focussing on 2 objects: possible or not?
Posted: Tue Feb 25, 2014 11:58 pm
by Dilvish
I'll expand on Geoff's answer for you, here is an example script that gets at least part of what you want. This sort of solves the issue with multiple target planets in that it, but it does not solve the issue with all the ships with that part in that system being affected, and if there are multiple such ships and multiple enemy planets then they each would choose a planet and there could be overlap. Since you describe the Source being a ship in this system, I am presuming you intend this to be in a Ship Part specification, and in that case there is no need to explicitly refer in the script to the fact that the Source is a ship containing that part. In this case you would just use the same special for both the planet and the ship and the special would simply have different EffectsGroups covering each of those cases.
Code: Select all
scope = Or [
Source
NumberOf 1 And [
Planet
Insystem Source.SystemID
OwnedBy EnemyOf Source.Owner
]
]
activation = And [
ContainedBy And [
System
Contains And [
Planet
OwnedBy EnemyOf Source.Owner
]
]
]
effects = AddSpecial "Planet-Ship-manipulation"
Re: scope focussing on 2 objects: possible or not?
Posted: Wed Feb 26, 2014 12:06 pm
by StGW44
Hello Dilvish,
thanks a lot for your answer and the example scrip! Seems I mis-interpreted the meaning of the "numberOf" statement totally!
Bringing this thread to an end, I recollect the data as follows:
I can set the focus on many different objects in the scope-scection of the effectsgroups, but the effects-statement cant distinguish single separate objects, where one affects a ship, another a planet.
I actually have been trying to do exactly what you suggested, putting the special on both, planet and ship. Still trying to get the ship part to turn off without overlapping occurences. This ship part is a bomb, doing several things to the planet and after the planet-side action, it is suppose to turn itself off. Latter part aint working for me...
I am using the "OrderedBombardedBy" statement, which works great for the planet, but I dont know how to identify the ship, that ordered the bombing.
The code for this became rather complicated and intertwined, thats why I spare u with it. If u want to take a look at it, I'd be happy to post it...
Best regards,
Robert
Re: scope focussing on 2 objects: possible or not?
Posted: Wed Feb 26, 2014 3:11 pm
by Dilvish
StGW44 wrote:I am using the "OrderedBombardedBy" statement, which works great for the planet, but I dont know how to identify the ship, that ordered the bombing. The code for this became rather complicated and intertwined, thats why I spare u with it. If u want to take a look at it, I'd be happy to post it...
Looking at Geoff's explanation of OrderedBombardedBy a bit more, it looks like you should be able to use it to identify both the bombarding ship and the bombarded planet, & might be able to fully clear up the multiples issues. Go ahead and post your current script and I'll see if I can give a further suggestion.
Re: scope focussing on 2 objects: possible or not?
Posted: Wed Feb 26, 2014 4:24 pm
by StGW44
Here is what I have been put together. The code produces pretty much reliable results, however, the part does not turn off the way I wanted it. Nesting Specials is not a good way to handle things, as there is a one-turn-delay until the nested Special appears...
(ship_part.txt)
Code: Select all
Part
name = "SR_WEAPON_LB"
description = "SR_WEAPON_LB_DESC"
class = General
mountableSlotTypes = Core
buildcost = 1000 * [[FLEET_UPKEEP_MULTIPLICATOR]]
buildtime = 12
tags = "BOMB"
location = All
effectsgroups = [
EffectsGroup
scope = And [
Building
ContainedBy And [
Planet
OrderedBombardedBy condition = Source
InSystem Source.SystemID
VisibleToEmpire Source.Owner
OwnedBy EnemyOf Source.Owner
]
]
activation = And [
Ship
NOT HasSpecial "LSB_INACTIVE"
]
effects = Destroy
EffectsGroup
scope = And [
Planet
InSystem Source.SystemID
OrderedBombardedBy condition = Source
OwnedBy EnemyOf Source.Owner
Or [
Planet Size = Tiny
Planet Size = Small
]
NOT Planet Size = Asteroids
VisibleToEmpire Source.Owner
]
activation = And [
Ship
NOT HasSpecial "LSB_INACTIVE"
]
effects = [ // removing all Special not aplicable for asteroids
RemoveSpecial "ECCENTRIC_ORBIT_SPECIAL"
RemoveSpecial "TIDAL_LOCK_SPECIAL"
RemoveSpecial "SLOW_ROTATION_SPECIAL"
RemoveSpecial "HIGH_AXIAL_TILT_SPECIAL"
RemoveSpecial "SOLID_CORE_SPECIAL"
RemoveSpecial "TECTONIC_INSTABILITY_SPECIAL"
RemoveSpecial "ANCIENT_RUINS_SPECIAL"
RemoveSpecial "PANOPTICON_SPECIAL"
RemoveSpecial "TUNNELS_SPECIAL"
RemoveSpecial "RESONANT_MOON_SPECIAL"
RemoveSpecial "GAIA_SPECIAL"
SetPlanetType Type = Asteroids
AddSpecial "DEPOP_PLANET" // removes people, buildings, troops and sets back meters
]
//##########################################
// NOT HasSpecial "TECTONIC_INSTABILITY_SPECIAL" ...could implement a planet chance into inferno?
// NOT HasSpecial "TUNNELS_SPECIAL" ...could implement the planet size being reduced by one?
EffectsGroup
scope = And [
Planet
InSystem Source.SystemID
OrderedBombardedBy condition = Source
OwnedBy EnemyOf Source.Owner
Or [
Planet Size = Medium
Planet Size = Large
Planet Size = Huge
]
VisibleToEmpire Source.Owner
]
activation = And [
Ship
NOT HasSpecial "LSB_INACTIVE"
]
effects = [
RemoveSpecial "SOLID_CORE_SPECIAL" // beings the planet is burnt to hell, it should warm up a bit...
RemoveSpecial "ANCIENT_RUINS_SPECIAL"
RemoveSpecial "PANOPTICON_SPECIAL"
RemoveSpecial "TUNNELS_SPECIAL"
RemoveSpecial "GAIA_SPECIAL"
SetPlanetType Type = Barren
AddSpecial "DEPOP_PLANET" // removes people, buildings, troops and meters
]
/* EffectsGroup // here the ship part needs to get deactivated
scope = Source
activation = And [
Ship
InSystem Source.SystemID
OrderedBombardedBy condition = Source [color=#FF0000]// Does not do the trick like that..[/color]
OwnedBy EnemyOf Source.Owner
VisibleToEmpire Source.Owner
]
effects = AddSpecial "LSB_INACTIVE"
*/
]
icon = "icons/ship_parts/laser-bomb.png"
(specials.txt)
Code: Select all
Special
name = "DEPOP_PLANET"
description = "DEPOP_PLANET_DESC"
effectsgroups = [
EffectsGroup
scope = And [
Planet
HasSpecial "DEPOP_PLANET"
WithinDistance 0.00001 Source
]
effects = [
SetPopulation Value = 0
SetIndustry Value = 0
SetTargetIndustry Value = 0
SetResearch Value = 0
SetTargetResearch Value = 0
SetMaxTroops Value = 0
SetMaxDefense Value = 0
// SetOwner Value = 0 [color=#FF0000]// Setting owner to "unowned" seems impossible??[/color]
// RemoveSpecial "DEPOP_PLANET" // but to a later time, so player can read results
AddSpecial "LSB_DEACTIVATE" // nesting does not work right, this is executed one turn after "DEPOP_PLANET"
]
]
graphic = ""
// playing around with the nested Specials but this is a dead end!!
Special
name = "LSB_DEACTIVATE"
description = "LSB_DEACTIVATE_DESC"
effectsgroups = [
EffectsGroup
scope = Or [
And [
OrderedBombardedBy condition = Source
Planet
InSystem Source.SystemID
]
And [
OrderedBombardedBy condition = Source
Ship
InSystemID = Source.SystemID
]
]
activation = And [
OrderedBombardedBy condition = Source
Ship
HasTag "Bomb"
InSystemID = Source.SystemID
]
effects = AddSpecial "LSB_INACTIVE"
]
graphic = ""
Special
name = "LSB_INACTIVE"
description = "LSB_INACTIVE_DESC"
effectsgroups = [
EffectsGroup
scope = And [
OrderedBombardedBy condition = Source
Ship
InSystem Source.SystemID
]
effects = SetTargetStructure Value / 2 // setting off such a bomb should inflict some damage on the acting ship as well...
]
graphic = ""
Re: scope focussing on 2 objects: possible or not?
Posted: Wed Feb 26, 2014 4:28 pm
by StGW44
Dilvish wrote:Looking at Geoff's explanation of OrderedBombardedBy[/url] a bit more, it looks like you should be able to use it to identify both the bombarding ship...
I would really appreciate an example of how I can trace the ship doing the bombing!
Best regrads,
Robert
Re: scope focussing on 2 objects: possible or not?
Posted: Wed Feb 26, 2014 7:33 pm
by Dilvish
As a first note, I think Geoff indicated that although the bombardment may not currently always cancel after one turn, it is supposed to and will be followed up on, the script should probably assume it is only for one turn per order.
StGW44 wrote:Here is what I have been put together....
Regarding this first piece, as an efficiency note I would suggest you consider
Code: Select all
InSystem Source.SystemID
VisibleToEmpire Source.Owner
OwnedBy EnemyOf Source.Owner
to be already covered by
Code: Select all
OrderedBombardedBy condition = Source
As for the main problem with the "EffectsGroup // here the ship part needs to get deactivated" Effectsgroup (besides being commented out), the InSystem and VisibleToEmpire portions are pointless -- remember the activation clause is a condition applied to the Source. The "OwnedBy EnemyOf Source.Owner" clause is a self-contradiction here that would cause any activation clause to fail, and the line
Code: Select all
OrderedBombardedBy condition = Source
should instead be
Code: Select all
Number low = 1 condition = OrderedBombardedBy condition = Source
For more info on Number and NumberOf
see here. I also think that the "SetTargetStructure Value / 2" clause currently part of the "LSB_INACTIVE" special should instead be one of the effects of this same EffectsGroup, because by the time the LSB_INACTIVE special is applied and processed as a special it will be the next turn and the ship is expected to be no longer bombarding the target planet. It looks to me that the LSB_INACTIVE special itself needs no EffectsGroups at all, it's merely a marker referenced by your main part script.
Regarding the DEPOP_PLANET special, it looks to me like the scope should just be "Source", the current scope is pointless; the SetOwner clause should use "-1" for the empireID to make something unowned (see, e.g., Psych_Dom). The LSB_DEACTIVATE special should be entirely unneeded.
See if that clears things up.
Re: scope focussing on 2 objects: possible or not?
Posted: Wed Feb 26, 2014 8:42 pm
by StGW44
Dilvish wrote:Regarding this first piece, as an efficiency note I would suggest you consider
Code: Select all
InSystem Source.SystemID
VisibleToEmpire Source.Owner
OwnedBy EnemyOf Source.Owner
to be already covered by
Code: Select all
OrderedBombardedBy condition = Source
Fixed and working
Dilvish wrote:Regarding the DEPOP_PLANET special, it looks to me like the scope should just be "Source", the current scope is pointless;
Fixed
Dilvish wrote:the SetOwner clause should use "-1" for the empireID to make something unowned (see, e.g., Psych_Dom).
Does unfortunately not work, it produces an error.
And to the main problem...
Dilvish wrote:Code: Select all
OrderedBombardedBy condition = Source
should instead be
Code: Select all
Number low = 1 condition = OrderedBombardedBy condition = Source
Here is what I wrote:
Code: Select all
EffectsGroup
scope = And [
Ship
HasTag "BOMB"
Number low = 1 condition = OrderedBombardedBy condition = Source
]
effects = [
AddSpecial "LSB_INACTIVE"
SetStructure Value / 2
]
Will not distinguish in between the ships at all. Any effect applies to everything. Adding the " Ship and the "BOMB" Tag narrows it down to the tagged ships, regardless of their location.
Or did I get something wrong here?
Thanks again for the help!
Re: scope focussing on 2 objects: possible or not?
Posted: Wed Feb 26, 2014 10:09 pm
by StGW44
Still not able to pinpoint the bombarding ship, I have been checking the log and found this passage:
Code: Select all
2014-02-26 23:01:08,900 DEBUG Server : BombardOrder::ExecuteImpl set for ship 6483 Schemali to bombard planet 161 Alula γ III
How come I cannot retrieve the ships ID using the "OrderedBombardedBy" command?
I sure hope there will be some usage for the code I am trying to get running, maybe later on somewhere in this awesome game?!
Best regards,
Robert
Re: scope focussing on 2 objects: possible or not?
Posted: Thu Feb 27, 2014 3:33 am
by Dilvish
StGW44 wrote:Here is what I wrote:
Code: Select all
EffectsGroup
scope = And [
Ship
HasTag "BOMB"
Number low = 1 condition = OrderedBombardedBy condition = Source
]
effects = [
AddSpecial "LSB_INACTIVE"
SetStructure Value / 2
]
??? I told you how to fix the activation clause, I didn't say to remove it entirely or to change that simple scope=Source clause. When you found your initial understanding of my advice didn't work for you, did you go back and review it before asking for more?
Dilvish wrote:the SetOwner clause should use "-1" for the empireID to make something unowned (see, e.g., Psych_Dom).
Does unfortunately not work, it produces an error.
If you want more help on this you should show at least the exact line you used (the whole effectsgroup should be pretty short so may as well show it all) and explain what error was produced.
Re: scope focussing on 2 objects: possible or not?
Posted: Thu Feb 27, 2014 10:33 am
by StGW44
Dilvish wrote:When you found your initial understanding of my advice didn't work for you, did you go back and review it before asking for more?
The "initial understandig" was the problem, solely on my side and no I didnt!
Have fixed it and you're right, it works. However, the bombing does not cancel itself out on my games...
Manually cancelling it out requires several clicks on the "bombing" and "cancel bombing" buttons until the original bombing order is canceled out. If not canceled, effects will keep on firing as well...
Dilvish wrote:the SetOwner clause should use "-1" for the empireID to make something unowned (see, e.g., Psych_Dom).
Does unfortunately not work, it produces an error.
Dilvish wrote:If you want more help on this you should show at least the exact line you used (the whole effectsgroup should be pretty short so may as well show it all) and explain what error was produced.
Code: Select all
2014-02-27 11:00:32,147 DEBUG Server : ServerApp::ProcessTurns movement
2014-02-27 11:00:32,281 ERROR Server : C:\Program Files (x86)\FreeOrion\default\specials.txt:2196:13: Parse error. Expected [ Effect, ... ] -OR- Effect here:
name = "DEPOP_PLANET"
description = "DEPOP_PLANET_DESC"
effectsgroups = [
EffectsGroup
scope = Source
effects = [
^
SetPopulation Value = 0
SetIndustry Value = 0
SetTargetIndustry Value = 0
SetResearch Value = 0
SetTargetResearch Value = 0
2014-02-27 11:00:32,408 DEBUG Server : Universe::serialize : Getting gamestate data
...has being the error message from this
Code: Select all
Special
name = "DEPOP_PLANET"
description = "DEPOP_PLANET_DESC"
effectsgroups = [
EffectsGroup
scope = Source
effects = [
SetPopulation Value = 0
SetIndustry Value = 0
SetTargetIndustry Value = 0
SetResearch Value = 0
SetTargetResearch Value = 0
SetMaxTroops Value = 0
SetMaxDefense Value = 0
SetOwner Value = -1
AddSpecial "LSB_DEACTIVATE"
]
]
graphic = ""
I mark out the "SetOwner" statement and it works...
Beings the fun-factor got lost here, its best to end this. Change of owner is irrelevant! Sorry for the aggrevation
Regards,
Robert