This is taken from an include file i am using to generate loot on npc death.. It works fine but keeps dropping the same item from the store. can anyone take a look at it and help me out. i need it to generate rendom items from the store.
Thanks
object GetEpicStore(object oDead)
{
string sEpicShop, sArea, sAreaBoss;
int nRndm, nCount;
object oEpicStore, oItem;
nRndm = d100();
sArea = GetTag(GetArea(oDead));
sAreaBoss = sArea;
oEpicStore = GetObjectByTag( "LOOT_EPIC_SHOP");
if( GetIsObjectValid( oEpicStore ) )
{ // -- check if we know item count
nCount = GetLocalInt( oEpicStore , "nItemCount" );
if( nCount <= 0 )
{ // -- Count Items in Store Inventory
oItem = GetFirstItemInInventory( oEpicStore );
while( GetIsObjectValid( oItem ) )
{
nCount++ ;
oItem = GetNextItemInInventory( oEpicStore );
}
SetLocalInt( oEpicStore , "nItemCount" , nCount );
}
}
{
return oEpicStore;
}
}
////////////////////////////////////////////////////////////////////////////////
void MakeEpicItemAppear(object oKiller)
{ // -- EPIC ITEMs LOOT DROPs
object oDead = OBJECT_SELF;
object oItem;
string sMsg, sEpicShop, sArea, sAreaBoss;
int iVFX, iChance, iRndm, nCount, nEpicAmount, nRndm;
effect eEffect;
// object oSetStore = OBJECT_INVALID;
object oEpicStore;
iChance = GetLocalInt(oDead, "EPIC_LOOT_CHANCE");
iRndm = d100();
if(iChance >= iRndm)
{
nRndm = d100();
{ // -- check if we know item count
int iPercentRoll = d100();
if( iPercentRoll <= iChance )
{
if( iPercentRoll <= 2 )
{ nEpicAmount = 2; }
else
{ nEpicAmount = 1; }
}
else
{ nEpicAmount = 0; }
while( nEpicAmount > 0 )
{
oEpicStore = GetEpicStore(oDead);
int nSelected;
int nRand = Random( nCount ) + 1;
oItem = GetFirstItemInInventory( oEpicStore );
for( nSelected = 1 ; nSelected < nRand ; nSelected++ )
{ oItem = GetNextItemInInventory( oEpicStore ); }
if (oItem != OBJECT_INVALID)
{ oItem = CopyItem(oItem, oKiller, TRUE); }
iVFX = Random(2);
if(iVFX==0){eEffect = EffectVisualEffect(VFX_IMP_BREACH);}
if(iVFX==1){eEffect = EffectVisualEffect(VFX_IMP_DESTRUCTION);}
if(iVFX==2){eEffect = EffectVisualEffect(VFX_IMP_HOLY_AID);}
sMsg = StringToRGBString("You Found An Epic Item!", STRING_COLOR_ELEC); // "+sMsg, sColor);
FloatingTextStringOnCreature(sMsg, oKiller, TRUE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oKiller);
nEpicAmount--;
}
}
}
}