Author Topic: Help Needed  (Read 341 times)

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Help Needed
« on: July 24, 2011, 10:00:14 pm »


               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--;
            }
        }
    }
}
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Help Needed
« Reply #1 on: July 24, 2011, 11:51:22 pm »


               You never gave nCount a value.  

////////////////////////////////////////////////////////////////////////////////
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_GREEN); // "+sMsg, sColor);
            FloatingTextStringOnCreature(sMsg, oKiller, TRUE);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oKiller);
            nEpicAmount--;
            }
        }
    }
}
               
               

               
            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Help Needed
« Reply #2 on: July 25, 2011, 12:15:17 am »


               Can you fix this for me. or explain what i need to change.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Help Needed
« Reply #3 on: July 25, 2011, 12:36:28 am »


               Create another function to return the number of items in your store as nCount. You have just missed having that counting of the number of items being used.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Help Needed
« Reply #4 on: July 25, 2011, 12:37:53 am »


               Nah, better yet have nCount = GetLocalInt( oEpicStore , "nItemCount" );
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Help Needed
« Reply #5 on: July 25, 2011, 12:56:15 am »


               And place the line Baragg gave you right after 

 oEpicStore = GetEpicStore(oDead);


If you place it before that line the local int will not yet be defined.
               
               

               
            

Legacy_Madasahatter

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Help Needed
« Reply #6 on: July 25, 2011, 01:51:15 am »


               Working just fine now thanks very much... '<img'>