Page 1 of 3 123 LastLast
Results 1 to 20 of 48

Thread: Problem with script

Hybrid View

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

    Default Problem with script

    i've made a script checking transgression of diplomatic stances. It looks like this:
    monitor_event FactionTurnStart FactionType byzantium
    and TargetFactionType bizancjum
    and TransgressionName = TC_DECLARED_WAR
    set_event_counter zdrada_bizancjum_byzantium 1
    end_monitor

    Unfortunately it doesn't work. Log file says that error is in line "and TargetFactionType bizancjum". I checked this line in 3 versions:
    and TargetFactionType bizancjum
    if TargetFactionType bizancjum
    TargetFactionType bizancjum
    No success.

    How to fix this problem?

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

    Default Re: Problem with script

    Probably that FactionTurnStart doesn't export a target faction. Try the Transgression event instead.

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

    Default Re: Problem with script

    Use UpdateAttitude because it's simple and activates around the start of the player's turn.

    And Attyla, mate, check your log when you script! You would have been able to work out that you have to use a different event to be able to export what your conditions need.
    Last edited by Taiji; September 22, 2011 at 07:03 AM.

  4. #4

    Default Re: Problem with script

    Withwnar
    I use it as an event. the TransgressionName is the condition only.

    Taji
    I don't know what UpdateAttitude is and how to use it. How it should look like? I've neve used it before. This way? :
    monitor_event UpdateAttitude FactionType byzantium
    and TargetFactionType bizancjum
    and TransgressionName = TC_DECLARED_WAR
    set_event_counter zdrada_bizancjum_byzantium 1
    end_monitor

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

    Default Re: Problem with script

    Transgression is an event. TransgressionName is a condition.

  6. #6

    Default Re: Problem with script

    Transgression is hardcoded event? It is not just a name of event? I thought it was just a name, so I changed it to something more choose a familiar In my version this is zdrada_bizancjum_byzantium. Especially because I need to know who betrays whom
    Last edited by attyla; September 22, 2011 at 09:20 AM.

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

    Default Re: Problem with script

    It's an event just like FactionTurnStart is. If you don't have a copy of the docudemons then hunt one down: it's priceless.

  8. #8

    Default Re: Problem with script

    OK Withwnar. I get you. I changed my script, but it still doesn't work. This is script i'm talking about:
    monitor_event FactionTurnStart FactionType byzantium
    add_events
    event counter zdrada_bizancjum_byzantium
    event counter serbia_pomoc_byzantium_zgoda
    event counter serbia_pomoc_byzantium_odmowa
    event counter serbia_pomoc_byzantium_uzyskana
    event counter serbia_spokoj
    date 0
    end_add_events
    end_monitor

    monitor_event PreFactionTurnStart FactionType serbia
    set_event_counter zdrada_bizancjum_byzantium 0
    set_event_counter serbia_pomoc_byzantium_zgoda 0
    set_event_counter serbia_pomoc_byzantium_odmowa 0
    set_event_counter serbia_pomoc_byzantium_uzyskana 0
    set_event_counter serbia_spokoj 1
    end_monitor

    ;monitor_event PreFactionTurnStart FactionType byzantium
    ; set_event_counter serbia_pomoc_byzantium_zgoda 0
    ; set_event_counter serbia_pomoc_byzantium_odmowa 0
    ; set_event_counter serbia_pomoc_byzantium_uzyskana 0
    ; set_event_counter serbia_spokoj 1

    ;if I_EventCounter zdrada = 1
    ;and DiplomaticStanceFromFactions serbia = Allied
    ; set_event_counter serbia_pomoc_byzantium_zgoda 1
    ; set_event_counter serbia_pomoc_byzantium_odmowa 1
    ; set_event_counter serbia_pomoc_byzantium_uzyskana 1
    ; set_event_counter serbia_spokoj 0
    ;end_if
    ;end_monitor

    ;monitor_event FactionTurnStart FactionType byzantium
    monitor_event Transgression FactionType byzantium
    and TargetFactionType bizancjum
    and TransgressionName = TC_DECLARED_WAR
    set_event_counter zdrada_bizancjum_byzantium 1
    end_monitor

    monitor_event FactionTurnStart FactionType serbia
    and I_NumberOfSettlements serbia > 0
    and I_NumberOfSettlements byzantium > 0
    and I_EventCounter zdrada_bizancjum_byzantium = 1
    historic_event serbia_pomoc_byzantium true factions { serbia, }
    if I_IsFactionAIControlled serbia
    generate_random_counter serbia_pomoc_byzantium 0 2
    if I_EventCounter serbia_pomoc_byzantium < 2
    set_event_counter serbia_pomoc_byzantium_zgoda 1
    if I_EventCounter serbia_pomoc_byzantium = 2
    set_event_counter serbia_pomoc_byzantium_odmowa 1
    end_if
    end_if
    end_if
    end_monitor

    monitor_conditions I_EventCounter serbia_pomoc_byzantium_zgoda = 1
    and I_NumberOfSettlements bizancjum > 0
    console_command diplomatic_stance serbia bizancjum AtWar
    spawn_army
    faction byzantium
    character random_name, general, age 18, x 363, y 167
    traits Factionleader 1 , GoodCommander 3 , PublicFaith 1 , BattleDread 2 , ReligionStarter 1 , HaleAndHearty 1
    unit Serbian Lancers exp 1 armour 1 weapon_lvl 0
    unit Serbian Lancers exp 1 armour 1 weapon_lvl 0
    unit Dismounted Serbian Lancers exp 1 armour 1 weapon_lvl 0
    unit Dismounted Serbian Lancers exp 1 armour 1 weapon_lvl 0
    end
    terminate_monitor
    end_monitor

    monitor_conditions I_EventCounter serbia_pomoc_byzantium_odmowa = 1
    console_command diplomatic_stance byzantium serbia Neutral
    historic_event serbia_odmowa true factions { byzantium, serbia, }
    terminate_monitor
    end_monitor
    What can be wrong?
    It should cause help of ally or broken pact after after the attack on the local fraction. Bizancjum is an attacked faction which was raised after riot in some byzantiums cities.

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

    Default Re: Problem with script

    Quote Originally Posted by attyla View Post
    This is script i'm talking about:
    ...
    What can be wrong?
    A lot. I'm having trouble following the logic of this script. For one thing, what faction are you playing?

    You have this:
    Code:
     monitor_event FactionTurnStart FactionType serbia
     and I_NumberOfSettlements serbia > 0
     and I_NumberOfSettlements byzantium > 0
     and I_EventCounter zdrada_bizancjum_byzantium = 1
    But prior to that you have this:
    Code:
     monitor_event PreFactionTurnStart FactionType serbia
     set_event_counter zdrada_bizancjum_byzantium 0
    So at turn start you're setting the counter to 0 and then, later in that turn start, testing to see if it is 1. It never will be.

    Also, on a side note, is that spawned army really supposed to be byzantium? From what I can tell it should be serbia.

    EDIT:
    On another side note... this:
    Code:
    generate_random_counter serbia_pomoc_byzantium 0 2
    ...is setting the counter to be a random number between 0 and 2. Is that what you intended? Because there is a 67% chance that serbia_pomoc_byzantium_zgoda will be set to 1 (<2 = 0 or 1) and a 33% chance that serbia_pomoc_byzantium_odmowa will be. If you were aiming for 50/50% then use 1 and 2 instead of 0 and 2.

    EDIT2:
    You have a lot of counters here, some of which are only being used to trigger the monitor_conditions monitors. Avoid monitor_conditions whenever possible.

    The whole thing could be rewritten like this:
    Spoiler Alert, click show to read: 
    Code:
    set_event_counter zdrada_bizancjum_byzantium 0
    
    monitor_event Transgression FactionType byzantium
      and TargetFactionType bizancjum
      and TransgressionName = TC_DECLARED_WAR
      set_event_counter zdrada_bizancjum_byzantium 1
    end_monitor
    
    monitor_event FactionTurnStart FactionType serbia
    
      if I_EventCounter zdrada_bizancjum_byzantium = 1
        
        ;reset so this only happens once per declared-war
        set_event_counter zdrada_bizancjum_byzantium 0
        
        if I_NumberOfSettlements serbia > 0
          and I_NumberOfSettlements byzantium > 0
    
          historic_event serbia_pomoc_byzantium true factions { serbia, }
          
          if I_IsFactionAIControlled serbia
          
            generate_random_counter serbia_pomoc_byzantium 0 2
            
            if I_EventCounter serbia_pomoc_byzantium < 2
              
              if I_NumberOfSettlements bizancjum > 0
                console_command diplomatic_stance serbia bizancjum AtWar
                
                spawn_army
                faction byzantium   ;<-- serbia?
                character random_name, general, age 18, x 363, y 167 
                traits Factionleader 1 , GoodCommander 3 , PublicFaith 1 , BattleDread 2 , ReligionStarter 1 , HaleAndHearty 1 
                unit Serbian Lancers exp 1 armour 1 weapon_lvl 0
                unit Serbian Lancers exp 1 armour 1 weapon_lvl 0
                unit Dismounted Serbian Lancers exp 1 armour 1 weapon_lvl 0
                unit Dismounted Serbian Lancers exp 1 armour 1 weapon_lvl 0
                end
              end_if
            end_if
              
            if I_EventCounter serbia_pomoc_byzantium = 2          
              console_command diplomatic_stance byzantium serbia Neutral
              historic_event serbia_odmowa true factions { byzantium, serbia, }
            end_if
    
          end_if
        end_if
        
      end_if
      
    end_monitor


    Functionally I think it's identical to yours but with fewer counters and monitors. And no monitor_conditions.

    I couldn't tell if all of this is only supposed to happen once. I haven't used terminate_monitor at all here so at the moment it will happen every time that faction attacks the other.

    Oh, and Taiji's suggestion makes sense. But I have never used it so am not sure what implication it would have on the sequence of things.
    Last edited by Withwnar; September 23, 2011 at 07:22 AM.

  10. #10

    Default Re: Problem with script

    i changed my script according to your indication but script still doesn't work (i mean Serbia didn't help or refused ask for help).

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

    Default Re: Problem with script

    Code:
    monitor_event UpdateAttitude FactionType byzantium
    and TargetFactionType bizancjum
    and DiplomaticStanceFactions = AtWar
    set_event_counter zdrada_bizancjum_byzantium 1
    end_monitor
    Like that^

  12. #12

    Icon1 Re: Problem with script

    It is important to realise that if you use an historic event question in your script, for example ‘historic_event serbia_pomoc_byzantium true factions { serbia, }’ the resulting event counters will be named ‘serbia_pomoc_byzantium_accepted’ and ‘serbia_pomoc_byzantium_declined’. When using ‘if’ statements in your script it is important to end each ‘if” statement with an ‘end_if’ before continuing to the next ‘if’ statement.
    Spoiler Alert, click show to read: 
    Code:
    	monitor_event Transgression FactionType byzantium
      		and TargetFactionType bizancjum
      		and TransgressionName = TC_DECLARED_WAR
      		set_event_counter zdrada_bizancjum_byzantium 1
    	end_monitor
    
    	monitor_event FactionTurnStart FactionType serbia
      		and I_EventCounter zdrada_bizancjum_byzantium = 1    
        		and I_NumberOfSettlements serbia > 0
         		and I_NumberOfSettlements byzantium > 0
              	and I_NumberOfSettlements bizancjum > 0
          		if I_IsFactionAIControlled serbia
            	generate_random_counter serbia_supports_byzantium 1 2
            end_if
            	if I_EventCounter serbia_supports_byzantium = 1
       		set_event_counter serbia_pomoc_byzantium_accepted 1
            end_if
            	if I_EventCounter serbia_supports_byzantium = 2
       		set_event_counter serbia_pomoc_byzantium_declined 1
            end_if
    		if I_LocalFaction serbia
          		historic_event serbia_pomoc_byzantium true factions { serbia, }
            end_if
       		set_event_counter zdrada_bizancjum_byzantium 0
       		set_event_counter serbia_supports_byzantium 0
    	end_monitor
    
    	monitor_conditions I_EventCounter serbia_pomoc_byzantium_accepted = 1
    		set_faction_standing serbia byzantium 1.0
    		set_faction_standing serbia bizancjum -1.0
               	console_command diplomatic_stance serbia byzantium allied
               	console_command diplomatic_stance serbia bizancjum AtWar
            spawn_army
                	faction byzantium
                	character	random_name, named character, age 18, x 363, y 167 
                	traits Factionleader 1 , GoodCommander 3 , PublicFaith 1 , BattleDread 2 , ReligionStarter 1 , HaleAndHearty 1 
                	unit	Serbian Lancers		exp 1 armour 1 weapon_lvl 0
                	unit	Serbian Lancers		exp 1 armour 1 weapon_lvl 0
                	unit	Dismounted Serbian Lancers		exp 1 armour 1 weapon_lvl 0
                	unit	Dismounted Serbian Lancers		exp 1 armour 1 weapon_lvl 0
            end
       		set_event_counter serbia_pomoc_byzantium_accepted 0
    	end_monitor
    
    	monitor_conditions I_EventCounter serbia_pomoc_byzantium_declined = 1       
              	console_command diplomatic_stance byzantium serbia Neutral
    		set_faction_standing serbia byzantium -0.5
             	historic_event serbia_odmowa factions { byzantium, serbia, }    
       		set_event_counter serbia_pomoc_byzantium_declined 0
    	end_monitor

  13. #13

    Default Re: Problem with script

    It must be something else. It doesn't work. Maybe it's a matter of that that TC_DECLARED_WAR doesn't contains war that is an effect of rebelling.

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

    Default Re: Problem with script

    I'm really confused.

    It should cause help of ally or broken pact after after the attack on the local fraction. Bizancjum is an attacked faction which was raised after riot in some byzantiums cities.
    So Bizancjum is an emerging faction after a Byzantium city rebels?

    If so: are these two factions already at war when the emerging happens?

    But if they're emerging then how can they be the local faction?

    EDIT:
    Okay, assuming that it's the Transgression monitor not firing, try this instead:

    Code:
    monitor_event Transgression FactionType byzantium
      and TargetFactionType bizancjum
      and TransgressionName = TC_DECLARED_WAR
      set_event_counter zdrada_bizancjum_byzantium 1
    end_monitor
    
    monitor_event FactionTurnStart FactionType byzantium
      and DiplomaticStanceFromFaction bizancjum = AtWar
       set_event_counter zdrada_bizancjum_byzantium 1
    end_monitor
    As it is it will fire every turn that these two factions are at war, so you'd need to add something to stop that happening. But it's a start.

    Also, depending on which faction has their turn start first this might not work until the following turn (2 end turns).
    Last edited by Withwnar; September 25, 2011 at 12:57 AM.

  15. #15

    Default Re: Problem with script

    So Bizancjum is an emerging faction after a Byzantium city rebels?
    yes it is. bizancjum is a faction shadowed by byzantium (infact bizantium is rebelled version of byzantium )

    i woul like to ask for onother thing: where can i find the description of this?:
    TC_BLOCKADE
    TC_ATTACKING_CRUSADING_GENERAL
    TC_INVADED_FORT
    TC_STOLE_BACK_SETTLEMENT
    TC_INVADED_SETTLEMENT
    TC_INVADED_WATCHTOWER
    TC_INVASION
    TC_FLEE_INVASION
    TC_CRUSADE_INVASION
    TC_NULLIFIED_ALLIANCE
    TC_BROKE_TREATY_TERMS
    TC_DIPLOMATIC_INSULT
    TC_DISHONOUR
    TC_DECLARED_WAR
    TC_MAJOR_ASSASSINATION_ATTEMPT
    TC_MINOR_ASSASSINATION_ATTEMPT
    TC_SABOTAGE
    TC_BRIBED_AWAY_ARMY
    TC_BRIBED_AWAY_CHARACTER
    TC_BRIBED_AWAY_SETTLEMENT
    TC_BRIBED_AWAY_FORT
    TC_BATTLE_ENGAGEMENT
    TC_INSTIGATE_SIEGE
    TC_SPYING
    TC_THREATEN_WAR
    TC_UNDECLARED_ATTACK
    TC_UNDECLARED_ATTACK_WITHDRAW
    TC_INSTIGATE_ASSAULT
    TC_BLOCKADE
    TC_BROKE_ALLIANCE

  16. #16

    Default Re: Problem with script

    And one more question:
    what to do to the script was executed, for example 2 rounds after doing the conditions?

  17. #17

    Default Re: Problem with script

    I have weird problem. This time is a matter of number of similar scripts. If i have one script all works fine. If i'll duplicate this script it doesn't work and the log file says nothing. So i would like to ask for checking this script. I did it some times, but i found nothing...

    bla
    ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    ;XXXXXXXXx BYZANTIUM XXXXXXXXXXX
    ;XXXXXXXXx BIZANCJUM XXXXXXXXXXX
    ;XXXXXXXXXxx SERBIA xXXXXXXXXXXX
    ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    monitor_event FactionTurnStart FactionType byzantium
    and DiplomaticStanceFromFaction bizancjum = AtWar
    set_event_counter zdrada_bizancjum_byzantium 1
    end_monitor

    monitor_event FactionTurnStart FactionType serbia
    and I_EventCounter zdrada_bizancjum_byzantium = 1
    and I_NumberOfSettlements serbia > 0
    and I_NumberOfSettlements byzantium > 0
    and I_NumberOfSettlements bizancjum > 0
    if I_IsFactionAIControlled serbia
    generate_random_counter serbia_supports_byzantium 1 2
    end_if
    if I_EventCounter serbia_supports_byzantium = 1
    set_event_counter serbia_pomoc_byzantium_accepted 1
    end_if
    if I_EventCounter serbia_supports_byzantium = 2
    set_event_counter serbia_pomoc_byzantium_declined 1
    end_if
    if I_LocalFaction serbia
    historic_event serbia_pomoc_byzantium true factions { serbia, }
    end_if
    set_event_counter zdrada_bizancjum_byzantium 0
    set_event_counter serbia_supports_byzantium 0
    end_monitor

    monitor_conditions I_EventCounter serbia_pomoc_byzantium_accepted = 1
    set_faction_standing serbia byzantium 1.0
    set_faction_standing serbia bizancjum -1.0
    console_command diplomatic_stance serbia byzantium allied
    generate_random_counter serbia_wsparcie_byzantium 1 3
    if I_EventCounter serbia_wsparcie_byzantium = 1
    console_command diplomatic_stance serbia bizancjum AtWar
    add_money byzantium 3000
    historic_event byzantium_serbia_pomoc_udzielona_1 true factions { byzantium, serbia, }
    end_if
    if I_EventCounter serbia_wsparcie_byzantium = 2
    spawn_army
    faction byzantium
    character random_name, general, age 18, x 325, y 153
    unit Serbian Lancers exp 0 armour 0 weapon_lvl 0
    unit Dismounted Serbian Lancers exp 0 armour 0 weapon_lvl 0
    end
    historic_event byzantium_serbia_pomoc_udzielona_2 true factions { byzantium, serbia, }
    add_money byzantium 2000
    end_if
    if I_EventCounter serbia_wsparcie_byzantium = 3
    spawn_army
    faction byzantium
    character random_name, general, age 18, x 325, y 153
    unit Serbian Lancers exp 0 armour 0 weapon_lvl 0
    unit Dismounted Serbian Lancers exp 0 armour 0 weapon_lvl 0
    end

    console_command diplomatic_stance serbia bizancjum AtWar
    add_money byzantium 1000
    historic_event byzantium_serbia_pomoc_udzielona_1 true factions { byzantium, serbia, }
    end_if
    set_event_counter serbia_pomoc_byzantium_accepted 0
    end_monitor

    monitor_conditions I_EventCounter serbia_pomoc_byzantium_declined = 1
    console_command diplomatic_stance byzantium serbia Neutral
    set_faction_standing serbia byzantium -0.5
    historic_event serbia_odmowa factions { byzantium, serbia, }
    set_event_counter serbia_pomoc_byzantium_declined 0
    end_monitor

    ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    ;XXXXXXXXx BYZANTIUM XXXXXXXXXXX
    ;XXXXXXXXx BIZANCJUM XXXXXXXXXXX
    ;XXXXXXXXXxx Gruzja xXXXXXXXXXXX
    ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    monitor_event FactionTurnStart FactionType byzantium
    and DiplomaticStanceFromFaction bizancjum = AtWar
    set_event_counter zdrada_bizancjum_byzantium 1
    end_monitor

    monitor_event FactionTurnStart FactionType saxons
    and I_EventCounter zdrada_bizancjum_byzantium = 1
    and I_NumberOfSettlements saxons > 0
    and I_NumberOfSettlements byzantium > 0
    and I_NumberOfSettlements bizancjum > 0
    if I_IsFactionAIControlled saxons
    generate_random_counter saxons_supports_byzantium 1 2
    end_if
    if I_EventCounter saxons_supports_byzantium = 1
    set_event_counter saxons_pomoc_byzantium_accepted 1
    end_if
    if I_EventCounter saxons_supports_byzantium = 2
    set_event_counter saxons_pomoc_byzantium_declined 1
    end_if
    if I_LocalFaction saxons
    historic_event saxons_pomoc_byzantium true factions { saxons, }
    end_if
    set_event_counter zdrada_bizancjum_byzantium 0
    set_event_counter saxons_supports_byzantium 0
    end_monitor

    monitor_conditions I_EventCounter saxons_pomoc_byzantium_accepted = 1
    set_faction_standing saxons byzantium 1.0
    set_faction_standing saxons bizancjum -1.0
    console_command diplomatic_stance saxons byzantium allied
    generate_random_counter saxons_wsparcie_byzantium 1 3
    if I_EventCounter saxons_wsparcie_byzantium = 1
    console_command diplomatic_stance saxons bizancjum AtWar
    add_money byzantium 3000
    historic_event byzantium_saxons_pomoc_udzielona_1 true factions { byzantium, saxons, }
    end_if
    if I_EventCounter saxons_wsparcie_byzantium = 2
    spawn_army
    character random_name, general, age 18, x 378, y 159
    unit georgian medium lancers exp 0 armour 0 weapon_lvl 0
    unit dismounted georgian medium lancers exp 0 armour 0 weapon_lvl 0
    end

    add_money byzantium 2000
    historic_event byzantium_saxons_pomoc_udzielona_2 true factions { byzantium, saxons, }
    end_if
    if I_EventCounter saxons_wsparcie_byzantium = 3
    spawn_army
    character random_name, general, age 18, x 378, y 159
    unit georgian medium lancers exp 0 armour 0 weapon_lvl 0
    unit dismounted georgian medium lancers exp 0 armour 0 weapon_lvl 0
    end

    console_command diplomatic_stance saxons bizancjum AtWar
    add_money byzantium 1000
    historic_event byzantium_saxons_pomoc_udzielona_1 true factions { byzantium, saxons, }
    end_if
    set_event_counter saxons_pomoc_byzantium_accepted 0
    end_monitor

    monitor_conditions I_EventCounter saxons_pomoc_byzantium_declined = 1
    console_command diplomatic_stance byzantium saxons Neutral
    set_faction_standing saxons byzantium -0.5
    historic_event saxons_odmowa factions { byzantium, saxons, }
    set_event_counter saxons_pomoc_byzantium_declined 0
    end_monitor

  18. #18

    Default Re: Problem with script

    OK i know now what's going on I shouldn't add
    monitor_event FactionTurnStart FactionType byzantium
    and DiplomaticStanceFromFaction bizancjum = AtWar
    set_event_counter zdrada_bizancjum_byzantium 1
    end_monitor
    in start of each script.

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

    Default Re: Problem with script

    I assume you're playing as Hungary? It might be this...

    (By the way, thanks for putting it in a CODE tag. Much easier to read. )

    This is your script:

    Code:
    monitor_event FactionTurnStart FactionType hungary 
      and DiplomaticStanceFromFaction byzantium = Allied 
      and I_EventCounter zdrada_bizancjum_byzantium = 1     
      and I_NumberOfSettlements hungary > 0 
      and I_NumberOfSettlements byzantium > 0 
      and I_NumberOfSettlements bizancjum > 0 
    
      if I_IsFactionAIControlled hungary 
        generate_random_counter hungary_supports_byzantium 1 2 
      end_if 
      
      if I_EventCounter hungary_supports_byzantium = 1 
        set_event_counter hungary_pomoc_byzantium_accepted 1 
      end_if 
      
      if I_EventCounter hungary_supports_byzantium = 2 
        set_event_counter hungary_pomoc_byzantium_declined 1 
      end_if 
      
      if I_LocalFaction hungary 
        historic_event hungary_pomoc_byzantium true factions { hungary, } 
      end_if 
      
      set_event_counter zdrada_bizancjum_byzantium 0 
      set_event_counter hungary_supports_byzantium 0 
    end_monitor
    You're only setting the hungary_supports_byzantium counter when it's the AI (red). That's fine but the blue and green bits are not in the is-the-AI IF block, so they're trying to read that counter value which has not been set (because it is not an AI Hungary).

    In fact, the counter has not even been created because the bit that is creating it is in the red block. If you try to compare a value (using I_EventCounter) of a counter that has not been created then it just comes out as TRUE. i.e. Both the blue and green I_EventCounter tests are returning TRUE which means that both hungary_pomoc_byzantium_accepted and hungary_pomoc_byzantium_declined are being set to 1.

    Try this...

    Code:
    monitor_event FactionTurnStart FactionType hungary 
      and DiplomaticStanceFromFaction byzantium = Allied 
      and I_EventCounter zdrada_bizancjum_byzantium = 1     
      and I_NumberOfSettlements hungary > 0 
      and I_NumberOfSettlements byzantium > 0 
      and I_NumberOfSettlements bizancjum > 0 
    
      if I_IsFactionAIControlled hungary 
        generate_random_counter hungary_supports_byzantium 1 2 
    
        if I_EventCounter hungary_supports_byzantium = 1 
          set_event_counter hungary_pomoc_byzantium_accepted 1 
        end_if 
      
        if I_EventCounter hungary_supports_byzantium = 2 
          set_event_counter hungary_pomoc_byzantium_declined 1 
        end_if 
      
      end_if 
      
      if I_LocalFaction hungary 
        historic_event hungary_pomoc_byzantium true factions { hungary, } 
      end_if 
      
      set_event_counter zdrada_bizancjum_byzantium 0 
      set_event_counter hungary_supports_byzantium 0 
    end_monitor
    Hint: indenting like this makes it much easier to spot this kind of mistake.
    Last edited by Withwnar; September 28, 2011 at 11:05 AM.

  20. #20

    Default Re: Problem with script

    it seems it works fine now. I really have no idea how did you find this bug... It's beyond my capabilities...

Page 1 of 3 123 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
  •