FANDOM


This is a training system that forces characters to find a valid trainer to be able to advance in level. So far it basically goes like this:

Set module experience slider to 0. Keep a local variable on the character to count how many experience points they have earned since they last leveled (i.e. instead of gaining experience, I just add the amount they should have gained to this variable). The character has an item that will tell them how much experience they've earned. They must find an NPC (or possibly placeable in cases like clerics praying at shrines to level) that is capable of training their class/level. (For example I have a trainer in my starting town that can train fighters, rangers, barbarians up to level 4, anyone else can't train there.)

Include script Edit

Just updates of the xp functions. (This is an include file that is used in several of my other scripts; I call it my_tools.)

//JUST SLIGHT EDITS OF DEFAULT XP SCRIPTS
void mGiveXPToCreature(object oPC, int iXP) {
    int iCurrent = GetLocalInt(oPC, "experience_earned");
    SetLocalInt(oPC, "experience_earned", iCurrent + iXP);
}
void mRewardPartyXP(int XP, object oTarget,int bAllParty=TRUE)
{
    // * for each party member
    // * cycle through them and
    // * and give them the appropriate reward
    // * HACK FOR NOW
    if (bAllParty == TRUE)
    {
        object oPartyMember = GetFirstFactionMember(oTarget, TRUE);
        while (GetIsObjectValid(oPartyMember) == TRUE)
        {
            mGiveXPToCreature(oPartyMember, XP);
            oPartyMember = GetNextFactionMember(oTarget, TRUE);
        }
    }
    else
    {
     mGiveXPToCreature(oTarget, XP);
    }
}

Death script Edit

Then we have the creature OnDeath script.

//::///////////////////////////////////////////////
//:: Default:On Death
//:: NW_C2_DEFAULT7
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Shouts to allies that they have been killed
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Oct 25, 2001
//:://////////////////////////////////////////////
#include "NW_I0_GENERIC"
//#include "NW_I0_TOOL"
//USES MY ALTERED XP FUNCTIONS
#include "my_tools"
void main()
{
    int nClass = GetLevelByClass(CLASS_TYPE_COMMONER);
    int nAlign = GetAlignmentGoodEvil(OBJECT_SELF);
    if(nClass > 0 && (nAlign == ALIGNMENT_GOOD || nAlign == ALIGNMENT_NEUTRAL))
    {
        object oKiller = GetLastKiller();
        AdjustAlignment(oKiller, ALIGNMENT_EVIL, 5);
    }
    SpeakString("NW_I_AM_DEAD", TALKVOLUME_SILENT_TALK);
    //Shout Attack my target, only works with the On Spawn In setup
    SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
    if(GetSpawnInCondition(NW_FLAG_DEATH_EVENT))
    {
        SignalEvent(OBJECT_SELF, EventUserDefined(1007));
    }
//ABOVE THIS IS JUST THE NWN DEFAULT ON_DEATH
//INCREMENTS PC XP VARIABLE BASED ON LVL vs. CR
    //give experience based on CR and character HitDice
    object oPC = GetLastKiller();
    float iCR = GetChallengeRating(OBJECT_SELF);
    int iHD = GetHitDice(oPC);
    int iXP1 = FloatToInt(((iCR/iHD) * 33));
    int iXP2 = (iXP1/2);
    mGiveXPToCreature(oPC, iXP1);
    mRewardPartyXP(iXP2, oPC, TRUE);
}

Trainer script 1 Edit

Now for an example of a trainer script.

//CHECKS WHETHER THE PC CAN BE TRAINED HERE
int StartingConditional()
{
    object oPC = GetPCSpeaker();
    int iLevel = GetLevelByClass(CLASS_TYPE_FIGHTER, oPC) + GetLevelByClass(CLASS_TYPE_BARBARIAN, oPC) + GetLevelByClass(CLASS_TYPE_RANGER, oPC);
    // Restrict based on the player's class
    int iPassed = 0;
    if(iLevel >= 1 && GetHitDice(oPC) <= 4)
        iPassed = 1;
    return iPassed;
}

Checks to see if the character is a warrior class and below level 4.

Trainer script 2 Edit

If they are an appropriate level then we charge them and actually give them the experience they earned, then reset their experience_earned variable.

//GIVES XP EARNED TO PC AND RESETS XP VARIABLE
void main()
{
    int iXP;
    object oPC = GetPCSpeaker();
    TakeGoldFromCreature(100, oPC, TRUE);
    iXP = GetLocalInt(oPC, "experience_earned");
    GiveXPToCreature(oPC, iXP);
    SetLocalInt(oPC, "experience_earned", 0);
}

Item activation script Edit

This is for the module OnActivateItem script. It tells the PC how much experience they have earned when they use their experience meter. (The experience meter is just a miscellaneous item that I gave the "Unique Power: Self Only" power with unlimited uses.)

void main()
{
    object oPC = GetItemActivator();
    object oItem = GetItemActivated();
    if (GetTag(oItem) == "ExperienceMeter") {
        SendMessageToPC(oPC, "You peer intently into the crystal.");
        SendMessageToPC(oPC, "You have earned " + IntToString(GetLocalInt(oPC, "experience_earned")) + " experience since you last trained.");
    }
}


Level-up script Edit

In the Module OnLevelUp script I heal the PC and reset their experience variable to 0.

void main()
{
    object oPC = GetPCLevellingUp();
    SendMessageToPC(oPC, "You feel stronger from your training.");
    AssignCommand(oPC, ActionCastSpellAtObject(SPELL_HEAL, oPC, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
    SetLocalInt(oPC, "experience_earned", 0);
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.