Discussion in   Coding Corner   started     10 years ago   August 12, 2013, 12:14:46 AM   by   Keldon

using luck to determine which drop chance catagory

Keldon
Offline
223 Posts
Topic :   using luck to determine which drop chance catagory
10 years ago  August 12, 2013, 12:14:46 AM

I have been trying unsuccessfully to have a mob pull the players luck when determining what to drop.  The plan is to use this to add further dynamics to a drop system (reward players for higher luck).


The best method I have come up with is (and trust me I have tried several) and it just does not see the players luck:


Code: [Select]

        public override int Luck{get {return base.Luck;}}






        public override void OnDeath(Container c)
        {
            base.OnDeath(c);
            {
                if (Luck > 500)
                    c.DropItem(new Katana());
            }


        }


at this point I am going to look to other things that I know how to do.  This one just has me stumped for now.

Kyn
Offline
336 Posts
#1 Re :   using luck to determine which drop chance catagory
10 years ago  August 12, 2013, 09:53:55 AM

My logic for this is simple... **Please ignore sloppy code, I wrote this post on my cell phone**


If luck >= 1000


then..... :) I'm sure you can figure out where I'm going with this.


Code: [Select]
public static int GetLuckChance( Mobile killer, Mobile victim )       
{


Code: [Select]
public void Generate( Mobile from, Container cont, bool spawning, int luckChance )       
 {         
 if ( cont == null )               
 return;           
 bool checkLuck = Core.AOS;           
 for ( int i = 0; i < m_Entries.Length; ++i )           
{               
LootPackEntry entry = m_Entries[i];               
bool shouldAdd = ( entry.Chance > Utility.Random( 10000 ) );               


 if ( !shouldAdd && checkLuck )               
 {                   
checkLuck = false;                   
 if ( LootPack.CheckLuck( luckChance ) )                   
    shouldAdd = ( entry.Chance > Utility.Random( 10000 ) );             
   }               
 if ( !shouldAdd )                   
continue;               
 Item item = entry.Construct( from, luckChance, spawning );



Note: this is for lootpack.cs if you want to do it on an individual basis the same method can be applied. For Evolution I've created a custom loot generator that was put into base creature. I can then apply different loot settings on a per creature basis.

Keldon
Offline
223 Posts
#2 Re :   using luck to determine which drop chance catagory
10 years ago  August 12, 2013, 11:46:01 AM

wow, in the 3 hours or so I messed with this I think I tried just about everything except getluckchance.  Folly of the coder I guess, the more you look at it the less it makes sense.


I do have something I am going to code out tonight and If it works like I think/hope it will we will have to talk about the reward a little bit.  It will be a branch out, but using luck to give a better box drop rate is something I wanted to do with these mobs.