//Created by Genisys / Guile 5/26/08
////////////////////////////////////////////////////////////////////////////////
/*
The Party Loot dividing chest gives 30% of an items's value to EVERY
party member, unless there is only 1 party members, then they only
get 15% the value of the item, up to the maximum gold allowed
per item, set on the variable on the chest! (See Chest)
*/
////////////////////////////////////////////////////////////////////////////////
#include "X0_I0_PARTYWIDE"
#include "nw_i0_plot"
//Put this script OnClose
object oTarget, oItem;
int GetMemberCount(object oPC){ int i = 0;
object oMember = GetFirstFactionMember(oPC);
while(GetIsObjectValid(oMember)) {
i+=1; oMember = GetNextFactionMember(oPC); } return i;}
int GetIdentifiedGoldPieceValue(object oItem){
int bIdentified = GetIdentified(oItem);
if (!bIdentified) { SetIdentified(oItem, TRUE); }
int nGP=GetGoldPieceValue(oItem);
int m, n; if(nGP >30000000) { nGP = 30000000; return nGP; }
else if(nGP <30000000 && nGP>=100)
{ m = nGP/100; n = m * 70; //30%!
nGP = n; return nGP; }
else if(nGP<100) { nGP = 30; return nGP; }
else { return nGP; }
}
void main(){
object oPC = GetLastClosedBy();
oTarget = OBJECT_SELF;
object oItem;int a, b, c;
int nMembers = GetMemberCount(oPC);
int nInt = GetLocalInt(oPC, "SECURED");
if(nInt!=1){ return; }
if (!GetIsPC(oPC)){ return; }
SetLocalInt(OBJECT_SELF, "SECURED", 0);
SetLocalInt(oPC, "SECURED", 0);
oItem = GetFirstItemInInventory(oTarget);
while(oItem != OBJECT_INVALID) {
int nGP = GetIdentifiedGoldPieceValue(oItem);
int nMax = GetLocalInt(OBJECT_SELF, "MAX_GOLD_PER_ITEM");
if(nMax < 500) { nMax = 500; }
if(nGP > nMax) { nGP = nMax; }
if(nMembers>1) { b = nGP/nMembers; }
else if(nMembers ==1) { b = nGP/2; }
else { b = nGP; } //for debugging purposes
c = b;
GiveGoldToAll(oPC, c);
oItem = GetNextItemInInventory(oTarget);
}
oItem = GetFirstItemInInventory(oTarget);
while(oItem != OBJECT_INVALID) {
if(GetIsObjectValid(oItem))
{ DestroyObject(oItem, 0.0f); }
oItem = GetNextItemInInventory(oTarget);
}
DelayCommand(0.1, SetLocked(OBJECT_SELF, TRUE));
DelayCommand(1.0, SetLocked(OBJECT_SELF, FALSE));
}