Results 1 to 19 of 19

Thread: Script Help

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Moneybags14's Avatar Ordinarius
    Join Date
    May 2010
    Location
    United States
    Posts
    709

    Default Script Help

    Hello all,

    Here is the piece of coding I am trying to get to work in my mod. But I am having a problem with it firing. I even made sure the code should fire but alas, it does not. Maybe I am doing something wrong? Any help would be appreciated.

    Code:
     
    monitor_event PreFactionTurnStart Not FactionIsLocal
     
    if I_NumberOfSettlements sicily < 13
    and Treasury > 5500
    historic_event test
    end_if
     
    end_monitor

  2. #2

    Default Re: Script Help

    just a random thought... try not as opposed to Not.

    Also, r u certain that sicily has more than 5500 in their treasury during their turn?

    the Condition Treasury is not meant to be inside an if statement. But some conditions will still work inside if statements, they have to correspond to the monitor event and not the if statement. Conditions you should use inside an if statement begin with I_... such as I_LocalFaction... and the condition Treasury requires a faction as a trigger... and it will call it from the monitor event... and you have not specified a faction... until the if statement... if statements do not act as triggers...

    You will want to rewrite it for each faction. with the faction in the monitor event...

    try somthign like

    monitor_event PreFactionTurnStart FactionName sicily
    and not FactionIsLocal
    and Treasury > 5500

    if I_NumberOfSettlements sicily < 13
    historic_event test
    end_if

    end_monitor

    I donot have my docudemons open but somehting liek that may work...

    Whenever you select an EVENT from the evetns list check the trigger requirements. Any Condition you use in this event will need the trigger in the conditions PARAMETERS. The condition just needs one of the triggers... Even then, you may find some combinations still dont work... But generally they will make sense... With this in mind, every condition you use in the monitor MUST have the SAME trigger/parameters in common. You can not mix and match...

    hope that is helpful
    ...longbows, in skilled hands, could reach further than trebuchets...

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

    Default Re: Script Help

    Quote Originally Posted by Tsarsies View Post
    ... some conditions will still work inside if statements, they have to correspond to the monitor event and not the if statement. Conditions you should use inside an if statement begin with I_... such as I_LocalFaction...
    You can use any condition in an IF statement so long as as the condition doesn't have any trigger requirements. As far as I know this limits it to these: I_xxx, IsFactionAIControlled, IsNightBattle, RandomPercent, TrueCondition.

    Also, according to the docudemons, these:
    LosingMoney (really? wouldn't this need a faction?)
    MissionSucceeded (? what mission?)

  4. #4

    Default Re: Script Help

    correct, there are some conditions that do not have a trigger requirement, such as I_XXX and the ones you stated. But as i said, some combinations either just don't make sense or don't work, even when everything else says it should...

    And in my previous post i meant Trigger Requirements, not Parameter...
    ...longbows, in skilled hands, could reach further than trebuchets...

  5. #5
    Moneybags14's Avatar Ordinarius
    Join Date
    May 2010
    Location
    United States
    Posts
    709

    Default Re: Script Help

    Thanks for the quick responses you two!

    I will try your suggestions tomorrow as it is late.

    Also, I loathe having to write a monitor for every faction since I am trying to have multiple treasury conditions... But it might come down too it.

  6. #6
    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: Script Help











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

    Default Re: Script Help

    Quote Originally Posted by Gigantus View Post
    Highly recommended.

  8. #8
    Moneybags14's Avatar Ordinarius
    Join Date
    May 2010
    Location
    United States
    Posts
    709

    Default Re: Script Help

    Thanks but the reason why I don't want to write that many monitors is because of game performance

    I was told that monitors create more "lag" then if everything was contained inside 1 monitor. Am I wrong? Because I will need about 10 monitors per faction if I cannot put it all inside 1 monitor.

    I am highly engineering my personal mod's economic/recruiting system for the AI which is the reason for checking their treasury/# of settlements.
    Last edited by Moneybags14; November 10, 2011 at 10:57 AM.

  9. #9
    Moneybags14's Avatar Ordinarius
    Join Date
    May 2010
    Location
    United States
    Posts
    709

    Default Re: Script Help

    EDIT: Double Post...
    Last edited by Moneybags14; November 10, 2011 at 10:58 AM. Reason: Double Posted

  10. #10

    Icon1 Re: Script Help

    Moneybags14: Here is a slightly different approach, which I think would get you what you want:
    Spoiler Alert, click show to read: 
    Code:
    declare_counter sicily_treasury_up
    
    	monitor_event FactionTurnEnd FactionType sicily
    		and IsFactionAIControlled
    		and Treasury > 5500
       		set_counter sicily_treasury_up 1
    	end_monitor
    
    	monitor_event FactionTurnStart FactionIsLocal
    		and I_CompareCounter sicily_treasury_up = 1
    		if I_NumberOfSettlements sicily <= 13
    		historic_event test_a
    	end_if
     		if I_NumberOfSettlements sicily > 13
    		historic_event test_b
    	end_if
       		set_counter sicily_treasury_up 0
    	end_monitor
    The majority of the script would be executed during the local faction’s turn, thereby minimise any possible time lag.

  11. #11

    Default Re: Script Help

    And most turn lag comes from events that monitor characters...

    A mod that has the region limit (199) and faction limit (31) will naturally have more lag than one with far less regions and settlements. From all my testing however, A monitor event itself does not really drag the end turn, unless the script is 'bulky' or tracking characters. by bulky i mean a monitor event with many conditions and if statements.

    And as TNZ stated, scripts firing during the players turn any lag they would normally provide you wont notice...
    ...longbows, in skilled hands, could reach further than trebuchets...

  12. #12
    Moneybags14's Avatar Ordinarius
    Join Date
    May 2010
    Location
    United States
    Posts
    709

    Default Re: Script Help

    Hmmm, well I ended up writing a monitor for every single condition because I could not get any workaround to work. The thing is I can't have the script run while it is the players turn because the command is to dictate what the AI can do for every single faction.

    I have edited the AI's behavior heavily so I was sure to run into some things that I didn't necessarily want to do... :/

    This script is to help the AI spend more money on buildings instead of stack spam and thus having economy later on. I have eliminated all money scripts and the AI seems to act more "human" although it is far from perfect(eg. the rebelling cities problem I have..)

    Here is the script for one faction

    Spoiler Alert, click show to read: 

    Code:
    monitor_event PreFactionTurnStart FactionType byzantium
    and not FactionIsLocal
     if I_EventCounter Allow_Recruiting = 1
      set_event_counter Allow_Recruiting 0
     end_if
    end_monitor
    monitor_event PreFactionTurnStart FactionType byzantium
    and not FactionIsLocal
    and Treasury > 5500
    and I_NumberOfSettlements byzantium < 3
     set_event_counter Allow_Recruiting 1
    end_monitor
    monitor_event PreFactionTurnStart FactionType byzantium
    and not FactionIsLocal
    and Treasury > 6000
    and I_NumberOfSettlements byzantium = 3
     set_event_counter Allow_Recruiting 1
    end_monitor
    monitor_event PreFactionTurnStart FactionType byzantium
    and not FactionIsLocal
    and Treasury > 6500
    and I_NumberOfSettlements byzantium = 4
     set_event_counter Allow_Recruiting 1
    end_monitor
    monitor_event PreFactionTurnStart FactionType byzantium
    and not FactionIsLocal
    and Treasury > 7000
    and I_NumberOfSettlements byzantium = 5
     set_event_counter Allow_Recruiting 1
    end_monitor
    monitor_event PreFactionTurnStart FactionType byzantium
    and not FactionIsLocal
    and Treasury > 7500
    and I_NumberOfSettlements byzantium = 6
     set_event_counter Allow_Recruiting 1
    end_monitor
    monitor_event PreFactionTurnStart FactionType byzantium
    and not FactionIsLocal
    and Treasury > 8000
    and I_NumberOfSettlements byzantium = 7
     set_event_counter Allow_Recruiting 1
    end_monitor
    monitor_event PreFactionTurnStart FactionType byzantium
    and not FactionIsLocal
    and Treasury > 8500
    and I_NumberOfSettlements byzantium = 8
     set_event_counter Allow_Recruiting 1
    end_monitor
    monitor_event PreFactionTurnStart FactionType byzantium
    and not FactionIsLocal
    and Treasury > 9000
    and I_NumberOfSettlements byzantium = 9
     set_event_counter Allow_Recruiting 1
    end_monitor
    monitor_event PreFactionTurnStart FactionType byzantium
    and not FactionIsLocal
    and Treasury > 10000
    and I_NumberOfSettlements byzantium > 11
     set_event_counter Allow_Recruiting 1
    end_monitor

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

    Default Re: Script Help

    I wonder if you could do away with the "faction" condition altogether?

    i.e. Remove the FactionType condition. That way all factions will use the same monitors and you don't need to replicate all of this for each faction.

    And possibly replace that first monitor with just this...
    Code:
    monitor_event PreFactionTurnStart 
     set_event_counter Allow_Recruiting 0
    end_monitor
    This will ensure that Allow_Recruiting=0 for the local faction's turn.

    EDIT: oh, no, sorry that won't work (the faction-removal bit) because that specific faction is still being used within the monitors.

    Okay, how about this...

    Code:
    monitor_event PreFactionTurnStart 
      set_event_counter Allow_Recruiting 0
      set_event_counter treasury_check 0
    end_monitor
    
    monitor_event PreFactionTurnStart 
      and not FactionIsLocal
      and Treasury > 5500
      set_event_counter treasury_check 5500
    end_monitor
    
    monitor_event PreFactionTurnStart 
      and not FactionIsLocal
      and Treasury > 6000
      set_event_counter treasury_check 6000
    end_monitor
    
    ... 
    
    monitor_event PreFactionTurnStart 
      and not FactionIsLocal
      and Treasury > 10000
      set_event_counter treasury_check 10000
    end_monitor
    
    monitor_event PreFactionTurnStart FactionType byzantium
      and not FactionIsLocal
    
      if I_EventCounter treasury_check = 5500
        and I_NumberOfSettlements byzantium < 3
        set_event_counter Allow_Recruiting 1
      end_if
      if I_EventCounter treasury_check = 6000
        and I_NumberOfSettlements byzantium = 3
        set_event_counter Allow_Recruiting 1
      end_if
    
      ...
    
      if I_EventCounter treasury_check = 10000
        and I_NumberOfSettlements byzantium > 11
        set_event_counter Allow_Recruiting 1
      end_if
    
    end_monitor
    The only monitor that would need to be duplicated is the last one, changing the faction name.

    I don't know if it would be any faster but it would be easier to write... less duplication.
    Last edited by Withwnar; November 11, 2011 at 12:50 AM.

  14. #14
    Moneybags14's Avatar Ordinarius
    Join Date
    May 2010
    Location
    United States
    Posts
    709

    Default Re: Script Help

    Hmmmm, that is definately a good idea Withwnar! Would definately reduce the monitors needed as I would add about 10 per faction with my barbaric method...

    I will try it out tomorrow because I am tired of looking at code for tonight

    Edit: I can't rep you because I gotta "spread it around" :/ booooooo haha

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

    Default Re: Script Help

    No worries mate.

    Less monitors, yes, but whether there are now more IFs and condition checks in total per turn I don't know.

  16. #16
    Moneybags14's Avatar Ordinarius
    Join Date
    May 2010
    Location
    United States
    Posts
    709

    Default Re: Script Help

    Actually, the total monitors would be about the same, and there would be even more "if" statements. So I'm not sure if this would help out turn performance.

    EDIT: I am having problems with your script even working Withwnar. I think there has to be something after PreFactionTurnStart
    Last edited by Moneybags14; November 11, 2011 at 08:17 PM. Reason: Problems with Script

  17. #17
    Moneybags14's Avatar Ordinarius
    Join Date
    May 2010
    Location
    United States
    Posts
    709

    Default Re: Script Help

    Ok I got it to work Withwnar. I had to modify your version of it.

    Here it is.

    Code:
    monitor_event PreFactionTurnStart
      campaign_wait 0.5
      set_event_counter Allow_Recruiting 0
      set_event_counter treasury_check 0
    end_monitor
    monitor_event PreFactionTurnStart not FactionIsLocal
    and Treasury > 5500
     set_event_counter treasury_check 5500
    end_monitor
    monitor_event PreFactionTurnStart not FactionIsLocal
    and Treasury > 6000
     set_event_counter treasury_check 6000
    end_monitor

    The bolded parts had to be put in the monitor line or else the script fails.

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

    Default Re: Script Help

    Oh yeah. I was bit hasty on my editing there.

    Actually, the total monitors would be about the same
    If you have, say, 20 factions then:
    Your way you would have 180 monitors (9 x 20).
    Mine you would have 30 monitors (10 + 20).

    Only the last one needs to be duplicated per faction.

  19. #19
    Moneybags14's Avatar Ordinarius
    Join Date
    May 2010
    Location
    United States
    Posts
    709

    Default Re: Script Help

    Its ok.
    happens!

    And yea your way has about 10% of the monitors compared to mine I looked at it real quick on my phone and I was confused haha.

    But yea I finally got it to work and have no problems so far. Now I can hunt down those mystery CTD's which are pissing me off...

Posting Permissions

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