Compatible Companion Mod Creation/Game Mechanics And Module Events

From Dragon Age Toolset Wiki
Jump to: navigation, search

We first need to discuss how the game makes use of scripts, and in particular our module event scripts (every mod has one). Every time something happens in the game, e.g., you open or close the inventory, talents, skills, or world map gui, all the module event scripts you have installed are fire and processed (probably in the order the mods where installed) as well as the core game scripts (typically these are processed first).

So if we want to capture the behavior of our NPC follower or a major event of the game it can be done here, e.g., the PC selected or dropped the follower in the partypicker, you begin travel, or the PC just finished talking to everyone at the gates in the climax, or the game is over and we're at the slideshow.

This game structure is indeed brilliant since it allows the main game and all mods installed to handle and process the same event, say EVENT_TYPE_BEGIN_TRAVEL or EVENT_TYPE_MODULE_HANDLE_GIFT or EVENT_TYPE_WORLD_MAP_CLOSED and so forth.

What we can't and can do

The only major resource we have to change is the partypicker, otherwise our NPC's won't show up. There is a way around this(item 4 below).

If you want your NPC to interject in the middle of a major dialog, that dialog resource has to be changed (I can't see any way around this one).

The thing to keep in mind is that every time something happens in the game, certain flags from core game resources are set. We can capture when these are set and continue the process appropriately.

In this way, I'll show you how we can do the following (I've done these for my mod Valeria, WITHOUT changing any core game resources, I'll use her as a reference):

1) Valeria banters with the party randomly WITHOUT changing any original game scripts.

2) Valeria accepts specific gifts WITHOUT changing the game scripts.

3) Valeria is in a nightmare area WITHOUT changing the game scripts.

4) Valeria has a dialog option to eliminate problems with partypicker compatibility. If she doesn't show up in the partypicker she can still be picked up or sent back to camp.

5) Valeria has her own dialog after major cutscenes (where appropriate) of the game WITHOUT changing resources of the game.

6) Valeria appears in all camps (basic camp, Arl Eamon's estates, post coronation), most cutscenes from the original game and at the city gates WITHOUT changing resources of the game.

7) Valeria behaves appropriately if the PC gets captured WITHOUT changing resources of the game.

8) Slideshow post coronation WITHOUT changing the resources of the game.


Everything on this wiki is currently written in such a way that only item 2, requires further modifications to make the scripts disjoint, so we can all use it(should you choose to) without conflicts and bugs.

General Note: The dynamic stage acl_1p is used in most dialogs you see below. Remember to check the "At current location" tick box. Actor1 should be PLAYER, Actor2 should be owner.

What do we need?

Well, basic knowledge of the toolset and scripting.

a) The NPC mod event handler, say "valeria_event_handler". The companion Valeria is given the tag, "valeria_npc"

b) A plot to hold all our NPC flags, call it "valeria_npc_hire". In the handler we should have the include:

#include "plt_valeria_npc_hire"

c) We need the following basic FLAGS:

  • PARTY_VALERIA_IN_PARTY
  • PARTY_VALERIA_JOINED
  • VALERIA_CHECK_RUNIT

These are there to handle Valeria(is she in party?, has she joined? do we need to run the script? it has to be done if we're in a camp site. you'll see what script)

d) Other flags to set when needed:

  • VALERIA_WYNNE_KILLED
  • VALERIA_RESPONSE_TO_BAD
  • VALERIA_ENTER_FADE
  • VALERIA_HAS_NIGHTMARE_A
  • VALERIA_HAS_NIGHTMARE_B
  • VALERIA_HAS_NIGHTMARE_C
  • VALERIA_SLOTH_DEMON_ATTACKS
  • VALERIA_SLOTH_DEMON_DEFEATED
  • VALERIA_WYNNE_KILLED_AT_CULLEN
  • VALERIA_DEN_CAPTURED_PC_CAPTURED
  • VALERIA_CLI_MAIN_PC_FINISHED_SETTING_FINAL_PARTY
  • VALERIA_EPI_JUMP_TO_SLIDE_SHOW, VALERIA_FIGHTING_ARCHDEMON

If you drop the valeria_ prefix (FOR YOUR MOD USE A DIFFERENT PREFIX EVERYWHERE) you'll recognize some flags from the original game. Everytime those are set, we'll need to set a corresponding flag in our NPC plot, so we run things only once.

I'll tell you which plots from the main game we need depending on what we're trying to do.

Basic structure of the module event handler

//core includes here
 
//core plot includes
 
//valeria function, plots etc, includes
 
#include "plt_valeria_npc_hire"
 
//constant definitions here
 
//function definitions here
 
(all this part 1)
 
void main()
{
    object oPC = GetHero(),me=OBJECT_SELF,ohire;
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    //function calls here, other important checks (part 2)
    //capture events
    switch(nEventType)
    {
     .....(part 3)
    }
}
 
//functions here (part 4)

For what follows, I'll break the event script into four parts for quick reference: Includes, (Main) Body, (Event) Handling, Functions

Capturing Main Campaign Event/Flag Changes, the function check_plot_changed()

The next script can be placed in the event handler, and allows us to capture and process main plot changes.

I'll do this structure a first time here

In 'includes' add:

void check_plot_changed(object oVal);

In 'body' add:

...
object oVal=UT_GetNearestObjectByTag(oPC,"valeria_npc");
...
 
check_plot_changed(oVal);
...

In 'functions' add:

//check if plot flags changed and act appropriately
 
void check_plot_changed(object oVal)
{
    object oPC=GetHero(); //if Valeria has not joined return
//leave some room here for the slideshow script addition
//it has to go above this check, otherwise if you don't pick her up
//the script won't fire and the appropriate slides won't be shown
    if (!WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE, PARTY_VALERIA_JOINED))
    return;
//every other addition to this function should be made below this check
...
//here depending on which core flag changed, act appropriately
...
 
}

We will be changing this function appropriately below, depending on what we wish to do.

Potential Disadvantage (not certain, it might cause lag in slow systems)

Now that we know how the handlers behave (from mods and the core game) we need to discuss the possible problems with this approach.

It all comes down to lag (although I don't really experience it but I put it here for completeness).

Whenever we intercept an event in Event handling, all the commands in the event handler Body will fire. That might slow some low end systems down.

Icon wiki arrow left disabled.png Compatible Companion Mod Creation Random Banter