Page 1 of 4 1234 LastLast
Results 1 to 20 of 71

Thread: Lesson 3

  1. #1
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,844
    Blog Entries
    10

    Default Lesson 3

    Sorry this is late, I had some stuff come up last night. I am extending the deadline for Lesson 2 for a week as several of you still seem to be having trouble with it. I have rewritten this lesson and dropped some things so that I can cover event_counters a bit more extensively. Initially I had planned to go into more depth on the various events you can use besides FactionTurnEnd which is what we have used the most of so far. I am going to write an explanation of some of those and a general guide on logic over the weekend for everyone to read, and I will include the things I dropped from this lesson into Lesson 4. I want to make sure everyone understands the counters and event_counters as much as possible before I move on as they are the most important aspect of scripting.


    This week we are going to be using event_counters with the EDB (export_description_buildings.txt) file and your script combined. To do this we will use the "requires" tag inside the EDB itself, and require an event_counter to be set to a specific value before we can recruit a unit, or build a building, or get a bonus. I highly suggest all of you take a look at the vanilla files and search for the event_counter named world_is_round. In the vanilla EDB you will see how it is used in the recruit_pool section to enable the Caravel. If you search for other event_counters you will see how they used gunpowder_discovered to enable both units and buildings.


    There are a lot of things we can use this for, and one of the first scripts I ever wrote for event counters was to deny the player from building something if he did not have a governor in the settlement, even if he had checked Manage All Settlements when he started the game, but still allow the AI to construct them anytime it wanted to. This is pretty simple once you get your head around the logic of it. The easiest way to do this is to deny the building to everyone, AI included, by requiring an event_counter, then set the event counter when it is the AI's turn, or when a player selects a settlement that has a governor in it.


    This is the line we will add to the EDB, I am adding it to the temple_catholic tree of buildings but you can add it to anything you like. At the end of the line you will see the event_counter that has been added:
    small_church city requires factions { normans, denmark, hre, scotland, france, england, hungary, poland, venice, papal_states, portugal, spain, sicily, milan, } and event_counter governor_present 1


    Now run your game and select one of your settlements that normally would be able to build this building. In the vanilla game I am using London. The building should NOT show up for you to select because we have not set the counter in your campaign script. I want to make sure you cannot construct it before we continue.


    Now that you know you cant build the building unless we manually set the counter, its time to write the script. For this we will be using the SettlementSelected event and checking to see if there is a governor in the settlement. If there is then we set the counter, if there is not then we leave the counter at 0.


    This will set the event_counter to 1 anytime we select a settlement that has a governor in it.
    Code:
    monitor_event SettlementSelected GovernorInResidence
     set_event_counter governor_present 1
    end_monitor


    But when we select a settlement that does not have a governor in it we need the counter to be set back to 0 so we cant build the building.
    Code:
    monitor_event SettlementSelected not GovernorInResidence
     set_event_counter governor_present 0
    end_monitor


    And finally we need the AI to have permission to build anytime it wants to, so at the end of the players turn we set the counter to 1.
    Code:
    monitor_event FactionTurnEnd FactionIsLocal
     set_event_counter governor_present 1
    end_monitor


    Some things you need to know:
    The requires event_counter line is a bit flawed in the EDB file. It will only detect 0 and 1 for event_counter values. Anything over 1 will be treated as a 1. If you need multiple options then you need multiple event_counters.


    When you are using event_counters in the EDB, you ALWAYS have to consider how the AI will handle things. For example the AI does not "know" that certain buildings can only be constructed if it has a governor in a settlement. It has no clue as it was never programmed to consider something like that. If we did not enable it for the AI all the time, it would not move a general into a settlement to be able to construct a building. This can really hurt the AI performance, so always consider how the AI will react when you are scripting.


    Now we are going to use the same concept with a different condition. Lets say that if a player is taxing a settlement too high we want to deny him the ability to construct a building that gives him a financial bonus. What we are trying to simulate here is that if a region has really high taxes then people will be less likely to start a new business. So following that line of thinking we will name our event_counter low_taxes. If low_taxes = 1 (true) then enable construction, if not then disable. The line we put in the EDB will be this:
    Code:
    and event_counter low_taxes 1


    We still want the AI to always have the option, so we create this monitor:
    Code:
    monitor_event FactionTurnEnd FactionIsLocal
     set_event_counter low_taxes 1 ;enable construction for AI 
    end_monitor


    And then to set our event_counter we first have to know what the tax rate is, so we use the SettlementTaxLevel condition. This will return one of the following: tax_low, tax_normal, tax_high, tax_extortionate. For my script anything over tax_normal will disable the building. I have commented this one to make it easier to understand.
    Code:
    monitor_event SettlementSelected SettlementTaxLevel > tax_normal ;taxes are above normal
     set_event_counter low_taxes 0 ;disable construction
    end_monitor
     
    monitor_event SettlementSelected SettlementTaxLevel < tax_high ;taxes are normal or lower
     set_event_counter low_taxes 1 ;enable construction
    end_monitor


    Your task is to create 3 different methods of enabling/disabling the contstruction of a building or specific unit(s). I want to see 1 set of monitors based on Settlement conditions, 1 set of monitors based on Faction conditions, and 1 set of monitors based on Character conditions (FactionLeacer or Governor). If you are going to apply the restriction to the AI as well, then I want an explanation why as I do not want to see scripts that I feel will put the AI at a disadvantage as far as decision making goes. Remember to check your trigger requirements for which conditions can be used with which events.

    I am leaving this one pretty open ended because there are SOOO many things you can do, and so many ways to do it. The most creative scripts earn rep points.
    Last edited by GrnEyedDvl; July 13, 2009 at 05:02 PM.

  2. #2

    Default Re: Lesson 3

    Finally i got some spare time:

    Settlement condition: to recruit units
    Spoiler Alert, click show to read: 
    Code:
    monitor_event SettlementSelected FactionIsLocal
    and GovernorInResidence
    set_event_counter invader_settled 1
    end_monitor
    monitor_event SettlementSelected FactionIsLocal
    and not GovernorInResidence
    set_event_counter invader_settled 0
    end_monitor
    monitor_event FactionTurnEnd FactionIsLocal
    set_event_counter invader_settled 1
    end_monitor
    EDB:
    Code:
    building taverns
    {
        levels brothel inn tavern coaching_house pleasure_palace 
        {
            brothel city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } and event_counter invader_settled 1
            {
                convert_to 0
                capability
                {
                    recruit_pool "Ferdacempa" 1 0.5 3 0 requires factions { southern_european, } and event_counter invader_recruit 1
                    recruit_pool "Huskarls" 1 0.5 5 0 requires factions { southern_european, } and region_religion anglo-saxon 90 and event_counter invader_recruit 1
                    agent spy  1  requires factions { northern_european, } 
                    agent spy  1  requires factions { middle_eastern, } 
                    agent spy  1  requires factions { eastern_european, } 
                    agent spy  1  requires factions { greek, } 
                    agent spy  1  requires factions { southern_european, } 
                    happiness_bonus bonus 1
                }
                material wooden
                construction  4 
                cost  1600 
                settlement_min town
                upgrades
                {
                    inn
                }
            }


    Character Condition: to construct a building
    Spoiler Alert, click show to read: 
    Code:
    monitor_event SettlementSelected FactionIsLocal
    and GovernorInResidence
    and FactionBuildingExists >= brothel
    set_event_counter big_hall 1
    end_monitor
    monitor_event SettlementSelected FactionIsLocal
    and not GovernorInResidence
    set_event_counter big_hall 0
    end_monitor
    monitor_event FactionTurnEnd FactionIsLocal
    set_event_counter big_hall 1
    end_monitor
    EDB:
    Code:
    building big_hall
    {
        levels drinking_hall mead_hall royal_palace royal_court
        {
            drinking_hall city requires factions { all, } and event_counter big_hall 1
            {
                convert_to 0
                capability
                {
                    happiness_bonus bonus 1
                }
                material wooden
                construction  4 
                cost  1600 
                settlement_min town
                upgrades
                {
                    mead_hall
                }
            }
            mead_hall city requires factions { all, } and event_counter big_hall 1
            {
                convert_to 0
                capability
                {
                    happiness_bonus bonus 1
                }
                material wooden
                construction  4 
                cost  2600 
                settlement_min town
                upgrades
                {
                    royal_palace
                }
            }
            royal_palace city requires factions { all, } and event_counter big_hall 1
            {
                convert_to 0
                capability
                {
                    happiness_bonus bonus 2
                }
                material wooden
                construction  4 
                cost  4600 
                settlement_min town
                upgrades
                {
                    royal_court
                }
            }
            royal_court city requires factions { all, } and event_counter big_hall 1
            {
                convert_to 0
                capability
                {
                    happiness_bonus bonus 3
                }
                material wooden
                construction  4 
                cost  6600 
                settlement_min town
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }


    Faction Condition: to construct horse breeder
    Spoiler Alert, click show to read: 
    Code:
    declare_counter trade_partners
    ;;;faction condition;;;;
    monitor_event FactionTradeAgreementMade FactionIsLocal
    and TargetFactionType gwynedd
    if I_EventCounter gwynedd_trade == 0
    and I_EventCounter gwynedd_trade_change == 0 
    set_event_counter gwynedd_trade 1
    inc_counter trade_partners 1
    set_event_counter gwynedd_trade_change 1
    end_if
    if I_EventCounter gwynedd_trade == 1
    and I_EventCounter gwynedd_trade_change == 0 
    set_event_counter gwynedd_trade 0
    inc_counter trade_partners -1
    set_event_counter gwynedd_trade_change 1
    end_if
    set_event_counter trade_cavallos 0
    end_monitor
    monitor_event FactionTradeAgreementMade FactionType gwynedd
    and TargetFactionType FactionIsLocal
    if I_EventCounter gwynedd_trade == 0
    and I_EventCounter gwynedd_trade_change == 0
    set_event_counter gwynedd_trade 1
    inc_counter trade_partners 1
    set_event_counter gwynedd_trade_change 1
    end_if
    if I_EventCounter gwynedd_trade == 1
    and I_EventCounter gwynedd_trade_change == 0
    set_event_counter gwynedd_trade 0
    inc_counter trade_partners -1
    set_event_counter gwynedd_trade_change 1
    end_if
    set_event_counter trade_cavallos 1
    end_monitor
    EDB
    Code:
    building horse_supplier
    {
        levels horse_farmer horse_dealer horse_trader
        {
            horse_farmer  requires factions { middle_eastern, eastern_european, greek, southern_european, northern_european, } and event_counter trade_cavallos 1
            {
                capability
                {
                trade_base_income_bonus bonus 1 requires event_counter is_the_ai 0
                trade_base_income_bonus bonus 2 requires event_counter is_the_ai 1
                }
                material wooden
                construction  2
                cost  3750 
                settlement_min village
                upgrades
                {
                    horse_dealer
                }
            }
    Last edited by Icedie El Guaraní; August 08, 2009 at 08:44 PM.
    Contribuitor IBIICB-WOTN-Modeler-Scripter


  3. #3
    Benz282's Avatar Vicarius
    Join Date
    May 2008
    Location
    East Coast, US
    Posts
    2,955

    Default Re: Lesson 3

    ^^ Lol

  4. #4

    Default Re: Lesson 3

    Lol , Icedie , nice spam there

  5. #5

    Default Re: Lesson 3

    I aint even done 2

  6. #6
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Re: Lesson 3

    Me too.

    I'm very busy in my RL at the moment.



  7. #7
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,760
    Blog Entries
    3

    Default Re: Lesson 3

    GED,

    You're using the following line for the AI monitor:

    Code:
     monitor_event FactionTurnEnd FactionIsLocal
    Shouldn't it be:

    Code:
     monitor_event FactionTurnEnd not FactionIsLocal
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  8. #8
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Lesson 3

    Quote Originally Posted by Sqυιd View Post
    GED,

    You're using the following line for the AI monitor:

    Code:
     monitor_event FactionTurnEnd FactionIsLocal
    Shouldn't it be:

    Code:
     monitor_event FactionTurnEnd not FactionIsLocal
    Well what it does is it sets the counter back to 1 on the player turn end, which means it will be 1 through all of the AI turns. If you aren't using a Selected event to fire it, or something of that nature, you'd probably want to set it to whatever the player has at the slave turn end or the PreFactionTurnStart. This could be done by simply setting a counter based on what the event counter is before setting it to 1 at the player turn end, and then using that counter to set the event counter back before the next player turn.

  9. #9
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,760
    Blog Entries
    3

    Default Re: Lesson 3

    I really should learn to read. I read the event as FactionTurnStart and not FactionTurnEnd. It would need to be not FactionIsLocal if the event was the FactionTurnStart event, but that would have needless setting of the event_counter.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  10. #10

    Default Re: Lesson 3

    Am I in lesson 3?

    I like to start with it.
    Developer of Rising Sumer
    Beta-tester for ChC; Mapper of Colonialism-TW;

  11. #11

    Default Re: Lesson 3

    About the FactionLeader condition ... if i want the eventcounter to increase , is this the appropriate use ? :
    Code:
    monitor_event SettlementSelected GovernorInResidence
      and IsFactionLeader
    
    end_monitor
    I checked the docudemons , but it's not very enlightening

    Anyway , i started on the rest , here's my script so far (needs 1 more entry , for the character stuff) :

    Spoiler Alert, click show to read: 
    Code:
    script
    
    ;;; armoury ;;;
    
    monitor_event SettlementSelected SettlementBuildingExists
       and BuildingName = plate_armourer
    
     set_event_counter armory_present 1 ; needed for royal barracks
    
    end_monitor
    
    monitor_event SettlementSelected not SettlementBuildingExists
       and BuildingName = plate_armourer
    
     set_event_counter armory_present 0
    
    end_monitor
    
    monitor_event FactionTurnEnd FactionIsLocal
    
     set_event_counter armory_present 1
    
    end_monitor
    
    ;;;;;;;;;;;Holy unit ;;;;;;;;;;;
    
    if I_LocalFaction england
      and DiplomaticStanceFromFaction papal_states > Allied
      and I_SettlementOwner Jerusalem = england
    
    set_event_counter holy_unit 1 ; needed for holy barracks
    
    end_if
    
    if not I_LocalFaction england
    
     set_event_counter holy_unit 1
    
    end_if
    
    ;;;;;;;;;;
    
    wait_monitors
    end_script


    Ofcourse , the appropriate building entries :

    Spoiler Alert, click show to read: 
    Code:
            royal_armoury city requires factions { turks, venice, milan, portugal, spain, } and event_counter armory_present 1 
            {
                convert_to 4
                capability
                {
                    recruit_pool "Musketeers"  1   0.5   4  0  requires factions { spain, portugal, milan, venice, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Janissary Musketeers"  1   0.5   4  0  requires factions { turks, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Arquebusiers"  1   0.7   6  0  requires factions { england, france, hre, denmark, spain, milan, venice, papal_states, sicily, poland, russia, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Portuguese Arquebusiers"  1   0.7   6  0  requires factions { portugal, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Sudanese Gunners"  1   0.7   6  0  requires factions { moors, egypt, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Janissary Archers"  1   0.7   6  0  requires factions { turks, } 
                    recruit_pool "Pikemen"  1   0.7   6  0  requires factions { france, } 
                    recruit_pool "Heavy Bill Militia"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Pike Militia"  1   0.7   6  0  requires factions { france, hre, spain, portugal, milan, venice, papal_states, sicily, } 
                    recruit_pool "Hand Gunners"  1   0.7   6  0  requires factions { denmark, poland, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Berdiche Axemen"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Arquebusiers"  1   0.7   6  0  requires factions { hungary, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Varangian Guard"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Hand Gunners"  1   0.7   6  0  requires factions { moors, turks, timurids, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Tabardariyya"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Hand Gunners"  1   0.7   6  0  requires factions { hre, spain, portugal, milan, venice, papal_states, sicily, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Bill Militia"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Heavy Pike Militia"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Partisan Militia"  1   0.7   6  0  requires factions { france, } 
                    recruit_pool "Halberd Militia"  1   0.7   6  0  requires factions { hre, papal_states, sicily, poland, hungary, } 
                    recruit_pool "Swordstaff Militia"  1   0.7   6  0  requires factions { denmark, } 
                    recruit_pool "Swordsmen Militia"  1   0.7   6  0  requires factions { spain, portugal, } 
                    recruit_pool "Italian Cavalry Militia"  1   0.7   6  0  requires factions { milan, venice, } 
                    recruit_pool "EE Cavalry Militia"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "Byzantine Infantry"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "Urban Militia"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "ME Halberd Militia"  1   0.7   6  0  requires factions { egypt, turks, timurids, } 
                    recruit_pool "Archer Militia"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Scots Pike Militia"  1   0.7   6  0  requires factions { scotland, } 
                    recruit_pool "Crossbow Militia"  1   0.7   6  0  requires factions { france, hre, denmark, spain, portugal, } 
                    recruit_pool "Genoese Crossbow Militia"  1   0.7   6  0  requires factions { milan, } 
                    recruit_pool "Pavise Crossbow Militia"  1   0.7   6  0  requires factions { venice, papal_states, sicily, hungary, } 
                    recruit_pool "EE Crossbow Militia"  1   0.7   6  0  requires factions { poland, russia, } 
                    recruit_pool "S Archer Militia"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Crossbow Militia"  1   0.7   6  0  requires factions { moors, } 
                    recruit_pool "Saracen Militia"  1   0.7   6  0  requires factions { egypt, turks, } 
                    recruit_pool "Sabadar Militia"  1   0.7   6  0  requires factions { timurids, } 
                    recruit_pool "Spear Militia"  1   0.7   6  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, Normans, } 
                    recruit_pool "Italian Spear Militia"  1   0.7   6  0  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Spear Militia"  1   0.7   6  0  requires factions { poland, russia, hungary, } 
                    recruit_pool "SE Spear Militia"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Spear Militia"  1   0.7   6  0  requires factions { moors, egypt, turks, timurids, } 
                    recruit_pool "Town Militia"  1   0.7   6  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, Normans, } 
                    recruit_pool "Italian Militia"  1   0.7   6  0  requires factions { milan, venice, papal_states, sicily, } 
                    recruit_pool "EE Town Militia"  1   0.7   6  0  requires factions { poland, hungary, } 
                    recruit_pool "EE Archer Militia"  1   0.7   6  0  requires factions { russia, } 
                    recruit_pool "SE Town Militia"  1   0.7   6  0  requires factions { byzantium, } 
                    recruit_pool "ME Town Militia"  1   0.7   6  0  requires factions { moors, turks, timurids, } 
                    recruit_pool "ME Archer Militia"  1   0.7   6  0  requires factions { egypt, } 
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, } 
                    recruit_pool "ME Spear Militia"  1   0.7   6  1  requires factions { mongols, } 
                    recruit_pool "Spear Militia"  1   0.7   6  0  requires factions { Normans, } 
                    recruit_pool "ME Town Militia"  1   0.7   6  0  requires factions { mongols, } 
                    recruit_pool "Town Militia"  1   0.7   6  0  requires factions { Normans, } 
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, } 
                    law_bonus bonus 3
                }
                material wooden
                construction  8 
                cost  15000 
                settlement_min huge_city
                upgrades
                {
                    holy_barrack
                }
            }
            holy_barrack city requires factions { england, } and event_counter holy_unit 1 
            {
                convert_to 4
                capability
                {
                    recruit_pool "Arquebusiers"  1   0.7   6  0  requires factions { england, france, hre, denmark, spain, milan, venice, papal_states, sicily, poland, russia, }  and event_counter gunpowder_discovered 1 
                    recruit_pool "Heavy Bill Militia"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Bill Militia"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Archer Militia"  1   0.7   6  0  requires factions { england, } 
                    recruit_pool "Spear Militia"  1   0.7   6  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, Normans, } 
                    recruit_pool "Town Militia"  1   0.7   6  0  requires factions { england, scotland, france, hre, denmark, spain, portugal, Normans, } 
    ;               recruit_pool "Cursade/Holy Unit"  1   0.7   6  0  requires factions { england, } 
    ;               recruit_pool "Cursade/Holy Unit"  1   0.7   6  0  requires factions { england, } 
    ;               recruit_pool "Cursade/Holy Unit"  1   0.7   6  0  requires factions { england, } 
    ;               recruit_pool "Cursade/Holy Unit"  1   0.7   6  0  requires factions { england, } 
    ;               recruit_pool "Cursade/Holy Unit"  1   0.7   6  0  requires factions { england, } 
                }
                material wooden
                construction  8 
                cost  15000 
                settlement_min huge_city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }


    Note that i didn't want to make holy/crusade mercs available for england (then i'd have to change EDU , right ?)

    and because i made an extra barrack building :

    Code:
    building barracks
    {
        convert_to castle_barracks
        levels town_watch town_guard city_watch militia_drill_square militia_barracks army_barracks royal_armoury holy_barrack
    in export_building :

    Code:
    {holy_barrack}    Holy Barrack
    
    {holy_barrack_desc}    Holy Barrack
    
    {holy_barrack_desc_short}    Holy Barrack
    Last edited by Killerbee; July 14, 2009 at 09:46 AM.

  12. #12
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,760
    Blog Entries
    3

    Default Re: Lesson 3

    Quote Originally Posted by KingTheoden1 View Post
    About the FactionLeader condition ... if i want the eventcounter to increase , is this the appropriate use ? :
    Code:
    monitor_event SettlementSelected GovernorInResidence
      and IsFactionLeader
    
    end_monitor
    I checked the docudemons , but it's not very enlightening
    It takes a bit to figure it out, but here a brief lesson on it:

    Quote Originally Posted by docudemon_events
    Identifier: SettlementSelected
    Event: The player has selected a settlement
    Exports: faction, settlement, region_id, best_finance_option
    Class: ET_SETTLEMENT_SELECTED
    Author: Guy
    Quote Originally Posted by docudemon_conditions
    Identifier: IsFactionLeader
    Trigger requirements: character_record
    Parameters: None
    Sample use: IsFactionLeader
    Description: Test to see if the character is a faction leader
    Battle or Strat: Either
    Class: CHARACTER_IS_LEADER
    Implemented: Yes
    Author: Lee
    These are the two pertinent parts of the docudemons. For a condition to be useable with a particular event the trigger requirement of the condition, character_record in this case, must appear in the list of exports for the event you are using the condition with. The IsFactionLeader requires a character_record, which the SettlementSelected event does not provide hence that monitor will not work properly if at all.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  13. #13
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Lesson 3

    Squid explained the event/condition correlation. Another thing about the script is I'm curious how you intend to use I_LocalFaction? As well, is there any particular reason the if statements are outside a monitor?

    For the former, I_LocalFaction just tells you which faction is the local faction. So if the player is England, I_LocalFaction england will always return true, and not I_LocalFaction england will always return false. They are not bounded by turns though. This means that what will happen is:

    If the player is England, the second counter will never fire and the event will be set to 1 if the conditions of the first counter are met.

    If the player is not England, the first counter will never fire, but the second counter will always fire. This means that if the player is any nation besides England they will be able to build the building without having to meet any other conditions.

    Now, if the goal of the script is to let England build it under those circumstances and allow the AI to build it at all times, it won't quite achieve that(as the counter is contingent on either the player not being england, or meeting the conditions). It also won't set the counter back if England falls below that papal relation and/or loses Jerusalem, so they'd only have to have it once.

    As to the if statements, the same is achieved by monitor_conditions. Whether or not performance or functionality is changed between the two I'm not sure of, but I encourage the use of if within monitors and monitor_conditions if you just want to check a condition without an event.

  14. #14

    Default Re: Lesson 3

    So it'd be more like :

    Code:
    monitor_event CharacterTurnStart CharacterIsLocal
       and IsFactionLeader
    
    end_monitor
    Thx squid , i see what you mean

    EDIT : Just saw your post Al . Yea , the script was meant to be that only if you are playing as england , you need to have these conditions (if you're playing as hre for instance , england would be able to build it right away)

    About the relations , i think this'll fix it , right ? :

    Code:
    monitor_event FactionTurnStart FactionType england
      and FactionIsLocal
      and DiplomaticStanceFromFaction papal_states > Allied
      and I_SettlementOwner Jerusalem = england
    
    set_event_counter holy_unit 1 ; needed for holy barracks
    
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and FactionIsLocal
      and DiplomaticStanceFromFaction papal_states < Allied
      and I_SettlementOwner Jerusalem = england
    
    set_event_counter holy_unit 1 ; needed for holy barracks
    
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and FactionIsLocal
      and DiplomaticStanceFromFaction papal_states > Allied
      and not I_SettlementOwner Jerusalem = england
    
    set_event_counter holy_unit 1 ; needed for holy barracks
    
    end_monitor
    Last edited by Killerbee; July 14, 2009 at 12:21 PM.

  15. #15
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Lesson 3

    Quote Originally Posted by KingTheoden1 View Post
    Just saw your post Al . Yea , the script was meant to be that only if you are playing as england , you need to have these conditions (if you're playing as hre for instance , england would be able to build it right away)

    About the relations , i think this'll fix it , right ? :

    Code:
    monitor_event FactionTurnStart FactionType england
      and FactionIsLocal
      and DiplomaticStanceFromFaction papal_states > Allied
      and I_SettlementOwner Jerusalem = england
    
    set_event_counter holy_unit 1 ; needed for holy barracks
    
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and FactionIsLocal
      and DiplomaticStanceFromFaction papal_states < Allied
      and I_SettlementOwner Jerusalem = england
    
    set_event_counter holy_unit 1 ; needed for holy barracks
    
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and FactionIsLocal
      and DiplomaticStanceFromFaction papal_states > Allied
      and not I_SettlementOwner Jerusalem = england
    
    set_event_counter holy_unit 1 ; needed for holy barracks
    
    end_monitor
    Right, it should work with the building set to only build for england then. As to your edit, I would advise you do one of the two (diplomatic and settlement owner) with each, rather than both. You don't need for instance in the second one to check the diplomatic stance, since it's being removed based on the settlement so the diplomatic stance is irrelevant(as it's already checked in the previous). The same for the settlement ownership in the first counter reverter. And in both, naturally it should set the counter to 0 as opposed to 1.

    Otherwise looks fine.

  16. #16

    Default Re: Lesson 3

    And in both, naturally it should set the counter to 0 as opposed to 1.
    Ofcourse , just saw it

    Hmm .. Is there a condition that says if you control the faction ? i checked 'I_Local_Faction' , 'FactionIsLocal' , 'FactionType' , but they all do pretty much the same

  17. #17

    Default Re: Lesson 3

    @KingTheoden1

    Is the post #11 your final product or is just another example of what you want to use, in any case, you set up an armory_present 1 as you event_counter but there is no event_counter with such name in your EDB what it should look something like,
    Code:
    monitor_event SettlementSelected SettlementBuildingExists
       and BuildingName = plate_armourer
    
     set_event_counter armory_present 1 ; needed for royal barracks
    
    end_monitor
    
    monitor_event SettlementSelected not SettlementBuildingExists
       and BuildingName = plate_armourer
    
     set_event_counter armory_present 0
    
    end_monitor
    
    monitor_event FactionTurnEnd FactionIsLocal
    
     set_event_counter armory_present 1
    
    end_monitor
    EDB:
    Code:
    royal_armoury city requires factions { turks, venice, milan, portugal, spain, } and event_counter armory_present 1 
            {
                convert_to 4
                capability
                {
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, } and event_counter armory_present 1
                    law_bonus bonus 3
                }
                material wooden
                construction  8 
                cost  15000 
                settlement_min huge_city
                upgrades
                {
                    holy_barrack
                }
            }
    But if your is working then i believe i miss understand the lesson,
    also in your holy unit script don´t you need a monitor_event event condition before the IF Statement?

    Well anyways i was just curious if you are aware of those details

    Edited:

    Never mind i saw it!! my bad

    Well this make me realize of something else
    @AL or GED
    in the green line; does this mean that the event_counter will make the building "royal_armoury" available ?
    and the blue line; this will make the "Peasant_Spearmen" available after the building is constructed. Right?

    Code:
    royal_armoury city requires factions { turks, venice, milan, portugal, spain, } and event_counter armory_present 1 
            {
                convert_to 4
                capability
                {
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, } and event_counter armory_present 1
    As you can tell my question osund stupid but i am only familiar with the EDB but never actually done anything bigger than add a unit to another faction.
    Last edited by Icedie El Guaraní; July 14, 2009 at 01:03 PM.
    Contribuitor IBIICB-WOTN-Modeler-Scripter


  18. #18
    Augustus Lucifer's Avatar Life = Like a beanstalk
    Patrician Citizen

    Join Date
    Aug 2006
    Location
    Mote of Dust
    Posts
    10,725

    Default Re: Lesson 3

    Quote Originally Posted by Icedie of South View Post
    @AL or GED
    in the green line; does this mean that the event_counter will make the building "royal_armoury" available ?
    and the blue line; this will make the "Peasant_Spearmen" available after the building is constructed. Right?

    Code:
    royal_armoury city requires factions { turks, venice, milan, portugal, spain, } and event_counter armory_present 1 
            {
                convert_to 4
                capability
                {
                    recruit_pool "Peasant Spearmen"  1   0.7   6  0  requires factions { Saxons, } and event_counter armory_present 1
    As you can tell my question osund stupid but i am only familiar with the EDB but never actually done anything bigger than add a unit to another faction.
    Yes, that's how it functions. Recruitment pools can be enabled and disabled for units within a building, and building can be enabled and disabled prior to being built(removing the conditions to allow building it does not remove the building, which is good for other applications). You can also flip between multiple pools of the same unit in the same building, and if two pools of one unit are active at the same time, it will read the last one down in the pool list. There's a lot of things like that regarding recruitment pools that have complex possibilities(though not nearly as complex as they should be).

  19. #19

    Default Re: Lesson 3

    I just finished it , dunno if there are any erros (will try out now)

    Spoiler Alert, click show to read: 
    Code:
    script
    
    ;;; armoury ;;;
    
    monitor_event SettlementSelected SettlementBuildingExists
       and BuildingName = plate_armourer
    
     set_event_counter armory_present 1
    
    end_monitor
    
    monitor_event SettlementSelected not SettlementBuildingExists
       and BuildingName = plate_armourer
    
     set_event_counter armory_present 0
    
    end_monitor
    
    monitor_event FactionTurnEnd FactionIsLocal
    
     set_event_counter armory_present 1
    
    end_monitor
    
    ;;;;;;;;;;;Holy unit ;;;;;;;;;;;
    
    monitor_event FactionTurnStart FactionType england
      and FactionIsLocal
      and DiplomaticStanceFromFaction papal_states > Allied
      and I_SettlementOwner Jerusalem = england
    
     set_event_counter holy_unit 1 ; needed for holy barracks
    
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and FactionIsLocal
      and DiplomaticStanceFromFaction papal_states < Allied
      and I_SettlementOwner Jerusalem = england
    
     set_event_counter holy_unit 0 ; needed for holy barracks
    
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and FactionIsLocal
      and DiplomaticStanceFromFaction papal_states > Allied
      and not I_SettlementOwner Jerusalem = england
    
     set_event_counter holy_unit 0 ; needed for holy barracks
    
    end_monitor
    
    monitor_event FactionTurnEnd FactionIsLocal
    ;   and not FactionType england ; just realised it wasn't good :P
    
     set_event_counter holy_unit 1 ; needed for holy barracks
    
    end_monitor
    
    ;;;;;;;;;; Hero stuff ;;;;;;;;;;;;;
    
    monitor_conditions I_FactionLeaderTrait england GoodCommander >= 2
    
     set_event_counter hero 1
    
    end_monitor
    
    monitor_conditions I_FactionLeaderTrait england GoodCommander <= 3
    
     set_event_counter hero 1
    
    end_monitor
    
    wait_monitors
    end_script


    Also needs a new building :

    Code:
    building hero_building
    {
        levels hero_building 
        {
            hero_building city requires factions { middle_eastern, } and event_counter hero 1
            {
                capability
                {
                    happiness_bonus bonus 4
                }
                material wooden
                construction  4 
                cost  1200 
                settlement_min city
                upgrades
                {
                }
            }
        }
        plugins 
        {
        }
    }
    Last edited by Killerbee; July 14, 2009 at 02:45 PM.

  20. #20

    Default Re: Lesson 3

    @ AL/GED

    How do i know how many square a character or title is from some one? i mean , i know i have to use the show_cursorstat cheat but that will give me the x, y coordinates only, or is there another way to find out ?

    If i set this script to lets say stone henge at x 316, y 81 that would be 0 squares right? but if i set the same coordinates (316, 81) but another square distance will it still work? or has to be accurate? yeah i am lazy to test it.

    Is referring to this
    Identifier: I_CharacterTypeNearTile
    Trigger requirements:
    Parameters: faction, character type, distance in squares, x, z
    Sample use: I_CharacterTypeNearTile romans_julii named_character, 10 48,30
    Description: Is a particular character type of a faction near a particular tile?
    Battle or Strat: Strat
    Class: I_CHARACTER_NEAR_TILE
    Implemented: Yes
    Author: Guy
    And in this:
    Identifier: I_CharacterTypeNearCharacterType
    Trigger requirements:
    Parameters: faction, character type, distance in squares, faction, character type
    Sample use: I_CharacterTypeNearCharacterType romans_julii spy 10 gaul named character
    Description: Is a particular character type of a faction near another particular character type of another faction?
    Battle or Strat: Strat
    Class: I_CHARACTER_NEAR_CHARACTER
    Implemented: Yes
    Author: Guy
    Is the named character from the faction Gaul?
    Contribuitor IBIICB-WOTN-Modeler-Scripter


Page 1 of 4 1234 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
  •