FreeOrion

Forums for the FreeOrion project
It is currently Wed Dec 13, 2017 5:09 am

All times are UTC




Post new topic Reply to topic  [ 42 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: Mon Jul 11, 2016 7:25 pm 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 213
Hi,

I am currently in the process of scripting supply ships to allow for faster deep space expansion.

1)
It seems though that I misunderstood how scope works.
The following ship part should be unloaded if the ship is in a system with a planet with the BLD_UNLOAD_SUPPLY building.
The scope in the code below should only consist of that single planet. It seems though that currently the effect is triggered on all planets which contain the BLD_UNLOAD_SUPPLY building.
Freeorion version is 0.4.5+ from June 6th

Code:
//... ship part CO_SUPPLIES_030...
    effectsgroups = [
        EffectsGroup   
            scope = And [
                Planet
                InSystem id = Source.SystemID
                Contains Building name = "BLD_UNLOAD_SUPPLY"
                Not HasSpecial name = "UNLOADING_SUPPLIES_SPECIAL"
                OwnedBy empire = Source.Owner
            ]
            effects = [



2) Also is there a way to access the value of the capacity? E.g. via something like Source.Capacity or similar?

Thanks in advance :)

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Mon Jul 11, 2016 7:44 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
Ophiuchus wrote:
2) Also is there a way to access the value of the capacity? E.g. via something like Source.Capacity or similar?
Something like
Code:
Source.PartCapacity name = "SHIP_PART_NAME"


For (1), maybe add an extra InSystem in the scope? Perhaps a ship in no system is causing the scope to match planets in any system.


Top
 Profile  
 
PostPosted: Mon Jul 11, 2016 7:48 pm 
Offline
Creative Contributor
User avatar

Joined: Fri Jun 28, 2013 11:45 pm
Posts: 3291
For one you need both a scope and an activation normally (although I'm never clear on this, I normally copy/paste from something that works and edit). Beyond that I'm not sure what you're trying to do, but a ship part that mimics the solar hull flagship fuel effect might be a viable approach.

_________________
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Mon Jul 11, 2016 8:23 pm 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 213
Geoff the Medio wrote:
Ophiuchus wrote:
2) Also is there a way to access the value of the capacity? E.g. via something like Source.Capacity or similar?
Something like
Code:
Source.PartCapacity name = "SHIP_PART_NAME"


For (1), maybe add an extra InSystem in the scope? Perhaps a ship in no system is causing the scope to match planets in any system.



MatGB wrote:
For one you need both a scope and an activation normally (although I'm never clear on this, I normally copy/paste from something that works and edit). Beyond that I'm not sure what you're trying to do, but a ship part that mimics the solar hull flagship fuel effect might be a viable approach.


@1)
Thanks, it seems an activation = InSystem helps.

@2)
Will try to use the capacity approach

@MatGb In the long run I want to play a game where my hidden ships cross enemy lines and add production to my hidden planets (e.g. building scanning stations or exobot colonies on outposts). At the moment I want to boost production on a system which is outside of my supply range. I am doing this via 'supply ships' which add some capacity to a planet which gradually gets used up.

Also thanks for both the fast replies :)

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Mon Jul 11, 2016 9:24 pm 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
In case it helps (I constantly have issues with getting it correct), the detailed description (alt link) of EffectsGroup might clarify activation.
Quote:
Contains one or more Effects, a Condition which indicates the objects in the scope of the Effect(s), and a Condition which indicates whether or not the Effect(s) will be executed on the objects in scope during the current turn.
Since Conditions operate on sets of objects (usually all objects in the universe), the activation condition bears some explanation.
It exists to allow an EffectsGroup to be activated or suppressed based on the source object only (the object to which the EffectsGroup is attached).
It does this by considering the "universe" containing only the source object.
If the source object meets the activation condition, the EffectsGroup will be active in the current turn.


Top
 Profile  
 
