FreeOrion

Forums for the FreeOrion project
It is currently Sat Dec 16, 2017 10:36 pm

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sun Sep 18, 2016 5:10 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
xlightwavex wrote:
How would i generate a number from 1 to 10 and add it to the damage deduction to a ship...
Random probability = 0.5 is a condition that selects objects in the universe, which are fleets, ships, buildings, planets, system, or fields. Conditions are used for scope or activation of effectsgroups, specifying locations where ship parts or hulls or buildings can be produced, or where specials can be generated, and in some statistic calculations.

If you want a random number to use as one of the parameters to an effect, use RandomNumber(0.0, 10.0) or similar. This is an operation, which returns a number. 0.0 and 10.0 are parameters that can be constant numbers as in the example, or could be expressions, like 10.0 + 5.0 or 1 + Source.Population.

I think you're trying to script something too complicated to start with all at once... Maybe start with just getting the scope for your effect to work as desired, then worry about how to calculate what to set meter values to using expressions and randomness.


Top
 Profile  
 
PostPosted: Sun Sep 18, 2016 7:08 pm 
Offline
Space Kraken

Joined: Mon Nov 16, 2015 5:57 am
Posts: 105
Geoff the Medio wrote:
I think you're trying to script something too complicated to start with all at once... Maybe start with just getting the scope for your effect to work as desired, then worry about how to calculate what to set meter values to using expressions and randomness.


Quote:
NumberOf number = NUMBER condition = CONDITION

Matches at most NUMBER objects that match CONDITION. If fewer than NUMBER objects match CONDITION, all such objects are matched. If more than NUMBER objects match CONDITION, NUMBER such objects are randomly selected and matched.


Ok so far i have this i have no idea if it will actually work i need to generate a sitrep to see i guess. The only thing i know is it doesn't error im not sure if this actually ends up with a ship being given to numberOf or not.

Code:
BuildingType
    name = "BLD_PLANET_GUN"
    description = "BLD_PLANET_GUN_DESC"
    buildcost = 25
    buildtime = 5
    location = And
   [
        Planet
        Not Contains Building name = "BLD_PLANET_GUN"
      Not Planet type = [GasGiant]
        OwnedBy empire = Source.Owner
    ]
   effectsgroups =
   [
        EffectsGroup
      scope = NumberOf number = 1 condition = And
      [
              Contains Planet And
             [
                Building name = "BLD_PLANET_GUN"
               OwnedBy empire = Source.Owner
             ]
             Contains Ship And
            [
               OwnedBy affiliation = EnemyOf empire = Source.Owner
            ]
      ]
       effects =
      [
            SetStructure value = Value - RandomNumber(10.0, 20.0)
        ]
   ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

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