Compatible Companion Mod Creation/Random Banter

From Dragon Age Toolset Wiki
Jump to: navigation, search

The Random Banter step describes how to integrate your custom companion into the random banter system.

What we need

A dialog resource, say "valeria_random_banter.dlg", a script "valeria_random_banters.nss" and a plot "valeria_random_banters"

You will notice that they are done in order of appearance in the .dlg file. Of course one can change that. Meaning if Alistair is in the party, all his banters will go through first, then Morrigan, then Leliana, etc, the way I had them in my file. To change that you can add a random chance to see if you initiate dialog with the party member.(see the script below, it is trivial)

valeria_random_banters.nss

First create this script. You can see what flags you need in plt_valeria_random_banters below (basically a flag for each companion you want Valeria to banter with). Alternatively, you can use the core plots to check who is in the party, but I find this more efficient, since we got full control over the script and plot resource.

//file valeria_random_banters.nss

#include "wrappers_h"
#include "plt_valeria_random_banter"
 
void  main()
{
    int i;
 
    WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, ALISTAIR_IN_PARTY, FALSE);
    WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, MORRIGAN_IN_PARTY, FALSE);
    WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, LELIANA_IN_PARTY, FALSE);
    WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, WYNNE_IN_PARTY, FALSE);
    WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, ZEVRAN_IN_PARTY, FALSE);
    WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, DOG_IN_PARTY, FALSE);
 
    object [] arParty = GetPartyList(GetHero());
    int nSize = GetArraySize(arParty);
    int which=Random(nSize)+1;
 
    if(GetTag(arParty[which]) == "gen00fl_alistair")
        WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, ALISTAIR_IN_PARTY, TRUE);
    if(GetTag(arParty[which]) == "gen00fl_morrigan")
        WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, MORRIGAN_IN_PARTY, TRUE);
    if(GetTag(arParty[which]) == "gen00fl_leliana")
        WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, LELIANA_IN_PARTY, TRUE);
    if(GetTag(arParty[which]) == "gen00fl_wynne")
        WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, WYNNE_IN_PARTY, TRUE);
    if(GetTag(arParty[which]) == "gen00fl_zevran")
        WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, ZEVRAN_IN_PARTY, TRUE);
    if(GetTag(arParty[which]) == "gen00fl_dog")
        WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, DOG_IN_PARTY, TRUE);
}
 
 
//to add a random chance for the party member to banter with Valeria you can simply change
...
    if(GetTag(arParty[which]) == "gen00fl_dog" && Random(10)==1)
        WR_SetPlotFlag(PLT_VALERIA_RANDOM_BANTER, DOG_IN_PARTY, TRUE);
...

This way it won't circle through all the banters of Alistair, then Morrigan's etc, but it will skip them with some probability (90%). This means the probability of an actual banter starting is .0025*.1=.00025 (1/400=.0025).

Changes in valeria_event_handler

I'll do this structure again(last time), the rest will be the same:

In 'includes' add:

void valeria_banter();

In 'body' add:

//valeria banter: run this only if valeria is in active party
    if (WR_GetPlotFlag(PLT_VALERIA_NPC_HIRE, PARTY_VALERIA_IN_PARTY))
        valeria_banter();

In 'functions' add:

void valeria_banter()
{
    int i;
 
    if(Random(400)!=1)//1 in 400 chance to start banter
        return;
 
    if(GetCombatState(GetHero()))//don't start if in combat
        return;
 
    object[] arParty = GetPartyList(GetHero());
    int nSize = GetArraySize(arParty);
 
    if(nSize<=2)//if only valeria and the PC no banter
        return;
 
    for(i=0;i<nSize;i++)
        if(!ClearAmbientDialogs(arParty[i]))
            return;
 
    object oval=UT_GetNearestObjectByTag(GetHero(),"valeria_npc");
    UT_Talk(oval,GetHero(),R"valeria_random_banter.dlg");
}

Structure of the file valeria_random_banter.dlg

Everything should be set to AMBIENT. First notice where we call the random_banter_script.

random_banter_script

Now, notice how we structure all the npc's we want Valeria to banter with. First is Alistair, if he's in the party, and so forth.

random_banter_script

Second is Morrigan and so forth.

random_banter_script

Notice that once a banter starts, it will never be shown again.

random_banter_script

An example with 3 NPC's (this is a dog banter with Valeria, and Zevran, if he's in the party(notice the condition C, using the valeria_random_banters flag) he joins in).

random_banter_script

Game Mechanics And Module Events Compatible Companion Mod Creation End Game Slideshow