Page 1 of 5 12345 LastLast
Results 1 to 20 of 99

Thread: Yes/No Event Tutorial

  1. #1
    Swagger's Avatar Imperial Coffee-Runner
    Join Date
    Apr 2007
    Location
    Portugal
    Posts
    12,434

    Default Yes/No Event Tutorial

    hello


    i haven't seen any tutorial on this so after some study and testing, i managed to get a simple, yet complete way to script Yes/No events

    first of all let me credit Boicote for his efforts on simplifying the Yes/No scripts


    i greatly recomend you to take a look at the CA's Docudemon files, for making your own script events, conditions and effects


    im now showing you how to make a simple yes-no event


    it's turn 1, and you recieve a message asking if you want to accept some blood money


    you either can accept it, or not

    accepting it will grant you extra 5000 denaries, if you don't, you lose 5000 denaries from your treasury (it's just a small example of course)

    to create one open the campaign_script.txt file inside data/world/maps/campaign/imperial_campaign/, you're also required a notepad/.txt editor



    here's the base script:

    Spoiler Alert, click show to read: 
    ;Money Extra Yes/No

    declare_counter extra_money_offered

    monitor_event FactionTurnStart FactionType egypt
    and I_LocalFaction egypt
    and I_TurnNumber = 1
    and I_CompareCounter extra_money_offered = 0

    add_events
    event counter extra_money_accepted
    event counter extra_money_declined
    end_add_events

    historic_event extra_money true factions { england, } ;makes event message appear
    set_counter extra_money_offered 1

    terminate_monitor
    end_monitor

    ;;;;;;;;;;;;;;;;;;;;;;;;; accepts blood money ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    monitor_conditions I_EventCounter extra_money_accepted = 1

    add_money England 5000 ;the effect is adding 5000 denaries
    historic_event extra_money_accepted factions { england, } ;message appears saying it was accepted

    terminate_monitor
    end_monitor

    ;;;;;;;;;;;;;;;;;;;;;;;;; doesn't accepts blood money ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    declare_counter extra_money_rejected

    monitor_conditions I_EventCounter extra_money_rejected = 1

    increment_kings_purse egypt -5000

    set_counter extra_money_rejected 1

    terminate_monitor
    end_monitor


    be sure to rename all the counters with the same name

    so if you rename the:

    ;;;;;;;;;;;;;;;;;;;;;;;;; doesn't accepts blood money ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    declare_counter extra_money_rejected
    be sure to also edit all the counter who have

    something_counter x_y_rejected
    with the exact same name


    and so on..




    as for the messages it will show, just open historic_events.txt placed in data/text folder

    and edit accordingly to all the

    historic_events BLABLA
    in my case:

    {EXTRA_MONEY_BODY} My Lord, we've been asked if we shall accept blood money, press "Accept" to get the money, press "Decline" to refuse the offer
    {EXTRA_MONEY_TITLE} Accept Blood Money?

    {EXTRA_MONEY_ACCEPTED_BODY} My Lord, we have accepted the money offer, the 5000k denaries have been increased in your royal treasury
    {EXTRA_MONEY ACCEPTED_TITLE} Money Accepted

    {EXTRA_MONEY_DECLINED_BODY} My Lord, we have refused the money offer, our royal treasury is now shorter by 5000k denaries
    {EXTRA_MONEY_DECLINED_TITLE} Money Refused

    this is a very simple Yes/No script, you can then add your own commands, conditions and events, and basicly, you can do nearly anything with this

    Personally i love this to add a great RPG style to the mods, as it can simulate a Kingdom Management system, where the player decisions have impact on the kingdom, and sometimes, the world itself



    Again, credits should be given to Boicote, for his work

    here are some of his projects, some of wich (1143) have this kind of Yes/No scripts:

    Med2tw Mod:

    Portvcale 0.3


    Kingdoms Mod:

    1143




    of course, any questions and doubts can be posted here
    Under the Patronage of the Dreadful cedric37!
    Ancs Guide, Emergent Factions , Yes/No Events |L'Outremer for Modders| Swagger's Skymod

  2. #2
    Gigantus's Avatar The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it
    Patrician Moderator Emeritus Administrator Emeritus Modding Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    46,915
    Blog Entries
    24

    Default Re: Yes/No Event Tutorial

    Nicely done, I just didn't get the time to write one, at least not in english, after my encounter with that problem.



  3. #3
    Swagger's Avatar Imperial Coffee-Runner
    Join Date
    Apr 2007
    Location
    Portugal
    Posts
    12,434

    Default Re: Yes/No Event Tutorial

    well thank you
    Under the Patronage of the Dreadful cedric37!
    Ancs Guide, Emergent Factions , Yes/No Events |L'Outremer for Modders| Swagger's Skymod

  4. #4
    Gigantus's Avatar The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it
    Patrician Moderator Emeritus Administrator Emeritus Modding Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    46,915
    Blog Entries
    24

    Default Re: Yes/No Event Tutorial

    Credit given when credit is due.



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

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

    Default Re: Yes/No Event Tutorial

    I'm not sure what this second part is about:
    Spoiler Alert, click show to read: 

    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;; doesn't accepts blood money ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    declare_counter extra_money_rejected
    
    monitor_conditions I_EventCounter extra_money_rejected = 1
    
    increment_kings_purse egypt -5000
    
    set_counter extra_money_rejected 1
    
    terminate_monitor
    end_monitor


    Accept/Decline require you to fire it off the _accepted and _declined counters, so a _rejected counter is not attached to the Yes/No selection but is considered wholly separate. The monitor above should not fire when a player clicks decline on the scroll. Additionally the above uses the outdated practice of using monitor_conditions which is a resource suck and has been replaced by a monitor_event.

    Example 1(w/o add_events):
    Spoiler Alert, click show to read: 

    Code:
    ;Start the decisions system
    monitor_event ScrollAdviceRequested ScrollAdviceRequested missions_scroll
    		and I_CompareCounter dec_system_activated == 1
    	historic_event choose_decisions true
    end_monitor
    
    ;Fire Decision 1 (D01)
    monitor_event EventCounter EventCounterType choose_decisions_accepted
    		and I_EventCounter choose_decisions_accepted == 1
    	wait 1 ; Give time for other event to clear the screen
    	historic_event decision_d01 true
    	set_event_counter choose_decisions_accepted 0
    end_monitor
    
    ;Abort Decisions System
    monitor_event EventCounter EventCounterType choose_decisions_declined
    		and I_EventCounter choose_decisions_declined == 1
    	set_event_counter choose_decisions_declined 0
    end_monitor

    Example 2(w/ add_events):
    Spoiler Alert, click show to read: 

    Code:
    ;Prompt player for Military(Accept) or choice of Economic/Cultural(Decline)
    monitor_event FactionTurnStart FactionIsLocal
    		and I_CompareCounter policy_timer == 0
    		
    	add_events
       		event counter policy1_accepted
       		event counter policy1_declined
       		date 0
      	end_add_events
      	historic_event policy1 true
    	set_event_counter policy1_declined 0
    end_monitor
    
    ;If Accepted, set to Military policy
    monitor_event EventCounter EventCounterType policy1_accepted
      and I_EventCounter policy1_accepted == 1
    	set_counter military_policy 1
    	set_event_counter policy1_accepted 0
    	historic_event military_policy
    	
    end_monitor
    
    ;If Declined, prompt for Economic(Accept) or Cultural(Decline)
    monitor_event EventCounter EventCounterType policy1_declined
      and I_EventCounter policy1_declined == 1
    	add_events
       		event counter policy2_accepted
       		event counter policy2_declined
       		date 0
      	end_add_events
      	historic_event policy2 true
    	set_event_counter policy2_declined 0
    	set_event_counter policy1_declined 0
    end_monitor
    
    ;If player chooses Accept, set to Economic
    monitor_event EventCounter EventCounterType policy2_accepted
      and I_EventCounter policy2_accepted == 1
    	set_counter economic_policy 1
    	set_event_counter policy2_accepted 0
    	historic_event economic_policy	
    end_monitor
    
    ;If player chooses Decline, set to Cultural
    monitor_event EventCounter EventCounterType policy2_declined
      and I_EventCounter policy2_declined == 1
    	set_event_counter policy2_declined 0
    	set_counter cultural_policy 1
    	historic_event cultural_policy	
    end_monitor


    The above scripts are stripped down, they don't do much else than show the accept/decline syntax, but they're taken from much more complex systems implemented in-game.

    I've yet to come across any issues trying to run the scrolls without the add_events, they work as intended in all places where I've used the shorter version. When you use add_events the game seems to like to set the _declined counter to 1 at some point from my experience, as before I started using set_event_counter *_declined 0 after the add_events it would fire any scripts based off the decline even if it was accept that was chosen.

    Furthermore the second script shows how you can easily make a two-choice system into a three or more choice system. The first scroll has Accept(Military) and Decline(Cultural or Economic, fires second scroll), and this is elaborated in the historic event so the player knows exactly what their options are. This could easily be extended to 4 options by splitting the first Accept/Decline into two parallel Accept/Declines, and further split in the same manner to allow multi-choice scrolls. As long as the first historic event explains the choices in full and whether to press Accept or Decline at each juncture to get what you want, you could technically have a stream of them without much strain on the player, if used sparingly.

    Lastly, I strongly advise against terminating monitors in 95% of cases. There are very few scripts you should only want to use once during a campaign. The above script seems like one of those that should easily come up multiple times but can't if it's terminated. It's much, much, much easier to just define the rules through conditions about how and when it appears as well as setting things like cooldown timers through the use of counters, than the clunky method of terminating monitors.

    Does anyone really want scripting tutorials on anything in particular? I mean, I could write them on a grip of things but all of it is explained in the University classes or answered when people pose workshop questions, so if we had a tut for every scripting condition or command it could get gnarly. Anyways drop me a line if you think there's some integral part of scripting that desperately needs a tutorial, it's really easy to take care of in most cases.
    Last edited by Augustus Lucifer; September 04, 2009 at 07:05 AM.

  6. #6
    Swagger's Avatar Imperial Coffee-Runner
    Join Date
    Apr 2007
    Location
    Portugal
    Posts
    12,434

    Default Re: Yes/No Event Tutorial

    thanks for the advise, but my script does work



    anyway what would you suggest to update my script in order to make it better?


    can you replace with your suggestions, without changing it that much?

    Spoiler Alert, click show to read: 

    ;Money Extra Yes/No

    declare_counter extra_money_offered

    monitor_event FactionTurnStart FactionType egypt
    and I_LocalFaction egypt
    and I_TurnNumber = 1
    and I_CompareCounter extra_money_offered = 0

    add_events
    event counter extra_money_accepted
    event counter extra_money_declined
    end_add_events

    historic_event extra_money true factions { england, } ;makes event message appear
    set_counter extra_money_offered 1

    terminate_monitor
    end_monitor

    ;;;;;;;;;;;;;;;;;;;;;;;;; accepts blood money ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    monitor_conditions I_EventCounter extra_money_accepted = 1

    add_money England 5000 ;the effect is adding 5000 denaries
    historic_event extra_money_accepted factions { england, } ;message appears saying it was accepted

    terminate_monitor
    end_monitor

    ;;;;;;;;;;;;;;;;;;;;;;;;; doesn't accepts blood money ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    declare_counter extra_money_rejected

    monitor_conditions I_EventCounter extra_money_rejected = 1

    increment_kings_purse egypt -5000

    set_counter extra_money_rejected 1

    terminate_monitor
    end_monitor



    thanks
    Under the Patronage of the Dreadful cedric37!
    Ancs Guide, Emergent Factions , Yes/No Events |L'Outremer for Modders| Swagger's Skymod

  7. #7

    Default Re: Yes/No Event Tutorial

    Quote Originally Posted by Augustus Lucifer View Post
    I'm not sure what this second part is about:
    Spoiler Alert, click show to read: 

    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;; doesn't accepts blood money ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    declare_counter extra_money_rejected
    
    monitor_conditions I_EventCounter extra_money_rejected = 1
    
    increment_kings_purse egypt -5000
    
    set_counter extra_money_rejected 1
    
    terminate_monitor
    end_monitor


    Accept/Decline require you to fire it off the _accepted and _declined counters, so a _rejected counter is not attached to the Yes/No selection but is considered wholly separate. The monitor above should not fire when a player clicks decline on the scroll. Additionally the above uses the outdated practice of using monitor_conditions which is a resource suck and has been replaced by a monitor_event.

    Example 1(w/o add_events):
    Spoiler Alert, click show to read: 

    Code:
    ;Start the decisions system
    monitor_event ScrollAdviceRequested ScrollAdviceRequested missions_scroll
            and I_CompareCounter dec_system_activated == 1
        historic_event choose_decisions true
    end_monitor
    
    ;Fire Decision 1 (D01)
    monitor_event EventCounter EventCounterType choose_decisions_accepted
            and I_EventCounter choose_decisions_accepted == 1
        wait 1 ; Give time for other event to clear the screen
        historic_event decision_d01 true
        set_event_counter choose_decisions_accepted 0
    end_monitor
    
    ;Abort Decisions System
    monitor_event EventCounter EventCounterType choose_decisions_declined
            and I_EventCounter choose_decisions_declined == 1
        set_event_counter choose_decisions_declined 0
    end_monitor

    Example 2(w/ add_events):
    Spoiler Alert, click show to read: 

    Code:
    ;Prompt player for Military(Accept) or choice of Economic/Cultural(Decline)
    monitor_event FactionTurnStart FactionIsLocal
            and I_CompareCounter policy_timer == 0
            
        add_events
               event counter policy1_accepted
               event counter policy1_declined
               date 0
          end_add_events
          historic_event policy1 true
        set_event_counter policy1_declined 0
    end_monitor
    
    ;If Accepted, set to Military policy
    monitor_event EventCounter EventCounterType policy1_accepted
      and I_EventCounter policy1_accepted == 1
        set_counter military_policy 1
        set_event_counter policy1_accepted 0
        historic_event military_policy
        
    end_monitor
    
    ;If Declined, prompt for Economic(Accept) or Cultural(Decline)
    monitor_event EventCounter EventCounterType policy1_declined
      and I_EventCounter policy1_declined == 1
        add_events
               event counter policy2_accepted
               event counter policy2_declined
               date 0
          end_add_events
          historic_event policy2 true
        set_event_counter policy2_declined 0
        set_event_counter policy1_declined 0
    end_monitor
    
    ;If player chooses Accept, set to Economic
    monitor_event EventCounter EventCounterType policy2_accepted
      and I_EventCounter policy2_accepted == 1
        set_counter economic_policy 1
        set_event_counter policy2_accepted 0
        historic_event economic_policy    
    end_monitor
    
    ;If player chooses Decline, set to Cultural
    monitor_event EventCounter EventCounterType policy2_declined
      and I_EventCounter policy2_declined == 1
        set_event_counter policy2_declined 0
        set_counter cultural_policy 1
        historic_event cultural_policy    
    end_monitor


    The above scripts are stripped down, they don't do much else than show the accept/decline syntax, but they're taken from much more complex systems implemented in-game.

    I've yet to come across any issues trying to run the scrolls without the add_events, they work as intended in all places where I've used the shorter version. When you use add_events the game seems to like to set the _declined counter to 1 at some point from my experience, as before I started using set_event_counter *_declined 0 after the add_events it would fire any scripts based off the decline even if it was accept that was chosen.

    Furthermore the second script shows how you can easily make a two-choice system into a three or more choice system. The first scroll has Accept(Military) and Decline(Cultural or Economic, fires second scroll), and this is elaborated in the historic event so the player knows exactly what their options are. This could easily be extended to 4 options by splitting the first Accept/Decline into two parallel Accept/Declines, and further split in the same manner to allow multi-choice scrolls. As long as the first historic event explains the choices in full and whether to press Accept or Decline at each juncture to get what you want, you could technically have a stream of them without much strain on the player, if used sparingly.

    Lastly, I strongly advise against terminating monitors in 95% of cases. There are very few scripts you should only want to use once during a campaign. The above script seems like one of those that should easily come up multiple times but can't if it's terminated. It's much, much, much easier to just define the rules through conditions about how and when it appears as well as setting things like cooldown timers through the use of counters, than the clunky method of terminating monitors.

    Does anyone really want scripting tutorials on anything in particular? I mean, I could write them on a grip of things but all of it is explained in the University classes or answered when people pose workshop questions, so if we had a tut for every scripting condition or command it could get gnarly. Anyways drop me a line if you think there's some integral part of scripting that desperately needs a tutorial, it's really easy to take care of in most cases.
    Both DLV and Divide and Conquer use multi-choice scrolls.
    I have been posting all over trying to get people to understand add_events is made redundant in M2TW-K...

    But well written and +REP I hope more people use these tutorials

  8. #8

    Default Re: Yes/No Event Tutorial

    help! I cannot figure this out?
    have tried adding it as a historic event,in desc strat events and whatever else I could think of!
    I cannot make it trigger.It has no ill effects on game just does not trigger and also when I do get it to
    work(eventually) I would add the events picture just like historic?
    thanks

  9. #9

  10. #10

    Default Re: Yes/No Event Tutorial

    here you go but please tell what I am doing wrong because there are at least three more I want to add to my mod
    thanks

  11. #11

    Default Re: Yes/No Event Tutorial

    many changes to make here, first add_events is redundant;

    Code:
    add_events
    historic_event economy_choice_mercantile true
    historic_event economy_choice_feudal agrarian true
    end_add_events
    and this is not valid;

    Code:
    historic_event *needs and event here* true factions { england, denmark, milan, spain, sicily, papal_states, moors, egypt,hungary, } ;makes event message appear
    try not to use monitor_conditions use monitor_event - because conditions are always active but an event triggers once per event instance.

    there are spaces here; (in red)
    Code:
    monitor_conditions I_EventCounter economy_style feudal agrarian = 1
    and you are missing the _accepted or _declined at the end of the EventCounter.

    Code:
    plus_1 {farms, }
    whats this? its not meant to be part of any script right?




    Code:
    ;
    ; Campaign script by gigantus
    ;

  12. #12

    Default Re: Yes/No Event Tutorial

    yes I am trying to figure this out first, my campaign script is like this:

    ;
    ; Campaign script by gigantus
    ;
    script

    end_script



    I have made no additions I have about three events I want to add
    and hopefully I can do this!
    thank you

  13. #13
    Gigantus's Avatar The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it
    Patrician Moderator Emeritus Administrator Emeritus Modding Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    46,915
    Blog Entries
    24

    Default Re: Yes/No Event Tutorial

    ;
    ; Campaign script by gigantus
    ;
    Another diligent use of my handy work



  14. #14

    Default Re: Yes/No Event Tutorial

    Quote Originally Posted by gigantus View Post
    Another diligent use of my handy work
    well does this mean u have to aprove the script first? lol

  15. #15

    Default Re: Yes/No Event Tutorial

    perhaps someone here can help I am trying to get a yes/no event in game(been struggling with it for a while just found out first, I need the Desc_event_images txt. from one of the kingdoms campaigns which I have located and copied in the correct location) I have also enterered the correct info in historic events an associated an image file with the event, my problem it will not fire???
    here is my script:

    script
    monitor event FactionTurnStart FactionIsLocal
    and I_TurnNumber = 0
    add_events
    event counter feast_and_banquet_accepted
    event counter feast_and_banquet_declined
    end_add_events
    historic_event feast_and_banquet true
    end monitor
    monitor_conditions I_EventCounter feast_and_banquet_accepted = 1
    add money 2500
    set_event_counter feast_and_banquet_accepted 0
    end_monitor
    monitor_conditions I_EventCounter feast_and_banquet_declined = 1
    add money -2500
    set_event_counter feast_and_banquet_declined 0
    end_monitor

    end_script

    thank you

  16. #16
    Gigantus's Avatar The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it
    Patrician Moderator Emeritus Administrator Emeritus Modding Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    46,915
    Blog Entries
    24

    Default Re: Yes/No Event Tutorial

    Simply check what Tarsies wrote



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

    Default Re: Yes/No Event Tutorial money and religion

    hello guys,i´m needing help in a complicated idea ...my idea is to create a event yes no and receive a message if i want or not the entrance in my regions of jews expeld from another country/region, if i accept,the jewish religion(that i added to my religions) will increase in 5% and i´ll be presented with money...1000 in my treasure (from the jewish merchants for exemple) if i refuse i´ll lose 40% of that ...400(imagine that´s because the stablished jews already in my Portugal kingdom hide some taxes from me because they are unhappy with my decision... for exemple....).It´s a two event and two consequence yes/no event....can someone show me how this can be done? Many thanks in advance............
    Homo Homini Lupus

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

    Default Re: Yes/No Event Tutorial

    Always forget someting.......it´s for vanilla....my mood...not in vanilla folder
    Homo Homini Lupus

  19. #19
    Gigantus's Avatar The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it
    Patrician Moderator Emeritus Administrator Emeritus Modding Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    46,915
    Blog Entries
    24

    Default Re: Yes/No Event Tutorial

    It is relatively easy. Have a look how the whole affair is structured in the spoiler in the first post. then check in the DocuDemons which command would be of use for you.



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

    Default Re: Yes/No Event Tutorial

    Thanks GIGANTUS but i doní know how to start,can you teach me? many thanks in advance
    Homo Homini Lupus

Page 1 of 5 12345 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
  •