FreeOrion

Forums for the FreeOrion project
It is currently Mon May 20, 2013 4:28 am

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Buildings.txt
PostPosted: Wed Jul 04, 2012 11:46 am 
Offline
Space Floater

Joined: Wed Jun 27, 2012 8:09 pm
Posts: 18
This is an example of what i been doing, and will show what i did in the Python Scripts. When i launch the game for the first time, i noticed that Home Planet can reconstruct the Imperial Capitol or Drydock. So i made some change for myself and corrected it with notepad software. So i am now using Komodo Edit 7 to redo what i did on the notepad.

You will see a picture down below that the Shipyard cannot be reconstructed and by copy the line that start And after location to and before you reach graphic =...
Code:
BuildingType
    name = "BLD_SHIPYARD_BASE"
    description = "BLD_SHIPYARD_BASE_DESC"
    buildcost = 50
    buildtime = 1
    location = And [
        Not Contains And [
            Building "BLD_SHIPYARD_BASE"
            OwnedBy TheEmpire Source.Owner
        ]
        OwnedBy TheEmpire Source.Owner
    ]
    graphic = "icons/building/shipyard.png"


Then i will copy/paste that line to this location...
Code:
BuildingType
    name = "BLD_SHIPYARD_ORBITAL_DRYDOCK"
    description = "BLD_SHIPYARD_ORBITAL_DRYDOCK_DESC"
    buildcost = 75
    buildtime = 1
    location = And [
        Contains And [
            Building name = "BLD_SHIPYARD_BASE"
            OwnedBy TheEmpire Source.Owner
        ]
        OwnedBy TheEmpire Source.Owner
            And [
                Not Contains And [
                    Building "BLD_SHIPYARD_ORBITAL_DRYDOCK"
                    OwnedBy TheEmpire Source.Owner
                ]
                OwnedBy TheEmpire Source.Owner   
            ]
    ]


You will see that i have added the lines from top portions to bottom and renamed "BLD_SHIPYARD_BASE".

This is the orginal code (4635)...
Code:
BuildingType
    name = "BLD_SHIPYARD_ORBITAL_DRYDOCK"
    description = "BLD_SHIPYARD_ORBITAL_DRYDOCK_DESC"
    buildcost = 75
    buildtime = 1
    location = And [
        Contains And [
            Building name = "BLD_SHIPYARD_BASE"
            OwnedBy TheEmpire Source.Owner
        ]
        OwnedBy TheEmpire Source.Owner
    ]


This will keep from players and AIs from rebuilding these structures over and over. Hope this help you guys if you wanna do these scripts, if not i can do it for you in time when i get a chance. There alot of buildings that needed to be fixed though.


Last edited by redindus on Wed Jul 04, 2012 6:54 pm, edited 6 times in total.

Top
 Profile  
 
 Post subject: Re: Buildings.txt
PostPosted: Wed Jul 04, 2012 4:43 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7887
Location: Vancouver, BC
Please attach images to posts, or paste as text in code tags for code, rather than using an external image host that will probably disappear in a few months or years.

It would be preferable if you could set up some macros to wrap the name of the building you're adding these location conditions for, to reduce the amount of duplicated text.

Also, note that this almost works, but not quite, in that if an empire has multiple enqueued copies of a building at a single location, and more than one finish on the same game turn, they will all still get produced.


Top
 Profile  
 
 Post subject: Re: Buildings.txt
PostPosted: Wed Jul 04, 2012 4:58 pm 
Offline
Space Dragon

Joined: Mon Aug 15, 2011 5:33 pm
Posts: 429
Such a situation would be rare and it would indeed fix most instances of duplicating buildings through player error :P


Top
 Profile  
 
 Post subject: Re: Buildings.txt
PostPosted: Wed Jul 04, 2012 5:15 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7887
Location: Vancouver, BC
I suppose the fact that one can still enqueue multple copies before the first finishes is a bigger issue than that some of them might finish on the same turn... Resolving that could be done with a condition that tests whether a planet has a specified ship or building being produced at it.


Top
 Profile  
 
 Post subject: Re: Buildings.txt
PostPosted: Sun Jul 08, 2012 2:22 pm 
Offline
Space Dragon

