Results 1 to 6 of 6

Thread: How to add incidents and dilemmas

  1. #1
    davidlallen's Avatar Shashu
    Join Date
    Jun 2011
    Posts
    152

    Default How to add incidents and dilemmas

    This tutorial describes how to add one "incident" and one "dilemma" to the game. This tutorial assumes basic familiarity with PFM, and it is current as of patch 7, early August 2011. Credits to Yarkis de Bodemloze for explaining many key steps.

    The only tool you will need is PFM. I have used version 1.66 with the additional data files I added in this thread. For basic instructions on PFM and creating mods, I recommend this thread. It is for NTW, but apart from some minor differences in pathnames, the steps apply to TWS2 also. I would like to keep this thread focused on incidents and dilemmas. So if you have not used PFM before, please try it out first and request PFM help in the PFM threads.

    The key files are:
    a. patch7.pack/db/cdir_configs_tables. Parameters to make testing easier.
    b. patch7.pack/db/incidents_tables. Incident icons and enable status.
    c. patch7.pack/db/cdir_events_incident_payloads_tables. Incident effect.
    d. patch7.pack/db/cdir_events_incident_option_junction_tables. Conditions for the incident to occur.
    e. local_en_patch.pack/text/db/incidents.loc. Text for the incident.
    f. local_en_patch.pack/text/startpos_jap_shogun.loc. Strings to make testing easier.
    g. patch7.pack/db/dilemmas_tables. Dilemma icons.
    h. patch7.pack/db/cdir_events_dilemmas_payloads_tables. Dilemma effects.
    i. patch7.pack/db/cdir_events_dilemmas_option_junction_tables. Conditions for the dilemma to occur.
    j. local_en_patch.pack/text/db/dilemmas.loc. Text for the dilemma.
    k. patch7.pack/db/cdir_events_dilemma_incidents_table. "Chain" incidents which occur after dilemmas.

    1. Create a temporary working folder. Using PFM, extract the files listed in (a-k) into this folder. I would like to keep this thread focused on incidents and dilemmas. So if you have not used PFM before, please try it out first and request PFM help in the PFM threads.

    2. Use PFM to create a new pack file with the files (a-k). Rename each of the tables (b,c,d,g,h,k). For example, rename (b) from incidents to tut_incidents. Do not rename the configs table (a) or the localization files (e,f,i). Change the pack type to "movie". Here is a screenshot of what your pack file should look like so far.



    3. Use PFM to open the table (a) in your new pack file. The lines we are interested in affect how often incidents and dilemmas occur. In order to make testing easier, we want to have these happen all the time, every turn if possible. This way, when you start a new game to test, you do not have to go through many turns before you see the effect. Change CDIR_CVN_EVENT_GENERATOR_BASE_CHANCE to 0.99, ...INCIDENT_BASE_CHANCE to 0.3, ...MIN_ROUNDS_BETWEEN_EVENTS to 1, ...MISSION_BASE_CHANCE to 0.01 and ...START_AFTER_ROUND to 1. I am not certain how the base chance fields interact. I believe that once the generator decides an event will occur (...BASE_CHANCE), then it will decide whether the event will be an incident, dilemma or mission. So the INCIDENT_BASE_CHANCE and MISSION_BASE_CHANCE "imply" a third variable which is not needed but could be called DILEMMA_BASE_CHANCE.

    4. In PFM, open table (b) in your new pack file. Delete all but one of the lines from this table. Make sure the line you keep has field 1 and field 5 set to "True", these appear to tell whether the incident is enabled. In field 2, choose an internal ID for your new incident such as "tut_incident". In fields 3 and 4, choose any icon you like.

    5. In PFM, open table (c) in your new pack file. This file gives the effect bundle which will happen as a result of the incident. Choosing an effect bundle is outside the scope of this tutorial; you can see the available options in the file. Delete all but one line from this file. In field 1, make sure to choose an integer which is not already used in the file; there are no numbers greater than 7000, so 7000 is safe. In field 3, enter the internal ID of your incident, "tut_incident". For now, choose the "p_able_sailors" bundle in field 4, and enter the string "DURATION[6]" in field 5. This will grant XP to your new ships for six turns.

    6. In PFM, open table (d) in your new pack file. This is the most complicated file. It gives the conditions and customizations for the incident. For example, an incident may only be valid if you are at war, and then it must be customized with the name of one faction with which you are at war. For this tutorial we will choose a simple incident, which does not require any customization and has a simple 100% chance to appear. Later, you can trace out different base game incidents and their conditions. Field 1 is an index field which must have unique values. There are no numbers greater than 6000 in the file, so 6000 is safe. Delete all the existing lines and enter the three lines:
    Code:
    6001 | 0 | tut_incident | VAR_CHANCE       | 100
    6002 | 0 | tut_incident | GEN_TARGET_NONE
    6003 | 0 | tut_incident | CND_UNIQUE
    7. In PFM, open table (e). You will see strings which give the title and detailed text in the dialog box for each incident. *DO NOT* delete the lines in this file. Instead, add two lines at the bottom:
    Code:
    incidents_localised_title_tut_incident | My Incident Title | True
    incidents_localised_description_tut_incident | My Incident Text | True
    8. Last table before we are done! In PFM, open table (f). We will make one change here, so that we can easily verify whether the mod is loaded. Scroll down to the second page and find the field "The Chosokabe clan can claim three things: ...". This is displayed in the "New Campaign" screen when you select Chosokabe as your starting position. Change this string to something you recognize, such as "Look! My mod loaded!". I often put a version number here if I have multiple tests going at once, to make sure I have copied the right file.

    9. Save the pack file. Now is a good time to double check your work. Make sure tables (a-e) are edited; (b,c,d) should only contain a few lines with the other lines deleted; and the pack type is movie.

    10. Copy the pack file into your game data directory and start a game! I choose Chosokabe, normal. Make sure your "Look! My mod loaded!" string appears. On turn 1, on normal, you can auto-resolve to kill the rebels; build a few units to protect against the Kono who will be coming. Then just hit "next turn" a few times. Within 3-4 turns you will see the incident appear. If it does not, check all the previous instructions for a spelling error or missed step. As far as I know, the game will silently ignore this type of error.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	inc-dil-screen.gif 