PostPosted: Sat Jul 16, 2016 7:17 pm 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 213
Geoff the Medio wrote:
Ophiuchus wrote:
2) Also is there a way to access the value of the capacity? E.g. via something like Source.Capacity or similar?
Something like
Code:
Source.PartCapacity name = "SHIP_PART_NAME"


Just for reference, the part capacity seems to be accessed without a reference, i.e. like this:
Code:
PartCapacity name = "SHIP_PART_NAME"

As I also didnt find a setter, I guess that part capacity is global and may only be set on on initialisation using
Code:
capacity =
.

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Sun Jul 17, 2016 2:22 am 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
For effects there are SetCapacity and SetMaxCapacity

e.g. SH_KRAKEN_2_BODY
Code:
SetMaxCapacity partname = "SR_TENTACLE" value = Value + min(Source.Age*0.15, 4)
SetCapacity partname = "SR_TENTACLE" value = Value + min(Source.Age*0.15, 4)


Top
 Profile  
 
PostPosted: Sun Jul 17, 2016 7:21 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
Ophiuchus wrote:
Just for reference, the part capacity seems to be accessed without a reference, i.e. like this:
Code:
PartCapacity name = "SHIP_PART_NAME"
Ah, yes. sorry. That is returning the "capacity" in the part definition script, eg.
Code:
Part
    name = "FT_BAY_1"
    description = "FT_BAY_1_DESC"
    class = FighterBay
    capacity = 2        /// <<=== This value
    mountableSlotTypes = External
    buildcost = 20 * [[FLEET_UPKEEP_MULTIPLICATOR]]
    buildtime = 1
    location = OwnedBy empire = Source.Owner
    icon = "icons/ship_parts/fighters-1.png"

That is often, but not always, the value of a particular ship's capacity meter for that particular part. It could be different if another effect, such as a refinement tech, has modified the meter. (There are also separate max capacity and capacity meters which are modified and behave differently, but the one you'd generally want to base stuff on would be capacity itself.)

I don't think there's actually a way to get the value of a particular part's capacity or max capacity on a particular ship to use in a calculation (eg. multiplying it by something and adding something). However, you can write a condition that checks the actual capacity of a part meter, using something like
Code:
Source.ShipPartMeter part = "PART NAME" Capacity low = 10 high = 100


Quote:
As I also didnt find a setter, I guess that part capacity is global and may only be set on on initialisation using
Code:
capacity =
.
The term "setter" is unclear; this isn't an object-oriented general-purpose programming language. You should refer to scripting the content definitions, then modifying the gamestate using effects.


Top
 Profile  
 
PostPosted: Sun Aug 14, 2016 3:47 pm 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 213
Geoff the Medio wrote:
I don't think there's actually a way to get the value of a particular part's capacity or max capacity on a particular ship to use in a calculation (eg. multiplying it by something and adding something). However, you can write a condition that checks the actual capacity of a part meter, using something like
Code:
Source.ShipPartMeter part = "PART NAME" Capacity low = 10 high = 100



Does that mean that every ship has internally exactly two values for every "PART NAME" (one capacity and one max capacity), regardless of how often the part is in a ship?
(Any hint where I should start reading c-code?)


Another question regarding industry and outposts - I wanted to add industry to outposts as well as for planets (to speed up building initial buildings on disconnected ) using my scripted supply ships. But it seems industry is always zero on outposts. Is there a specific reason for this or am I doing something wrong?

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Mon Aug 15, 2016 12:17 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
Ophiuchus wrote:
Does that mean that every ship has internally exactly two values for every "PART NAME" (one capacity and one max capacity), regardless of how often the part is in a ship?
Yes.
Quote:
(Any hint where I should start reading c-code?)
Ship.h maybe?
https://github.com/freeorion/freeorion/ ... Ship.h#L14
Quote:
But it seems industry is always zero on outposts. Is there a specific reason for this or am I doing something wrong?
I'm seeing a similar result, and I'm not sure why; an effect increasing all empire-owned planets' industry meter doesn't seem to have any affect on an outpost, even when its target industry is well above zero.