Joined: Mon Aug 15, 2011 5:33 pm
Posts: 429
@ Redindus: Any chance of getting the patch?


Top
 Profile  
 
 Post subject: Re: Buildings.txt
PostPosted: Mon Jul 09, 2012 5:31 pm 
Offline
Space Floater

Joined: Wed Jun 27, 2012 8:09 pm
Posts: 18
Zireael wrote:
@ Redindus: Any chance of getting the patch?


I havent done anything yet, been waiting for someone say something and wasnt sure whos in charge. I did few things to it and realise that alot of building structures will need that codes i mention above to prevent players and/or AIs from making it again (if already constructed). Its not that hard to do, unless rewrite it in different language or idea of code structures.


Top
 Profile  
 
 Post subject: Re: Buildings.txt
PostPosted: Mon Jul 09, 2012 11:18 pm 
Offline
Designer and Programmer
User avatar

Joined: Tue Aug 14, 2007 6:33 pm
Posts: 1770
Location: Orion
I think what Geoff meant by his post is that at some point, he's going to add a condition that matches planets on which a particular building is being produced, which will make a more robust solution possible.

In other words, feel free to implement a stop-gap solution if you'd like, but it's probably more practical to just hold off on this and focus on something that will be more useful in the long run.

_________________
Warning: Antarans in dimensional portal are closer than they appear.


Top
 Profile  
 
 Post subject: Re: Buildings.txt
PostPosted: Tue Jul 10, 2012 1:22 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7887
Location: Vancouver, BC
Bigjoe5 wrote:
...it's probably more practical to just hold off on this and focus on something that will be more useful in the long run.
A nearly-complete solution to preventing double-production of buildings would need an extra condition, but that's not really a reason not to add a partial solution now, if someone's so inclined.


Top
 Profile  
 
 Post subject: Re: Buildings.txt
PostPosted: Tue Jul 10, 2012 8:11 am 
Offline
Space Floater

Joined: Wed Jun 27, 2012 8:09 pm
Posts: 18
Bigjoe5 wrote:
I think what Geoff meant by his post is that at some point, he's going to add a condition that matches planets on which a particular building is being produced, which will make a more robust solution possible.

In other words, feel free to implement a stop-gap solution if you'd like, but it's probably more practical to just hold off on this and focus on something that will be more useful in the long run.


I agreed, adding a condition to certain planets might work without having to add all those copy/paste code for each lines. Less codes, run faster :)


Top
 Profile  
 
 Post subject: Re: Buildings.txt
PostPosted: Sun Jul 15, 2012 2:23 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7887
Location: Vancouver, BC
Geoff the Medio wrote:
A nearly-complete solution to preventing double-production of buildings would need an extra condition...
In the SVN version, I've added an Enqueued condition, which should be usable something like:
Code:
Enqueued type = Building name = "BLD_OBSERVATORY" empire = Source.Owner low = 0 high = 1
which will match planets where the indicated empire has within the indicated range of number of items enqueued of the indicated type and name.

For preventing multiple-enqueues of a particular building, you'd just need to specify high = 0, which would exclude any planet with 1 or more of the indicated building type enqueued. (low = 0 is assumed if not specified.) To prevent multiple production of a particular building, you'd want to And this with a condition that checks how many of the building are already present on the planet, so that having one present or enqueued prevents any more from being enqueued or having PP applied if already enqueued.

This also works for ship designs (type = Ship) by name or number, so a ship could have a condition that matches planets where the same design is enqueued (using design = Source.DesignID) or location conditions could refer to predefined ship designs by name, as in
Code:
Enqueued type = Ship name = "SD_SCOUT" low = 1
which would match any planet where at least one "Scout" ship (of the predefined variety) is enqueued by any empire.

I haven't actually tested this, though.

Edit: There's probably a bit of a problem with using the Enqueued condition: the location condition is tested to decide if something can be added to the queue, and to decide if something on the queue can receive PP that turn. That means that for something not be enqueuable, it also will not receive any funding, and if it does receive funding, it is enqueuable. So, if the limit for something on the queue is set at 1, then it will be enqueuable, but not fundable once on the queue. If the limit is 2, it will be enqueuable twice, though won't be fundable after the second copy is enqueued.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


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 © 2000, 2002, 2005, 2007 phpBB Group