Results 1 to 16 of 16

Thread: Emergent Generals

  1. #1
    SonofPeverel's Avatar GLORY TOTHE BROTHERHOOD
    Content Emeritus

    Join Date
    Oct 2009
    Location
    Texas
    Posts
    1,219

    Default Emergent Generals

    I was drawn to write this tutorial by my search for a full emergent general script. I have found bits and pieces, but never a tutorial dedicated solely to emergent generals. This tutorial is based off of my compiled notes on the topic. I would like to thank Gigantus (for his patient advice ) and David93.


    The goal of this tutorial is two-fold. Firstly, I would like to give modders a working script that they can copy and paste directly into their work. Secondly, I hope to teach some new modders what all is needed in order to create their own emergent general scripts. So here goes:

    Code:
     monitor_event PreFactionTurnStart FactionIsLocal
      and FactionType england
      and I_TurnNumber > 3
      and I_NumberOfSettlements england < 5
      historic_event a_hero_emerges
      spawn_army
       faction england
       character random_name, named character, age 18, x 111, y 145
       traits GoodCommander 1
       unit NE Bodyguard  exp 2 armour 0 weapon_lvl 0
      end
      terminate_monitor
     end_monitor
    This script is set up to be fully functional with kingdoms. Place this script at the bottom of the campaign_script file in the data\world\maps\campaign\imperial_campaign folder, just above the end scripts section. For an experienced scripter, looking for a pre-made script, you can stop reading as the rest of this tutorial will break down each line of the script.
    monitor_event PreFactionTurnStart FactionIsLocal: This line has three crucial parts. The monitor tells the engine to check for the following event, while the PreFactionTurnStart instructs it to check before the start of the turn (obviously). FactionIsLocal (faction is human) is the first condition that must be met before this event can trigger in-game. This could also read:
    monitor_event PreFactionTurnStart not FactionIsLocal (each condition can be a “not” condition)
    Each following condition is scripted on its own line (tabbed one time from the monitor_event line) .
    This particular event is set to trigger when a player is England, it is after turn three, and the player has less than 5 regions.
    Code:
      and FactionType england
      and I_TurnNumber > 3
      and I_NumberOfSettlements england < 5
      historic_event a_hero_emerges
    I have added the historic_event a_hero_emerges line to trigger an in-game pop up to let the player know that a faction has had a general emerge. For this to work we have to add a historic event in the historic_events.txt file in the data\text folder
    Code:
    {A_HERO_EMERGES_BODY}At the time of their greastest need, this man has emerged as a hero for the people.
    {A_HERO_EMERGES_TITLE}A Hero Emerges
    Add these lines at the bottom of this file.

    The following part of the script tells the engine what to do once the conditions are met. In this case we want a general to spawn so we need to use the spawn_army identifier.
    Code:
      spawn_army
       faction england
       character random_name, named character, age 18, x 111, y 145
       traits GoodCommander 1
       unit NE Bodyguard  exp 2 armour 0 weapon_lvl 0
      end
    The next line deals with which faction receives the spawned army, followed by the characters name, age, and location on the map where they will spawn. I have used random_name, but you can use any name as long as they are in the proper places in the data files: descr_names and descr_names_lookup, along with the data/text file: names.
    The next line gives the spawned general his traits and can be followed by an ancillary line below. (A list of traits and ancillaries can be found in their proper data files.
    This line: “unit NE Bodyguard exp 2 armour 0 weapon_lvl 0 “ is important, as a general must have a bodyguard. If you wish to add additional units to your general’s army, you will need additional unit lines (max 20 total). To find unit names to replace “ NE Bodyguard” look in the export_descr_unit file in the data folder and choose the name on the “type” line.
    The next few lines end the script:
    End (ends the spawn_army)
    terminate_monitor (will not allow the monitor to trigger more than once)
    end_monitor (ends the monitor)

    Once again this is just a compilation of my notes on this topic and I hope it helps someone learn this skill MUCH faster than I did
    This is my first tutorial and any advice on structure or changes would be appriciated.
    SoP
    Last edited by SonofPeverel; July 18, 2011 at 07:16 PM.

    HOUSE OF HADER

  2. #2
    SpyrosM91's Avatar Despotes
    Join Date
    Aug 2010
    Location
    Patras, Greece
    Posts
    3,675

    Default Re: Emergent Generals

    instead of this: {A_HERO_EMERGES_BODY} don't you mean: {AN_INSPIRATION_EMERGES_BODY} ????

    the same with: {...._TITLE}
    Proud Tsardoms Total War: Historian - Coder - Scripter - Mapper

  3. #3
    SonofPeverel's Avatar GLORY TOTHE BROTHERHOOD
    Content Emeritus

    Join Date
    Oct 2009
    Location
    Texas
    Posts
    1,219

    Default Re: Emergent Generals

    Quote Originally Posted by SpyrosM91 View Post
    instead of this: {A_HERO_EMERGES_BODY} don't you mean: {AN_INSPIRATION_EMERGES_BODY} ????

    the same with: {...._TITLE}
    I thought I had chaged everything to a_hero and missed that in the script..Thanks for pointing that out, love the edit tool.

    HOUSE OF HADER

  4. #4
    SpyrosM91's Avatar Despotes
    Join Date
    Aug 2010
    Location
    Patras, Greece
    Posts
    3,675

    Default Re: Emergent Generals

    then you also forgot this one:

    and FactionType england
    and I_TurnNumber > 3
    and I_NumberOfSettlements england < 5
    historic_event an_inspiration_emerges


    Proud Tsardoms Total War: Historian - Coder - Scripter - Mapper

  5. #5
    SonofPeverel's Avatar GLORY TOTHE BROTHERHOOD
    Content Emeritus

    Join Date
    Oct 2009
    Location
    Texas
    Posts
    1,219

    Default Re: Emergent Generals

    Haha thanks mate..

    HOUSE OF HADER

  6. #6
    Polycarpe's Avatar Back into action!
    Join Date
    Feb 2010
    Location
    Quebec, Canada
    Posts
    3,338

    Default Re: Emergent Generals

    Very nice tutorial, those who don't get scripts (like me) will have an handy tool. +rep

  7. #7

    Default Re: Emergent Generals

    Nice mate, +rep

    The Orcs of Gundabad Erin go Bragh FROGS

    When I came back to Dublin I was court marshaled in my absence and sentenced to death in my absence, so I said they could shoot me in my absence"
    Brendan Behan
    The Irish won an Empire
    The Scots ran an Empire
    The English lost an Empire

    "When I told the people of Northern Ireland that I was an atheist, a woman in the audience stood up and said, 'Yes, but is it the God of the Catholics or the God of the Protestants in whom you don't believe?"
    - Quentin Crisp

    There is one weapon that the British cannot take away from us: we can ignore them.
    - Michael Collins

    They have nothing in their whole imperial arsenal that can break the spirit of one Irishman who doesn't want to be broken.
    - Bobby Sands

  8. #8

    Default Re: Emergent Generals

    looks good...+rep

  9. #9

    Default Re: Emergent Generals

    And what if I want ANYONE (not just england, lets say that in a certain playthrough when I am playing as scotland, I want this to happen as well)? should be like this:

    and FactionType england, scotland

    or

    and FactionType england
    and FactionType scotland


    Anyhow, could someone please post a full list of conditions? There are thousands of coders who would give their lives for them!

  10. #10

    Default Re: Emergent Generals

    Quote Originally Posted by khatmar View Post
    Anyhow, could someone please post a full list of conditions? There are thousands of coders who would give their lives for them!
    uhm, link

  11. #11
    SonofPeverel's Avatar GLORY TOTHE BROTHERHOOD
    Content Emeritus

    Join Date
    Oct 2009
    Location
    Texas
    Posts
    1,219

    Default Re: Emergent Generals

    Quote Originally Posted by khatmar View Post
    And what if I want ANYONE (not just england, lets say that in a certain playthrough when I am playing as scotland, I want this to happen as well)? should be like this:

    and FactionType england, scotland

    or

    and FactionType england
    and FactionType scotland


    Anyhow, could someone please post a full list of conditions? There are thousands of coders who would give their lives for them!
    Sorry I have been in Haiti for a couple of weeks. I made a separate entry per faction so that the extra army units can be unique to that faction

    HOUSE OF HADER

  12. #12

    Default Re: Emergent Generals

    I do not understand why it does not work for me.


    I copy the code as such in campagin_script above "end script" or, in other occasions, above "Wait monitors".


    Either the game jumps me or I get "error" to the left of the campaign radar map and cancels all the codes and makes them not appear.


    What I can be doing wrong? I try to put the code in the submod Sship.

  13. #13

    Default Re: Emergent Generals

    Quote Originally Posted by toteking93 View Post
    I do not understand why it does not work for me.


    I copy the code as such in campagin_script above "end script" or, in other occasions, above "Wait monitors".


    Either the game jumps me or I get "error" to the left of the campaign radar map and cancels all the codes and makes them not appear.


    What I can be doing wrong? I try to put the code in the submod Sship.
    Hi toteking93,
    You pm'd me about this and your pm had more info, please could you include here the text you tried adding to the script in [code] tags ?

    From the pm info it looked like you were copying the OP version very exactly - did you check that the x,y coordinates for the army to spawn would work for your mod? And that your 'england' has less than 5 settlements?

    Also as you seem to have included the 'historic_event a_hero_emerges' line, did you also add the necessary text entries for that?

  14. #14

    Default Re: Emergent Generals

    Hi, copy/past from mi final part of campaign_script: (I put it that way in case I was putting it in the wrong place of the document)

    if I_SettlementOwner Marrakesh = milan
    faction_emerge jerusalem milan 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = kievan_rus
    faction_emerge jerusalem kievan_rus 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = rum
    faction_emerge jerusalem rum 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = timurids
    faction_emerge jerusalem timurids 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = teutonic_order
    faction_emerge jerusalem teutonic_order 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = kwarezm
    faction_emerge jerusalem kwarezm 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = lithuania
    faction_emerge jerusalem lithuania 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = russia
    faction_emerge jerusalem russia 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = moors
    faction_emerge jerusalem moors 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = egypt
    faction_emerge jerusalem egypt 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = turks
    faction_emerge jerusalem turks 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = mongols
    faction_emerge jerusalem mongols 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = cumans
    faction_emerge jerusalem cumans 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = byzantium
    faction_emerge jerusalem byzantium 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if
    if I_SettlementOwner Marrakesh = slave
    faction_emerge jerusalem slave 5 400.0 0.0 1.2 town true unused_label1 unused_name 30
    end_if


    destroy_buildings scotland hidden_temporary_buildings false
    destroy_buildings sicily hidden_temporary_buildings false
    destroy_buildings milan hidden_temporary_buildings false
    destroy_buildings denmark hidden_temporary_buildings false
    destroy_buildings turks hidden_temporary_buildings false
    destroy_buildings venice hidden_temporary_buildings false
    destroy_buildings pisa hidden_temporary_buildings false
    destroy_buildings kievan_rus hidden_temporary_buildings false
    destroy_buildings rum hidden_temporary_buildings false
    destroy_buildings timurids hidden_temporary_buildings false
    destroy_buildings france hidden_temporary_buildings false
    destroy_buildings hre hidden_temporary_buildings false
    destroy_buildings aragon hidden_temporary_buildings false
    destroy_buildings england hidden_temporary_buildings false
    destroy_buildings poland hidden_temporary_buildings false
    destroy_buildings teutonic_order hidden_temporary_buildings false
    destroy_buildings kwarezm hidden_temporary_buildings false
    destroy_buildings russia hidden_temporary_buildings false
    destroy_buildings portugal hidden_temporary_buildings false
    destroy_buildings lithuania hidden_temporary_buildings false
    destroy_buildings spain hidden_temporary_buildings false
    destroy_buildings hungary hidden_temporary_buildings false
    destroy_buildings cumans hidden_temporary_buildings false
    destroy_buildings norway hidden_temporary_buildings false
    destroy_buildings moors hidden_temporary_buildings false
    destroy_buildings egypt hidden_temporary_buildings false
    destroy_buildings papal_states hidden_temporary_buildings false
    destroy_buildings mongols hidden_temporary_buildings false
    destroy_buildings byzantium hidden_temporary_buildings false
    destroy_buildings jerusalem hidden_temporary_buildings false
    destroy_buildings slave hidden_temporary_buildings false


    historic_event jerusalem_emerged
    set_counter jerusalem_emerge 0
    end_monitor




    ;monitor_event FactionTurnEnd FactionType pisa
    ;
    ; faction_emerge venice pisa 1 65.0 0.0 1.2 town true unused_label1 unused_name 30
    ; historic_event city_betrayal
    ;end_monitor




    monitor_event PreFactionTurnStart FactionIsLocal
    and FactionType england
    and I_TurnNumber = 3
    and I_NumberOfSettlements england > 5
    historic_event a_hero_emerges
    spawn_army
    faction england
    character random_name, named character, age 18, x 111, y 145
    traits GoodCommander 1
    unit NE Bodyguard exp 2 armour 0 weapon_lvl 0
    end
    terminate_monitor
    end_monitor


    wait_monitors
    end_script

  15. #15

    Default Re: Emergent Generals

    ah! the coordinates belong to the location of a diplomat england in the first turn, I use his and in the first turn I move it so that it is not in the same place where the general appears.

  16. #16

    Default Re: Emergent Generals

    And this is the final of my historic_event in the folder "text":

    {NEW_MINDSET_JERUSALEM_TITLE} ¿Nueva era en el Reino de Jerusalén?
    {NEW_MINDSET_EGYPT_BODY}\n\nFaltando gloria y éxito con sus acciones anteriores, el nuevo líder de los fatimids ha decidido borrar los lazos diplomáticos y cesar el fuego con sus antiguos enemigos. Nuestros espías no están seguros de si esto los llevará a la gloria o a su desaparición final ...
    {NEW_MINDSET_EGYPT_TITLE} ¿Nueva era para los fatimíes?
    {NEW_MINDSET_MOORS_BODY}\n\nFaltando gloria y éxito con sus acciones anteriores, el nuevo líder de los almorávides ha decidido borrar los lazos diplomáticos y cesar el fuego con sus antiguos enemigos. Nuestros espías no están seguros de si esto los llevará a la gloria o a su desaparición final ...
    {NEW_MINDSET_MOORS_TITLE} ¿Nueva era para los almorávides?
    {A_HERO_EMERGES_BODY} At the time of their greastest need, this man has emerged as a hero for the people.
    {A_HERO_EMERGES_TITLE} A Hero Emerges

Posting Permissions

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