Results 1 to 4 of 4

Thread: Why is this monitor so sensitive to removing comments?

Hybrid View

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

    Default Why is this monitor so sensitive to removing comments?

    EDIT AFTERWARDS: Below is lots of irrelevant text by myself - a result of serious misunderstanding. Nothing sensitive in the monitor. I recommend that you don't spend time trying to figure out this. Instead take a look at this.

    Hello guys. Now I have a really strange one, hope someone can provide an explanation and help. I'm trying to create a monitor that under certain conditions takes an enemy city (here "Roxoland"), spawns there a character "John" and gives him certain traits based on some values stored in counters B, C and D (in this example below only B is relevant) + some ancillaries. Player also gets an advisor message to inform of the event and the camera moves to show Roxoland. The script also contains a spy named "Indicatorspy" that is used to store certain data. He is not really relevant here.

    I got the script working ok. When the city is taken, John appears on top of it with ancillaries 1 and 2 and traitA (these given by the first monitor) and some level of trait B (given by the second monitor). Then I cleaned the script a bit and removed unnecessary comments (here the rows regarding counter 4 and counter 10). And kaboom! the script stopped functioning correctly. Now he would get only the ancillaries and trait given by the first monitor, but trait B is completely absent! I tested multiple times and the only way I can get it back to work is to put the two commented rows back. I still have a gut feeling that it has something to do with the timing of this monitor, as these spawn army monitors seem to be somehow sensitive to errors.

    Why does this happen? Does the monitor have "too many things happening" and would it need instead some wait command?

    Two monitors below. The whole does not function when red rows are deleted. (Haven't tried if one of them would be enough)

    Code:
    monitor_event FactionTurnStart FactionType romans_scipii
        and FactionIsLocal
        and I_CompareCounter counter1 = 4
        and I_CompareCounter counter2 = 1
        and RandomPercent < 5
                advance_advice_thread PromptThreadSuccessThread 1
                set_counter counter3 0
    ;            set_counter counter4 0
                set_counter counter5 0
                set_counter counter6 1
                set_counter counter7 0
                set_counter counter8 0
                set_counter counter9 1
    ;            set_counter counter10 1
                set_counter counter_A 1
                console_command capture_settlement Roxoland
                    spawn_army 
                    faction romans_scipii
                    character John, named character, command 5, influence 0, management 0, subterfuge 0, age 20, , x 216, y 124 
                    unit new superior cavalry, soldiers 10 exp 1 armour 0 weapon_lvl 0
                    end
                console_command give_ancillary John ancillary1
                console_command give_ancillary John ancillary2
                console_command give_trait John traitA 1    
                console_command kill_character "Indicatorspy"        ; a spy that is used to store some game data as traits
                spawn_character romans_scipii Indicatorspy, spy, command 0, influence 0, management 0, subterfuge 0, age 20, , x 254, y 154
                console_command give_ancillary Indicatorspy thisisindicatorspy
                set_counter indicator_a 1
                set_counter indicator_b 1
                 move_strat_camera 216,124
    end_monitor
    
    (Several other monitors removed between these)
    
    monitor_event FactionTurnStart FactionType romans_scipii
            and I_CompareCounter counter_A = 1
                if I_CompareCounter counter_B = 1
                    console_command give_trait John Trait_B 1
                end_if
                if I_CompareCounter counter_B = 2
                    console_command give_trait John Trait_B 2
                end_if
                if I_CompareCounter counter_B = 3
                    console_command give_trait John Trait_B 3
                end_if
                ...
                (removed a long list of similar conditions connected to counter_B, counter_C and counter_D) 
                ...
            set_counter counter_A 0
    end_monitor
    Name John is not available to other factions and Trait_B levels + text file should be ok. BI 1.6 in use.

    EDITED a bit later: OK, now it gets really strange. I thought to try which of the comments is the decisive one. Removed first one and it still functioned ok. Then removed the second and in a way hoped that it would stop functioning (because then I would know the location of problem), but no no no! Now it works without the two commented rows completely fine!
    I cannot be happy for this, however, since now I know that the functioning seems to be unreliable and I don't know the reason why it sometimes works and sometimes not. Any ideas?
    Last edited by chrisb; January 19, 2012 at 12:11 PM.

  2. #2

    Default Re: Why is this monitor so sensitive to removing comments?

    A further question that may be relevant here. I am trying at the same time to spawn a supportive army for John, lead by James. It is spawn when counters 8 and 9 have value 1. Counter 9 gets the value with the previous monitor and counter 8 is set to 1 elsewhere. But for some reason the following does not work. James is not there (north of Roxoland) although John is in Roxoland.

    Code:
    monitor_event FactionTurnEnd FactionType romans_scipii
        and FactionIsLocal
        and I_CompareCounter counter8 = 1
        and I_CompareCounter counter9 = 1
                        spawn_army 
                        faction romans_scipii
                        character James, named character, command 5, influence 0, management 0, subterfuge 0, age 20, , x 216, y 126 
                        unit        new general bodyguard early,                        soldiers 20 exp 5 armour 0 weapon_lvl 0
                        unit        new cavalry elite,                soldiers 80 exp 5 armour 0 weapon_lvl 0
                        end
            set_counter counter9 0
            set_counter counter8 0
    end_monitor
    Any ideas why this doesn't work?

    EDITED: I guess I presented a bit fuzzy question yesterday and I'm not surprised that no-one has responded. I've had some further thoughts myself, but since they are more general in nature, I'll put them into another thread. I would be happy though if someone would check the spawn army script here and say if there is something wrong with it.

    EDITED AGAIN: Got the spawn army part working ok. I noticed that counter 9 had been (erratically) set to 0 in an earlier monitor... embarassing. But would still like to understand more about the order of monitors, see above.
    Last edited by chrisb; January 14, 2012 at 06:17 PM.

  3. #3
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Why is this monitor so sensitive to removing comments?

    I'm not sure why you need the 2nd monitor to check for FactionTurnStart. Why not use monitor_conditions I_CompareCounter counter_A = 1 instead? And, is there a reason why you want to put code to be in a separate monitor? Do you have more than 1 place where you're setting counter_A to 1?
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  4. #4

    Default Re: Why is this monitor so sensitive to removing comments?

    Quote Originally Posted by HouseOfHam View Post
    I'm not sure why you need the 2nd monitor to check for FactionTurnStart. Why not use monitor_conditions I_CompareCounter counter_A = 1 instead? And, is there a reason why you want to put code to be in a separate monitor? Do you have more than 1 place where you're setting counter_A to 1?
    Actually, I'm using it primarily because I'm so noob in scripting that I cannot yet use monitor_conditions. Will have to learn that as well. But on the other hand, this was just an example and yes, there could be other places too where counter_A is set to 1. Hence two different monitors, although it would probably be better with one monitor_event and one monitor_conditions.

    By the way, does anyone mind if I remove substantial parts of the first and second message. Since they were a result of my own misunderstanding...

    But this one would still be very cool to understand better.
    Last edited by chrisb; January 16, 2012 at 09:09 AM.

Posting Permissions

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