Results 1 to 6 of 6

Thread: Scripting for new building

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    julianus heraclius's Avatar The Philosopher King
    Join Date
    May 2006
    Location
    Australia
    Posts
    5,382

    Default Scripting for new building

    I'm having problems trying to create a hunnic foederati building.

    This what it looks like in the script.

    script
    ;======================================================
    ; Declare Counters
    ;======================================================
    declare_counter settlementowner_Ravenna
    declare_counter settlementowner_Verona
    declare_counter settlementowner_Sirmium
    declare_counter settlementowner_Carthage
    declare_counter Foederati_Hunnic_Treaty
    ;======================================================
    ; Recruitment of Hunnic Foederati after 380AD
    ;======================================================
    monitor_event FactionTurnStart FactionType empire_east
    set_counter Foederati_Hunnic_Treaty 1
    end_monitor
    monitor_event FactionTurnStart FactionType empire_east
    and I_CompareCounter Foederati_Hunnic_Treaty = 0
    and I_TurnNumber > 2
    and I_SettlementOwner Sirmium = empire_east
    and not SettlementBuildingExists = foederati_treaties1
    and not I_SettlementOwner Sirmium = alemanni
    and not I_SettlementOwner Sirmium = franks
    and not I_SettlementOwner Sirmium = saxons
    and not I_SettlementOwner Sirmium = celts
    and not I_SettlementOwner Sirmium = berbers
    and not I_SettlementOwner Sirmium = slavs
    and not I_SettlementOwner Sirmium = lombardi
    and not I_SettlementOwner Sirmium = goths
    and not I_SettlementOwner Sirmium = ostrogoths
    and not I_SettlementOwner Sirmium = huns
    and not I_SettlementOwner Sirmium = sassanids
    and not I_SettlementOwner Sirmium = sarmatians
    and not I_SettlementOwner Sirmium = moors
    and not I_SettlementOwner Sirmium = romano_british
    and not I_SettlementOwner Sirmium = roxolani
    and not I_SettlementOwner Sirmium = slave
    console_command create_building Sirmium "foederati_treaties1"
    end_monitor

    And in the export_descr_buildings.txt file, this is what I put.

    building hinterland_foederati_treaties1
    {
    levels foederati_treaties1
    {
    foederati_treaties1 requires factions { roman, } and hidden_resource not_here
    {
    capability
    {
    }
    construction 1
    cost 400
    settlement_min city
    upgrades
    {
    }
    }
    }
    plugins
    {
    }
    }

    building foederati_recruitment_huns
    {
    levels foederati_camp_huns foederati_settlement_huns foederati_tribe_huns
    {
    foederati_camp_huns requires factions { roman, } and building_present_min_level hinterland_foederati_treaties1 foederati_treaties1
    {
    capability
    {
    recruit "hunnic foederati" 0 requires factions { roman, }
    }
    construction 1
    cost 2000
    settlement_min town
    upgrades
    {
    foederati_settlement_huns
    }
    }
    foederati_settlement_huns requires factions { roman, } and hidden_resource foederati
    {
    capability
    {
    recruit "hunnic foederati" 0 requires factions { roman, }
    recruit "foederati hunnic lancers" 0 requires factions { roman, }

    }
    construction 2
    cost 3000
    settlement_min large_town
    upgrades
    {
    foederati_tribe_huns
    }
    }
    foederati_tribe_huns requires factions { roman, } and hidden_resource foederati
    {
    capability
    {
    recruit "hunnic foederati" 1 requires factions { roman, }
    recruit "foederati hunnic lancers" 1 requires factions { roman, }
    }
    construction 3
    cost 5000
    settlement_min city
    upgrades
    {
    }
    }
    }
    plugins
    {
    }
    }

    Now, it works it I remove the and hidden_resource not_here, but I get the building in the construction list for a ll roman buildings, but when it is included, the script doesn't construct the building in the construction list.

    Any ideas.

    Thanks

    Avatar & Signature by Joar

  2. #2
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Scripting for new building

    Bad syntax:
    Code:
    and not SettlementBuildingExists = foederati_treaties1
    and not I_SettlementOwner Sirmium = alemanni
    ; etc.
    The 'not' keyword does not work with conditions that use logical operators as parameters. Try re-writing it as:
    Code:
    and SettlementBuildingExists < foederati_treaties1
     and I_SettlementOwner Sirmium != alemanni ; not-equal
    ; etc.
    Btw, when do you want the building to be created?
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  3. #3
    julianus heraclius's Avatar The Philosopher King
    Join Date
    May 2006
    Location
    Australia
    Posts
    5,382

    Default Re: Scripting for new building

    Quote Originally Posted by HouseOfHam View Post
    Bad syntax:
    Code:
    and not SettlementBuildingExists = foederati_treaties1
    and not I_SettlementOwner Sirmium = alemanni
    ; etc.
    The 'not' keyword does not work with conditions that use logical operators as parameters. Try re-writing it as:
    Code:
    and SettlementBuildingExists < foederati_treaties1
     and I_SettlementOwner Sirmium != alemanni ; not-equal
    ; etc.
    Btw, when do you want the building to be created?
    Well, in game it will be created around the time of 380AD. This is when apparently a group of huns were settled in Pannonia as foederati along with some alans and ostrogoths, so of course the number of turns will be greater than what I have shown.

    I'm still not sure about the scripting though, as I have used "not" before and the script has worked fine.

    As I said, the script works fine if I don't use the hidden resource "not_here" in the edb.txt file, but of course the foederati building automatically appears in all roman cities.

    This script is designed to "trigger" the creation of the foederati building tree. The script triggers the foederati_treaties1, which in game shows up as the treaty. This then allows the building of the foederati building tree. The tree is dependent on the foederati_treaties1 being created.

    The hidden resource "not_here" is designed to prevent the building appearing befroe the script trigger.

    As I said, the trigger works without the hidden resource, but not when it is included.

    Avatar & Signature by Joar

  4. #4
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Scripting for new building

    1.
    The 'not' keyword does not work with conditions that use logical operators as parameters.
    This was explained back in 2005 by JeromeGrasdyke, lead developer at CA. It means you...
    - can use "not" with conditionis like FactionIsLocal, I_LocalFaction, CultureType, GeneralFoughtInCombat, etc.
    - cannot use "not" with conditions that use '<', '>', '=', '!=' like I_SettlementOwner, NumKilledGenerals. Instead, have to invert the logical operator.

    If you do a bit of testing, you'll notice that using it incorrectly (as in "and not SettlementBuildingExists = foederati_treaties1") always returns the same result.

    2. All the "and not I_SettlementOwner Sirmium = whatever" conditions (even if they worked with "not") are useless because there is already a "and I_SettlementOwner Sirmium = empire_east" condition above.

    3. I suspect the hidden_resource requirement is somehow getting inherited by the foederati_recruitment_huns building, but that would be a better question for the experts. It's possible that what you're trying to do can't be done that way.

    4. Have you tried running my EDB validator on your mod?
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  5. #5

    Default Re: Scripting for new building

    At least to test it, try not using the hidden resource and instead remove the factions so it appears as "requires factions { , }".

    Expand your borders, a mod based on XGM 5.

  6. #6
    julianus heraclius's Avatar The Philosopher King
    Join Date
    May 2006
    Location
    Australia
    Posts
    5,382

    Default Re: Scripting for new building

    Thanks for the help guys. I found the problem with "set_counter Foederati_Hunnic_Treaty 1" line. When I removed that it worked.

    Cheers

    Avatar & Signature by Joar

Posting Permissions

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