Author Sticky: Post Working Scripts Here
mindtakerr Posted: Thursday, 18 July 03:25AM
Name: Mindtakerr's Include File
What it does: Just provides some functions that (I think) are useful
Notes:
Use of each function:

GetNearestPC
Usage: GetNearestPC(); Will find the nearest PC to the caller object.

GetNearestNPC
Usage: GetNearestNPC(); Will find the nearest NPC to the caller object.

GiveGoldToParty
Usage: GiveGoldToParty(int AmountOfGoldToGive); Gives the entire party the amount of gold specified.

GiveXPToParty
Usage: GiveXPToParty(int AmountOfExperiencePointsToGive); Gives the entire party the amount of experience points specified.

TransportPartyToDestination
Usage: TransportPartyToDestination(string DestinationTag, float Delay); Transports the party to the specified waypoint by its tag after a delay of Delay seconds.

GetIsArmed
Usage: GetIsArmed(object Creature); Determines if the Creature passed to it is armed.

GetTotalLevel
Usage: GetTotalLevel(object Creature); Gets the total level of all the classes of the Creature passed to it.

I hope some scripters find these useful.

Here's the script itself. To use it, just save the script as mindtakerr_inc. Then, at the top of the script you want to use it on, just type #include "mindtakerr_inc".

NWScript:
//::///////////////////////////////////////////////

//:: Name: Mindtakerr's Include File

//:: FileName: mindtakerr_inc

//:: Copyright (c) 2001 Bioware Corp.

//:://////////////////////////////////////////////

/*

*/

//:://////////////////////////////////////////////

//:: Created By: mindtakerr

//:: Updated On: 07/17/02

//:://////////////////////////////////////////////

//::///////////////////////////////////////////////

//:: Name: GetNearestPC

//:: Copyright (c) 2001 Bioware Corp.

//:://////////////////////////////////////////////

/*

    GetNearestPC returns the nearest PC to the caller.

*/

//:://////////////////////////////////////////////

//:: Created By: mindtakerr

//:: Created On: 07/16/02

//:://////////////////////////////////////////////

object GetNearestPC()

{

    return GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);

}

//::///////////////////////////////////////////////

//:: Name: GetNearestNPC

//:: Copyright (c) 2001 Bioware Corp.

//:://////////////////////////////////////////////

/*

    GetNearestNPC returns the nearest NPC to the caller.

*/

//:://////////////////////////////////////////////

//:: Created By: mindtakerr

//:: Created On: 07/16/02

//:://////////////////////////////////////////////

object GetNearestNPC()

{

    return GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_NOT_PC);

}

//::///////////////////////////////////////////////

//:: Name: GiveGoldToParty

//:: Copyright (c) 2001 Bioware Corp.

//:://////////////////////////////////////////////

/*

    GiveGoldToParty gives nGP gold pieces to each member

    of the current party.

*/

//:://////////////////////////////////////////////

//:: Created By: mindtakerr

//:: Created On: 07/16/02

//:://////////////////////////////////////////////

void GiveGoldToParty(int nGP)

{

    object oPC = GetNearestPC();

    object oParty = GetFirstFactionMember(oPC);

    while(GetIsObjectValid(oParty)) {

        GiveGoldToCreature(oParty, nGP);

        oParty = GetNextFactionMember(oPC);

    }

}

//::///////////////////////////////////////////////

//:: Name: GiveXPToParty

//:: Copyright (c) 2001 Bioware Corp.

//:://////////////////////////////////////////////

/*

    GiveXPToParty gives nXP experience points to

    each member of the current party.

*/

//:://////////////////////////////////////////////

//:: Created By: mindtakerr

//:: Created On: 07/16/02

//:://////////////////////////////////////////////

void GiveXPToParty(int nXP)

{

    object oPC = GetNearestPC();

    object oParty = GetFirstFactionMember(oPC);

    while(GetIsObjectValid(oParty)) {

        GiveXPToCreature(oParty, nXP);

        oParty = GetNextFactionMember(oPC);

    }

}

//::///////////////////////////////////////////////

//:: Name: TransportPartyToDestination

//:: Copyright (c) 2001 Bioware Corp.

//:://////////////////////////////////////////////

/*

    This will transport every member of the party

    to the waypoint with the given tag,

    sDestinationWaypointTag, and will delay each

    member by fWait seconds.

*/

//:://////////////////////////////////////////////

//:: Created By: mindtakerr

//:: Created On: 07/16/02

//:://////////////////////////////////////////////

void TransportPartyToDestination(string sDestinationWaypointTag, float fWait)

{

    object oDestination = GetWaypointByTag(sDestinationWaypointTag);

    object oPC = GetNearestPC();

    object oParty = GetFirstFactionMember(oPC);

    while(GetIsObjectValid(oParty)) {

        AssignCommand(oParty, ActionWait(fWait));

        AssignCommand(oParty, ActionJumpToObject(oDestination));

        oParty = GetNextFactionMember(oPC);

    }

}

//::///////////////////////////////////////////////

//:: Name: GetIsArmed

//:: Copyright (c) 2001 Bioware Corp.

//:://////////////////////////////////////////////

/*

    GetIsArmed will return TRUE if the passed in

    oCreature is armed with a weapon.  It will return

    FALSE if the creature is not armed.

*/

//:://////////////////////////////////////////////

//:: Created By: mindtakerr

//:: Created On: 07/17/02

//:://////////////////////////////////////////////

int GetIsArmed(object oCreature)

{

    return (GetIsObjectValid(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oCreature)));

}

//::///////////////////////////////////////////////

//:: Name: GetTotalLevel

//:: Copyright (c) 2001 Bioware Corp.

//:://////////////////////////////////////////////

/*

    GetTotalLevel returns the sum of the levels of

    all three classes of the passed in oCreature.

*/

//:://////////////////////////////////////////////

//:: Created By: mindtakerr

//:: Created On: 07/17/02

//:://////////////////////////////////////////////

int GetTotalLevel(object oCreature)

{

    int nTotal = 0;

    int nCounter;

    for (nCounter = 1; nCounter <= 3; nCounter++)

        nTotal += GetLevelByPosition(nCounter, oCreature);

    return nTotal;

}



_________________
Michael Ham
Check out The Six Realms of Bel'Abourd; a fantasy RPG work in progress.
www.bakedhamgames.com