Page 5 of 5 FirstFirst 12345
Results 81 to 99 of 99

Thread: Yes/No Event Tutorial

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: Yes/No Event Tutorial

    Okay, something must be VERY wrong with my references.
    I have tried putting in your script, but my game now CTD when i input your code (somehow i find that intriguing, i like the challenge)

    I tried searching a bit deeper into the log (*script* trace) and found the following:

    Spoiler Alert, click show to read: 
    10:40:37.073 [game.script.exec] [trace] exec <terminate_monitor> at line 3914 in data/world/maps/campaign/custom/test_campaign/campaign_script.txt
    10:40:37.073 [game.script.exec] [trace] exec <historic_event> at line 3939 in data/world/maps/campaign/custom/test_campaign/campaign_script.txt
    10:40:37.330 [system.rpt] [error] Medieval 2: Total War encountered an unspecified error and will now exit.

    (This is the point where it goes wrong)
    Spoiler Alert, click show to read: 
    Code:
    3938    monitor_event FactionTurnStart FactionType england
    3939        historic_event mission_issued true                  ; yes\no message pop up
    3940        while I_EventCounter mission_issued_accepted = 0    ; while-loop to pause the script until a decision is made
    3941            and I_EventCounter mission_issued_declined = 0
    3942        end_while
    3943        if I_EventCounter mission_issued_accepted = 1
    3944            add_money england 1200
    3945            set_event_counter mission_issued_accepted 0    ;resetting for next use
    3946        end_if
    3947        if I_EventCounter mission_issued_declined = 1
    3948            ; do stuff
    3949          set_event_counter mission_issued_declined 0    ;resetting for next use
    3950        end_if
    3951            set_event_counter mission_issued_issued 0          ;resetting for next use
    3952        terminate_monitor                              ; terminate if single use
    3953    end_monitor


    Any ideas?
    It kind of seems like it still goes by M2tw data, instead of kingdoms (descr_events_image)

  2. #2

    Default Re: Yes/No Event Tutorial

    It worked! Thank you..

    I'm fairly confident that it was rooted in the Virtual "Home Depot"
    So deleting them seems to have done the job...

    +REP (once again) for Gigantus

  3. #3

    Default Re: Yes/No Event Tutorial

    So just to recap, this is the complete *working* code:
    Spoiler Alert, click show to read: 

    Code:
        ;###########################################################
        ;################### HIGH KING OF KALMAR ###################
        ;###########################################################
        
        declare_counter kalmar_union
        
        ;######################### HKoK Stage 1 #########################
        
        monitor_event FactionTurnStart FactionType denmark
            and I_TurnNumber = 0
            
            historic_event kalmar_notification
            
            terminate_monitor
            
        end_monitor
        
        ;######################### HKoK Stage 2 #########################
        
        monitor_event FactionTurnStart FactionType denmark
            and I_EventCounter kalmar_union = 0
            and I_SettlementOwner Arhus denmark
            and I_SettlementOwner Stockholm denmark
            and I_SettlementOwner Oslo denmark
            and I_SettlementOwner Helsinki denmark
            and I_SettlementOwner Kalmar denmark
            
            historic_event kalmar_stage2
            set_event_counter kalmar_union 1
            spawn_army 
            faction slave
            character    Stenkil of_Sweden, named character, age 58, x 153, y 181
            traits DukeSweden 3 , Bloodthirsty 2 , GoodCommander 1 , BattleDread 2 , StrategyDread 2 , PublicFaith 1, Loyal 1, ContentGeneral 3
            unit        NE Bodyguard                exp 9 armour 1 weapon_lvl 0
            unit        Spear Militia                exp 4 armour 1 weapon_lvl 0
            unit        Spear Militia                exp 4 armour 1 weapon_lvl 0
            unit        Spear Militia                exp 4 armour 1 weapon_lvl 0
            unit        Peasant Archers                exp 4 armour 1 weapon_lvl 0
            unit        Peasant Archers                exp 4 armour 1 weapon_lvl 0
            unit        Peasant Archers                exp 4 armour 1 weapon_lvl 0
            end
            spawn_army 
            faction slave
            character    Haakon of_Norway, named character, age 65, x 154, y 180
            traits DukeNorway 3 , Bloodthirsty 2 , GoodCommander 1 , BattleDread 2 , StrategyDread 2 , PublicFaith 1, Loyal 1, ContentGeneral 3
            unit        NE Bodyguard                exp 9 armour 1 weapon_lvl 0
            unit        Spear Militia                exp 4 armour 1 weapon_lvl 0
            unit        Spear Militia                exp 4 armour 1 weapon_lvl 0
            unit        Spear Militia                exp 4 armour 1 weapon_lvl 0
            unit        Peasant Archers                exp 4 armour 1 weapon_lvl 0
            unit        Peasant Archers                exp 4 armour 1 weapon_lvl 0
            unit        Peasant Archers                exp 4 armour 1 weapon_lvl 0
            end
            
            terminate_monitor        
            
        end_monitor
        
        ;######################### HKoK Stage 3 #########################
        
        monitor_event FactionTurnStart FactionType denmark
            and I_EventCounter kalmar_union = 1
            and I_SettlementOwner Arhus denmark
            and I_SettlementOwner Stockholm denmark
            and I_SettlementOwner Oslo denmark
            and I_SettlementOwner Helsinki denmark
            and I_SettlementOwner Kalmar denmark
            and not I_CharacterExists Haakon of_Norway
            and not I_CharacterExists Stenkil of_Sweden
            
            historic_event kalmar_question true
            while I_EventCounter kalmar_question_accepted = 0    ; while-loop to pause the script until a decision is made
                and I_EventCounter kalmar_question_declined = 0
            end_while
            if I_EventCounter kalmar_question_accepted = 1
                historic_event kalmar_now
                add_money denmark 5000
                set_event_counter kalmar_union 2
            end_if
            if I_EventCounter kalmar_question_declined = 1
                add_money denmark 20000
            end_if
            
            terminate_monitor
            
        end_monitor
        
        ;######################### HKoK Traits & Ancillaries #########################
        
        monitor_event CharacterSelected CharacterIsLocal
            and I_EventCounter kalmar_union = 2
            and IsFactionLeader
            and I_SettlementOwner Arhus denmark
            and I_SettlementOwner Stockholm denmark
            and I_SettlementOwner Oslo denmark
            and I_SettlementOwner Helsinki denmark
            and not FactionwideAncillaryExists HK_Kalmar
            
            console_command remove_ancillary this Duke_Denmark
            console_command remove_ancillary this Duke_Sweden
            console_command remove_ancillary this Duke_Norway
            console_command remove_ancillary this Duke_Finland
            console_command give_ancillary this HK_Kalmar
            console_command give_trait this HKKalmar 3
            
            historic_event kalmar_question_accepted event/kalmar_union.bik
            
        end_monitor
        
        monitor_event CharacterSelected CharacterIsLocal
            and FactionwideAncillaryExists HK_Kalmar
            and FactionwideAncillaryExists Duke_Denmark
            
            console_command remove_ancillary this Duke_Denmark
        end_monitor
        
        monitor_event CharacterSelected CharacterIsLocal
            and FactionwideAncillaryExists HK_Kalmar
            and FactionwideAncillaryExists Duke_Sweden
            
            console_command remove_ancillary this Duke_Sweden
        end_monitor
        
        monitor_event CharacterSelected CharacterIsLocal
            and FactionwideAncillaryExists HK_Kalmar
            and FactionwideAncillaryExists Duke_Norway
            
            console_command remove_ancillary this Duke_Norway
        end_monitor
        
        monitor_event CharacterSelected CharacterIsLocal
            and FactionwideAncillaryExists HK_Kalmar
            and FactionwideAncillaryExists Duke_Finland
            
            console_command remove_ancillary this Duke_Finland
        end_monitor

  4. #4
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Yes/No Event Tutorial

    You seem to be running a 'provincial campaign' but the relevant file is in the shared data folder - that shouldn't really make a difference.

    Line 3939 got executed, else there wouldn't be an entry, something happened after that. I am assuming the two historic_event entries for mission_issued exit? {MISSION_ISSUED_TITLE} and {MISSION_ISSUED_BODY}?

    Have you ever sorted out your virtual store? If not then run this tutorial from step 3 onward and delete the m2tw folder in the virtual store directory if it is present.

    check in your descr_event_images files if this entry is in there completely as underneath, blue is the placement of the accept\decline symbols on the message:
    Code:
    historic_event
        icon    historic
        importance high
        heading_items    3
        footer_items    1
        format
        {
            string    center verdana black
            image    center
            spacer    8
            multistring    left verdana_sml khaki left
            condition
            {
                true
                {
                    group center 8
                    {
                        accept    right
                        decline   left
                    }
                }
                false
                {
                    group center 8
                    {
                        spacer 1    ; dummy item to fix event message formatting wrt header and footer items
                    }
                }
            }
        }










  5. #5
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Yes/No Event Tutorial

    Looks fine, just a note:
    Code:
        monitor_event CharacterSelected CharacterIsLocal
            and FactionwideAncillaryExists HK_Kalmar
            and FactionwideAncillaryExists Duke_Denmark
            
            console_command remove_ancillary this Duke_Denmark
        end_monitor
    You have to expect error message about the removal of the ancillary in the case the ancillary exists but not wit the selected character. Rather use HasAncType to test if the character has this ancillary. You will need to edit the EDA and give the ancillary a unique type entry so that this works properly - the ancillary name does not get tested here.
    I would also suggest to have a monitor that tests for the existence and then sets a counter that can be used to terminate all these testing monitors (good housekeeping for the win!)
    Code:
        monitor_event FactionTurnstart I_EventCounter kalmar_union = 2
            and not I_WorldwideAncillaryExists Duke_Denmark
            set_event_counter no_DukeDenmark 1
            terminate_monitor
        end_monitor
        
        monitor_event CharacterSelected CharacterIsLocal
            if I_EventCounter no_DukeDenmark > 0   ; terminate if ancillary doesn't exist
                terminate_monitor
            end_if
            and FactionwideAncillaryExists HK_Kalmar
            and Has AncType [type entry of Duke_Demnamrk ancillary]
            console_command remove_ancillary this Duke_Denmark
        end_monitor










  6. #6
    Civis
    Join Date
    Aug 2009
    Location
    Always temporary.
    Posts
    186

    Icon5 Re: Yes/No Event Tutorial

    Hello everyone,
    So, I've been doing experiments with these yes/no decisions and I attempted to make one that is supposed to cause a type of magical effect (really, just remove fog of war until the end of the turn), it doesn't work, no effects happen whatsoever. Here is what I have now:
    Code:
    monitor_event PreFactionTurnStart FactionIsLocal
        set_event_counter air_magic_accepted 0
        set_event_counter air_magic_declined 0
    end_monitor 
    
    monitor_event FactionTurnStart FactionIsLocal
        and FactionBuildingExists >= alchemy_school
        and I_LocalFaction scotland
        historic_event air_s_reveal true
    end_monitor
    monitor_event EventCounter EventCounterType air_magic_accepted
        and I_EventCounter air_magic_accepted == 1
        add_money scotland, -10000
        console_command toggle_fow
    end_monitor
    No effects, not even a money deduction. Any ideas? Is this even possible?

  7. #7
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Yes/No Event Tutorial

    Your event is called 'air_s_reveal' and the accepted counter\condition is called 'air_magic' - no surprise here: it has to be same name.

    Code:
    monitor_event PreFactionTurnStart FactionIsLocal
        set_event_counter air_magic_accepted 0
        set_event_counter air_magic_declined 0
    end_monitor 
    
    monitor_event FactionTurnStart FactionIsLocal
        and FactionBuildingExists >= alchemy_school
        and I_LocalFaction scotland
        historic_event air_magic true
    end_monitor
    monitor_event EventCounter EventCounterType air_magic_accepted
        and I_EventCounter air_magic_accepted == 1
        add_money scotland, -10000
        console_command toggle_fow
    end_monitor










  8. #8
    Civis
    Join Date
    Aug 2009
    Location
    Always temporary.
    Posts
    186

    Default Re: Yes/No Event Tutorial

    Cool! Thanks!
    It worked. Here's what I changed it too:

    Code:
    monitor_event PreFactionTurnStart FactionIsLocal
        set_event_counter air_s_reveal_accepted 0
        set_event_counter air_s_reveal_declined 0
    end_monitor 
    
    monitor_event FactionTurnStart FactionIsLocal
        and FactionBuildingExists >= alchemy_school
        and I_LocalFaction scotland
        historic_event air_s_reveal true
    end_monitor
    monitor_event EventCounter EventCounterType air_s_reveal_accepted
        and I_EventCounter air_s_reveal_accepted == 1
        add_money scotland, -10000
        console_command toggle_fow
    end_monitor
    But now I'm having trouble undoing this. My plan was to deactivate this at the beginning of the next turn, but that isnt happening. AND, the event message keeps appearing every turn.

    Here's what I got:

    Code:
    monitor_event FactionTurnStart FactionIsLocal
        and I_CompareCounter air_s_reveal_accepted == 1
        set_counter air_s_reveal_accepted 0
        console_command toggle_fow
    end_monitor

  9. #9
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Yes/No Event Tutorial

    If this is a one time event then simply terminate the monitors. You also don't need the first monitor then:

    Code:
    monitor_event FactionTurnStart FactionIsLocal
        and FactionBuildingExists >= alchemy_school
        and I_LocalFaction scotland
        historic_event air_s_reveal true
        terminate_monitor
    end_monitor
    
    monitor_event EventCounter EventCounterType air_s_reveal_accepted
        and I_EventCounter air_s_reveal_accepted == 1
        add_money scotland, -10000
        console_command toggle_fow
        terminate_monitor
    end_monitor










  10. #10
    Civis
    Join Date
    Aug 2009
    Location
    Always temporary.
    Posts
    186

    Default Re: Yes/No Event Tutorial

    What about if I wanted this to be random at times? Like I planned on adding a random trigger. My hope was for this to have a low % chance of happening from time to time and be an asset that shows up.

  11. #11
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Yes/No Event Tutorial

    You could generate a random number and then test for that in the conditions before triggering the event:

    Code:
    monitor_event FactionTurnStart FactionIsLocal
        and FactionBuildingExists >= alchemy_school
        and I_LocalFaction scotland
        generate_random_counter air_s_reveal_chance 1 20  ; creates counter with value between 1 and 20
        if I_EventCounter air_s_reveal_chance = 1  ; 5% (100\20) chance of this happening
            historic_event air_s_reveal true
        end_if
    end_monitor
    
    monitor_event EventCounter EventCounterType air_s_reveal_accepted
        and I_EventCounter air_s_reveal_accepted == 1
        add_money scotland, -10000
        console_command toggle_fow
        set_event_counter air_s_reveal_accepted 0  ; resetting counter for next time
    end_monitor










  12. #12
    Civis
    Join Date
    Aug 2009
    Location
    Always temporary.
    Posts
    186

    Default Re: Yes/No Event Tutorial

    Not quite, made the trigger stop.
    I added this as a random modifier:
    and RandomPercent < 5.

    So now the message stops appearing every turn, and that's good. A step in the right direction. But the FOW still doesn't reappear unless I enter it manually.

    This is it now:

    Code:
    monitor_event FactionTurnStart FactionIsLocal
        and FactionBuildingExists >= alchemy_school
        and I_LocalFaction scotland
        and RandomPercent < 5
        historic_event air_s_reveal true
    end_monitor
    monitor_event EventCounter EventCounterType air_s_reveal_accepted
        and I_EventCounter air_s_reveal_accepted == 1
        add_money scotland, -10000
        console_command toggle_fow
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
        and I_CompareCounter air_s_reveal_accepted == 1
        and I_LocalFaction scotland
        console_command toggle_fow
        set_event_counter air_s_reveal_accepted 0 
    end_monitor

  13. #13
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Yes/No Event Tutorial

    toggle_fow is a bit iffy: can't say I managed to get it working within a monitor.










  14. #14
    Civis
    Join Date
    Aug 2009
    Location
    Always temporary.
    Posts
    186

    Default Re: Yes/No Event Tutorial

    It is possible to do the command in reverse. I tested by ending turn a few times and the same event option would appear (with the random chance), and when I select 'accept' the FOW comes back (with another 10000 deduction, as it says in the script).

    I noticed something with the second part:

    Code:
    monitor_event FactionTurnStart FactionIsLocal
        and I_EventCounter air_s_reveal_accepted == 1
        and I_LocalFaction scotland
        console_command toggle_fow
        set_event_counter air_s_reveal_accepted 0 
    end_monitor
    This is supposed to 'reverse' the effect, as Im sure you guessed. I experimented with adding an event message to appear and to add money to see if those would trigger. Nothing happened at all with this. In my impression, this part is not triggering at all.

  15. #15
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Yes/No Event Tutorial

    My bad: CompareCounter in the third monitor doesn't work at all with event counters - it needs to be I_EventCounter. I should have noticed that right from the beginning.










  16. #16
    Civis
    Join Date
    Aug 2009
    Location
    Always temporary.
    Posts
    186

    Default Re: Yes/No Event Tutorial

    Oh, no. Not your bad. I already tried to run both EventCounter and CompareCounter. Neither work, the third monitor simply does not fire at all.

  17. #17
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Yes/No Event Tutorial

    The third monitor may not fire because of the timing of the event. Try changing it to FactionTurnEnd. I have also changed the 'local faction' condition a bit.

    Code:
    monitor_event FactionTurnEnd FactionType scotland
        and I_EventCounter air_s_reveal_accepted == 1
        and FactionIsLocal
        console_command toggle_fow
        set_event_counter air_s_reveal_accepted 0 
    end_monitor










  18. #18
    Civis
    Join Date
    Aug 2009
    Location
    Always temporary.
    Posts
    186

    Default Re: Yes/No Event Tutorial

    It worked! I let it run a few times in the same campaign going back and forth, it works solidly so far! Thanks a bunch!
    You might see me here again, I'm gonna be testing some strange scripts to see whatever kind of 'magic effect' I can do. If anything works, I'll post it here for others.

  19. #19
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Yes/No Event Tutorial











Page 5 of 5 FirstFirst 12345

Posting Permissions

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