Results 1 to 9 of 9

Thread: How to make your own historic events

  1. #1

    Default How to make your own historic events

    While doing some digging I cracked this method - it's quite simple to edit actually.

    To start off I suggest you visit the NTW Script-o-Rama. From there you will find a basic introduction to scripting, helpful tips and advice on tools to use (mainly notepad ++). This thread assumes you have basic knowledge, all of which is available in the script-o-rama.

    This method should also work for Empire:TW; I can't comment on S2TW.

    Part 1 - Files Needed
    You'll need to add the following db tables and files to your mod pack, as these are the ones we'll be editing:
    • events_tables
    • events_view_group_junct_tables
    • export_historic_events.lua

    You'll also need to make some changes in the localisation.loc


    Part 2 -The Simple Method
    This method explains the how, not the why. Please refer to the advanced method for a more full explanation.

    To get yourself off the ground with this quickly you'll need to begin by adding a new entry to events tables. As you can see, I've made one here called myEvent. The only columns which you need to worry about are the ones labelled "Imageas" (should be "Image", typo on my behalf), "Dynamic" and "Image2". The rest of the entries make absolutely no difference to this process, contrary to popular belief. "Dynamic" should always be set to false, Imageas and Image2 control the image used by the in game pop-up; you can edit these as you see fit.

    Spoiler for events_tables






    Next you need to go to events_view_group_junct_tables. Simply make a new entry with your event key and the value "all_factions", as seen below.

    Spoiler for events_view_group_junct_tables






    Next you need to go to export_historic_events.lua. At the end of this file you need to make a duplicate block of code, as you can see I have done. This is where the actual information about when the event triggers is stored, not the db file. You will need to edit the arguments passed to the function conditions.IsTriggerableHistoricalEvent(). (Simply put, you'll need to edit what's in between the brackets).
    • The first number (in my example, 2) is the turn in the year that the event will display.
    • The string that follows it (in my example, "myEvent") is the name of your event - this must match the db key of your event.
    • The next number is the year in which the event will fire.
    • The next string seems defunct; it always contains information about the season, but in my testing it has had no impact on the end result.
    • The final argument, context, must never be changed.


    The final thing to edit in this lua file is the function effect.historical_event(). The string passed to this function is the name of your event. Again, this must match the db key of your event.

    Spoiler for export_historic_events.lua






    The final item we need to edit is the loc. We simply make 2 new entries:
    • events_event_text_foo
    • events_onscreen_name_foo


    Where "foo" is the name of your event. Shown below is an example of this.

    Spoiler for localisation




    As you can see below, the event works as intended - in my case firing on the second turn of 1805.

    Spoiler Alert, click show to read: 


    Now for the more detailed explanation.

    Part3 -Some advanced explanation

    Why are most of the db values ignored?
    My theory is that the .lua we edit was automatically generated pre-release. It used the data is the db columns to build the lua code - this was probably a method employed by CA so that game developers who weren't proficient in Lua could easily create and test historic events. Remember that this is a leftover from Empire, a game that had far more historic events than NTW. This is backed up by the comment at the top of the file:
    "Automatically generated via export from Empire.mdb
    Edit manually at your own risk"

    Either way, we need to edit the Lua code directly to make any changes. It should be noted that in order to change existing events you'll need to edit the Lua code directly also.





    Any more info on the function and it's conditions?
    Yes. You can call the function directly by using effect.historical_event(), but this needs a context argument passed from the HistoricalEvents event. So you can only use this function inside an HistoricalEvents event block. If this is used at the start of every turn you will get a historic event message each and every turn start. It is the conditions.IsTriggerableHistoricalEvent() function that restricts it to firing once. A summary of the arguments to the two functions:

    conditions.isTriggerableHistoricalEvent
    1. Turn in year
      • Type: Int
      • Notes: The turn in the given year which the event will fire on.
    2. Event name
      • Type: String
      • Notes: The db key of the event
    3. Year
      • Type: Int
      • Notes: The Year in which the event will fire
    4. Season
      • Type: String
      • Notes: Seems to be unused
    5. context
      • Type: userdata
      • Notes:Must be used with HistoricalEvents event


    effect.historical_event
    1. Name
      • Type: String
      • Notes: The db key of the event
    2. context
      • Type: userdata
      • Notes:Must be used with HistoricalEvents event




    Feel free to post with any questions
    Last edited by T.C.; December 13, 2011 at 07:04 PM.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  2. #2

    Default Re: How to make your own historic events

    Nice tutorial

  3. #3

    Default Re: How to make your own historic events

    Thanks for that, would use this for b&g 3.0

  4. #4
    Primergy's Avatar Protector of the Union
    Join Date
    Mar 2009
    Location
    Augsburg
    Posts
    2,491

    Default Re: How to make your own historic events

    "Turn in year" doesn't seam to exist in ETW (neither db, nor in the events.lua) - can another command be used or is this fixed?

  5. #5
    Kinggeorge's Avatar Laetus
    Join Date
    Aug 2011
    Location
    Dominion of Canada
    Posts
    19

    Default Re: How to make your own historic events

    thanks ill be using this for a long time. great tutorial mate!

  6. #6

    Default Re: How to make your own historic events

    Is there a way with historical events where you can code a 'reward' for instance gives a nation a unit like with missions?

  7. #7
    Steph's Avatar Maréchal de France
    Patrician Artifex

    Join Date
    Apr 2010
    Location
    Pont de l'Arn, France
    Posts
    9,174

    Default Re: How to make your own historic events

    depends what you want to do exactly, but basically yes, you can grant units to a faction. You need to carefully set up the conditions.

  8. #8

    Default Re: How to make your own historic events

    So for example I wanted to grant the UK a unit of Brunswick Line Infantry could I use the code "grant_unit:Inf_Line_Brunswick_Line_Infantry#settlement:eur_hannover:braunschweig") ?

  9. #9
    Steph's Avatar Maréchal de France
    Patrician Artifex

    Join Date
    Apr 2010
    Location
    Pont de l'Arn, France
    Posts
    9,174

    Default Re: How to make your own historic events

    More or less, with some small mistakes corrected (the syntax has a few errors). But:
    - You can only add units to settlement, not in small towns I think.
    - You cannot grant UK a unit Brunswick unit in Hannover: you grant a Brunswick unit to whatever faction controls Hannover. So you need to add a condition: if UK capture Hannover, then give them a Brunswick unit. If you use the command without connection for the first turn, the Brunswick unit would go to France. Even if France is not suppose to be able to recruit it. And it can lead to issue (like if the uniform is defined for UK, but not for France, you'd get the old ETW uniform placeholder).

    That's why it is easier to add units to faction when starting the game: at least you are sure who controls each region.

Posting Permissions

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