Well alright. Failed.Bard's script definitely has some good stuff in there so I "borrowed" from him.
'>
So I'm mixing it up a bit now but keeping everything that you originally asked for. Each player will get thier own roll of 4 to six items. Each player will then get his or her 4 to 6 random items(none the same). And now while each player might get some of the same items as the other players based on chance, it is still random for each player. This is also more efficient now thanks to Bard's suggestions.
So here's my last attempt. Hope it works.
void CreateBossLoot(object oPC, object oStore, int iStock)
{
int iItemsGet = d3() + 3;//Player gets 4 to 6 items
int iItems = iItemsGet;
//Get random and unique item place numbers we will use
int iItem1, iItem2, iItem3, iItem4, iItem5, iItem6;
while (iItemsGet > 0)
{
int iRand = Random(iStock)+1;
if (iRand != iItem1 ||
iRand != iItem2 ||
iRand != iItem3 ||
iRand != iItem4 ||
iRand != iItem5)
{
if (!iItem1) iItem1 = iRand;
else if (!iItem2) iItem2 = iRand;
else if (!iItem3) iItem3 = iRand;
else if (!iItem4) iItem4 = iRand;
else if (!iItem5) iItem5 = iRand;
else if (!iItem6) iItem6 = iRand;
iItemsGet--;
}
}
//Now lets make the items
int iCurrentItem;
object oItem = GetFirstItemInInventory(oStore);
while (GetIsObjectValid(oItem) && iItems > 0)
{
iCurrentItem++;
if (iCurrentItem == iItem1 ||
iCurrentItem == iItem2 ||
iCurrentItem == iItem3 ||
iCurrentItem == iItem4 ||
iCurrentItem == iItem5 ||
iCurrentItem == iItem6)
{
CopyItem(oItem, oPC, TRUE);
iItems--;
}
oItem = GetNextItemInInventory(oStore);
}
}
void main()
{
object oArea = GetArea(OBJECT_SELF);
object oStore = GetNearestObjectByTag("Tag of store", OBJECT_SELF, 1);
effect eNeg = EffectDamage(20, DAMAGE_TYPE_NEGATIVE);
int iStock = GetLocalInt(oStore, "MY_NUM_ITEMS");
if (!iStock)
{
int iInt;
object oItem = GetFirstItemInInventory(oStore);
while (GetIsObjectValid(oItem))
{
iInt++;
oItem = GetNextItemInInventory(oStore);
}
SetLocalInt(oStore, "MY_NUM_ITEMS", iInt);
iStock = iInt;
}
object oPC = GetFirstPC();
while (GetIsObjectValid(oPC))
{
if (GetArea(oPC) == oArea)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, eNeg, oPC);
if (!GetIsDead(oPC))
CreateBossLoot(oPC, oStore, iStock);
}
oPC = GetNextPC();
}
}
P.S. This script would be even more efficient if you preplaced, in the tooset, the int variable on the store for the amount of items it will have in it.
P.S.S. @ Greyfort. As far as players getting the same items, I think he just meant for them to not get all the exact same items as per my original script idea. He wanted each player to get their own random items. I think.