Views:	880 
Size:	50.3 KB 
ID:	177080  
    Attached Files Attached Files
    Last edited by davidlallen; August 15, 2011 at 08:37 PM.

  2. #2
    davidlallen's Avatar Shashu
    Join Date
    Jun 2011
    Posts
    152

    Default Re: How to add incidents and dilemmas

    Now that we have done an incident, let us add a dilemma. Build upon the mod file you created in the first post.

    11. Dilemma file (g) is similar to incident file (b) in step 4. Delete all the other lines and add one line with the internal ID of your dilemma, "tut_dilemma". None of the long string fields matter; the game fetches these from file (i) anyway. Make sure the first field is "True"; I believe this is required to enable the dilemma.

    12. Dilemma file (h) is similar to incident file (c) in step 5. The main difference is that each line has a field to indicate whether it applies to the FIRST or SECOND choices in the dilemma. Delete all the lines and add these two lines:
    Code:
    FIRST  | tut_dilemma | 3001 | 0 | p_foreign_prosperity | True | DURATION[6]
    SECOND | tut_dilemma | 3002 | 0 | p_thriving_markets   | True | DURATION[6]
    If your PFM does not show a boolean field, that is fine; you can ignore it.

    13. Dilemma file (i) is similar to incident file (d) in step 6. Later, you can trace out any base game dilemmas and their conditions. Delete all the lines and enter the new lines:
    Code:
    tut_dilemma | 5001 | 0 | VAR_CHANCE      | 100
    tut_dilemma | 5002 | 0 | GEN_TARGET_NONE
    tut_dilemma | 5003 | 0 | CND_UNIQUE
    14. Dilemma file (j) is similar to incident file (e) in step 7. *DO NOT* delete the lines in this file. Add six lines at the bottom:
    Code:
    dilemmas_localised_title_tut_dilemma               | My Dilemma    | True
    dilemmas_localised_description_tut_dilemma         | My top text.  | True
    dilemmas_localised_first_choice_title_tut_dilemma  | First Button  | True
    dilemmas_localised_first_choice_label_tut_dilemma  | First Text.   | True
    dilemmas_localised_second_choice_title_tut_dilemma | Second Button | True
    dilemmas_localised_second_choice_label_tut_dilemma | Second Text.  | True
    15. Similar to steps 8-10. Update the string in table (f) with a newer string, like "Look! My dilemma mod loaded!". Double check your work. Save the pack file. Copy the pack file into the game data directory. Play a game! The dilemma should show up within the first 10 turns.

    16. A dilemma can have "chained" or "child" incidents, depending on which choice you picked. This shows the consequences of your decision later in the game. We will add two more incidents and link them to this dilemma. The key table which captures this information is (k). Delete the contents, then add the lines:
    Code:
    FIRST  | tut_dilemma | tut_dil_foll_1
    SECOND | tut_dilemma | tut_dil_foll_2
    17. Add the details to files you have previously modified. In file (b), add the lines:
    Code:
    False | tut_dil_foll_1 | ... | ... | False
    False | tut_dil_foll_2 | ... | ... | False
    The first and last fields must be false. These are related to enabling the incidents. If you put "True", then the chained incident can appear even if you did not make the corresponding dilemma choice. Where I have written "..." you can leave any valid icon name there, from a line which you may clone. In file (c), add the lines:
    Code:
    7002 | 0 | tut_dil_foll_1 | p_able_sailors | DURATION[6]
    7003 | 0 | tut_dil_foll_2 | p_able_sailors | DURATION[8]
    For the purposes of this tutorial, I have kept the same effect bundle but different duration. The only way you will notice the difference is by the duration. In file (d), add the lines:
    Code:
    6004 | 0 | tut_dil_foll_1 | VAR_CHANCE       | 100
    6005 | 0 | tut_dil_foll_1 | GEN_TARGET_NONE  | 100
    6006 | 0 | tut_dil_foll_1 | CND_UNIQUE
    6007 | 0 | tut_dil_foll_2 | VAR_CHANCE       | 100
    6008 | 0 | tut_dil_foll_2 | GEN_TARGET_NONE  | 100
    6009 | 0 | tut_dil_foll_2 | CND_UNIQUE
    In file (e), add the lines:
    Code:
    incidents_localised_title_tut_dil_foll_1 | My First Followup | True
    incidents_localised_description_tut_dil_foll_1 | My incident text. | True
    incidents_localised_title_tut_dil_foll_2 | My Second Followup | True
    incidents_localised_description_tut_dil_foll_2 | My incident text. | True
    In file (i), add the line:
    Code:
    tut_dilemma | 5004 | 0 | VAR_FOLLOWUP_CHANCE | 100
    18. Update the string in table (f) with a newer string, like "Look! My chain mod loaded!". Double check your work; files (b,c,d,e,i,k) are all modified with the chain information. Save the pack file. Copy the pack file into the game data directory. Play a game! Remember which button you chose during the dilemma; play a few more turns; the corresponding incident should show up.
    Last edited by davidlallen; August 15, 2011 at 06:43 PM.

  3. #3
    davidlallen's Avatar Shashu
    Join Date
    Jun 2011
    Posts
    152

    Default Re: How to add incidents and dilemmas

    reserved
    Last edited by davidlallen; August 15, 2011 at 03:23 PM.

  4. #4
    Shashu
    Join Date
    Mar 2009
    Posts
    179

    Default Re: How to add incidents and dilemmas

    Ya Know, you'd think the creation of a general would be somewhere in dilemma, yet all I can seem to find is the UI choice for it.

  5. #5
    davidlallen's Avatar Shashu
    Join Date
    Jun 2011
    Posts
    152

    Default Re: How to add incidents and dilemmas

    There are two dilemmas which seem to cover this:

    s_promotion_post_battle "Fit for Command"
    My lord, one of our valiant warriors has proved his mettle in securing this victory for the clan. It is our belief that his talents are wasted in the rank-and-file and that he will best serve the clan leading our forces in battle.
    1. An army needs leadership if it is to wage war effectively. We will exercise his martial prowess to further our military objectives.
    2. This man's ability is unquestionable, but we have no need of his services for the time being.

    s_promotion_turn_start "Eager to Serve"
    My lord, the son of one of your most loyal subjects - a fine warrior, I am told - desires to prove his worth to you and the clan. As such, he requests the opportunity to lead your glorious forces in battle.
    1. An army needs leadership if it is to wage war effectively. We will give him the chance to prove his worth.
    2. This man's eagerness to serve is admirable, but we do not require his services for the time being.

    However, the conditions for these are very weird, and it is possible that the game doesn't actually use them to generate the new generals we see. If not, I don't have any leads for where else to look.

  6. #6
    Bad213Boy's Avatar Kirā
    Join Date
    Nov 2011
    Location
    Chicago
    Posts
    297

    Default Re: How to add incidents and dilemmas

    Where is CDIR_CVN_EVENT_GENERATOR_BASE_CHANCE located? You show it in step 3, but you never say where you got it from.

    Nevermind, I found it it in Column 3. You should have listed which column to use.
    Last edited by Bad213Boy; January 31, 2012 at 02:06 PM.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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