Randomly targeting a enemy ship in system.
Moderators: Oberlus, Committer
-
- Space Kraken
- Posts: 111
- Joined: Mon Nov 16, 2015 5:57 am
Randomly targeting a enemy ship in system.
Ok so i had a thought, im sure most of you have seen star wars, Now if you remember empire strikes back, when they were on the ice planet, they had the giant ion cannon that fired to clear a path so the ships could escape.
So my question is how would i approach making a building that can fire, one really damaging shot per turn, on a random enemy ship, in the same system ? As well as limiting it to one gun per planet or system ?
Alternatively if that's not possible could i make this as a planets special, such as a artificial moon is.
I see that mines can basically do this to all enemy ships in a system but i think i like the idea of a single gun hitting a ship each turn early on as a defense.
So my question is how would i approach making a building that can fire, one really damaging shot per turn, on a random enemy ship, in the same system ? As well as limiting it to one gun per planet or system ?
Alternatively if that's not possible could i make this as a planets special, such as a artificial moon is.
I see that mines can basically do this to all enemy ships in a system but i think i like the idea of a single gun hitting a ship each turn early on as a defense.
-
- Programmer
- Posts: 389
- Joined: Sun Feb 14, 2016 12:08 am
Re: Randomly targeting a enemy ship in system.
Combat exists in 3 rounds, each object firing at a random enemy every round. The only current scenario that comes to mind when a ship doesn't fire during a round, would be when all of the opposing ships are not visible.
Buildings do not have an attack event, and are not part of combat currently (there is some discussion about it around here somewhere).
For a weapon that fires on ships, I'd argue it should be attackable and hence be part of combat. Additionally, it may be tough to argue that this should not just add to the planetary defense value.
Specials are not universe objects, so would not be capable of combat afaik.
Ignoring the above and just adding an effect to a building (special is viable too):
Define a building and define location to planets without this building. Alternatively, for one per system (needs testing, not 100%):
May also want to define EnqueueLocation specifically to help the AI not waste production (it may not build it anyway, still helpful to players and prevents some potential loopholes).
For the random selection, use NumberOf, or one of the SortedNumberOf associated tokens, in your effectsgroup scope.
Buildings do not have an attack event, and are not part of combat currently (there is some discussion about it around here somewhere).
For a weapon that fires on ships, I'd argue it should be attackable and hence be part of combat. Additionally, it may be tough to argue that this should not just add to the planetary defense value.
Specials are not universe objects, so would not be capable of combat afaik.
Ignoring the above and just adding an effect to a building (special is viable too):
Define a building and define location to planets without this building.
Code: Select all
location = And [
Planet
Not Contains
Building name = "BUILDING_NAME"
]
Code: Select all
location = And [
Planet
Not ContainedBy And [
System
Contains
Building name = "BUILDING_NAME"
]
]
For the random selection, use NumberOf, or one of the SortedNumberOf associated tokens, in your effectsgroup scope.
Re: Randomly targeting a enemy ship in system.
As possible workarounds, besides increasing the defense stat of the planet, you could also have the building spawn (and respawn if destroyed) some specifically designed stationary ship.
Another option would be to have the building work similar to the mine techs - just don't damage all ships but a single one. Take a look at the effect groups of the mine techs and e.g. SP_CHAOS_WAVE.focs.txt for the single target to see how it could potentially work.
Another option would be to have the building work similar to the mine techs - just don't damage all ships but a single one. Take a look at the effect groups of the mine techs and e.g. SP_CHAOS_WAVE.focs.txt for the single target to see how it could potentially work.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
-
- Space Kraken
- Posts: 111
- Joined: Mon Nov 16, 2015 5:57 am
Re: Randomly targeting a enemy ship in system.
Yes i wouldn't want this to be a defensive stat. Since mines already can hit any enemy ships in a system
I think it's better if a planetary gun can fire on any enemy ships in the system. It would be nice as well if the gun could only fire if not destroyed.
Im still dabbling with scripting though which brings up a question.
location = And
[
Planet
Not Contains
Building name = "BUILDING_NAME"
]
Why would it be 'Not' Contains instead of just Contains ?
Second what exactly does the 'Planet' keyword here specify or how does it act as a instruction ?
In the following Deathspore's script snippet, i see something which is similar but it includes Species as well. Then i see InSystem id ? i have no clue what this alludes to.
Which i turned into this using macros, though i hate all the brackets i actually think its still easier to read though im not sure if the name actually describes it well.
Provided i can get a grip on 'what the meaning and actions' of these scripting command do or are doing specifically, i could devise a keyword naming system. Im thinking i could probably simply use macro's and a disable txt file to create and describe a ton of wrapped up commands to simplify the entire scripting process. If this in fact creates a overhead problem it could still be used in a scripting editor as commands to output to script, (to either the focs or later if the focs are changed over to the py files syntax).
Were can i find information on what the scripting keywords are doing and how they are different or relate. Such as Contains And [ ContainedBy And [ or is it best to simply ask as i am now.
for instance its not clear to me what the 'location' we are actually referring to is ? in the below is it the Planet or the System.
Yet here we have specified system directly (though i wouldn't say explicitly) so im guessing we are saying any planet in the system with said building fulfills the condition (though again it is not fully implicit either).
I think it's better if a planetary gun can fire on any enemy ships in the system. It would be nice as well if the gun could only fire if not destroyed.
Im still dabbling with scripting though which brings up a question.
location = And
[
Planet
Not Contains
Building name = "BUILDING_NAME"
]
Why would it be 'Not' Contains instead of just Contains ?
Second what exactly does the 'Planet' keyword here specify or how does it act as a instruction ?
In the following Deathspore's script snippet, i see something which is similar but it includes Species as well. Then i see InSystem id ? i have no clue what this alludes to.
I have to say the script command syntax is not intuitive at all. In fact i've been running macro tests just to see if i can wrap it up as i learn it to simplify it. For example this in sh_heavy_asteriods i ran some tests.EffectsGroup // players can order death spores used on enemies
scope = And [
Planet
Species
InSystem id = Source.SystemID
OrderedBombardedBy condition = Source
Or [
OwnedBy affiliation = EnemyOf empire = Source.Owner
Unowned
]
VisibleToEmpire empire = Source.Owner
HasTag name = "ORGANIC"
]
Code: Select all
location = And
[
Contains And
[
Building name = "BLD_SHIPYARD_BASE"
OwnedBy empire = Source.Owner
]
ContainedBy And
[
System
Contains And
[
Building name = "BLD_SHIPYARD_AST"
OwnedBy empire = Source.Owner
]
]
]
Code: Select all
[[TargetLocationBegins]]
[[ThisEmpireLocationContainsBuilding("BLD_SHIPYARD_BASE")]]
[[ThisEmpireSystemLocationContainsBuilding("BLD_SHIPYARD_AST")]]
[[TargetLocationEnds]]
Were can i find information on what the scripting keywords are doing and how they are different or relate. Such as Contains And [ ContainedBy And [ or is it best to simply ask as i am now.
for instance its not clear to me what the 'location' we are actually referring to is ? in the below is it the Planet or the System.
Code: Select all
location = And [
Contains And
[
Building name = "BLD_SHIPYARD_BASE"
OwnedBy empire = Source.Owner
]
Code: Select all
ContainedBy And
[
System
Contains And [
Building name = "BLD_SHIPYARD_AST"
OwnedBy empire = Source.Owner
]
-
- Programmer
- Posts: 389
- Joined: Sun Feb 14, 2016 12:08 am
Re: Randomly targeting a enemy ship in system.
http://www.freeorion.org/index.php/Effe ... cificationxlightwavex wrote:Why would it be 'Not' Contains instead of just Contains ?
Second what exactly does the 'Planet' keyword here specify or how does it act as a instruction ?
As is, the building may be constructed
- Planet on any Planet object
- Not Contains which does not already contain
- Building name = "BUILDING_NAME" any building with this name
https://github.com/freeorion/freeorion/ ... 2.cpp#L103Then i see InSystem id ? i have no clue what this alludes to.
https://github.com/freeorion/freeorion/ ... ion.h#L828
InSystem: Matches all objects that are in the system with the indicated id
id is optional, if omitted it will default to the source object system
While I find it pretty straight forward, if a method opens it up to more people and doesn't cause issues, that might be helpful.I have to say the script command syntax is not intuitive at all. In fact i've been running macro tests just to see if i can wrap it up as i learn it to simplify it.
Might read better asCode: Select all
[[TargetLocationBegins]] [[ThisEmpireLocationContainsBuilding("BLD_SHIPYARD_BASE")]] [[ThisEmpireSystemLocationContainsBuilding("BLD_SHIPYARD_AST")]] [[TargetLocationEnds]]
Code: Select all
location = And [
[[ContainsOwnedBuilding("BLD_SHIPYARD_BASE")]]
[[ContainedBySystemWIth(ContainsOwnedBuilding("BLD_SHIPYARD_AST"))]]
]
The .disabled extension is typically used for entries which are mostly correct, but are not used for some reason (problem with script or not balanced well).Im thinking i could probably simply use macro's and a disable txt file
The only files that are read are those with the .focs.txt extension and specific files denoted with the .inf extension.
The exception is when one of those files contains an #include statement, which basically replaces the statement with the contents of the requested file(s).
It is safe to use any extension other than .focs.txt, though for review it should follow the existing guidelines.
(see the README in default/scripting)
Viewing the source with an editor with syntax highlighting (e.g. an IDE) is probably the most common method.Were can i find information on what the scripting keywords are doing and how they are different or relate. Such as Contains And [ ContainedBy And [ or is it best to simply ask as i am now.
For any exposed token, limit the search to the parse/ directory for a shorter reference (or omit the default/ directory).
If you compile from source with cmake (not certain if a doc target is specified for MSVC/XCode), you can edit doc/Doxyfile.in to include source files and graphs, then "make doc".
This would give you a localized version of the cpp documentation with source linking and call graphs.
It is any object that contains the building (with the source owner).its not clear to me what the 'location' we are actually referring to is ? in the below is it the Planet or the System.Code: Select all
location = And [ Contains And [ Building name = "BLD_SHIPYARD_BASE" OwnedBy empire = Source.Owner ]
Currently only planets can contain buildings, but there is no requirement here for a planet or system.
It would probably be more efficient to limit this to planets first, instead of trying to match with every object.
Generally you want to try for the smallest group first, checking if each ship contains a building is kind of pointless
After constraining the number of objects down some, being more generic is less of a burden (any object from 30 objects vs any from 30,000).
-
- Space Kraken
- Posts: 111
- Joined: Mon Nov 16, 2015 5:57 am
Re: Randomly targeting a enemy ship in system.
Earlier you mentioned EnqueueLocation.
Is this really just a option, to tell the ai not to build more then one or a certain number of a thing ?
EnqueueLocation = [[ENQUEUE_BUILD_ONE_PER_PLANET]]
I keep changing up the naming as i learn though.
Then as per your previous planet explanation, would the below be a more efficient way to script the above?
Im still a little confused by the difference then between 'ContainedBy' from 'Contains' ?
Also
Within "scripting/specials/worldtree.focs.txt" the specific code segment shown below.
I see a line of text that has what appears to be a condition keyword however it seems to me these are all conditions already. What is the significance of this (condition =) keyword added to this line > Not WithinStarlaneJumps jumps = 2 condition = And [ ... ect ... ]. Why is it not, WithinStarlaneJumps jumps = 2 And [
For example in the below code snippet.
It appears this say's " if a planet is un-owned by anyone within two jumps ".
#4) ?
How do i know when the extra, (condition =) syntax is necessary ? or is it always for a sub-condition.
On syntax again using the same example.
#5) ?
Do the below changes remain valid, will the following change still work, from this...
to this...
#1) ?From the wiki...
The EnqueueLocation condition sets the constraining condition under which the respective content (or a ship design using the content) may be placed on the Build Queue. If not explicitly specified, the EnqueueLocation condition will default to be the same as the Location condition. The EnqueueLocation is only evaluated at the time of placing the item on the queue; it need not remain true (and so, for example, may prohibit that the subject content is already enqueued at that location)
Is this really just a option, to tell the ai not to build more then one or a certain number of a thing ?
EnqueueLocation = [[ENQUEUE_BUILD_ONE_PER_PLANET]]
Ah i see that would be for the building placement. I was thinking of how to target the location for the firing of the building, but this is very useful. I imagine that's used often for any building that can only be built once.As is, the building may be constructed
Planet // on any Planet object
Not Contains // which does not already contain
Building name = "BUILDING_NAME" // any building with this name
If you removed Not, you would only be able to build it on planets that have the building already constructed.
I don't think i want to go that far then im into c code basically, and that will drive me nuts time wise. Im spoiled absolutely rotten from using c# for so long. I did see that notation for casing it just looked prettier that way i didn't want to change it i changed it thoughIf you compile from source with cmake (not certain if a doc target is specified for MSVC/XCode), you can edit doc/Doxyfile.in to include source files and graphs, then "make doc".
This would give you a localized version of the cpp documentation with source linking and call graphs.
...maintaining consistent syntax is important...
This is a pet peave of mine, made into a discipline, Im a firm believer in names not being shortened, if it makes them less clear to me or others, basically i name things so that, if i come back to it, say a month later, its clear what it does or can do for me. Unnecessarily shortening names is a old habit that i repel now, that once derived from the need to save bytes at the cost of clarity. That is a old idea that serves no purpose now but for its cost.....Might read better as ...
I keep changing up the naming as i learn though.
Code: Select all
[[TARGET_LOCATION_BEGINS]]
[[THIS_PLAYERS_PLANET_CONTAINS_BUILDING("BLD_SHIPYARD_BASE")]]
[[THIS_PLAYERS_SYSTEM_CONTAINS_BUILDING("BLD_SHIPYARD_AST")]]
[[TARGET_LOCATION_ENDS]]
#2) ?It would probably be more efficient to limit this to planets first, instead of trying to match with every object.
//Note this is code that is already in the game within "scripting/ship_hulls/asteroid/SH_HEAVY_ASTEROID.focs.txt". I see it repeated in many other places as well.Code: Select all
Contains And [ Building name = "BLD_SHIPYARD_BASE" OwnedBy empire = Source.Owner ]
Then as per your previous planet explanation, would the below be a more efficient way to script the above?
#3) ?Contains And
[
Planet // specify planets as the first applicable target condition to narrow the search
Building name = "BLD_SHIPYARD_BASE"
OwnedBy empire = Source.Owner
]
Im still a little confused by the difference then between 'ContainedBy' from 'Contains' ?
Also
Within "scripting/specials/worldtree.focs.txt" the specific code segment shown below.
I see a line of text that has what appears to be a condition keyword however it seems to me these are all conditions already. What is the significance of this (condition =) keyword added to this line > Not WithinStarlaneJumps jumps = 2 condition = And [ ... ect ... ]. Why is it not, WithinStarlaneJumps jumps = 2 And [
For example in the below code snippet.
It appears this say's " if a planet is un-owned by anyone within two jumps ".
#4) ?
How do i know when the extra, (condition =) syntax is necessary ? or is it always for a sub-condition.
Code: Select all
location = And [
Planet
Not Planet type = [Asteroids GasGiant Inferno]
Not Planet size = [tiny huge]
Not WithinStarlaneJumps jumps = 2 condition = And
[
System
Contains And
[
Planet
OwnedBy affiliation = AnyEmpire
]
]
]
#5) ?
Do the below changes remain valid, will the following change still work, from this...
Code: Select all
Planet
Not Planet type = [Asteroids GasGiant Inferno]
Not Planet size = [tiny huge]
Code: Select all
Planet Not Planet type = [Asteroids GasGiant Inferno]
Planet Not Planet size = [tiny huge]
-
- Programmer
- Posts: 389
- Joined: Sun Feb 14, 2016 12:08 am
Re: Randomly targeting a enemy ship in system.
This doesn't relate directly to the AI, I mentioned it because it will keep both the AI and human players from trying to build more than one at the planet.xlightwavex wrote:Earlier you mentioned EnqueueLocation.
Is this really just a option, to tell the ai not to build more then one or a certain number of a thing ?
Without modifying the AI, it could possibly try to build one at a specific planet each turn, thus wasting production.
This EnqueueLocation condition should further restrict adding this building to the queue if one is already enqueued at the same planet.
I assume you could just add this new restriction to the location condition instead, I had not realized it defaulted to location.
I was not trying to imply that is would not work, it may never be a huge factor in performance by itself.Note this is code that is already in the game within "scripting/ship_hulls/asteroid/SH_HEAVY_ASTEROID.focs.txt". I see it repeated in many other places as well.
Work is continually done to improve existing entries, so once you finish some addition or rewrite it is good to look it over for potential bottlenecks.
Would match only match a system and never a planet (since planets do not contain planets).Code: Select all
Contains And [ [b]Planet[/b] // specify planets as the first applicable target condition to narrow the search Building name = "BLD_SHIPYARD_BASE" OwnedBy empire = Source.Owner ]
Additionally, I believe this may check for planets that are buildings.
Code: Select all
Planet
Contains And [
Building name ...
]
Planet, System, Fleet are containers.Im still a little confused by the difference then between 'ContainedBy' from 'Contains' ?
Contains matches objects in those containers.
ContainedBy is from the contained objects perspective.
System_X might Contain ship_b. ship_b is therefore ContainedBy System_X.
I believe removing some of those token requirements is on a todo list, currently it is always required.What is the significance of this (condition =) keyword added to this line > Not WithinStarlaneJumps jumps = 2 condition = And [ ... ect ... ]. Why is it not, WithinStarlaneJumps jumps = 2 And [ ?
... how do i know when the extra, (condition =) syntax is necessary ?
Limits the special from being created on a planet that is within 2 jumps of an empire owned planet (not just a specific players empire).It appears this say's " if a planet is un-owned by anyone within two jumps ", ...Code: Select all
location = And [ Planet Not Planet type = [Asteroids GasGiant Inferno] Not Planet size = [tiny huge] Not WithinStarlaneJumps jumps = 2 condition = And [ System Contains And [ Planet OwnedBy affiliation = AnyEmpire ] ] ]
Specials can be spawned during universe generation, so this keeps the worldtree from being spawned right next to a homeworld.
If the change does not error (guessing it is ok), it is equivalent toDo the below changes remain valid, will the following change still work, from this...to this...Code: Select all
Planet Not Planet type = [Asteroids GasGiant Inferno] Not Planet size = [tiny huge]
Code: Select all
Planet Not Planet type = [Asteroids GasGiant Inferno] Planet Not Planet size = [tiny huge]
Code: Select all
Planet
Not Planet type = ...
Planet
Not Planet size = ...
-
- Space Kraken
- Posts: 111
- Joined: Mon Nov 16, 2015 5:57 am
Re: Randomly targeting a enemy ship in system.
Additionally, I believe this may check for planets that are buildings.Would limit it specifically to Planets that contain the building.Code: Select all
Planet Contains And [ Building name ... ]
I see. Ships are always in fleets even alone right so they can always be matched. So it is basically two different ways to return or identify which container applies to another under specific conditions.Planet, System, Fleet are containers.
Contains matches objects in those containers.
container System_X might Contain object ship_b.
ContainedBy is from the contained objects perspective.
object ship_b is therefore ContainedBy container System_X.
I worded that previous question poorly i should have asked instead are these the same ?
Code: Select all
Planet
Not Planet type = [Asteroids GasGiant Inferno]
Not Planet size = [tiny huge]
Code: Select all
Planet Not Planet type = [Asteroids GasGiant Inferno]
Planet Not Planet size = [tiny huge]
Code: Select all
> ? < Not Planet size = [tiny huge]
-
- Programmer
- Posts: 389
- Joined: Sun Feb 14, 2016 12:08 am
Re: Randomly targeting a enemy ship in system.
You are restricting the match in scope/location.
Given some universe with only 3 planets:
Planet1 = Medium Terran
Planet2 = Asteroids Asteroids
Planet3 = Tiny Toxic
location = And [
Planet location = {Planet1, Planet2, Planet3}
Not Planet type = [Asteroids GasGiant Inferno] location = {Planet1, Planet3}
Not Planet size = [tiny huge] location = {Planet1}
]
Again, this is from my limited perspective, so please take my lack of experience into consideration here.
Given some universe with only 3 planets:
Planet1 = Medium Terran
Planet2 = Asteroids Asteroids
Planet3 = Tiny Toxic
location = And [
Planet location = {Planet1, Planet2, Planet3}
Not Planet type = [Asteroids GasGiant Inferno] location = {Planet1, Planet3}
Not Planet size = [tiny huge] location = {Planet1}
]
Again, this is from my limited perspective, so please take my lack of experience into consideration here.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Randomly targeting a enemy ship in system.
Those parameter names were semi-recently made all mandatory, actually. They used to be all optional, but were forced to be included to make the meaning clearer to the reader.dbenage-cx wrote:I believe removing some of those token requirements is on a todo list, currently it is always required.What is the significance of this (condition =) keyword added to this line > Not WithinStarlaneJumps jumps = 2 condition = And [ ... ect ... ]. Why is it not, WithinStarlaneJumps jumps = 2 And [ ?
... how do i know when the extra, (condition =) syntax is necessary ?
As far as I recall, the only exceptions are within Contains, ContainedBy, Not, And, and Or conditions, which have a list of sub-conditions (or a single sub-condition for Not, Contains, and ContainedBy) and no "condition =" required before each. I semi-justify this by And and Or being somewhat special logical composing conditions, and more so because Or and And require a list of sub-conditions of arbitrary length, and all of them take just condition parameters, and not a mix of different types of parameters like WithinDistance or WithinJumps type conditions.
-
- Space Kraken
- Posts: 111
- Joined: Mon Nov 16, 2015 5:57 am
Re: Randomly targeting a enemy ship in system.
Makes sense to me basically your just trimming down the query of applicable locations thru each line which is a iteration thru / of the previous results..dbenage-cx wrote:You are restricting the match in scope/location.
Given some universe with only 3 planets:
Planet1 = Medium Terran
Planet2 = Asteroids Asteroids
Planet3 = Tiny Toxic
location = And [
Planet location = {Planet1, Planet2, Planet3}
Not Planet type = [Asteroids GasGiant Inferno] location = {Planet1, Planet3}
Not Planet size = [tiny huge] location = {Planet1}
]
Again, this is from my limited perspective, so please take my lack of experience into consideration here.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Randomly targeting a enemy ship in system.
No; Contains matches objects that contain other objects.xlightwavex wrote:Contains matches objects in those containers.
Code: Select all
Contains Planet
Code: Select all
Contains Ship
-
- Space Kraken
- Posts: 111
- Joined: Mon Nov 16, 2015 5:57 am
Re: Randomly targeting a enemy ship in system.
Ok i think i got the basics for the location understood so ill focus on the EffectsGroup now.
Last question and back on topic, until the next time.
The planet gun...
Does the search matches in the scope follow or iterate downwards as well ?
How does 'Or' work in the scripting, it seems a little weird how i see it used in the files ?
As well NumberOf number = and Random probability = usage is also hard to wrap my head around.
Here's what i scribbled out, i think it looked better before i tried to insert numberOf, and then i got really confused.
Well im very tired, if you answer ill reply later on, when i get a chance to digest it.
Last question and back on topic, until the next time.
The planet gun...
Does the search matches in the scope follow or iterate downwards as well ?
How does 'Or' work in the scripting, it seems a little weird how i see it used in the files ?
As well NumberOf number = and Random probability = usage is also hard to wrap my head around.
Here's what i scribbled out, i think it looked better before i tried to insert numberOf, and then i got really confused.
Well im very tired, if you answer ill reply later on, when i get a chance to digest it.
Code: Select all
Tech
name = "DEF_PLANET_GUN_1"
description = "DEFENSE_SHORT_DESC"
short_description = "DEFENSE_SHORT_DESC"
category = "DEFENSE_CATEGORY"
researchcost = 12 * [[TECH_COST_MULTIPLIER]]
researchturns = 3
prerequisites = "DEF_ROOT_DEFENSE"
unlock = Item type = Building name = "BLD_PLANET_GUN_1"
graphic = "icons/tech/defense.png"
BuildingType
name = "BLD_PLANET_GUN_1"
description = "BLD_PLANET_GUN_1_DESC"
buildcost = 20
buildtime = 5
location = And
[
Planet
Not Contains Building name = "BLD_PLANET_GUN_1"
Not Planet type = [GasGiant]
OwnedBy empire = Source.Owner
]
EnqueueLocation = [[ENQUEUE_BUILD_ONE_PER_PLANET]]
//
// ok time to figure out how this applies to effects groups
//
EffectsGroup
scope = And
[
System
Contains And
[
Planet
OwnedBy empire = Source.Owner
Building name = "BLD_PLANET_GUN_1"
NumberOf number = 1 condition = And
[
Fleet
ContainsBy And
[
OwnedBy affiliation = EnemyOf empire = Source.Owner
]
]
]
]
activation = Not Unowned
effects =
[
SetStructure value = Value - 5 + 15 * Random probability = 1 //?
]
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Randomly targeting a enemy ship in system.
As well NumberOf number = and Random probability = usage is also hard to wrap my head around.
Code: Select all
NumberOf number = 5 condition = Ship
Code: Select all
Random probability = 0.5
Or is a logical or operation. If an object matches any of the subconditions, then it wil be matched by the containing Or condition.How does 'Or' work in the scripting, it seems a little weird how i see it used in the files ?
Code: Select all
Or [ Planet Ship ]
Or does its matching in order of the conditions as scripted, so:
Code: Select all
And [ Planet Random probability = 0.5]
Code: Select all
Or [ Planet Random probability = 0.5]
Code: Select all
And [ Planet NumberOf number = 5 condition = All]
Code: Select all
And [ NumberOf number = 5 condition = Planet]
-
- Space Kraken
- Posts: 111
- Joined: Mon Nov 16, 2015 5:57 am
Re: Randomly targeting a enemy ship in system.
Humm its not what they do, its the usage syntax that i don't understand mostly.
Basically what is returned to were especially with the containsBy
How would i generate a number from 1 to 10 and add it to the damage deduction to a ship in the example code which in this case i wrote and im sure it didn't work because i still don't fully grasp the operation order.
To say if this were a programming language i might say something like.
The problem its hard to say this in the script. It is unclear to me how the script commands function together in usage.
Though i did think random probability literally returned a random number.
Basically what is returned to were especially with the containsBy
How would i generate a number from 1 to 10 and add it to the damage deduction to a ship in the example code which in this case i wrote and im sure it didn't work because i still don't fully grasp the operation order.
To say if this were a programming language i might say something like.
Code: Select all
if(
System[currentSystemId].Planet[currentPlanetId].Has("BLD_PLANET_GUN_1")
&&
System[currentSystemId].Planet[currentPlanetId].ContainsEnemyFleetInSystem()
)
{
int fid = FirstFoundEnemyFleetIdOfCurrentPlayerAt(currentSystemId, currentPlanetId);
int shipId = (int)Random(0, fid.Count());
if(fid.Count() > 0)
{
Fleets[fid].Ships[shipId ].hp += -(3 + Random(0, 10));
}
}
Though i did think random probability literally returned a random number.