FreeOrion

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

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Sep 16, 2016 6:50 pm 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
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.


Top
 Profile  
 
PostPosted: Sat Sep 17, 2016 2:51 am 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
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.
Code:
location = And [
    Planet
    Not Contains
        Building name = "BUILDING_NAME"
]
Alternatively, for one per system (needs testing, not 100%):
Code:
location = And [
    Planet
    Not ContainedBy And [
        System
        Contains
            Building name = "BUILDING_NAME"
    ]
]

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.


Top
 Profile  
 
PostPosted: Sat Sep 17, 2016 6:29 am 
Offline
AI Contributor

Joined: Tue Feb 17, 2015 11:54 am
Posts: 224
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.

_________________
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0


Top
 Profile  
 
PostPosted: Sat Sep 17, 2016 7:01 pm 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
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.
Quote:
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"
]


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.

Code:
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
            ]
        ]
    ]


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.

Code:
[[TargetLocationBegins]]
        [[ThisEmpireLocationContainsBuilding("BLD_SHIPYARD_BASE")]]
        [[ThisEmpireSystemLocationContainsBuilding("BLD_SHIPYARD_AST")]]
[[TargetLocationEnds]]


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.

Code:
location = And [
        Contains And
      [
            Building name = "BLD_SHIPYARD_BASE"
            OwnedBy empire = Source.Owner
        ]


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).

Code:
ContainedBy And
            [
            System
            Contains And [
                Building name = "BLD_SHIPYARD_AST"
                OwnedBy empire = Source.Owner
            ]


Top
 Profile  
 
PostPosted: Sat Sep 17, 2016 11:01 pm 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
xlightwavex 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 ?

http://www.freeorion.org/index.php/Effe ... cification
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.

Quote:
Then i see InSystem id ? i have no clue what this alludes to.

https://github.com/freeorion/freeorion/ ... 2.cpp#L103
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


Quote:
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.

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.

Quote:
Code:
[[TargetLocationBegins]]
        [[ThisEmpireLocationContainsBuilding("BLD_SHIPYARD_BASE")]]
        [[ThisEmpireSystemLocationContainsBuilding("BLD_SHIPYARD_AST")]]
[[TargetLocationEnds]]

Might read better as
Code:
location = And [
    [[ContainsOwnedBuilding("BLD_SHIPYARD_BASE")]]
    [[ContainedBySystemWIth(ContainsOwnedBuilding("BLD_SHIPYARD_AST"))]]
]
Something to keep in mind down the road, maintaining consistent syntax is important, so a switch from macro case to camel case here would likely be frowned on in any PR.

Quote:
Im thinking i could probably simply use macro's and a disable txt file

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).
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)


Quote:
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.
Viewing the source with an editor with syntax highlighting (e.g. an IDE) is probably the most common method.
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.

Quote:
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:
location = And [
        Contains And
      [
            Building name = "BLD_SHIPYARD_BASE"
            OwnedBy empire = Source.Owner
        ]

It is any object that contains the building (with the 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).


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 2:11 am 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
Earlier you mentioned EnqueueLocation.
Quote:
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)


#1) ?
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]]

Quote:
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.


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.

Quote:
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.

...maintaining consistent syntax is important...


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 though :(

Quote:
....Might read better as ...

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.

I keep changing up the naming as i learn though.
Code:
[[TARGET_LOCATION_BEGINS]]
       [[THIS_PLAYERS_PLANET_CONTAINS_BUILDING("BLD_SHIPYARD_BASE")]]
       [[THIS_PLAYERS_SYSTEM_CONTAINS_BUILDING("BLD_SHIPYARD_AST")]]
[[TARGET_LOCATION_ENDS]]


Quote:
It would probably be more efficient to limit this to planets first, instead of trying to match with every object.

Code:
Contains And
   [
            Building name = "BLD_SHIPYARD_BASE"
            OwnedBy empire = Source.Owner
        ]

//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.


#2) ?
Then as per your previous planet explanation, would the below be a more efficient way to script the above?

Quote:
Contains And
[
Planet // specify planets as the first applicable target condition to narrow the search
Building name = "BLD_SHIPYARD_BASE"
OwnedBy empire = Source.Owner
]


#3) ?
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:
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
            ]
        ]
    ]


On syntax again using the same example.

#5) ?
Do the below changes remain valid, will the following change still work, from this...
Code:
Planet
        Not Planet type = [Asteroids GasGiant Inferno]
        Not Planet size = [tiny huge]

