GiveGoldToAllEqually

From NWN Lexicon



Contents

[edit] GiveGoldToAllEqually(object, int)

Divides a given amount of gold equally among PCs in a PC's party

void GiveGoldToAllEqually(
    object oPC,
    int nGoldToDivide
);

[edit] Parameters

oPC

Player Character

nGoldToDivide

amount of gold to share


[edit] Description

Given a PC and a gold value, divides it equally among the PCs of the Player Character's party. None is given to associates.

Please note the Known Bugs, and that using GiveGoldToAll() might be a better option.



[edit] Remarks

Include library for party-wide functions.

NOTE: this library is included in "x0_i0_common" already.
Do NOT dual-include both files or you will get errors!


[edit] Known Bugs

This uses GetNumberPartyMembers(), which will add one (counting the original oPC twice).

The work around is obvious: just get the correct # of party members, divide the gold by that amount and use GiveGoldToAll function.


[edit] Requirements

#include " X0_I0_PARTYWIDE "

[edit] Version

1.62

[edit] Example

// By using the fix above, we divide 100 gold between the oPC's
// party as a reward for a job completed.
 
// Possibly would update the journal in the same script (with a note 
// about how much the reward was, and how poor the PC's are!)
 
// If the function was fixed, we'd normally just use GiveGoldToAllEqually()
 
#include "X0_I0_PARTYWIDE"
 
void main()
{
     // Get PC to reward
     object oPC = GetPCSpeaker();
 
     // Reward the party
     int nGold = 100;
 
     // Get gold for each PC
     // - Take one off GetNumberPartyMembers(), see known bugs
     int nMembers = GetNumberPartyMembers(oPC) - 1;
 
     // Give the correct gold to all of them
     GiveGoldToAll(oPC, nGold/nMembers);
}

[edit] See Also



 author: Peter Busby, editor: Jasperre, additional contributor(s): Jasperre, Tom Raynor
 

Personal tools
Categories