Results 1 to 6 of 6

Thread: Creating a World - Advanced recruiting with event counters

  1. #1
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,123
    Blog Entries
    35

    Default Creating a World - Advanced recruiting with event counters

    CreditsThis tutorial is a summary of ideas and code discussed in the two threads underneath, all credit goes to the participants:
    IntroductionStarting and stopping of recruiting via event counter isn't really something new - it has been done since the game got published (the_world_is_round, gunpowder_discovered), so what's new?
    The problem of using event_counter conditions is lying in the fact that disabling was resetting the pool, making the condition unsuitable for frequent switching on\off - leaving only the 'freeze' script command which was 'clumsy' at best. As it happens it was a matter of WHEN (at the end of the slave faction's turn) to switch the condition back on to retain the previous accumulated pool - not unlike the principle of 'switching on temporary again after switching off' in another tutorial of mine:
    Coding
    Mercenary recruitment restricted to factions
    imperial_campaign_scriptThe two [faction] monitors require replicating for every faction eligible. Alternatively faction specific counters can be used, which would require a cloning of the mercenary line with those counters.
    Code:
    monitor_event PreFactionTurnStart FactionType [faction]
      set_event_counter merc_turn 1
    end_monitor
    
    monitor_event PreFactionTurnStart not FactionType [faction]
      set_event_counter merc_turn 0
    end_monitor
    
    monitor_event FactionTurnEnd FactionType slave
      set_event_counter merc_turn 1
    end_monitor
    descr_mercenaries
    Code:
    pool [pool name]
        regions [region names]
        unit [unit name]            exp 0 cost 220 replenish 0.15 - 0.35 max 3 initial 5  events { merc_turn }
    Seasonal recruitment
    imperial_campaign_scriptThe script part assumes a 12 turn per year set up with the campaign starting in winter. Recruiting time will be from October to March.
    Code:
    monitor_event PreFactionTurnStart FactionIsLocal
      inc_event_counter season_time 1
      if I_EventCounter season_time > 9            ; from October
        and I_EventCounter season_time < 4        ; to March
        set_event_counter recruit_season 1
      end_if
      if I_EventCounter season_time > 3            ; from April
        and I_EventCounter season_time < 10        ; to September
        set_event_counter recruit_season 0
      end_if
    end_monitor
    
    monitor_event FactionTurnEnd FactionType slave
      set_event_counter recruit_season 1
      if I_EventCounter season_time > 12
        set_event_counter season_time 0            ; resetting season counter
      end_if
    end_monitor
    export_descr_buildings
    Code:
                capability
                {
                    recruit_pool "[unit name]"  1   0.2   2  0  requires factions { [faction name], } and event_counter recruit_season 1
                }
    ConclusionBased on this principle and the examples I am sure this can be expanded to simulate other on\off principles of recruiting - I am working on a script to restrict recruiting based on the relative number of units fielded versus settlements owned where this scripting will certainly feature.
    Last edited by Gigantus; January 26, 2016 at 04:53 AM.










  2. #2

    Default Re: Creating a World - Advanced recruiting with event counters

    Using event_counters can make for extremely sophisticated and dynamic recruitment - representing reforms or other sorts of changes in military tactics over time.

  3. #3

    Default Re: Creating a World - Advanced recruiting with event counters

    Another example is in the Americas campaign_script

    Faction standing events for native mercenary recruitment

    ; - Spain must be allied with native factions to recruit mercenaries from those factions
    ; - Events tracked through the script will keep track of standing and prohibit or allow access to mercenary pools
    ; - Spain will have separate mercenary pools setup for each region where special mercenaries are available
    ;;; Spain is allied with Aztecs
    monitor_event FactionTurnStart FactionType spain
    and I_EventCounter spain_allied_aztecs == 0
    and DiplomaticStanceFromFaction aztecs = Allied

    add_events
    event counter spain_allied_aztecs
    date 0
    end_add_events

    end_monitor
    the americas campaign_script also contains a way to accumulate prestige_points - so you could make certain mercenaries only available to a faction if the leader has a certain level of prestige.

  4. #4
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,123
    Blog Entries
    35

    Default Re: Creating a World - Advanced recruiting with event counters

    Correct, the americas uses the descr_mercenaries event switch triggered by the monitor you listed. It's based on the state of alliances, underneath the monitor that switches the merc recruitment off again:
    Code:
    ;;; Spain no longer allied with Aztecs
        monitor_event FactionTurnStart FactionType spain
            and I_EventCounter spain_allied_aztecs == 1
            and DiplomaticStanceFromFaction aztecs > Allied
            
            set_event_counter spain_allied_aztecs 0
    
        end_monitor

    The prestige points principle used in americas is basically a counter that increases upon successfully completing missions (set of conditions). At defined levels an award (set of command) is issued - it is not related to recruiting as far as I could see.
    In the end it can be used (like any other set of conditions) to set the necessary event counters to facilitate the event switch in descr_mercenaries.
    Last edited by Gigantus; January 22, 2017 at 11:33 PM.










  5. #5
    Ñolofinwë, King of the Ñoldor's Avatar Foederatus
    Join Date
    Mar 2018
    Location
    Catania, Sicily: Where my heart lies.
    Posts
    44

    Default Re: Creating a World - Advanced recruiting with event counters

    Fixed my problem. This can be deleted.
    Last edited by Ñolofinwë, King of the Ñoldor; April 08, 2018 at 11:37 PM. Reason: Problem solved. :D

  6. #6
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,123
    Blog Entries
    35

    Default Re: Creating a World - Advanced recruiting with event counters

    Please describe your problem and how you fixed it - others may learn from it.










Tags for this Thread

Posting Permissions

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