Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: Allowing AI to recruit exclusive units

Hybrid View

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

    Default Allowing AI to recruit exclusive units

    Is it possible to allow the AI to recruit certain units? I am making my own pike and musket mod, and teh annoying thing about the AIs musket and missle units in general, is that it likes to move them into 60-70% range before deploying to shoot. A way around this I have thought is to give AI units that have 30% more range that are not recruitable by the player.

  2. #2

    Icon1 Re: Allowing AI to recruit exclusive units

    Squatlover: Yes. But you would need to do this:

    Code:
    campaign_script:
    
    ;###### AI Faction Recruit Pool #######
    
    	monitor_event PreFactionTurnStart FactionIsLocal
    		set_event_counter is_ai_faction 0
    	end_monitor
    
    	monitor_event PreFactionTurnStart not FactionIsLocal
    		set_event_counter is_ai_faction 1
    	end_monitor
    
    export_descr_buildings:
    
    recruit_pool "Musket Militia"  1   0.15   2  0  requires factions { england, } and event_counter is_ai_faction 0
    
    recruit_pool "Ai Musket Militia"  1   0.15   2  0  requires factions { england, } and event_counter is_ai_faction 1
    Last edited by TNZ; September 02, 2010 at 01:16 AM.

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

    Default Re: Allowing AI to recruit exclusive units

    To save the event counter from firing every AI turn:

    Code:
    	monitor_event FactionTurnEnd FactionIsLocal
    		set_event_counter is_ai_faction 1
    	end_monitor

  4. #4

    Icon1 Re: Allowing AI to recruit exclusive units

    Quote Originally Posted by Taiji View Post
    To save the event counter from firing every AI turn:

    Code:
    	monitor_event FactionTurnEnd FactionIsLocal
    		set_event_counter is_ai_faction 1
    	end_monitor
    Thanks Taiji. That’s a good idea. Maybe it would work better this way:
    Code:
    campaign_script:
    
    ;###### Set Faction Recruit Pool #######
    
    	monitor_event PreFactionTurnStart FactionIsLocal
    		set_event_counter is_local_faction 1
    		set_event_counter is_ai_faction 0
    	end_monitor
    
    	monitor_event FactionTurnEnd FactionIsLocal
    		set_event_counter is_ai_faction 1
    		set_event_counter is_local_faction 0
    	end_monitor
    
    export_descr_buildings:
    
    recruit_pool "Musket Militia"  1   0.15   2  0  requires factions { england, } and event_counter is_local_faction 1
    
    recruit_pool "Ai Musket Militia"  1   0.15   2  0  requires factions { england, } and event_counter is_ai_faction 1

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

    Default Re: Allowing AI to recruit exclusive units

    Yes that should actually work. I seem to remember EDB doesn't like 0 value event tracking for recruitment. I think it works OK with 'not event_counter blah_blah 1' though, so this should work too:
    Code:
    	monitor_event PreFactionTurnStart FactionIsLocal
    		set_event_counter is_ai_faction 0
    	end_monitor
    
    	monitor_event FactionTurnEnd FactionIsLocal
    		set_event_counter is_ai_faction 1
    	end_monitor
    export_descr_buildings:
    Code:
    recruit_pool "Musket Militia"  1   0.15   2  0  requires factions { england, } and not event_counter is_ai_faction 1
    
    recruit_pool "Ai Musket Militia"  1   0.15   2  0  requires factions { england, } and event_counter is_ai_faction 1
    Last edited by Taiji; August 30, 2010 at 08:36 AM.

  6. #6

    Default Re: Allowing AI to recruit exclusive units

    Quote Originally Posted by Taiji View Post
    Yes that should actually work. I seem to remember EDB doesn't like 0 value event tracking for recruitment. I think it works OK with 'not event_counter blah_blah 1' though, so this should work too:
    Code:
        monitor_event PreFactionTurnStart FactionIsLocal
            set_event_counter is_ai_faction 0
        end_monitor
    
        monitor_event FactionTurnEnd FactionIsLocal
            set_event_counter is_ai_faction 1
        end_monitor
    export_descr_buildings:
    Code:
    recruit_pool "Musket Militia"  1   0.15   2  0  requires factions { england, } and not event_counter is_ai_faction 1
    
    recruit_pool "Ai Musket Militia"  1   0.15   2  0  requires factions { england, } and event_counter is_ai_faction 1
    I've tried this, and the AI are still recruiting the musket militia not the AI musket militia.

  7. #7

    Default Re: Allowing AI to recruit exclusive units

    Thanks guys!

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

    Default Re: Allowing AI to recruit exclusive units

    You're welcome and good luck, it's a cool idea
    Last edited by Taiji; August 30, 2010 at 08:43 AM.

  9. #9
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: Allowing AI to recruit exclusive units

    You might go a little further and save the script from firing every round. After all who is AI and who isn't gets determined only once at the beginning of the campaign, so you could create 23 or so counters, each for each of the factions, and then check if that faction is AI-controlled in the EDB. So for instance for a French unit, check if France is AI-controlled. Then as far as the script goes, have it determine at the end of the first round which factions are AI-controlled, and terminate itself.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

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

    Default Re: Allowing AI to recruit exclusive units

    It's a good point, but one thing we sacrifice by doing it that way is hotseat functionality.

  11. #11

    Icon1 Re: Allowing AI to recruit exclusive units

    Code:
    	monitor_event PreFactionTurnStart FactionIsLocal
    		and I_TurnNumber = 0
    		if I_LocalFaction england
    		set_event_counter england_local_faction 1
    	end_if
    		if I_IsFactionAIControlled england
    		set_event_counter england_ai_faction 1
    	end_if
    		if I_LocalFaction scotland
    		set_event_counter scotland_local_faction 1
    	end_if
    		if I_IsFactionAIControlled scotland
    		set_event_counter scotland_ai_faction 1
    	end_if
    		if I_LocalFaction ireland
    		set_event_counter ireland_local_faction 1
    	end_if
    		if I_IsFactionAIControlled ireland
    		set_event_counter ireland_ai_faction 1
    	end_if
    		if I_LocalFaction wales
    		set_event_counter wales_local_faction 1
    	end_if
    		if I_IsFactionAIControlled wales
    		set_event_counter wales_ai_faction 1
    	end_if
    		if I_LocalFaction burgundy
    		set_event_counter burgundy_local_faction 1
    	end_if
    		if I_IsFactionAIControlled burgundy
    		set_event_counter burgundy_ai_faction 1
    	end_if
    		if I_LocalFaction flanders
    		set_event_counter flanders_local_faction 1
    	end_if
    		if I_IsFactionAIControlled flanders
    		set_event_counter flanders_ai_faction 1
    	end_if
    	terminate_monitor
    	end_monitor

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

    Default Re: Allowing AI to recruit exclusive units

    That's probably impossible unless you messed up, so show us exactly what you have tried. Upload your EDB and campaign_script.
    Last edited by Taiji; September 10, 2010 at 12:59 PM.

  13. #13

    Default Re: Allowing AI to recruit exclusive units

    Campaign script:

    ;
    ; Campaign script
    ;
    script
    ; ---------------------
    ; counters

    restrict_strat_radar false

    declare_counter Opened_Faction_Overview_Scroll
    declare_counter Opened_Settlement_Scroll
    declare_counter mongols_sarkel
    declare_counter mongols_yerevan
    declare_counter mongols_baghdad
    declare_counter timurids_sarkel
    declare_counter timurids_yerevan
    declare_counter timurids_baghdad

    monitor_event PreFactionTurnStart FactionIsLocal
    set_event_counter is_ai_faction 0
    end_monitor

    monitor_event FactionTurnEnd FactionIsLocal
    set_event_counter is_ai_faction 1
    end_monitor
    Last edited by squatlover; September 19, 2010 at 04:19 PM. Reason: added attachments

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

    Default Re: Allowing AI to recruit exclusive units

    The first thing to suspect is the campaign_script. Any error in the log?

    Whatever, try this Attachment 109756

    I stripped everything else out for you.
    Last edited by Taiji; September 20, 2010 at 06:29 AM.

  15. #15

    Default Re: Allowing AI to recruit exclusive units

    Not working with the new script

    I changed my EDB to read
    recruit_pool "Mercenary Arquebusiers" 1 0.5 2 0 requires factions { all, } and event_counter is_ai_faction 0
    recruit_pool "Mercenary ArquebusiersAI" 1 0.5 2 0 requires factions { all, } and event_counter is_ai_faction 1

    But somehow the enemy is still recruiting mercenary arquebusiers - and not able to recruit the AI version

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

    Default Re: Allowing AI to recruit exclusive units

    And the log says what?

    Try a trace, see if the counter is set. From the sounds of things the script isn't working for some reason.
    Last edited by Taiji; September 20, 2010 at 08:15 PM.

  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: Allowing AI to recruit exclusive units

    The game does not accept an event conditions with zero.

    Use the negative condition: and not event_counter is_ai_faction 1

    To enable recruitment by AI faction:
    and event_counter is_ai_faction 1

    To enable recruitment by player:
    and not event_counter is_ai_faction 1
    Last edited by Gigantus; September 21, 2010 at 03:47 AM.










  18. #18

    Default Re: Allowing AI to recruit exclusive units

    I tried that initially but it didn't work either, and the AI walks about with mercenary arquebusiers not the AI versions

    The system log gives a lot of errors where I haven't made unit cards.

  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: Allowing AI to recruit exclusive units

    1. Did you add those conditions to all instances of those units in the EDB?
    2. Compress and upload your log










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

    Default Re: Allowing AI to recruit exclusive units

    If "The system log gives a lot of errors where I haven't made unit cards." is meant to answer my question about what is in the log, then maybe you have failed to put the campaign script in the correct folder.

    Your CS is probably not being read at all if you are not getting any error message and yet it is not working.
    Last edited by Taiji; September 22, 2010 at 09:12 AM.

Page 1 of 2 12 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
  •