Author Sticky: Post Working Scripts Here
ShadeRaven Posted: Monday, 22 July 05:39PM
Script name: More Core Rules Accurate Animal Companions

What it does: Puts more realistic limits on a Druid or Ranger for summoning an Animal Companion. In the PHB, the Animal Companion can only be up to 2 HD in size. However, the Spell Animal Friendship is used to getting a "companion" of higher level (they recommend up to the Druid's level for the adventuring druid). Note that the spell allows a Will Save to resist and must be cast at a valid target. Thus, what I did was to put into Animal Companion script code that would reflect that 3rd level+ need for a Druid. The Druid/Ranger (after 3rd level) must be in a Wilderness setting and when casting the spell, the target creature now gets a Will Saving throw to resist. The Druid/Ranger cannot cast this spell (animal friendship) more than once per 24 hours to reflect the fact that they would have to find another valid animal target, rememorize the animal friendship spell, and also rememorize the original spell it was replacing. I don't actually require the Ranger or Druid to be near a valid target to get their companion (it will be considered natural for them to find at least 1 appropriate target per 24 hour period).

Notes: For each Area, a Local Int must be set to TRUE (or 1) to indicate that it is a wilderness zone (and thus allowing the summon to take place. It should look something like this (this is from my area's OnEnter script):

SetLocalInt(OBJECT_SELF, "Wilderness", TRUE);

The script: This should be used as the new N2_S2_ANIMALCOM (replacing the default).

NWScript:
void main()

{

    // Number of Hours between Animal Companions.

    object oMod = GetModule();

    int iACPeriod = 24;

    string sPC = GetName(OBJECT_SELF);

    string sACText = sPC + " hasn't waited long enough to summon another companion.";

    string sWildText = sPC + " isn't in a Wilderness Setting.";

    string sWillText = "The animal companion resisted the call of " + sPC + ".";

    //First get the time last rested and the current time.

    int iLastHourAC = GetLocalInt(oMod, ("LastHourAC" + sPC));

    int iLastDayAC = GetLocalInt(oMod, ("LastDayAC" + sPC));

    int iLastYearAC = GetLocalInt(oMod, ("LastYearAC" + sPC));

    int iLastMonthAC = GetLocalInt(oMod, ("LastMonthAC" + sPC));

    int iHour = GetTimeHour();

    int iDay  = GetCalendarDay();

    int iYear = GetCalendarYear();

    int iMonth = GetCalendarMonth();

    int iHowLong = 0;

    if (iLastYearAC != iYear)

        iMonth = iMonth + 12;

    if (iLastMonthAC != iMonth)

        iDay = iDay + 28;

    if (iDay != iLastDayAC)

        iHour = iHour + 24 * (iDay - iLastDayAC);

    iHowLong = iHour - iLastHourAC;

    // Not waited long enough?

    if (iHowLong < iACPeriod || GetLocalInt(GetArea(OBJECT_SELF), "Wilderness") == 0)

    {

        AssignCommand(OBJECT_SELF, ClearAllActions());

        if (iHowLong < iACPeriod)

            FloatingTextStringOnCreature(sACText, OBJECT_SELF, FALSE);

        if (GetLocalInt(GetArea(OBJECT_SELF), "Wilderness") == 0)

            FloatingTextStringOnCreature(sWildText, OBJECT_SELF, FALSE);

    } else {

        SetLocalInt(oMod, ("LastHourAC" + sPC), GetTimeHour());

        SetLocalInt(oMod, ("LastDayAC" + sPC), GetCalendarDay());

        SetLocalInt(oMod, ("LastMonthAC" + sPC), GetCalendarMonth());

        SetLocalInt(oMod, ("LastYearAC" + sPC), GetCalendarYear());

        // The Will Save to resist the "Summons."

        //   - Base Will Save for Animals should = +1 per 3 levels

        //       (of Druid since the Druid Level = the AC's HD)

        int iHD = GetLevelByClass(CLASS_TYPE_DRUID);

        int iWillBonus = iHD/3;

        // The DC of Animal Friendship = 10 + 1 + Wis Mod

        int iDC = 10 + 1 + GetAbilityModifier(ABILITY_WISDOM);

        // Make Saving throw if Druid is over level 2.

        //   No save below level 3 because a Druid is supposed to get a free

        //   2 HD or less creature before then.

        if (d20()+iWillBonus >= iDC && iHD > 2) {

            FloatingTextStringOnCreature(sWillText, OBJECT_SELF, FALSE);

            // Give time back for next summon.  Making it half as long a wait.

            int iHour = GetTimeHour();

            iHour -= iACPeriod/2;

            if (iHour < 0) {

                SetLocalInt(oMod, ("LastHourAC" + sPC), iHour+24);

                SetLocalInt(oMod, ("LastHourAC" + sPC), iHour+24);

            } else {

                SetLocalInt(oMod, ("LastHourAC" + sPC), iHour);

                SetLocalInt(oMod, ("LastDayAC" + sPC), GetCalendarDay()-1);

            }

        } else {

            //Yep thats it

            SummonAnimalCompanion();

        }

    }

}



Worked great in testing.
Enjoy!

[Edit] Changed the Wait Period from 12 to 24. I use 12 hours waiting because I have my modules set to 4 minutes per hour (twice as long as the default setting). Changed it to 24 for here since I expect most people play with 2 minute hours.
_________________
Imitation is the sincerest form of imitation.

For good NWN information, visit Neverwinter Vault

For my Analyses/Guides visit: ShadeRaven's NWN Guides