Results 1 to 9 of 9

Thread: Increase units of AI factions not human player

Hybrid View

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

    Default Increase units of AI factions not human player

    Can someone teach me how to increase the number of units whenever I start a new campaign without affecting the human player. (AI only)

    I want to know what's wrong with this text in descr_strat. (EB)

    ; City: Rome
    ; Region: Latium
    ; --------------------
    (blah, blah, blah)

    army
    unit roman cavalry eqvites consvlares exp 1 armour 0 weapon_lvl 0
    ;script for AI
    ;unit roman infantry triarii early exp 5 armour 0 weapon_lvl 0
    ;unit roman infantry triarii early exp 5 armour 0 weapon_lvl 0
    ;unit roman infantry triarii early exp 5 armour 0 weapon_lvl 0
    ;unit roman infantry triarii early exp 5 armour 0 weapon_lvl 0
    ;unit roman infantry triarii early exp 5 armour 0 weapon_lvl 0


    I added some AI scripts but it doesn't seem to work.
    Last edited by Luskan; November 02, 2009 at 11:34 PM.

  2. #2
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,751
    Blog Entries
    3

    Default Re: Increase units of AI factions not human player

    Because there's no such thing as script for AI . . .

    You'd need to create a campaign script that generates units at the start of the campaign for each faction if the faction isn't the local faction.

    Code:
    monitor_event FactionTurnStart I_TurnNumber = 1
    and not FactionIsLocal
    ...
    end_monitor
    or something of the like, the syntax above probably isn't correct.
    Last edited by Squid; November 03, 2009 at 10:12 AM.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  3. #3

    Default Re: Increase units of AI factions not human player

    @ Squid: I'm not sure what your intention was, but turn counting starts from 0, so if you want to have the script happen the very first turn, it should be TurnNumber = 0

  4. #4

    Default Re: Increase units of AI factions not human player

    Quote Originally Posted by Sqυιd View Post
    Because there's no such thing as script for AI . . .

    You'd need to create a campaign script that generates units at the start of the campaign for each faction if the faction isn't the local faction.

    Code:
    monitor_event FactionTurnStart I_TurnNumber = 1
    and not FactionIsLocal
    ...
    end_monitor
    or something of the like, the syntax above probably isn't correct.

    [/code]
    I'm sorry, my last question was a bit confusing, I just want to increase the garrison and stacks oF factions that are controlled by AI, but without affecting the human player in case the human players play that certain faction. (Sorry for my bad English)

    There are some questions that still left me confused
    1. I wanted to increase the garrison to an AI faction without adding a general, how can I do that?
    (can you give me a detailed example since the one Ham provides has general in it, and I don't know if spawn is the right word since the army I want to add to the AI will be there at the start of the campaign.)


    Let's use this as an example, If I want to put these units in the city of Rome at the very beginning of the game (controlled by AI) without adding Nero, what part of the script should I change?
    monitor_event FactionTurnEnd FactionType romans_julii
    and I_TurnNumber = 3

    spawn_army
    faction romans_julii
    character Nero, named character, command 6, influence 6, management 7, subterfuge 0, age 29, , x 89, y 90
    unit roman generals guard cavalry early, exp 1 armour 0 weapon_lvl 0
    end

    console_command create_unit "Nero" "roman hastati" 12 1 0 0
    console_command create_unit "Nero" "roman velite" 3 2 0 0
    console_command create_unit "Nero" "roman slinger" 3 2 0 0
    terminate_monitor
    end_monitor

    2. EB has a script called EBBS script, should I put the script there? or create another file in data/scripts and renamed it "campaign script" and put the script there?

    Optional
    3. If the first question in number 2 is a "yes", should I put it in the bottom most part of the script.
    Last edited by Luskan; November 03, 2009 at 10:36 AM.

  5. #5

    Default Re: Increase units of AI factions not human player

    I think he was just going for the general idea, not the specifics...

  6. #6

    Default Re: Increase units of AI factions not human player

    I don't have the files on this computer, but I know exactly how to do what you want. When I get home, I will post how.

    Expand your borders, a mod based on XGM 5.

  7. #7
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,751
    Blog Entries
    3

    Default Re: Increase units of AI factions not human player

    You don't need the spawn_army command at all. Also inside the monitor you should have an if for each faction. Also as pointed out in the post after mine the first turn in a game is represented by I_TurnNumber = 0 (not I_TurnNumber = 1 from my example or I_TurnNumber = 3 from your example).

    Ex.

    Code:
    monitor_event FactionTurnStart I_TurnNumber = 0
    and not FactionIsLocal
    
    e_select_settlement
    
    if FactionType = romans_julii
       console_command create_unit "Rome" "roman hastati" 12 1 0 0
       console_command create_unit "Rome" "roman velite" 3 2 0 0
       console_command create_unit "Rome" "roman slinger" 3 2 0 0
      
       console_command create_unit "Croton" "roman hastati" 12 1 0 0
       console_command create_unit "Croton" "roman velite" 3 2 0 0
       console_command create_unit "Croton" "roman slinger" 3 2 0 0
    
       ...
      end
    
    if FactionType = greek_cities
       console_command create_unit . . .
       console_command create_unit . . .
       console_command create_unit . . .
    
       ...
    end
    
    etc.
    
    end_monitor
    EDIT: You'll want to enhance this so that there's a counter which increases every time an if statement is run, and then have a final if in the monitor which compares the counter to 1 less than the number of factions you have in the game (20 for vanilla) and terminates the monitor when the counter matches that number.
    Last edited by Squid; November 03, 2009 at 12:26 PM.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  8. #8

    Default Re: Increase units of AI factions not human player

    What you want is a campaign script. There is no need for monitors, only if statements.

    Campaign scripts fire as soon as descr_strat is parsed and can be used to give AI controlled factions a boost at the beginning of the game without boosting human players using that faction.

    First, you must declare your campaign script in descr_strat. To do that add this to the very end of your descr_strat

    Code:
    script
    Your_Campaign_Script.txt
    Then create a text file named "Your_Campaign_Script.txt" (this file just needs to have the same name as the file name you put in descr_strat).

    In the script start with these lines:
    Code:
    script
        suspend_during_battle on
    Then for each (AI) faction that you want to add units too you need to add this code:

    Code:
        if not I_LocalFaction 'faction internal name'
    
        end_if
    This means that whatever code you add between the "if" and "end_if" will happen only if the player isn't using that faction. If you leave out the "not" the code will run only if the player is using that faction. This way you can create two different armies in the same city or at the same general.

    Now to add units use this code:

    Code:
            console_command create_unit City "unit name" # xp wp arm
    
            console_command create_unit "General's Name" "unit name" # xp wp arm
    The first is an example for a city, and the second for a general in the field. The first number after the unit's name is the amount of units, the second is experience, the third and fourth are weapons and armor respectively. Use the internal names of cities without quotes, and the internal names in quotes for generals. Unit names are taken from export_descr_units and should be in quotes.

    So for example, we would have this for Rome:

    Code:
        if not I_LocalFaction romans_julii
    
            console_command create_unit Rome "allied hastati" 4 2 1 1
    
            console_command create_unit "Decius Mus" "roman equites" 1 3 1 1
    
        end_if
    Finally, at the end of the script, add this:
    Code:
    terminate_script
    The campaign script should be used only to help balance the beginning of the campaign as the player cannot save while it is running, but a script of this sort runs almost instantly.

    Expand your borders, a mod based on XGM 5.

  9. #9

    Default Re: Increase units of AI factions not human player

    Thank you for the replies, it was somehow tiresome to make a script work, but it's worth the effort .

Posting Permissions

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