to this...
Code:
Planet Not Planet type = [Asteroids GasGiant Inferno]
Planet Not Planet size = [tiny huge]


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 5:44 am 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
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 ?

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.
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.

Quote:
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.

I was not trying to imply that is would not work, it may never be a huge factor in performance by itself.
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.

Quote:
Code:
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
]

Would match only match a system and never a planet (since planets do not contain planets).
Additionally, I believe this may check for planets that are buildings.
Code:
Planet
Contains And [
    Building name ...
]
Would limit it specifically to Planets that contain the building.

Quote:
Im still a little confused by the difference then between 'ContainedBy' from 'Contains' ?

Planet, System, Fleet are containers.
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.

Quote:
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 ?

I believe removing some of those token requirements is on a todo list, currently it is always required.

Quote:
It appears this say's " if a planet is un-owned by anyone within two jumps ", ...
Code:
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
            ]
        ]
    ]

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).
Specials can be spawned during universe generation, so this keeps the worldtree from being spawned right next to a homeworld.

Quote:
Do the below changes remain valid, will the following change still work, from this...
Code:
Planet
        Not Planet type = [Asteroids GasGiant Inferno]
        Not Planet size = [tiny huge]

to this...
Code:
Planet Not Planet type = [Asteroids GasGiant Inferno]
Planet Not Planet size = [tiny huge]

If the change does not error (guessing it is ok), it is equivalent to
Code:
Planet
Not Planet type = ...
Planet
Not Planet size = ...

Which is limiting the results of planets with specific type to ... planets.


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 7:21 am 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
Quote:
Additionally, I believe this may check for planets that are buildings.
Code:
Planet
Contains And [
    Building name ...
]

Would limit it specifically to Planets that contain the building.


Quote:
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 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.



I worded that previous question poorly i should have asked instead are these the same ?
Code:
Planet
Not Planet type = [Asteroids GasGiant Inferno]
Not Planet size = [tiny huge]
To say... does the Planet keyword carry down to the next line, or implicitly imply to the second line, that it also counts towards, > Not Planet size = [tiny huge], < that it remains in scope. So that it essentially evaluates to the below.
Code:
Planet Not Planet type = [Asteroids GasGiant Inferno]
Planet Not Planet size = [tiny huge]


It doesn't error but its unclear how far planets scope goes because there are no brackets for it. If it does not i.e. if it is not still relating to Planets on the second line. Then what container does this second line actually search thru ? Planet, System and Fleet ?

Code:
> ? < Not Planet size = [tiny huge]


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 8:04 am 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
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.


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 8:11 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
dbenage-cx wrote:
Quote:
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 ?

I believe removing some of those token requirements is on a todo list, currently it is always required.
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.

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.


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 8:17 am 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
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.


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..


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 8:20 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
xlightwavex wrote:
Contains matches objects in those containers.
No; Contains matches objects that contain other objects.
Code:
Contains Planet
would match systems that contain at least planet.
Code:
Contains Ship
would match fleets (which always contain at least one ship) and systems that contain at least one ship.


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 10:46 am 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
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.

Code:
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 //?
    ]


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 1:20 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
Quote:
As well NumberOf number = and Random probability = usage is also hard to wrap my head around.

Code:
NumberOf number = 5 condition = Ship
Will match (up to) 5 Ships. If there are less than 5 ships in the universe, it will match all of them.
Code:
Random probability = 0.5
Has a 50% chance of matching each object, independent of all other objects being matched or not.
Quote:
How does 'Or' work in the scripting, it seems a little weird how i see it used in the files ?
Or is a logical or operation. If an object matches any of the subconditions, then it wil be matched by the containing Or condition.
Code:
Or [ Planet Ship ]
will match any object that is a planet or that is a ship.
Or does its matching in order of the conditions as scripted, so:
Code:
And [ Planet Random probability = 0.5]
will find all planets, then give each of them a 50% chance of being matched.
Code:
Or [ Planet Random probability = 0.5]
will match all planets and give all other objects a 50% chance of being matched.
Code:
And [ Planet NumberOf number = 5 condition = All]
Will select 5 objects, and if any of those are planets, will match them.
Code:
And [ NumberOf number = 5 condition = Planet]
Will select 5 planets (or all if there are 5 or less in the universe).


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 4:29 pm 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
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.

Code:
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));
  }
}


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.


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