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:
object GetNearestPC()
{
return GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
}
object GetNearestNPC()
{
return GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_NOT_PC);
}
void GiveGoldToParty(int nGP)
{
object oPC = GetNearestPC();
object oParty = GetFirstFactionMember(oPC);
while(GetIsObjectValid(oParty)) {
GiveGoldToCreature(oParty, nGP);
oParty = GetNextFactionMember(oPC);
}
}
void GiveXPToParty(int nXP)
{
object oPC = GetNearestPC();
object oParty = GetFirstFactionMember(oPC);
while(GetIsObjectValid(oParty)) {
GiveXPToCreature(oParty, nXP);
oParty = GetNextFactionMember(oPC);
}
}
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);
}
}
int GetIsArmed(object oCreature)
{
return (GetIsObjectValid(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oCreature)));
}
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
|