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

Thread: A Guide to Events

  1. #1

    Default A Guide to Events

    A Guide to Events


    General Introduction:

    Hello again, after writing a guide to how the events in The long road I decided to make a more general and extensive guide to event scripting. Hopefully this can serve as a resource for anyone wanting to write up events for his or her mod. Regardless of them being random events or historic ones and with some notes on how to go around things and why. In the end this tutorial should contain pretty much everything you need to know, as well as links to valuable tutorials on a number of related subjects, but also some case studies and minor scripts that can be used.

    Some parts might be repetitions of my old tutorial (wich I might have deleted in due time) but I will add them here anyway, -hopefully in a better lay out-. To make sure this is a comprehensive and complete guide.

    Table of Contents:
    -subject to change as I go along-

    What are Events
    Some basics


    Event Triggering
    Historic Events
    Geographic events
    Dynamic events
    Random events


    Data collecting and processing
    Types of data
    Data collecting
    Data processing
    Campaign Script Build up
    List of interesting conditions
    Comments


    Event effects

    Counter based effects
    Linking effects
    Multi Turn events
    EDB linking
    EDCT & EDA linking
    Useful Small Scripts
    List of interesting commands
    Additional data processing
    Comments


    Case Studies


    Glossary of useful links

    Last edited by ilmrik; August 30, 2011 at 07:10 AM.

  2. #2

    Default Re: A Guide to Events

    What are events?

    Introduction:
    The basics of event scripting as well as a short rundown of some campaign script basics.

    What Are Events?

    Some Basics
    Events are messages displayed during the course of the campaign, usually they only give some information an something that happened e.g. the domesday book being written. However some also have a more profound effect in things such as Football being banned, wich allows for yeoman to be recruited, or the Mongol event wich makes the mongols appear.

    These last examples are what interests us, because with some modding we can make events do practically anything by adding some scripts to the "campaign script". The introduction of choice events in Kingdoms makes the possibilities almost endless.

    You'll however need some experience with the campaign script, I'll be adding notes etc to keep it all as accessible as possible but I still strongly suggest reading up on it first.
    A good tutorial can be found here courtesy of Alpaca
    Counters and Event Counters


    Introduction

    This is one of the basic things relating to events, the ability to store data. There are 2 types of counter. There is some confusion going around about the difference between counters and event_counters so I'll give a full explanation and overview of their functions since getting it wrong might cause your event not to work.

    Anyway first things first, although counters and event_counters are basically identical in every way it is very important to realize that they are in no way interchangeable or connected! You could both an event_counter and a counter with the same name in a script and they would not influence each other at all.

    So as I rule to keep things clear I always name counters in lower case and event_counters in upper case.
    e.g. "FlandersProsperity" is a counter and "FLANDERS_PROSPERITY" is an event_counter. I suggest you find a similar way to distinguish them.

    Now on to the uses for these things, I divided everything up into the 3 big groups you find in any script:
    commands, events and conditions.

    Event Counters

    Introduction

    Thanks to the added commands in kingdoms event counters pretty much render normal counters obsolete due to a number of reasons. Firstly and arguably most importantly they can be referred to in a host of other files (EDB, EDCT, etc ) secondly they have a number of extra features that normal counters don't have.

    Commands
    Commands are the part of the script that actually makes the game do things, there are a few commands relating to event_counters. All of these concern the changing of the value of a certain
    event_counter.

    The two basic commands for event_counters are "inc_event_counter" and "set_event_counter", Both are quite straightforward.
    "inc_event_counter" increases the value of the counter by the specified amount ( which can be negative)
    "set_event_counter" set the value of the specified counter to the specified value.

    Remember that the script is always read from top to bottom ( seems obvious but still ) so the order you
    put commands in can be important.

    example:
    Code:
    inc_event_counter FLANDERS_PROSPERITY 2
    set_event_counter FLANDERS_PROSPERITY 0
    Will give you a value of 0 for the FLANDERS_PROSPERITY event_counter,
    reversing the order would give you a value of 2.

    A very important note if you are going to link to other files with your event_counters.
    Before an event counter is used for the first time it doesn't exist, which can cause problems for some of the dependent files like the EDB since a condition with a non-existent event_counter is ignored. There are a few ways of resolving this issue, adding "set_event_counter FLANDERS_PROSPERITY 0" to the campaign script will create it but you could also add an entry to the descr_events.txt.

    The other group of commands for event_counters is a bit different, since their primary objective isn't really the changing of an event_counter value ( although they do so as a side effect).
    Their goal is to make the historic event appear in game, showing the actual event message.
    Running an historic_event will also automatically generate an event_counter with the same name and increase its value by 1.
    The 3 ways of running an event via the campaign script are
    Code:
     historic_event FLANDERS_PROSPERITY
    or
    Code:
      add_events 
        event    historic   FLANDERS_PROSPERITY  date    20 30
      end_add_events
    These just run the event, the latter has the advantage of allowing for some extra's like the snap to location icon in the event. Both increase the FLANDERS_PROSPERITY event_counter by 1

    Code:
     historic_event FLANDERS_PROSPERITY true
    Adding the 'true' creates a choice event instead of a normal one. Choice historic events generate two additional event_counters in the form of EVENT_NAME_accepted and EVENT_NAME_declined one of which is set to 1 depending on whether you accept or decline.

    Another great command for event_counters is the generate_random_counter, which despite its misleading name does use event_counters and not normal counters ( note that I got this wrong in later parts of the tutorial, this will be fixed once I get to these parts). All it does is generate a random value for an event counter, between the specified values. This is a brilliant command for any event scripter to add some variation to things. If the event_counter doesn't exist yet it's created by the command.
    e.g.
    Code:
    generate_random_counter FLANDERS_PROSPERITY 1 5


    Conditions


    Obviously all this setting of values wouldn't be useful unless there is some way of checking this value later on. This is done with the "I_EventCounter" condition which compares the value of a counter with an integer value.
    e.g.
    Code:
    I_EventCounter FLANDERS_PROSPERITY = 5


    Monitors


    A final big selling point about event_counters is that they have their own monitor-able event, so you can use them to trigger things just by changing their value.
    Code:
    monitor_event EventCounter TrueCondition
    end_monitor
    Will trigger every time an event_counter changes value, this monitor can be refined further to

    Code:
    monitor_event EventCounter*EventCounterType FLANDERS_PROSPERITY 
    and I_EventCounter FLANDERS_PROSPERITY = 3 
    end_monitor
    This monitor will only trigger if the event counter that changed value is the FLANDERS_PROSPERITY one and it's value is now 3,
    A fact also usable for the choice events ( remember they generate their own event_counters )

    Code:
    monitor_event EventCounter*EventCounterType FLANDERS_PROSPERITY_accepted 
    and I_EventCounter FLANDERS_PROSPERITY_accepted = 1 
    end_monitor
    The second I decide to accept the event this monitor triggers allowing me to add in the effects.

    Counters

    Counters are very much like event_counters but cannot be used as a reference in other files and have fewer options. The only thing vaguely better about counters is that the script will warn you about typo's in their name as it won't recognize them.

    This is because counters need to be declared before they can be used, simply by using the command "declare_counter" a newly declared counter starts at value 0
    Code:
    declare_counter FlandersProsperity
    The other commands used are "inc_counter" and "set_counter" basically work the same way as their "event_counter" counterparts.

    "I_CompareCounter is the condition used to check a counters value in the same way that I_EventCounter is used for event_counters. So I refer to those parts for more information.



    Event Triggering

    Introduction:
    Essentially the first step for every event, the point where it all begins.There are a few ways it can be done. I'll be going over them and mentioning some pro's and con's of each in this chapter.Which one you pick will depend greatly on what exactly you wish to achieve an why. The actual effects will be discussed later

    Historic/Counter Event Triggers


    Historic/Counter Event Triggers
    There are a few kinds of events in M2TW, generally they are all triggered via the "descr_events" file. They can easily be used to trigger additional events, in fact thats how all the mongol/tumirid effects are triggered in vanilla.
    It's a simple way and goes like this:
    Extract from descr_events:

    Code:
    event    historic    PIKEMEN
    date    200 240
    ;(c. Mid 13th century)
    What this does is very simple somewhere between turn 200 and 240 the historic event PIKEMEN is played. Wich automatically increase the event_counter PIKEMEN by 1 aswel as giving a message. You can use this to trigger additional effects by adding this to the campaign_script:

    Code:
    monitor_event EventCounter EventCounterType PIKEMEN
    and I_EventCounter PIKEMEN = 1 
      effects go here
    terminate_monitor
    end_monitor
    Counter events are very similar but they don't display a message, they can be linked to in exactly the same way.Adv The main advantage is how easy it all is, the game automatically picks a random date and plays the event. all you have to do is add the effects.D All dates are pretty fixed in time so it's not very useful for random events. Also no real exterior conditionals can be added.
    Might not be the most efficient way of adding a very large amount of events.

    Additional comments and scripts


    Even tough this isn't technically about the use of the descr_events file the effect is very similar to it. The add_events command wich is considered mostly redundant by scripters in M2TW. But it has some uses if you ask me.
    It is also a work around for the main disadvantage of this type of triggers ( the lack of conditions )
    How does it work, from the campaign_script
    Code:
    monitor_event FactionTurnStart FactionIsLocal 
    
      add_events 
        event    historic    MATCHLOCK  date    20 30
        event    counter    ADV_MATCHLOCK  date    40 50
      end_add_events
    
    terminate_monitor 
    end_monitor
    The effect is quite straight forward, after this monitor is triggered the corresponding historic/counter event will be played sometime randomly between the stated turns.
    This means you get some sort of control over the events, without having to add toomuch additional script.
    An example use can be found in the case studies: Faction Goals (still WIP at this point)


    Direct Monitor Triggering

    Direct Monitor Triggering

    Another very straight forward way of triggering events is directly from a monitor. The examples are many and diverse. be sure to check out this tutorial courtesy of AJStoner for a lot of examples on them aswel as an abundance of extra info on events.
    Example:
    Code:
    monitor_event FactionTurnStart FactionIsLocal 
    and RandomPercent < 11 
      -effects-
    end_monitor
    This event just has a 10% chance of triggering every turn start.

    Advantages:

    All conditions are ellegible
    Straight forward to add
    Can be used for both fixed date events as well as for random events

    Disadvantages

    Some monitors slow down the game when used in large numbers

    Additional comments and scripts

    The main disadvantages of this way of triggering wich is the amount of monitors that can spiral out of control quite quickly can be counteracted by making the structure slightly more complex.

    Say you have a group of events based around having a large cathedral in your realm, instead of giving them all a seperate monitor you can just make 1 with several if statements. like so:

    Code:
    declare_counter RandomEvent
    
    monitor_event FactionTurnStart FactionIsLocal 
    and FactionBuildingExists == large_cathedral
    and RandomPercent < 3
       generate_random_counter RandomEvent 1 4 
    
           if I_CompareCounter RandomEvent = 1 
             -event 1-
           end_if 
    
           if I_CompareCounter RandomEvent > 1 
           and I_CompareCounter RandomPercent < 4
             -event 2-
           end_if 
    
           if I_CompareCounter RandomEvent = 4 
             -event 3-
           end_if 
    
    end_monitor
    This is also a very easy way to give some events a larger chance of happening than others. In this case 25% for event 1 ,50% for event 2 and 25% for event 3

    Conditional Monitor Triggering

    Conditional Monitor Triggering

    Tough very similar to direct monitor triggering, this way involves a more excessive aproach and is more suited for very heavily scripted systems. it cuts down on the total number of monitors by using "if" statements combined with a significant amount of "data collecting" (see later).

    An example (from TLR rewritten to work for kingdoms):
    Code:
    if I_CompareCounter FlandersEventRunning == 0
    and I_CompareCounter FlandersLocal == 1
    
      set_counter PositiveNegative 0 
    
            if I_CompareCounter FlandersHappy <= -120 
              inc_counter PositiveNegative -1 
            end_if 
    
            if I_CompareCounter FlandersHappy <= -60
              inc_counter PositiveNegative -1 
            end_if 
    
            if I_CompareCounter FlandersHappy >= -60
            and I_CompareCounter FlandersHappy <= 60 
                if RandomPercent < 51 
                 inc_counter PositiveNegative -1
                end_if 
                if RandomPercent < 51 
                 inc_counter PositiveNegative 1
                end_if 
             end_if
    
            if I_CompareCounter FlandersHappy >= 120 
              inc_counter PositiveNegative 1 
            end_if 
    
            if I_CompareCounter FlandersHappy >= 60
              inc_counter PositiveNegative 1 
            end_if 
    
    
       if I_EventCounter EARLY_INDUSTRIAL_AGE == 1
       and RandomPercent < 6 
         set_counter FlandersEventRunning 1
    
         if I_CompareCounter PositiveNegative < 0 
           generate_random_counter FlandersEarlyIndustrialAgeEvent -1 -3
         end_if 
    
         if I_CompareCounter PositiveNegative => 0 
           generate_random_counter FlandersEarlyIndustrialAgeEvent 1 3
         end_if 
    
       end_if
    
    end_if
    Advantages:
    Lower total amount of monitors
    Makes it easier to prevent events overstacking

    Disadvantages:
    Monitors are significantly longer
    More data collection needed as not all conditionals can be used


    Event Triggering Conditionals

    Introduction:
    There are a lot of things that could trigger an event, the following chapters will be going over some of the most common conditions.

    Event Triggering Based on Buildings

    Triggering an event can be done is several ways as discussed earlier,
    This chapter will give some examples of worked out ways to trigger things.
    Some events revolve around a certain building being present and use this as a condition to trigger,
    The most obvious condition would seem to be FactionWideBuildingExists. It checks or the building exists in your realm.
    It doesn't however take into account how many of these buildings you have when triggering.

    Code:
    monitor_event FactionTurnStart FactionIsLocaland 
    FactionWideBuildingExists > market fleece_fair
    and randompercent < 6
     historic_event GREAT_YEAR_FOR_FLEECE_FAIR true
    end_monitor
    Gives me a 5% chance of having the event every turn, independent of how many fleece fairs my kingdom has.
    There is a second way of making a similar script that is capable of taking the amount of buildings you have in your realm into account.
    It involves 2 monitors instead of 1, the first monitor will just be there to be the actual trigger, the second monitor will execute the event.
    The trigger looks like this;
    Code:
    monitor_event SettlementTurnStart SettlementIsLocal
    and SettlementBuildingExists > market fleece_fair
    and RandomPercent < 6
    and not UnderSiege
    and I_EventCounter GREAT_YEAR_FOR_FLEECE_FAIR = 0
     set_event_counter GREAT_YEAR_FOR_FLEECE_FAIR 1
    end_monitor
    What it does is give you a 5% chance to trigger the event every time a settlement with the right building starts it's turn in your kingdom,
    or said differently you have a 5% chance of triggering the event for every fleece_fair in your realm.
    In addition to this you can add some extra conditionals such as the under siege one which excludes cities that are currently being besieged.

    The second part of the script will now hold the actual event and run it only if it has been previously triggered.

    Code:
    monitor_event FactionTurnStart FactionIsLocal
    and I_EventCounter GREAT_YEAR_FOR_FLEECE_FAIR = 1
      historic_event GREAT_YEAR_FOR_FLEECE_FAIR true
      set_event_counter GREAT_YEAR_FOR_FLEECE_FAIR 0
    end_monitor



    [/LEFT]


    Last edited by ilmrik; January 17, 2012 at 10:58 AM.

  3. #3

    Default Re: A Guide to Events

    Data Collecting and Processing

    Introduction:

    This chapter deals with the other vital part in the triggering of events,
    we now know how to make events trigger but we also want to control when they trigger.


    Types of Data

    Types of Data
    All the data we can use to trigger events are basically conditions, 2 kinds of conditions exist: The ones attached to a specific monitor export, like FactionIsLocal/ FactionWideBuildingExists etc
    and the "free ones" usually denoted by an I_ such as I_CompareCounter, I_EventCounter, I_Settlementowner etc

    Both have their advantages and disadvantages,

    The first monitor related one has more "relative options" since you can easily combine them.
    for example:
    Code:
    monitor_event SettlementTurnStart SettlementIsLocal 
    and FactionType england
    and SettlementName antwerp 
      -event- 
    end_monitor
    This monitor only triggers when Antwerp controlled by the local player, who is playing as England.
    However doing something similar for all the settlements will require a lot of monitors.

    Also these conditionals can't be integrated in if statements


    The second kind has more absolute implications, but can be used in if statements
    Code:
     monitor_event FactionTurnStart FactionType england 
    
    if I_settlementOwner antwerp == england 
      -event- 
    end_if 
    
    end monitor
    So I have to decide wich settlement and wich faction, wich gives me a lot less leeway. wich ramps up the amount of if statements very quickly but they can all be included in a single monitor.

    Data Collecting

    As mentioned above the conditions aren't always as handy as one would like, there is however a way to work around this. The game has a prime way of storing data in the form of counters.
    This is especially important for mods with random choice events as they might prefer the if statements over the monitors.

    Basically what you do is use a simple counter to keep track of things that you can later refer to again in if statements. This allows you to put all the event triggers in one place and process them all at once. Wich makes the prevention of overstacking of events a lot simpler.
    I use them to keep track of all sorts of things. I divided the entire map in smaller geopolitical entities say counties/city states etc and the script keeps track of several things related to them.
    example counter
    FlandersLocal : tells me wether or not Flanders belongs to the local player
    FlandersHappy: tells me about how prosperous the region is
    FlandersDevelop: keeps track of it's development
    FlandersMerchants: keeps track of the power/happiness of the merchants
    etc

    But I also keep track of other things ( more large scale)
    example counters:
    LocalMerchants: keeps track of how well your realm is for merchants
    LocalPious: keeps track of how pious your nation behaves
    LocalNobles: keeps track of how loyal/powerful your nobles are
    etc

    All these counters are attached to a ( rather large ) amount of "normal" monitors
    Code:
    monitor_event BuildingCompleted SettlementBuildingFinished >= merchants_wharf
    and SettlementName Antwerp
    and SettlementIsLocal
     inc_counter FlandersMerchants 2
    end_monitor
    or on a factionwide basis:
    Code:
    monitor_event BuildingCompleted SettlementBuildingFinished >= naval_academy
    and SettlementIsLocal
     inc_counter LocalNaval 5
    end_monitor
    This all ensures that I always have enough things to play around with when triggering my events.

    Additional notes and comments

    Depending on howmany events you are adding it might be wise to make some sort of allowance for "local only" events. As you can see some of my counters have the Local... name wich essentially means that nomatter wich faction you are playing it will always be this counter that has to be referenced in the triggering section.

    All AI factions just follow a much lighter historic accurate way. This allows you to have the same piece of script run the event nomatter wich faction you are playing, very useful for more random events such as "merchants flock to the city" or "Nobles rebel" etc. While the AI never actually gets these events but is just assumed to deal with these internal things as was historicly likely.
    So region controlled by venice will automatically drift towards high on merchant power/ free cities
    and French regions will become very feudal/ noble oriented.


    Data Processing

    Now we've collected a lot of data in the form of counter during our turn we can start by processing it. This can be done in a single monitor and have effects run accordingly. These effects can be any effect an event has aswel and will be elaboratly explained in the next chapter.

    Code:
            if I_CompareCounter FlandersHappy < -200 
               set_counter FlandersHappy -200
            end_if
            if I_CompareCounter FlandersHappy > 200
               set_counter FlandersHappy 200
            end_if
    
    
            if I_CompareCounter FlandersHappy >= 175
            and I_EventCounter Flanders_VERYHAPPY == 0
             set_event_counter Flanders_VERYUNHAPPY 0
             set_event_counter Flanders_UNHAPPY 0
             set_event_counter Flanders_DISCONTENT 0
             set_event_counter Flanders_NEUTRAL 0
             set_event_counter Flanders_CONTENT 0
             set_event_counter Flanders_HAPPY 0
             set_event_counter Flanders_VERYHAPPY 1
                if I_CompareCounter FlandersLocal == 1
                 historic_event Flanders_VERYHAPPY true 
                end_if
            end_if 
    .
    .
    .
            if I_CompareCounter FlandersHappy <= -175
            and I_EventCounter Flanders_VERYUNHAPPY == 0
             set_event_counter Flanders_VERYUNHAPPY 1
             set_event_counter Flanders_UNHAPPY 0
             set_event_counter Flanders_DISCONTENT 0
             set_event_counter Flanders_NEUTRAL 0
             set_event_counter Flanders_CONTENT 0
             set_event_counter Flanders_HAPPY 0
             set_event_counter Flanders_VERYHAPPY 0
                if I_CompareCounter FlandersLocal == 1
                 historic_event Flanders_VERYUNHAPPY true 
                end_if
            end_if
    
    ;---------Flanders Merchants------------------------------------------------------------------------------
    
            if I_CompareCounter LocalMerchants > 60
            and I_CompareCounter LocalMerchants < 91
            and RandomPercent < 6 
              inc_counter FlandersMerchants 1 
              inc_counter FlandersNobles -1
            end_if 
    
            if I_CompareCounter LocalMerchants > 90
            and RandomPercent < 10 
              inc_counter FlandersMerchants 1 
              inc_counter FlandersNobles -1
            end_if 
    
            if I_CompareCounter FlandersMerchants > 15
              set_counter FlandersMerchants 15
            end_if 
    
            if I_CompareCounter FlandersMerchants < 0
              set_counter FlandersMerchants 0
            end_if
    
    
            if I_CompareCounter FlandersMerchants > 10
            and I_EventCounter Flanders_MERCHANTS = 0 
                if I_CompareCounter FlandersLocal == 1
                  historic_event Flanders_MERCHANTS true
                end_if 
             set_event_counter Flanders_MERCHANTS 1
            end_if


    Last edited by ilmrik; October 26, 2011 at 01:01 PM.

  4. #4

    Default Re: A Guide to Events

    Event Effects

    Introduction:


    Event Build up

    Single Event Build Up

    A single event is just that,
    It runs, triggers a couple of effects and warns you about it and then ends. It doesn't offer you any choices and basically works like all the vanilla events. Not suprisingly the most efficient ways to trigger it is how it was done in vanilla by a historic/counter event trigger or by a direct monitor trigger. The build up is essentially always the same:
    Code:
    monitor_event 
      -effects-
    end_monitor
    This simple form is the building block of more extensive scripts as well. By either adding extra features
    or having monitors interlink.



    Choice Event Build Up
    Any choice event naturally consist of 3 parts.
    -The part that gives you the actual event and any initial effects
    -Option 1: Choice accepted
    -Option 2: Choice declined
    There are a few ways of writing them up but the idea is pretty much the same all around.

    Code:
     
    monitor_event FactionTurnStart FactionIsLocal
    
      if RandomPercent < 15
         set_counter LocalMerchantEvent 1 
         historic_event Merchants_Require_Aid 
         -intial effects- 
      end_if
    These are the effects:
    Accepted and Declined

    Code:
      while I_CompareCounter LocalMerchantEvent == 1 
    
        monitor_event EventCounter EventCounterType Merchants_Require_Aid_accepted 
          set_event_counter Merchants_Require_Aid_accepted 0
          set_counter LocalMerchantEvent 0
          
          -Accepted Effects-
    
          end_monitor
    
        monitor_event EventCounter EventCounterType Merchants_Require_Aid_declined 
          set_event_counter Merchants_Require_Aid_declined 0
          set_counter LocalMerchantEvent 0
          
          -Declined Effects-
    
          end_monitor
    
      end_while
    The effects of your choice.
    The while loop is what makes it all tick essentially pausing the monitor until you have made a decision.
    Thanks to the nature of conditional data you can add all the events one after the other in a single monitor_event.
    Now we've established how we have to put the effects we'll be moving on to what the script can do.

    Multi Turn Events

    Making events run over several turns is a lot easier than one would think this chapter will show you how. Their are 2 basic ways of doing things but they all achieve pretty much the same thing.

    Counter Based Multiturn
    Counter Based Multi Turn
    Counter Based Multi turn events work with a counter wich is set as part of the effects, this counter will then trigger the follow up effect the next turn. Lets continue with the event from the last chapter with some additions to make it multiturn if I accept the first proposal.

    Now a first issue that presents itself is the fact that instead of running over 2 seperate turns the event would run the first event and if I accept the second event directly after it. The easiest way to prevent this would be to place the second event above the first because the monitor is read from top to bottom.
    I'm going to be using a more invasive system here because it's more fail proof, it might not be nessecairy for this specific example but if you intend to build more complex event trees you'll probably need it anyway.
    I'm adding the counter FlandersDelay, This counter will delay all the events by one turn because it's always set to 1 when a follow up event is triggered but the actual follow up event will only run when it's 0. At the start of each turn FlandersDelay is reduced by 1 if it's > 0.
    See comments in red

    Code:
     
    monitor_event FactionTurnStart FactionIsLocal 
    if I_CompareCounter FlandersDelay > 0 
          inc_counter FlandersDelay -1
       end_if
    
       if RandomPercent < 15 
       and I_CompareCounter FlandersEvent == 0 
           historic_event FLANDES_MERCHANTS_REQUIRE_AID true
           set_counter FlandersEvent 1 
           -intitial effects Event 1-
       end_if 
    
       while I_CompareCounter FlandersEvent == 1
                monitor_event EventCounter EventCounterType FLANDERS_MERCHANTS_REQUIRE_AID_accepted 
                    set_counter FlandersEvent 2
                    set_counter FlandersDelay 1
                    -accepted effects Event 1-
                end_monitor
    
                monitor_event EventCounter EventCounterType FLANDERS_MERCHANTS_REQUIRE_AID_declined
                    set_counter FlandersEvent 0
                    -declined effects Event 1-
                end_monitor
       end_while
    
       if I_CompareCounter FlandersEvent == 2 
       and I_CompareCounter FlandersDelay == 0
           historic_event FLANDES_MERCHANTS_FOLLOW_UP true
           set_counter FlandersEvent 3 
           -intitial effects Event 2-
       end_if 
    
       while I_CompareCounter FlandersEvent == 3
                monitor_event EventCounter EventCounterType FLANDERS_MERCHANTS_REQUIRE_AID_accepted 
                    set_counter FlandersEvent 0
                    -accepted effects Event 2-
                end_monitor
    
                monitor_event EventCounter EventCounterType FLANDERS_MERCHANTS_REQUIRE_AID_declined
                     set_counter FlandersEvent 0
                     -declined effects Event 2-
                 end_monitor
       end_while
    
    end_monitor



    Long Term Events


    Ripple Events


    Counter Based Effects

    Counter Based Effects
    Probably the easiest of all the effects to understand and implement. Like mentioned earlier the game uses a counter to store information. So that's what we'll be doing. What I want to know is how well the local player treats his merchants and the counter "LocalMerchants" is going to help me keep track of that.

    Beginner Aid
    Spoiler Alert, click show to read: 

    Like any counter we'll have to declare it first, just type the following line right under the "script" line right at the top of your campaign script.

    Code:
    declare_counter LocalMerchants

    Any newly declared counter always has 0 as value. But say we pick Venice a country with a long Mercantile tradition it would be reasonable to assume that they get some sort of boost.
    We achieve this by simply adding the following conditional underneath out declare_counter line

    Code:
    if I_LocalFaction = venice
      set_counter LocalMerchants 15
    end_if
    Since everything not in a monitor will only be read by the script once ( at the start of a new campaign) we don't have to worry about this slowing the script down or repeating itself constantly.
    These same 3 lines can be used for any other faction you wish to give a boost ( or penalty ) at start up. Do note that I only do this for the local faction, this allows you to severely cut down on the number of events. As every event can theoretically be made available for every faction and so has to be put into the campaign script only once ( as opposed to once per faction).


    A simple little event could be the Merchants_Require_Aid we've used earlier:
    "Merchant caravans harrassed!

    My lord our merchants often fall under attack from robber barons perhaps we should issue a new charter to place them under protection of the crown
    and punish all that break it. Do you wish to accept his new charter?"

    and the 2 effects would be Accepted:
    Increases the Merchants happiness slightly
    Code:
        monitor_event EventCounter EventCounterType Merchants_Require_Aid_accepted 
          set_event_counter Merchants_Require_Aid_accepted 0
          set_counter LocalMerchantEvent 0
          
          inc_counter LocalMerchants 2
    
        end_monitor
    Declined:
    Decreases the merchants happiness slightly
    Code:
        monitor_event EventCounter EventCounterType Merchants_Require_Aid_declined 
          set_event_counter Merchants_Require_Aid_declined 0
          set_counter LocalMerchantEvent 0
          
          inc_counter LocalMerchants -2
    
        end_monitor
    At the moment this counter doesn't really do anything yet it only keeps track of things,
    Apart from being able to reference it in different parts of the campaign script we can have it affect various other files. To do this however we'll need a different kind of counter, the "event_counter"
    it's in many ways similar to the normal counter except it doesn't have to be declared at the start of the script and it's options are a bit more limited than that of a normal "counter".

    Processing counters is actually very easy and goes like this

    Code:
    if I_CompareCounter LocalMerchants < 20
       set_event_counter Local_Merchants_Low 0
       set_event_counter Local_Merchants_High 0
     end_if 
    
    if I_CompareCounter LocalMerchants < 40
    and I_CompareCounter LocalMerchants => 20
      set_event_counter Local_Merchants_Low 1
      set_event_counter Local_Merchants_High 0
    end_if 
    
    if I_CompareCounter LocalMerchants => 40
        set_event_counter Local_Merchants_Low 0
        set_event_counter Local_Merchants_High 1
      end_if 
    
    if I_CompareCounter LocalMerchants => 40
      set_event_counter Local_Merchants_Low 0
      set_event_counter Local_Merchants_High 1
    end_if
    How we can reference these event counters in other files will be explained in the next chapter(s)

    Events and the EDB

    I'm not going to be explaining the entire EDB if you have no experience with it I suggest these reading these 2 tutorials.
    A guide to the Export_descr_Buildings.txt by Mythic_Commodore
    How to create a new Hidden_Resource by St. Polycarpe
    Also be sure to read AJ Stoners tutorial on complex interactive events.
    Events and the EDB

    Activating/Deactivating Building Effects

    Building effects are some of the most direct ways to influence your settlements controling everything from recruitment options until trade bonusses. By using an event counter you can activate/deactivate these effects.
    The principle is very simple and best illustrated by an example:
    from the export_descr_buildings.txt, in the capability part of a building.
    Code:
    population_health_bonus bonus -2  requires factions { all, } and event_counter PORTUGAL_VERYUNHAPPY 1
    This can be applied to all building effects and recruit effects, by using the command "set_event_counter" in the campaign script you can activate it:
    from the campaign script:
    Code:
    set_event_counter PORTUGAL_VERYUNHAPPY 1 
    The City/Castle Centre

    Now things like this could make some of the capability section of buildings very long, it gets even worse when you have to duplicate entire sections to account for building upgrades etc.
    Therefor it might be smart to include a single 1 level building to all of your settlements ( TLR uses a Town Square / Castle Courtyard ). This building can then include all the trade boosts etc that a region gets.
    You can even take it a step further ( wich I am now doing for TLR ) and make a single 1 level building for every town or region. see the chapter on creating buildings for more information on how to do this without needing a disproportional amount of building trees.


    Extra options

    Besides the usual building effects I did some research into the EDU and found some interesting extra ways to influence things with recruit pool capabilities. Now some basic experience boosting building options exist but these are often lacking either the completeness or not specific enough.

    Now I noticed that vanilla M2TW uses some "incomplete" recruit options to allow retraining and free upkeep units. These don't show up in the building browser ingame but do work. The full potential is however a lot larger than that.

    First the basics, most of you will already know this but I added some sidenotes with might be slightly less known at the end.
    A standard entry:
    from EDB
    Code:
    recruit_pool "NE Bodyguard" 0 0.05 1 0 requires factions { england, scotland, france, hre, denmark, poland, hungary, slave, }
    There are 4 numbers
    -This number specifies howmany units are available when the building is build/when you capture a settlement with this building in it

    -This number affects the refresh rate of units, the value is added to the available number every turn every time it hits the treshold 1 a new unit is made available.

    -The maximum available number of units

    -Experience of the newly recruited unit

    Some Sidenotes,
    Althoug all of these numbers are usually integer numbers (0, 1, 2, 3, 4 ) this is not a nessecity bear that in mind.
    Also the maxiumum available number isn't always the actual maxiumum it can be exceeded because of the way the game processes these lines. The common believe is that the "maximum number" is a sort of maximum value that is written in stone. While in fact it behaves more like a comparitive value
    if the current recruit pool value >= The maxiumum value do not add theincremental value.

    For example say I have a recruit_pool line like this
    Code:
    recruit_pool "NE Bodyguard" 0 3 1 0 requires factions { england, scotland, france, hre, denmark, poland, hungary, slave, }
    The game would start by checking the recruit pool value wich we'll take as 0.
    0 < 1 so the game will proceed onto the next step; increasing the value:
    0 + 3 = 3

    so next turn I'll have 3 units of NE bodyguard available even though the maximum is theoretically 1

    The The maxiumum value also controls what shows up in game and what doesn't
    if it's <0 then it won't be visible ( but it will have an effect)
    Okay, with the theory behind us what can we do with this ?

    "Hidden" Unit Specific Experience Boosts

    Say I want to increase the experience of all the "Longbowmen" armed in a region, you could just work with a hidden_resource and multiple etries etc.
    It can however be done in an easier way ( if you have a single level building ) by adding this line.
    Code:
    recruit_pool "Longbowmen" 0 0.1 0.1 2 requires factions { all }
    This won't show up in the building capabilities section nor will it ever produce a unit on it's own (so you can add as many as you like) but every longbowmen unit that is recruited will have experience 2 ( unless another entry would give it more it seems the highest is always used )

    Sample use
    Using giving a chapterhouse HQ the factionwide ability of boosting exp for all the knights of it's order (without making the knights available in all your settlements)

    Unit recruiting speed boost

    Say you want an independent building to boost the recruitment speed of specific units.
    For example a very late game gun factory/royal arsenal type building wich improves the quality and recruitment speed of all gun armed units in your realm. Just give it the faction wide capability :
    Code:
    recruit_pool "Arquebusiers" 0 0.9 0.3 0 requires factions { all }
    recruit_pool "Musketeers  " 0 0.9 0.3 0 requires factions { all }
    This will give all regions that already produce this unit a 0.3 boost in unit refreshing, again without giving a "free unit" to regions that don't have the sufficient level of barracks. You'll also be able to retrain musketeers/Arquebusiers everywhere in your realm.

    On top of that you can even make a combined system, lets say you normally need atleast level 3 barracks to create gunpowder units. However if you have a Gun Factory like the one above it could reduce this to level 2 by adding this line to your level 2 barracks.
    Code:
    recruit_pool "Arquebusiers" 0 0.1 0.1 0 requires factions { all }
    recruit_pool "Musketeers  " 0 0.1 0.1 0 requires factions { all }
    on it's own this is just another invisible entry that on it's own does nothing however combined with the Gun Factory you'd essentially get 1 unit every 3 turns:
    Code:
      recruit_pool "Arquebusiers" 0 0.1 0.1 0 requires factions { all }
    + recruit_pool "Arquebusiers" 0 0.9 0.3 0 requires factions { all }
    ----------------------------------------------------------------------
      recruit_pool "Arquebusiers" 0   1 0.4 0 requires factions { all }


    Hidden available units

    Some units are just avaible in a region without any structures needed, Peasants and the likes now you can just add these openly to the "town centre"/"castle courtyard" but I feel that secretly is a lot cleaner and prevents unnesecairy clugging of building effects. It's also a solution for the ( in my opinion horrible ) duplicate unit syndrom a lot of buildings have.

    Like illustrated earlier it's possible to "overflow" your max available units so adding this line

    Code:
      recruit_pool "Peasants" 0 0.99 0.1 0 requires factions { all }
    Now this will create 1 units of peasants every 10 turns without showing up in the building capability.

    Same for the Longbowmen, say I have a AoR in england for the longbowmen, but they are available everywhere for england. Normally this would cause interference but if you write it like this the unit will only show up once in the building capability but they will spawn twice as fast for England and have a real pool maximum of 2
    Code:
    recruit_pool "Longbowmen" 0 1 0.1 0 requires factions { all } and hidden_resource england
    recruit_pool "Longbowmen" 0 0.99 0.1 0 requires factions { england }

    Last edited by ilmrik; January 01, 2012 at 09:11 PM.

  5. #5

    Default Re: A Guide to Events

    Useful small scripts

    Introduction:
    Well we've had the basics of event making now I'll be adding some extra scripting examples wich can be used in various ways to achieve the effect that you want. And will hopefully make your script more streamlined and sensetive.

    While Loop Scripts
    One of the main problems with events is that they tend to be very rigidly scripted things, this is okay for clearly time based events ( e.g. the appearence of the Hussites ) but tends to get trickier for more random events like e.g. "Noble grants military aid" or "Merchants ask for additional investments"

    Depending on the time that these events are triggered they might have very different effects
    you can hardly have a Noble sending you levy spearmen and peasant archers in 1740
    or be expected to pay 10.000 florins to invest in trade on turn 3
    and you don't want events to be identical every time either!

    Now a first step I took in dealing with this is by using some sort of division over the different ages via "if" statements. Wich is a most logical step as each historic period had it's own problems and advancements. However it still left a lot to be desired since I wanted the development of the region and of the nation to affect the outcome of the events.
    A nation that invested heavily in it's merchants should reap the benefits of this when a merchant event came along. And a very Feudal oriented nation should get other units that a nation that is constantly working on the professionalism of it's armies. All in all I wanted to shift more power to the players choices.
    Also last but not least I want to be able to tweak my events rather easily should they appear to be too expensive or cheap or produce toomuch men etc.

    To do this without adding like 80-100 lines of if statements per event x 50 ish events per county x 106 counties was my goal and this is what I came up with.
    I decided for a more centralised approach wich allowed me to do achieve everything I wanted. it all revolves around a serie of while loops wich get incorperated into the monitor aswel.

    How does it work?


    Up until now I've used a direct way to include the event effects by putting them straight into the monitor like so.
    Code:
        monitor_event EventCounter EventCounterType RandomMerchantEvent1
          set_event_counter RandomMerchantEvent1_accepted 0
          set_counter LocalRandomMerchantEvent 0
          
          console_command add_money 3000
    
            if RandomPercent < 30 
              console_command add_money 1500
            end_if 
    
        end_monitor
    Typing out everything for every event, now this is going to change as I'm introducing a new counter "ExtraIncomeMerchants" and replace all the entries like so:

    Code:
        monitor_event EventCounter EventCounterType RandomMerchantEvent1
           set_event_counter RandomMerchantEvent1_accepted 0
           set_counter LocalRandomMerchantEvent 0
           
           inc_counter ExtraIncomeMerchants 6 
     
         end_monitor
    I do this for all the events so essentially there isn't a single "strict" number in there anymore. Then I add this piece of script:

    Code:
     
    while I_CompareCounter ExtraIncomeMerchant > 0 
    
      if I_TurnNumber =< 150 
         generate_random_counter RandomNumber 1-8
      end_if
    
     if I_TurnNumber > 150 
        generate_random_counter RandomNumber 5-12
     end_if
    so this gives me a random number based on what turn it is wich allows me to make things more expensive later in the game. All kinds of other things can be included here aswel. Now lets include the mercantile power of our nation into the equation by doing this:
    -Note that <1 is the worst outcome and >12 is the best-
    Code:
      if I_CompareCounter LocalMerchants < 5
        inc_counter RandomNumber -1 
      end_if 
    
      if I_CompareCounter LocalMerchants < 12
        inc_counter RandomNumber -1 
      end_if 
    
      if I_CompareCounter LocalMerchants > 28
        inc_counter RandomNumber 1 
      end_if 
    
      if I_CompareCounter LocalMerchants > 35
        inc_counter RandomNumber 1 
      end_if 
    
      if I_CompareCounter LocalMerchants > 50
         inc_counter RandomNumber 1 
       end_if
    Really anything you want you can put it in there, kept track of howmany fairs a nation has? why not put it in there, merchant charters etc etc it's up to you!
    Now next up is the actual earning of money all I still have to do is this:

    Code:
     
    if I_CompareCounter RandomNumber = 1 
       console_command add_money 237 
    end_if 
    
    if I_CompareCounter RandomNumber = 2 
       console_command add_money 346 
    end_if 
    
    ...
    
    if I_CompareCounter RandomNumber > 12 
      console_command add_money 1278
    end_if 
    
    inc_counter ExtraIncomeMerchant -1 
    
    end_while
    By doing this the script will just keep repeating these steps until you run out of your acumulated extra income counters and then move on ( this really shouldn't take more than a fraction of a second).

    These same steps can be used for practically anything, from creating units based on your timeline to unforseen extra expenses.

    Choosing a city script

    Say you want a player to be able to choose in wich city he wants to build a certain event based building or you want to rally all the nobles from a region in a given province etc. This script will be what you need basically. It lets you pick the city you want on the map. It consists of 2 things, the first gives you some time to decide, the second logs your decision.

    The decider works as follows:
    Code:
     
    historic_event Decide_Drydock_Antwerp_Bruges_London
    
      while I_EventCounter Decide_Drydock_Antwerp_Bruges_London_accepted = 0 
      and I_EventCounter Decide_Drydock_Antwerp_Bruges_London_declined = 0 
    
      end_while
    it's basically a pauser, it tells you what you can decide between and as long as you don't close the scroll you can look around. As soon as you do you move on to the second part. you can incorperate the event text in her too.

    "Commissioning of a Royal drydock

    My lord our navies are falling behind we must increase the size of our fleet our naval engineers have already determined 3 suitable sites for it. do you wish to build it? take some time to look at the possible locations Antwerp, Bruges and London if you decide to build it you will have to decide wich of these cities it will be in.
    Followed by the unit specifications.

    Accept/Decline"

    Code:
    if I_EventCounter Decide_Drydock_Antwerp_Bruges_London_accepted = 1 
         while I_EventCounter Decide_Drydock_Antwerp_Bruges_London_accepted = 1 
    
              if I_SettlementSelected = Antwerp   
                 -effects for Antwerp-
                 set_event_counter Decide_Drydock_Antwerp_Bruges_London_accepted = 0
              end_if 
    
              if I_SettlementSelected = Bruges   
                 -effects for Bruges-
                 set_event_counter Decide_Drydock_Antwerp_Bruges_London_accepted = 0
              end_if 
    
              if I_SettlementSelected = London   
                 -effects for London-
                 set_event_counter Decide_Drydock_Antwerp_Bruges_London_accepted = 0
              end_if 
    
        end_while 
    end_if 
    
    if I_EventCounter Decide_Drydock_Antwerp_Bruges_London_declined = 1 
       -declined effects-
    end_if
    It might be wise to add some sort of notification to show that the city has been picked to start. Also you should make sure that the 3 regions actually belong to the local player ( I just collect the data anyway I'll include how in the Data collection section )

    That's how easy it is, I've been experimenting with the "flash settlement" command but it doesn't seem to be functioning if anyone has got this to work let me know as it would make a great addition to this script. As it would allow additional criteria to be added.

    Random pick with extra criteria


    We have used the "generate_random_counter" several times now and it's a great kingdoms addition to our event scripting toolbox and only has one minor drawback. The lack of a possibility to add extra conditionals to your choice this is however very easily fixed with the following script:

    Example:
    We want some sort of advanced trade building to be offered in a random position. What we don't want however is it being placed in some backwater province in the middle of nowhere. let's assume that we only have 4 provinces in the entire world to show the principle.
    data already collected for the example: Merchant power in the various cities
    -note this is just to show how the general idea of this script works to actually use this event it will need more development-

    Code:
    generate_ random_counter RandomNumber 1 4
    while I_CompareCounter RandomNumber != 0
    Another while loop, these things are godsends really. It will need one entry for every city you wish it to pick from. They should look like this:

    Code:
        if I_CompareCounter RandomNumber = 1
             if I_CompareCounter AntwerpMerchants < 20
                inc_counter RandomNumber 1 
             end_if 
    
             if I_CompareCounter AntwerpMerchants > 20 
                -effects for Antwerp-
                set_counter RandomNumber 0 
             end_if 
        end_if
    Principle is easy enough if the city corresponding with the random number doesn't have an adequate merchant base the script will move on to the next one. Now the last entry in the list should be slightly different:


    Code:
        if I_CompareCounter RandomNumber = 4
             if I_CompareCounter ChampagneMerchants < 20
                set_counter RandomNumber 1 
             end_if 
    
             if I_CompareCounter ChampagneMerchants > 20 
                -effects for Champagne-
                set_counter RandomNumber 0 
             end_if 
        end_if 
    
    end_while 
    This all is followed by the obvious end while. So if you get to the last city ( either by it being picked randomly or because the previous one wasn't elegible)
    There are 2 options
    a) The last city is elegible and RandomNumber is set to 0, the end_while is reached and the script moves on
    b) The last city is not elegible and RandomNumber is set to 1, the end_while is reached and the script starts reading at the beginning of the while loop again.


    Additional comments
    Now the more perceptive modder will have already spotted a flaw in this little script:
    what happens if none of the cities are elegible? Well the way it is written now it will loop around until the sun explodes ( or you stop playing M2TW wichever comes first).

    I'll discuss 2 options to solve this problem, there are others ways but they are basically all variations of these 2.

    Option 1:

    Probably the easiest one is to just have atleast 1 city that is always elegible, perhaps your capital or something. Some examples:

    I want my home province to be able to be picked, just add this lines to the appropriate entry in the loop
    Code:
        if I_CompareCounter RandomNumber = 1
             if I_CompareCounter LondonMerchants < 20
                inc_counter RandomNumber 1 
             end_if 
    
             if I_CompareCounter LondonMerchants > 20 
             and I_LocalFaction != england
                -effects for London-
                set_counter RandomNumber 0 
             end_if 
    
             if I_LocalFaction == england
                -effects for London-
                set_counter RandomNumber 0 
             end_if 
        end_if

    You could also add an extra option for "lesser" home provinces wich gives them a procentual chance to be picked despite not meeting the criteria. Favoritism all the way!

    Be careful with the positioning though the "set_counter RandomNumber 0" has to be below the "inc_counter RandomNumber 1" otherwise the script will pick 2 places!!

    Code:
        if I_CompareCounter RandomNumber = 1
             if I_CompareCounter NottinghamMerchants < 20
                inc_counter RandomNumber 1 
                     if I_LocalFaction == england
                     and RandomPercent < 51
                        -effects for Nottingham-
                        set_counter RandomNumber 0 
                      end_if 
             end_if 
    
             if I_CompareCounter NottinghamMerchants > 20 
                -effects for Nottingham-
                set_counter RandomNumber 0 
             end_if 
    
        end_if
    Option 2:
    The lack of a suitable city means the effect is just not run. This might not be very convenient for an event but could be when using this script to trigger things. What will you need to do ? Firstly we'll need a new counter, I'll call it "RandomTracker". It should always be set to 0 before a loop using it starts! Now every time we go over a city and it's not elegible this tracker should be increased by 1.
    Code:
    set_counter RandomTracker 0
    while I_CompareCounter RandomNumber != 0
    Code:
     
        if I_CompareCounter RandomNumber = 1
             if I_CompareCounter AntwerpMerchants < 20
                inc_counter RandomNumber 1 
                inc_counter RandomTracker 1
             end_if 
    
             if I_CompareCounter AntwerpMerchants > 20 
                -effects for Antwerp-
                set_counter RandomNumber 0 
             end_if 
        end_if
    Then we'll need to add this piece of script under the final entry. Where "n" is the number of entries.
    This will end the loop once every entry has been found inelegible atleast once.
    Code:
       if I_CompareCounter RandomTracker > n
          set_counter RandomNumber 0
       end_if
    Last edited by ilmrik; October 26, 2011 at 08:28 AM.

  6. #6

    Default Re: A Guide to Events

    Case studies

    I'll be adding some events here to show the possibilities of the various subjects touched in the tutorial.

    Faction goals
    WIP am still working on it for TLR
    The intention:
    Adding some more historic goals to the faction played by the local player, including time based ones to give the player some more historic direction.

    Requirements:
    -Only runs for the local player

    Overview of the event:
    I'm gonna make a hypothetical event for the early days of England, just before the Norman conquest of London,
    What I want to do is give the player the choice to play with either the Saxons or the Normans and based on that give the player some objectives to play around with.

    Coding the event:
    Code:
     
    monitor_event FactionTurnStart FactionIsLocal 
    and FactionType == england
       historic_event GAMESTART_SAXONS_OR_NORMANS
    terminate_monitor
    end_monitor
    History shapes itself
    Spoiler Alert, click show to read: 

    -some historic info-
    Since you decided to play England you now get the choice to play either with the current Saxon rulers or with the Norman claiments to the throne
    Accept: Saxons
    decline: Normans


    Code:
    monitor_event EventCounter EventCounterType GAMESTART_SAXONS_OR_NORMANS_ACCEPTED 
    and I_EventCounter GAMESTART_SAXONS_OR_NORMANS_ACCEPTED =1 
       set_event_counter SAXONS_LOCAL 1 
       
          add_events 
            event historic SAXON_GOAL_1  date 4 6     
          end_add_events
    terminate_monitor
    end_monitor
    SAXON_LOCAL: enables the recruitment of Saxon units as england
    SAXON_GOAL_1: retaking of London so that the Normans don't get a foothold

    Last edited by ilmrik; August 30, 2011 at 09:20 AM.

  7. #7

    Default Re: A Guide to Events

    glossary goes here

  8. #8
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: A Guide to Events

    Excellent tutorial, Ilmrik! Probably the best I've seen on the subject.

    And a great section on while loops - Well done! +rep

  9. #9

    Default Re: A Guide to Events

    Thanks Taiji, I still have a lot of work to do with it but I have plenty of research left ^.^

    Anyway I added some tidbits here and there and worked on the general lay out.
    Also added some research I did on the EDB that people might find interesting, see the bottom of events and the EDB. Under "Extra Options"

  10. #10
    HELLEKIN's Avatar Miles
    Join Date
    Nov 2007
    Location
    LISBON - PORTUGAL
    Posts
    396

    Default Re: A Guide to Events

    hello guys,can we unlock buildings with a historic event?How can i do that ...ex: i want the event "templars arrive to Portugal" , a image appears and unlock 1 building(casa templaria) that has 2 upgrades in EDB (grande casa templaria and casa do capitulo templaria" if this is possible can you help me and teach me?Many thanks in advance



    Solved....finaly
    Last edited by HELLEKIN; December 10, 2011 at 05:38 PM.
    Homo Homini Lupus

  11. #11
    Clanish's Avatar Libertus
    Join Date
    Sep 2011
    Location
    the most beautiful country of the wourld
    Posts
    58

    Default Re: A Guide to Events

    hi,i´m new in here and in mooding and the idea to make my own events is realy exiting,and has i read the previous tread i would like to know how to unlock buildings with a event too,i didn´t understend the tutorial,in my case i would like to unlock le Prieuré hospitalière and le Grand Prieuré hospitalière to be able to train all hospitaliers in this buildings only,can someone show how it is?i know...i´m a noob,please can help me?Sorry my english.

  12. #12
    HELLEKIN's Avatar Miles
    Join Date
    Nov 2007
    Location
    LISBON - PORTUGAL
    Posts
    396

    Default Re: A Guide to Events

    hello,clanish i´ll try to help only in building....the event the guys have to help you because i can´t i still learning ....

    IN DATA/EXP_DESC_BUILDINGS

    building Hospitaller
    {
    levels Prieuré_hospitalière Le_Grand_Prieuré_hospitalière
    {
    Prieuré hospitalière city requires factions { the faction you want or all, }
    {
    capability
    {
    recruit_pool "Knights Hospitaller" 1 0.4 3 0 requires factions { the faction you want or all, }
    recruit_pool "other unit" 1 0.4 3 0 requires factions { the faction you want or all, }
    recruit_pool "other unit" 1 0.4 3 0 requires factions { the faction you want or all, }
    }
    material wooden
    construction 3-----------------------------number of turns to build,can be change to tht valor you want
    cost 2400----------------------------------the cost of building,can be change to tht valor you want
    settlement_min large_city-------------------min requirement to building,can be change
    upgrades
    {
    Le_Grand_Prieuré_hospitalière
    }
    }
    Le_Grand_Prieuré_hospitalière city requires factions { the faction you want or all, }
    {
    capability
    {
    recruit_pool "Knights Hospitaller" 1 0.4 3 0 requires factions { the faction you want or all, }
    recruit_pool "other unit" 1 0.4 3 0 requires factions { the faction you want or all, }
    recruit_pool "other unit" 1 0.4 3 0 requires factions { the faction you want or all, }
    }
    material wooden
    construction 6
    cost 4800
    settlement_min huge_city
    upgrades
    {
    }
    }
    }
    plugins
    {
    }
    }




    IN DATA/TEXT/EXPORT_BUILDINGS


    {Prieuré_hospitalière}Prieuré hospitalière
    {Prieuré_hospitalière_desc}DO NOT TRANSLATE
    {Prieuré_hospitalière_desc_short}DO NOT TRANSLATE
    {Prieuré_hospitalière_southern_european}Prieuré hospitalière
    {Prieuré_hospitalière_southern_european_desc}big description
    {Prieuré_hospitalière_southern_european_desc_short}smal description
    {Le_Grand_Prieuré_hospitalière}Prieuré hospitalière
    {Le_Grand_Prieuré_hospitalière_desc}DO NOT TRANSLATE
    {Le_Grand_Prieuré_hospitalière_desc_short}DO NOT TRANSLATE
    {Le_Grand_Prieuré_hospitalière_southern_european}Prieuré hospitalière
    {Le_Grand_Prieuré_hospitalière_southern_european_desc}big description
    {Le_Grand_Prieuré_hospitalière_southern_european_desc_short}smal description


    to acess the text you´ll have to use the tool string_bin_converter (in the tools section of the downloads)to format the files then it´s easy,and always save the files as read only or it won´t work...its all help i can do to you the event is for the brain guys ....hope it helps
    Homo Homini Lupus

  13. #13
    Clanish's Avatar Libertus
    Join Date
    Sep 2011
    Location
    the most beautiful country of the wourld
    Posts
    58

    Default Re: A Guide to Events

    thank you hellekin,but the event?how to do?can help please

  14. #14

    Default Re: A Guide to Events

    Quote Originally Posted by HELLEKIN View Post
    building Hospitaller
    {
    levels Prieuré_hospitalière Le_Grand_Prieuré_hospitalière
    {
    Prieuré hospitalière city requires factions { the faction you want or all, } and event_counter NAME_OF_TRIGGER_EVENT 1
    {
    .....
    Le_Grand_Prieuré_hospitalière
    }
    }
    Le_Grand_Prieuré_hospitalière city requires factions { the faction you want or all, } and event_counter NAME_OF_TRIGGER_EVENT 1
    {
    ....
    I'll work some more on the tutorials once I get back as some things seem to still be unclear,
    anyway this is how you make something available after a certain event, there are 2 ways to trigger the actual event counter (and make the building available):

    Either add it to the desc_events ( atleast I think that's whats it called you can find it in the same folder as the campaign_script ) Now the building will automatically become available on a certain turn ( when the event runs see the entry for gunpowder etc in the same file), don't forget to add a description for the event in the txt.strings

    or via campaign script, by using the "set_event_counter NAME_OF_TRIGGER_EVENT 1" command in a monitor. if you are going to do this don't forget to add an set_event_counter NAME_OF_TRIGGER_EVENT 0 somewhere outside a monitor in the campaign script because I seem to remember someone saying an event counter doesn't exist until you use it wich could cause problems.

  15. #15
    EP!anastasi's Avatar Biarchus
    Join Date
    Jul 2008
    Location
    Athens, Greece
    Posts
    652

    Default Re: A Guide to Events

    Wow, this looks like a great tutorial!

    Especially for a real newb like me, i have just started to understand how some things work and mess with some files a bit... Well written and thorough, i really thank you!





    ...I'm afraid the most i can help you with in return, is point you a couple of typos i spotted...

    Quote Originally Posted by Counters and Event Counters
    You could both an event_counter and a counter with the same name in a script <snip>
    So as I rule...
    I guess the word "have" is missing: "You could have both an event_counter and a counter with the same name in a script ..." and then "So as a rule..."
    Quote Originally Posted by Historic/Counter Event Triggers
    Adv The main advantage is how easy it all is, the game automatically picks a random date and plays the event. all you have to do is add the effects.D
    Quote Originally Posted by Event Triggering Based on Buildings (first code)
    FactionIsLocaland
    Last edited by EP!anastasi; February 04, 2012 at 07:30 AM.
    Quote Originally Posted by 1988matej View Post
    <snip> i won't preorder to get the dacian's, wont pay for the elephant dlc nor will i settle for a dumbed down game <snip>
    "My garden may be smaller than your Rome, but my pilum is harder than your sternum!"

    a great song ... and one more ... ok, one last






    (\__/)
    ( O.o)
    (> < ) This is Bunny. Please help Bunny reach global domination by copying this message and pasting it to your own signature. Thank you!










    Fred Putz
    Quote Originally Posted by Fred Putz View Post
    Hmm - in my political spectrum Nazism is always on the extreme stupid wing.
    jimkatalanos

    Quote Originally Posted by jimkatalanos View Post
    Can someone delete this one temporarily?
    It's way too active and I am worried.
    Spoiler Alert, click show to read: 
    Taiji
    Quote Originally Posted by Taiji View Post
    Honestly there is no ceremony while I sacrifice stuff
    Garbarsardar
    Quote Originally Posted by Garbarsardar View Post
    <snip> the behaviour of moderators is a clear example of the corruption that absolute power brings to these hitherto innocent kids. Jom, Hesus, Ishan, Giga, were a merry bunch of fellows until the DeletePostDemon went into them and made them do the unthinkable. Praise the lord. And pass the bucket.
    ~Gort~
    Quote Originally Posted by ~Gort~ View Post
    Irony is one of the few saving graces of humanity.
    irelandeb
    Quote Originally Posted by irelandeb View Post
    What we understand is neglible compared to what we know we don't understand, never mind what we don't know we don't understand.
    Squid
    Quote Originally Posted by Squid View Post
    It won't help, people will believe what they want to believe even when presented with incontrovertible proof to the contrary.
    Magicman2051
    Quote Originally Posted by Magicman2051 View Post
    Clarifying, I don't disagree with what I quoted, I don't agree with it either.
    Aradan
    Quote Originally Posted by Aradan View Post
    You do make sense.

  16. #16

    Default Re: A Guide to Events

    Thank you, I'll be expanding it once I release the beta version of TLR 3.0.

  17. #17
    EP!anastasi's Avatar Biarchus
    Join Date
    Jul 2008
    Location
    Athens, Greece
    Posts
    652

    Default Re: A Guide to Events

    Quote Originally Posted by ilmrik View Post
    Thank you, I'll be expanding it once I release the beta version of TLR 3.0.
    Looking forward to both of them (expansion of tutorial and TLR 3.0 beta)
    Quote Originally Posted by 1988matej View Post
    <snip> i won't preorder to get the dacian's, wont pay for the elephant dlc nor will i settle for a dumbed down game <snip>
    "My garden may be smaller than your Rome, but my pilum is harder than your sternum!"

    a great song ... and one more ... ok, one last






    (\__/)
    ( O.o)
    (> < ) This is Bunny. Please help Bunny reach global domination by copying this message and pasting it to your own signature. Thank you!










    Fred Putz
    Quote Originally Posted by Fred Putz View Post
    Hmm - in my political spectrum Nazism is always on the extreme stupid wing.
    jimkatalanos

    Quote Originally Posted by jimkatalanos View Post
    Can someone delete this one temporarily?
    It's way too active and I am worried.
    Spoiler Alert, click show to read: 
    Taiji
    Quote Originally Posted by Taiji View Post
    Honestly there is no ceremony while I sacrifice stuff
    Garbarsardar
    Quote Originally Posted by Garbarsardar View Post
    <snip> the behaviour of moderators is a clear example of the corruption that absolute power brings to these hitherto innocent kids. Jom, Hesus, Ishan, Giga, were a merry bunch of fellows until the DeletePostDemon went into them and made them do the unthinkable. Praise the lord. And pass the bucket.
    ~Gort~
    Quote Originally Posted by ~Gort~ View Post
    Irony is one of the few saving graces of humanity.
    irelandeb
    Quote Originally Posted by irelandeb View Post
    What we understand is neglible compared to what we know we don't understand, never mind what we don't know we don't understand.
    Squid
    Quote Originally Posted by Squid View Post
    It won't help, people will believe what they want to believe even when presented with incontrovertible proof to the contrary.
    Magicman2051
    Quote Originally Posted by Magicman2051 View Post
    Clarifying, I don't disagree with what I quoted, I don't agree with it either.
    Aradan
    Quote Originally Posted by Aradan View Post
    You do make sense.

  18. #18

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

    Default Re: A Guide to Events

    Not possible as far as I know.

  20. #20

    Default Re: A Guide to Events

    First of all, that's a great tutotial!

    I am not sure if this is the right place to put my question but it is related to events and monitors.

    I am trying to implement the following:

    Upon any adoption (captain->general, marriage, etc.) the adopted character should be selected, moved off map and afterwards respawned with their own custom bodyguard unit. Moving and respawning the character should work once the adopted character is selected. And that's the issue:

    I can monitor the initialisation of the event (for example the adoption of a captain) but it seems I can't monitor the decision made and execute code based on it. I tried many variations to capture the decision but it simply doesn't work

    Code:
    monitor_event LesserGeneralOfferedForAdoption FactionIsLocal
        console_command add_money 1234
    
        monitor_event EventCounter EventCounterType LesserGeneralOfferedForAdoption_accepted
            console_command add_money 2345
            e_select_character, console_command give_trait this GoodCommander 4
        end_monitor
            
        monitor_event EventCounter EventCounterType LesserGeneralOfferedForAdoption_declined
            console_command add_money 3456
        end_monitor
            
    end_monitor
    The main monitor
    Code:
    monitor_event LesserGeneralOfferedForAdoption FactionIsLocal
    triggers and
    Code:
     console_command add_money 1234
    is executed. Both
    Code:
     monitor_event EventCounter EventCounterType
    statements are also executed but the code inside (adding 2345 or 3456 money) is not.

    What am I missing?

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
  •