DMH-Online

Dungeon Masters Helper · Est. 2005

Misc Scripts

NWN Script: function_includes.htm

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

⌂ All Scripts ← PreviousNext → 👁 Category List

All Misc Scripts

📄 arena 📄 cast_bless_on_PC 📄 change_music 📄 chess_game 📄 climbing 📄 climbing_002 📄 common_includes_002 📄 cone_aoe 📄 cron 📄 cross_country_travel 📄 daoc_style_graves 📄 determine_time 📄 effects 📄 escort 📄 ez_respawn 📄 faction 📄 floating_text 📄 function_includes 📄 gambling 📄 include_sounds 📄 include_time_date 📄 jail 📄 jail_system 📄 journal_entry 📄 logbook 📄 manage_action_queue 📄 mmorpg_vault 📄 mod_intro 📄 mod_intro_002 📄 mod_intro_003 📄 mod_intro_005 📄 pers_world_database 📄 pers_world_database_002 📄 piller_of_fire 📄 plot_item 📄 portal_system 📄 portal_system_002 📄 puking 📄 quest_escort 📄 rep_per 📄 reward_rp 📄 rotation 📄 save_pc_location_002 📄 save_pc_location_003 📄 skill_checks 📄 skill_checks_002 📄 slot_machine 📄 story 📄 swimming 📄 take20_bypass 📄 vis_waypoint 📄 working_temple 📄 working_temple_002 📄 xp_gold_loss 📄 xp_gold_loss_002 📄 xp_loss_action