Results 1 to 11 of 11

Thread: Scripting based on Difficulty and AI/Player

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    tornnight's Avatar Forum Bot
    Join Date
    Dec 2006
    Location
    Virginia, U.S.A.
    Posts
    1,755

    Default Scripting based on Difficulty and AI/Player

    Difficulty Script
    Code:
    declare_counter difficulty
    declare_counter difficulty_easy
    declare_counter difficulty_medium
    declare_counter difficulty_hard
    declare_counter difficulty_very_hard
    declare_counter difficulty_set
     
    monitor_event FactionTurnStart FactionIsLocal
     and I_CompareCounter difficulty_set = 0
     and CampaignDifficulty = easy
     
      set_event_counter difficulty_easy 1
      set_event_counter difficulty_medium 0
      set_event_counter difficulty_hard 0
      set_event_counter difficulty_very_hard 0
     
     set_counter difficulty 1
     set_counter difficulty_set 1
     
     log always Campaign Difficulty: easy
     
     terminate_monitor
    end_monitor
     
    monitor_event FactionTurnStart FactionIsLocal
     and I_CompareCounter difficulty_set = 0
     and CampaignDifficulty = medium
     
      set_event_counter difficulty_easy 0
      set_event_counter difficulty_medium 1
      set_event_counter difficulty_hard 0
      set_event_counter difficulty_very_hard 0
     
     set_counter difficulty 2
     set_counter difficulty_set 1
     
     log always Campaign Difficulty: medium
     
     terminate_monitor
    end_monitor
     
    monitor_event FactionTurnStart FactionIsLocal
     and I_CompareCounter difficulty_set = 0
     and CampaignDifficulty = hard
     
      set_event_counter difficulty_easy 0
      set_event_counter difficulty_medium 0
      set_event_counter difficulty_hard 1
      set_event_counter difficulty_very_hard 0
     
     set_counter difficulty 3
     set_counter difficulty_set 1
     
     log always Campaign Difficulty: hard
     
     terminate_monitor
    end_monitor
     
    monitor_event FactionTurnStart FactionIsLocal
     and I_CompareCounter difficulty_set = 0
     and CampaignDifficulty = very_hard
     
      set_event_counter difficulty_easy 0
      set_event_counter difficulty_medium 0
      set_event_counter difficulty_hard 0
      set_event_counter difficulty_very_hard 1
     
     set_counter difficulty 4
     set_counter difficulty_set 1
     
     log always Campaign Difficulty: very_hard
     
     terminate_monitor
    end_monitor
    AI/Player Script
    Code:
     
    declare_counter local_england
    declare_counter ai_england
     
    monitor_event FactionTurnStart FactionIsLocal
     and FactionType england
     
      set_event_counter local_england 1
      set_event_counter ai_england 0
     
     if not I_HotseatEnabled
      terminate_monitor
     end_if
    
    end_monitor
     
    monitor_event FactionTurnStart not FactionIsLocal
     and FactionType england
     
      set_event_counter local_england 0
      set_event_counter ai_england 1
     
     if not I_HotseatEnabled
      terminate_monitor
     end_if
     
    end_monitor
    You can also add building capabilities specific to a campaign difficulty level and depending on if it's for the AI or player.

    Code:
    income_bonus bonus 200 requires factions { england, } and event_counter local_england 1 and event_counter difficulty_easy 1
     
    income_bonus bonus 400 requires factions { england, } and event_counter ai_england 1 and event_counter difficulty_easy 1
    You can now use the difficulty counter for events that occur during the Local Faction and AI Factions. The CampaignDifficulty condition only works correctly for the Local Faction. It returns medium for AI faction events.

    Code:
    I_CompareCounter difficulty >= 3
    Last edited by tornnight; June 20, 2007 at 09:33 AM. Reason: Correction
    "The first casualty when war comes, is truth." - Hiram Johnson
    Developer of The Long Road Modification

  2. #2

    Default Re: Scripting based on Difficulty and AI/Player

    Very useful! Thanks tornnight.

  3. #3
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Scripting based on Difficulty and AI/Player

    Hey mate,
    Good of you to write this down, I'm using a very similar script but was too lazy to write about it
    What do you think about putting it into the script-o-rama (with due credit of course)? I fear this thread will be buried in a fairly short time (and I'd like to collect such stuff in the script-o-rama anyways).

    No thing is everything. Every thing is nothing.

  4. #4
    tornnight's Avatar Forum Bot
    Join Date
    Dec 2006
    Location
    Virginia, U.S.A.
    Posts
    1,755

    Default Re: Scripting based on Difficulty and AI/Player

    Sure. Thats a good idea.
    "The first casualty when war comes, is truth." - Hiram Johnson
    Developer of The Long Road Modification

  5. #5
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Scripting based on Difficulty and AI/Player

    Quote Originally Posted by tornnight View Post
    Sure. Thats a good idea.
    Ok, thanks. I added it under the how-to section.

    No thing is everything. Every thing is nothing.

  6. #6

    Default Re: Scripting based on Difficulty and AI/Player

    What conditions are permissible in these building requirements? All of them?

  7. #7
    tornnight's Avatar Forum Bot
    Join Date
    Dec 2006
    Location
    Virginia, U.S.A.
    Posts
    1,755

    Default Re: Scripting based on Difficulty and AI/Player

    Quote Originally Posted by Klink View Post
    What conditions are permissible in these building requirements? All of them?
    No in fact it isn't even a subset of the conditions. It's a rather unique set.

    The best place to look is the EDB Guide.

    The only difference is that the event_counter condition has been added for MTW2.
    "The first casualty when war comes, is truth." - Hiram Johnson
    Developer of The Long Road Modification

  8. #8

    Default Re: Scripting based on Difficulty and AI/Player

    ok, thanks.

  9. #9

    Default Re: Scripting based on Difficulty and AI/Player

    Just what i was looking for

  10. #10

    Default Re: Scripting based on Difficulty and AI/Player

    1. "declare_counter local_england" and "declare_counter ai_england" are redundant, as local_england and declare_counter ai_england are event_counters

    2. And here is the "modern" way: all starting monitors terminate when they have nothing to do, best compatibility with Hotseat, can be used for all the factions, less fuss.
    A. Since you can't change campaign difficulty mid-game, Difficulty Script:
    Spoiler Alert, click show to read: 
    Code:
    ; default is medium difficulty
    set_event_counter DifficultyLevel 0
    set_event_counter DifficultyLevel_easy 0
    set_event_counter DifficultyLevel_medium 0
    set_event_counter DifficultyLevel_hard 0
    set_event_counter DifficultyLevel_very_hard 0
    
    while I_EventCounter DifficultyLevel = 0
    
     monitor_event PreFactionTurnStart CampaignDifficulty = easy
    
        set_event_counter DifficultyLevel 1
        set_event_counter DifficultyLevel_easy 1
          terminate_monitor
     end_monitor
    
     monitor_event PreFactionTurnStart CampaignDifficulty = medium
    
        set_event_counter DifficultyLevel 2
        set_event_counter DifficultyLevel_medium 1
        terminate_monitor
     end_monitor
    
     monitor_event PreFactionTurnStart CampaignDifficulty = hard
    
        set_event_counter DifficultyLevel 3
        set_event_counter DifficultyLevel_hard 1
        terminate_monitor
     end_monitor
    
     monitor_event PreFactionTurnStart CampaignDifficulty = very_hard
    
        set_event_counter DifficultyLevel 4 
        set_event_counter DifficultyLevel_very_hard 1
     
        terminate_monitor
     end_monitor 
    
    end_while



    B. AI/Player Script:
    Spoiler Alert, click show to read: 
    Code:
    monitor_event PreFactionTurnStart not IsFactionAIControlled
    
      set_event_counter is_the_ai 0
    
    end_monitor
    
    monitor_event PreFactionTurnStart IsFactionAIControlled
    
      set_event_counter is_the_ai 1
    
    end_monitor


    Then:
    Spoiler Alert, click show to read: 
    Code:
    income_bonus bonus 200 requires factions { england, } and event_counter DifficultyLevel_easy 1 and event_counter is_the_ai 0
     
    income_bonus bonus 400 requires factions { england, } and event_counter DifficultyLevel_easy 1 and event_counter is_the_ai 1
    Last edited by gsthoed; September 04, 2014 at 04:15 PM. Reason: Updated method

  11. #11

    Default Re: Scripting based on Difficulty and AI/Player

    I updated my previous post. With this new method, all "A" monitors are terminated in first PreFactionTurnStart.

Tags for this Thread

Posting Permissions

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