Aller au contenu

Photo

Help Needed


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Madasahatter

Madasahatter
  • Members
  • 111 messages
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--;
            }
        }
    }
}

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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--;
            }
        }
    }
}

#3
Madasahatter

Madasahatter
  • Members
  • 111 messages
Can you fix this for me. or explain what i need to change.

#4
Baragg

Baragg
  • Members
  • 271 messages
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.

#5
Baragg

Baragg
  • Members
  • 271 messages
Nah, better yet have nCount = GetLocalInt( oEpicStore , "nItemCount" );

#6
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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.

#7
Madasahatter

Madasahatter
  • Members
  • 111 messages
Working just fine now thanks very much... :)