Edit: Figured it out, I think. When a planet has 0 population, during post-combat meter updating, a special Depopulate() function is called on the planet, which resets all the planets' resource meters to 0. The idea for this is that when a planet "starves" or otherwise loses all its population, it doesn't have big resource output for many turns afterwards as the meter slowing ticks down towards its (presumable) new target value of 0. So, for outposts to have functional resource outputs, some adjustments to the game rules will be needed...

If you comment out the ->Reset() lines in that function, it might/should work, though I suspect we don't want to do that in master until after the release due to potential balance / bugs that could result...


Top
 Profile  
 
PostPosted: Mon Aug 15, 2016 11:14 am 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 213
Geoff the Medio wrote:
Figured it out, I think. When a planet has 0 population, during post-combat meter updating, a special Depopulate() function is called on the planet, which resets all the planets' resource meters to 0. The idea for this is that when a planet "starves" or otherwise loses all its population, it doesn't have big resource output for many turns afterwards as the meter slowing ticks down towards its (presumable) new target value of 0. So, for outposts to have functional resource outputs, some adjustments to the game rules will be needed...

If you comment out the ->Reset() lines in that function, it might/should work, though I suspect we don't want to do that in master until after the release due to potential balance / bugs that could result...


Second that. Hm. Will come back to that after 0.4.6
Thanks for the research.

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Thu Oct 13, 2016 12:16 am 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 213
0.4.6 is out, I am back :)

It looks the Depopulate is called only on population centers, does that include outposts?

I added a condition to skip the call to Depopulate in empty species name. But can't check it
because my visual studio is broken again :(

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
 Post subject: Supply ships are ready
PostPosted: Sat Oct 22, 2016 7:20 pm 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 213
Supply ships are in quite ok/polished shape now, need some feedback from you guys

To use:
0) use the branch https://github.com/agrrr3/freeorion/tre ... pply-ships
1) Research the technology "Generic Industrial Supplies"
2) Use the encyclopedia

I need feedback on the following topics:
* do you like the feature?
* did i handle the git branches correctly? should i create a pull request?
* can someone review the code and the stringtables (my mother tongue is not english)?

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Sat Oct 22, 2016 8:17 pm 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
I haven't tested it yet, but it certainly looks interesting ;)
This seems like it might take a lot of attention from the user, but I will reserve further judgment until I actually try it.

Quote:
did i handle the git branches correctly? should i create a pull request?

No merges from master, please use rebase instead.
You might move the change to universe/PopCenter.cpp to a new PR, this change alone needs testing with the rest of the game.
Does default/scripting/specials/UNLOADING_SUPPLIES.focs.txt need all of these comments? I find it hard to read through.
Stringtable look great on first pass, For sitrep messages, it is preferred to start them with some context, e.g. "At %system%: ..."


Top
 Profile  
 
PostPosted: Sun Oct 23, 2016 2:10 pm 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 213
Ok, first thanks for the review :)

Done
* I rebased the code. And squashed the commits.
* I threw the bulk of comments away
* I rearranged the sitreps

Todo
* Splitting out the population center change (rebasing? cherry picking? dunno)

Question
* in default/scripting/specials/UNLOADING_SUPPLIES.focs.txt I use some min-/maxing to prevent hypothetical situations where industry is below zero. Is that bullshit and should be done away, or does it make sense and should handle this situation like I did?
* Regarding the 'takes a lot of attention'. I did three real games using a species which has bad supply (see below). Even with that experience, supply ships were ok, not too much micromanagement.
Handling monsters (even on low setting) took much more attention from me.

p.s.: If you like to try; meet the Travelers:
https://github.com/agrrr3/freeorion/tree/sp_travelers
supply ships come in really handy, as it is hard to set up supply lines with the Travelers. The species is I think a little overpowered, probably will nerf the population down to bad. Also I am not decided on what kind of planets they should be specialized on. They live in the same ecological niche as do the Trith.
I actually didn't build on outposts, but used mostly colonies.

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] 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