Page 1 of 2 12 LastLast
Results 1 to 20 of 30

Thread: Limit the building to one per faction

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Maestro Ugo's Avatar Civis
    Join Date
    Oct 2010
    Location
    Zagreb, Croatia
    Posts
    185

    Default Limit the building to one per faction

    Hi everyone!

    I'm trying to make a building that could be buildable only once per faction, meaning that once you build it in one of your cities it becomes unavailable for building in other cities.

    Any easy way of doing this? I could make it a guild, but I would prefer the simple way.

    Thank you.

    Tired of rampant corruption? Try ICS - Improved Corruption System for TATW3.1.

  2. #2

    Default Re: Limit the building to one per faction

    Quote Originally Posted by Maestro Ugo View Post
    Hi everyone!

    I'm trying to make a building that could be buildable only once per faction, meaning that once you build it in one of your cities it becomes unavailable for building in other cities.

    Any easy way of doing this? I could make it a guild, but I would prefer the simple way.

    Thank you.
    I think you can do this with a hidden resource(one of the first line in export_descr_buildings)
    Then you must add " and hidden_resource " + name of your resource to the capability of your building.
    You must also add the name of your resource to descr_regions(You will found this in your campaign/base folder).

    I hope this help you.


  3. #3
    Maestro Ugo's Avatar Civis
    Join Date
    Oct 2010
    Location
    Zagreb, Croatia
    Posts
    185

    Default Re: Limit the building to one per faction

    Cheers for the reply, but I'm not completely sure if I understand. I want the player to choose which region he will build it in, not for that to be decided by a hidden resource. Or am I completely off here?

    Tired of rampant corruption? Try ICS - Improved Corruption System for TATW3.1.

  4. #4

    Default Re: Limit the building to one per faction

    Quote Originally Posted by Maestro Ugo View Post
    Cheers for the reply, but I'm not completely sure if I understand. I want the player to choose which region he will build it in, not for that to be decided by a hidden resource. Or am I completely off here?
    I'm sorry, I don't understanded what you mean.
    I don't think there is no way to limit the number of buildings, but I can be wrong.


  5. #5
    Maestro Ugo's Avatar Civis
    Join Date
    Oct 2010
    Location
    Zagreb, Croatia
    Posts
    185

    Default Re: Limit the building to one per faction

    I probably wasn't clear enough - I want players to be able to build this building only once per faction (once per game) in a city of their choosing. To be more concrete, I'm trying to add a building Provincial Capitol, which would be buildable only once in a region of player's choosing.

    Tired of rampant corruption? Try ICS - Improved Corruption System for TATW3.1.

  6. #6
    makanyane's Avatar Praeses
    Content Emeritus

    Join Date
    Feb 2006
    Posts
    9,093
    Blog Entries
    1

    Default Re: Limit the building to one per faction

    think you need to put it in the background script - with event counter change when the building is built - and EDB requirement that event counter change is <x for each faction, with unique event and requirement for each faction.

    Am not sure if 'adding building to queue' within settlement can trigger an event counter or not - if it doesn't you may have an issue with multiple buildings started simultaneously... anyway you need to have a look at the scripting advice and documents.

  7. #7
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Limit the building to one per faction

    zero counter doesn't work in EDB: and event_counter provincial_capitol_built 0

    instead make it negative: and not event_counter provincial_capitol_built 1










  8. #8
    Maestro Ugo's Avatar Civis
    Join Date
    Oct 2010
    Location
    Zagreb, Croatia
    Posts
    185

    Default Re: Limit the building to one per faction

    Quote Originally Posted by Gigantus View Post
    zero counter doesn't work in EDB: and event_counter provincial_capitol_built 0

    instead make it negative: and not event_counter provincial_capitol_built 1
    Thank you kind sir, that seems like a possible solution!
    The weird thing is that if I set it up like you propose the building doesn't appear in the game at all... What am I missing...

    Tired of rampant corruption? Try ICS - Improved Corruption System for TATW3.1.

  9. #9
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Limit the building to one per faction

    declare_counter provincial_capitol_built events don't need to be declared
    monitor_event BuildingCompleted provincial_capitol ;not sure about terminology of this line
    and FactionType [faction_name]
    and NumBuildingsCompletedFaction provincial_capitol => 1
    set_event_counter provincial_capitol_built_[faction_name] 1
    end_monitor

    EDB: requires { [faction_name], } and not event_counter provincial_capitol_built_[faction_name] 1

    This will need one monitor per faction and one faction requirement line per faction in the EDB. Not sure if the EDB part actually works.

    Alternatively you could use the "FactionBuildingExists" condition together with the "FactionTurnEnd" event, but you will still need one monitor per faction.
    Last edited by Gigantus; December 22, 2011 at 12:54 AM.










  10. #10
    Maestro Ugo's Avatar Civis
    Join Date
    Oct 2010
    Location
    Zagreb, Croatia
    Posts
    185

    Default

    Quote Originally Posted by Gigantus View Post
    declare_counter provincial_capitol_built events don't need to be declared
    monitor_event BuildingCompleted provincial_capitol ;not sure about terminology of this line
    and FactionType [faction_name]
    and NumBuildingsCompletedFaction provincial_capitol => 1
    set_event_counter provincial_capitol_built_[faction_name] 1
    end_monitor

    EDB: requires { [faction_name], } and not event_counter provincial_capitol_built_[faction_name] 1

    This will need one monitor per faction and one faction requirement line per faction in the EDB. Not sure if the EDB part actually works.

    Alternatively you could use the "FactionBuildingExists" condition together with the "FactionTurnEnd" event, but you will still need one monitor per faction.
    That looks good! I'm very new to modding, so don't really understand the engine language. I thought I could define it for all factions at once. Thank you very much for your help, will try this as soon as I get home.

    Okay, I played around with this for quite some time, but I can't get it to work. The problem is that I can't verify any of the solutions proposed above - if they will actually prevent the building from being built twice, because as soon as I add the line "and not event_counter provincial_capitol_built_factionname 1" the building is not there to choose in the first place.

    So, some of the solutions might work, I just cant get so far as to actually test them as I cant build the building in the first place. If I test it without the line above I can build the building normally. Any idea what's going on? Shouldn't the counter by default, even if there is no monitor event be = 0 and thus satisfy the requirement of "and not event_counter provincial_capitol_built_factionname 1"? It seems that the game for some reason treats this condition as not met, even though no counter has been set.

    EDIT: Are we sure "not" will work as intended here?

    I'm losing faith here, can someone please help me dubug this bugger?

    For some reason the building I'm trying to create doesn't show in the game if the event_trigger is included, I am at a loss as to the reason for this.

    Here is what I addded in the EDB:

    Code:
    ;###########################################
    ;########### Provincial Capitol ############
    ;###########################################
    building provincial_capitol_gondor
    {
        levels provincial_capitol_gondor
        {
              provincial_capitol_gondor city requires factions { gondor, }  and event_counter provincial_capitol_buildable_gondor 1
            {
                capability
                {
                    law_bonus bonus 1
                }
                material stone
                construction  1 
                cost  1000 
            settlement_min large_town
                upgrades
                {
                }
        }
        }
        plugins 
        {
        }
    }
    I added the descriptions in text/export_buildings.txt as well as entries in export_descr_buildings_enums.txt.

    Here is what I added in the campaign_script.txt, it was proposed in this thread by Aikanar:
    Code:
    monitor_event    PreFactionTurnStart    FactionIsLocal
    and FactionType gondor
    set_event_counter provincial_capitol_buildable_gondor    1 ;set the event counter on 1 permanently
    terminate_monitor
    end_monitor
    
    monitor_event BuildingCompleted    SettlementBuildingFinished    =    provincial_capitol_gondor
    set_event_counter provincial_capitol_buildable_gondor    0 ; set the event counter on 0 permanently
    end_monitor
    Still, the building doesn't show up in the game. It's mostly likely something trivial my inexperienced eye just cant spot. Any ideas?
    Last edited by Ishan; December 23, 2011 at 12:29 AM. Reason: Triple Post

    Tired of rampant corruption? Try ICS - Improved Corruption System for TATW3.1.

  11. #11
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Limit the building to one per faction

    Add this line to the top of your script, it will remove the radar restriction. If this restriction is not removed after adding the line, then your script doesn't work. There is a good chance that you will get an error message in the log:

    restrict_strat_radar false










  12. #12
    Maestro Ugo's Avatar Civis
    Join Date
    Oct 2010
    Location
    Zagreb, Croatia
    Posts
    185

    Default Re: Limit the building to one per faction

    Quote Originally Posted by Gigantus View Post
    Add this line to the top of your script, it will remove the radar restriction. If this restriction is not removed after adding the line, then your script doesn't work. There is a good chance that you will get an error message in the log:

    restrict_strat_radar false
    As I'm modifying TATW3.0 script, this line is already in. But you are right in thinking the script doesn't run. I just checked and the script is not running for some obscure reason when I add my lines - but is running perfectly without them.

    Quote Originally Posted by TNZ View Post
    Maestro Ugo: In the ‘campaign_script’ file, Gondor’s name is ‘sicily’ and not ‘gondor’:
    Spoiler Alert, click show to read: 
    Code:
    ;###### Gondor Provincial Capitol #######
    
    add_events
        event    counter    provincial_capitol_buildable_gondor 1
        date    0
    end_add_events
    
    set_event_counter provincial_capitol_buildable_gondor 1
    
        monitor_event BuildingCompleted FactionType sicily
            and SettlementBuildingFinished = provincial_capitol_gondor
            set_event_counter provincial_capitol_buildable_gondor 0
        terminate_monitor
        end_monitor

    This may help. It can be a bit confusing:
    Spoiler Alert, click show to read: 
    Code:
    Faction:            Culture:            Religion:
    
    
    sicily = GONDOR         gondor                numenorian = Dúnedain    
    
    
    byzantium = ARNOR        northern_european         northmen = Northmen    
    
    
    milan = ROHAN             northern_european        northmen = Northmen
    
    
    scotland = DALE         northern_european        northmen = Northmen
    
    
    turks = ERIADOR         northern_european        northmen = Northmen
    
    
    slave = SLAVE             northern_european         heretic = Others
    
    
    moors = DWARVES         southern_european        islam = Dwarves
    
    
    egypt = HIGH ELVES         greek                orthodox = Elves
    
    
    mongols = SILVAN ELVES         greek                orthodox = Elves
    
    
    papal_states = SAURON         eastern_european         catholic = Followers of Melkor
    
    
    england = MORDOR         eastern_european        catholic = Followers of Melkor
    
    
    france = ISENGARD         eastern_european        catholic = Followers of Melkor
    
    
    hre = ORCS MM             eastern_european        catholic = Followers of Melkor
    
    
    portugal = ANGMAR        eastern_european        catholic = Followers of Melkor    
    
    
    spain = HARAD             middle_eastern            catholic = Followers of Melkor
    
    
    venice = EASTERLINGS         middle_eastern            catholic = Followers of Melkor
    Cheers! I didn't know that - I saw "gondor" in the EDB and automatically assumed it's a valid faction. Thank you for the info, and that list is very useful. I have changed it everywhere to sicily - just to be on the safe side. I tried your code, but it also didn't work - it seems that whatever I do I break the script. Is there something I'm missing? In TATW script there is the field "Additional scripts" in the end of the file where I put my code not changing anything else, still whatever I put in from the suggestions offered above - the script breaks, in that once I start a game it doesn't run as evidenced by the lack of the welcome message in the first turn.

    Quote Originally Posted by Withwnar View Post
    I think that this is the wrong way around. Zero counters do work and "not event_counter" does not.

    TNZ's "sicily" fix should do the trick. "gondor" is probably safe in EDB because "gondor" is also a culture but in campaign_script it must be sicily.

    Your (Aikanar's) script will only work when playing Gondor, not for an AI Gondor. Is that what you wanted? If not then change...

    Code:
    monitor_event    PreFactionTurnStart    FactionIsLocal
    and FactionType sicily
    to...

    Code:
    monitor_event    PreFactionTurnStart FactionType  sicily
    export_descr_buildings_enums.txt is not needed. A leftover from RTW I believe.

    Also, this will only prevent one being built after the first one has been built. It won't prevent more than one being added to the construction queue when none have been built yet.

    @TNZ
    byzantium/Arnor religion is numenorian.
    Even the experts disagree I see...

    Nevermind, though - I dropped the "not" and defined 1 as buildable not built in the script. And yes, I want it to work for the player only.

    Thank you all for your inputs, any ideas what I'm doing wrong to the script? Here is the screenshot of the piece of the script I added, I changed nothing else in the file:
    Spoiler Alert, click show to read: 


    With these or any other lines added the script doesn't run, and thus my building doesn't appear in the game. Do I have to change something else in another file?

    Tired of rampant corruption? Try ICS - Improved Corruption System for TATW3.1.

  13. #13

    Icon1 Re: Limit the building to one per faction

    Maestro Ugo: In the ‘campaign_script’ file, Gondor’s name is ‘sicily’ and not ‘gondor’:
    Spoiler Alert, click show to read: 
    Code:
    ;###### Gondor Provincial Capitol #######
    
    add_events
    	event	counter	provincial_capitol_buildable_gondor
    	date	0
    end_add_events
    
    set_event_counter provincial_capitol_buildable_gondor 1
    
    	monitor_event BuildingCompleted FactionType sicily
    		and SettlementBuildingFinished = provincial_capitol_gondor
    		set_event_counter provincial_capitol_buildable_gondor 0
    	terminate_monitor
    	end_monitor

    This may help. It can be a bit confusing:
    Spoiler Alert, click show to read: 
    Code:
    Faction:			Culture:			Religion:
    
    
    sicily = GONDOR 		gondor				numenorian = Dúnedain	
    
    
    byzantium = ARNOR		northern_european 		numenorian = Dúnedain	
    
    
    milan = ROHAN 			northern_european		northmen = Northmen
    
    
    scotland = DALE 		northern_european		northmen = Northmen
    
    
    turks = ERIADOR 		northern_european		northmen = Northmen
    
    
    slave = SLAVE 			northern_european 		heretic = Others
    
    
    moors = DWARVES 		southern_european		islam = Dwarves
    
    
    egypt = HIGH ELVES 		greek				orthodox = Elves
    
    
    mongols = SILVAN ELVES 		greek				orthodox = Elves
    
    
    papal_states = SAURON 		eastern_european 		catholic = Followers of Melkor
    
    
    england = MORDOR 		eastern_european		catholic = Followers of Melkor
    
    
    france = ISENGARD 		eastern_european		catholic = Followers of Melkor
    
    
    hre = ORCS MM 			eastern_european		catholic = Followers of Melkor
    
    
    portugal = ANGMAR		eastern_european		catholic = Followers of Melkor	
    
    
    spain = HARAD 			middle_eastern			catholic = Followers of Melkor
    
    
    venice = EASTERLINGS 		middle_eastern			catholic = Followers of Melkor
    Last edited by TNZ; December 23, 2011 at 03:52 AM.

  14. #14
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Limit the building to one per faction

    Quote Originally Posted by Gigantus View Post
    zero counter doesn't work in EDB: and event_counter provincial_capitol_built 0

    instead make it negative: and not event_counter provincial_capitol_built 1
    I think that this is the wrong way around. Zero counters do work and "not event_counter" does not.

    TNZ's "sicily" fix should do the trick. "gondor" is probably safe in EDB because "gondor" is also a culture but in campaign_script it must be sicily.

    Your (Aikanar's) script will only work when playing Gondor, not for an AI Gondor. Is that what you wanted? If not then change...

    Code:
    monitor_event    PreFactionTurnStart    FactionIsLocal
    and FactionType sicily
    to...

    Code:
    monitor_event    PreFactionTurnStart FactionType sicily
    export_descr_buildings_enums.txt is not needed. A leftover from RTW I believe.

    Also, this will only prevent one being built after the first one has been built. It won't prevent more than one being added to the construction queue when none have been built yet.

    @TNZ
    byzantium/Arnor religion is numenorian.
    Last edited by Withwnar; December 23, 2011 at 01:17 AM.

  15. #15
    Minas Moth's Avatar Senator
    Join Date
    Feb 2011
    Location
    Croatia
    Posts
    1,338

    Default Re: Limit the building to one per faction

    assuming everything else is good (no mistakes in edb or campaign script), you should delete map.rwm file in data>world>maps>base folder. if you don't your buildings (new ones you add) will never work... so try that...

  16. #16

    Default Re: Limit the building to one per faction

    Quote Originally Posted by Withwnar View Post
    I think that this is the wrong way around. Zero counters do work and "not event_counter" does not.
    No it's the other way around for EDB, i can never forget this.
    Code:
    and event_counter xyz 0<---Doesn't works
    and not event_counter xyz 1<---Works
    Quote Originally Posted by Minas Moth View Post
    assuming everything else is good (no mistakes in edb or campaign script), you should delete map.rwm file in data>world>maps>base folder. if you don't your buildings (new ones you add) will never work... so try that...
    There is no need to delete map.rwm file unless there are some changes in the base folder. When dealing with EDB the only exception is when you're adding a hidden resource in it, which requires an entry in the descr_regions.txt file (in base folder).

  17. #17
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Limit the building to one per faction

    Quote Originally Posted by Ishan View Post
    No it's the other way around for EDB, i can never forget this.
    Code:
    and event_counter xyz 0<---Doesn't works
    and not event_counter xyz 1<---Works
    My apologies Gigantus. Must have some crossed wires somewhere. Thanks Ishan.

    @Maestro
    Hmm, that script looks okay, though I'm not familiar with the BuildingCompleted event (as in I haven't used it before). Any errors in the log?

    EDIT:
    It is from Scripting 101 that I got the zero rule from. Something I read ages ago and has stuck in my brain. Perhaps it was for RTW?
    event_counter:
    Similar to a counter, the difference is that when you use this with the EDB file it is used as a true/false flag. 0 is false, anything else is true. Event counters do not have to be declared.
    Last edited by Withwnar; December 23, 2011 at 04:07 AM.

  18. #18
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Limit the building to one per faction

    event_counter:
    Similar to a counter, the difference is that when you use this with the EDB file it is used as a true/false flag. 0 is false, anything else is true. Event counters do not have to be declared.
    I think this was a tad obscure: everything written there is correct, it just doesn't state how it should it be written in the EDB.

    If the event has not fired in the script then the flag is zero=false, meaning the regular requirement (and event_counter [event_name] 1) will not fire.
    If you wish a requirement to be valid when the flag is zero=false, then the requirement has to negative as the game does not recognize the zero as a valid entry after the event requirement.










  19. #19

    Icon1 Re: Limit the building to one per faction

    @TNZ
    byzantium/Arnor religion is numenorian.
    Code:
    byzantium = ARNOR		northern_european 		numenorian = Dúnedain
    Maestro Ugo: Try this:
    Spoiler Alert, click show to read: 
    Code:
    ;###### Gondor Provincial Capitol #######
    
    add_events
    	event	counter	provincial_capitol_buildable_gondor
    	date	0
    end_add_events
    
    	monitor_event FactionTurnStart FactionIsLocal 
    		and FactionType sicily
    		set_event_counter provincial_capitol_buildable_gondor 1
    	terminate_monitor
    	end_monitor
    
    	monitor_event FactionTurnStart FactionIsLocal 
    		and FactionType sicily
    		and FactionBuildingExists = provincial_capitol_gondor
    		set_event_counter provincial_capitol_buildable_gondor 0
    	terminate_monitor
    	end_monitor

  20. #20
    Maestro Ugo's Avatar Civis
    Join Date
    Oct 2010
    Location
    Zagreb, Croatia
    Posts
    185

    Default Re: Limit the building to one per faction

    Thank you all for your time and effort, I'm still struggling, though...

    There is a problem I'm missing somewhere and it's just something very basic as my script appeares to malfunction.

    First, Withwnar, when I use the script published earlier the log is normal (only standard errors in it that appear always), when I use the method proposed by TNZ I get this in the end of my error log:
    Code:
    15:32:09.079 [game.script] [error] Script parsing error at line 63548, column 5 in mods/Third_Age_3/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    <end_add_events> expected
    
    15:32:09.079 [game.script] [error] Script parsing error at line 63549, column 1 in mods/Third_Age_3/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    Couldn't create a script from file mods/Third_Age_3/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    I have no idea what the problem was as end_add_events exists. The line number, by the way, refers to: "event counter provincial_capitol_buildable_gondor"

    The problem is that whatever I try either kills the script and prevents it from running, or it runs but my commands are ignored. For example, just for testing I tried the simple money adding code just to see if it will work:
    Code:
    monitor_event FactionTurnStart FactionType sicily
     console_command add_money sicily, 10000
    end_monitor
    The script runs, but this part I added doesn't work - the money is never added to the faction, I tried several turns - nothing. I tried using the console and adding money manually and it worked fine...

    What in the name of sanity is going on here?...

    EDIT: Okaaaaay... If I put the code (the testing, money one) in the beginning of the script file it works, but if I put it in the end it never gets read... Is this even possible?!?!?!? Is there an information as to the number of lines the script file has after which the game fails to read or something?

    EDIT2: It works! It works! It bloody WORKS!
    as long as I put the code in the beginning of the file... Can anyone explain this?
    +rep for everyone helping me to get to this point, by the way.
    Last edited by Maestro Ugo; December 23, 2011 at 09:23 AM.

    Tired of rampant corruption? Try ICS - Improved Corruption System for TATW3.1.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •