DMH-Online

Dungeon Masters Helper · Est. 2005

PCs Scripts

NWN Script: give_pc_item.htm

Author Sticky: Post Working Scripts Here
ByronDM Posted: Thursday, 04 July 03:20AM
There are already functions to give the party gold or XP, but I could not find one to give each player an item, so I modified the Gold one like so:

What it does: Gives every PC in the party an item or a stack of items

Params:
sResRef - the ResRef of the object
oTarget - a PC.
bAllParty - if true, everyone in the party gets the item, otherwise, just the target get it.
nStackSize - the number of items to give each target.

NWScript:
void RewardPartyItem(string sResRef, object oTarget,int bAllParty=TRUE, int nStackSize=1)
{
    // * 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)
        {
            //AssignCommand(oPartyMember, SpeakString("MY GP reward is: " + IntToString(GP)));
            CreateItemOnObject(sResRef, oPartyMember, nStackSize);
            //GiveGoldToCreature(oPartyMember, GP);
            oPartyMember = GetNextFactionMember(oTarget, TRUE);
        }
    }
    else
    {
        CreateItemOnObject(sResRef, oTarget, nStackSize);
        //GiveGoldToCreature(oTarget, GP);
    }
}



I used this to give the players some Cure Light Wounds potions as a reward for a quest.

⌂ All Scripts ← PreviousNext → 👁 Category List

All PCs Scripts

📄 adjust_faction 📄 alt_idle_pc_anim 📄 bleeding 📄 bleeding_002 📄 bleeding_003 📄 bleeding_004 📄 creature_item 📄 drop_items 📄 force_zone 📄 give_pc_item 📄 inspect_inv 📄 limited_druid 📄 move_items_to_container 📄 notify_of_loot 📄 pc_respawn 📄 pc_respawn_002 📄 pc_respawn_003 📄 pc_respawn_004 📄 pc_respawn_005 📄 pc_respawn_006 📄 pc_respawn_007 📄 remove_neg 📄 save_spots 📄 strip_inv_give_gold 📄 strip_inv_plot 📄 subraces 📄 subraces_002 📄 voting