Best way to drop on player backpack?

Insert Coin

Active Member
Dec 2, 2018
44
5
37
Hello guys!
Im looking to do some drops doing in players backpack,not in corpse,so i ask here for the best way to do that,i see the script of the fleshrenderer on Doom as example,i see this code:

Code:
public override void OnDeath(Container c)
        {

            List<DamageStore> rights = GetLootingRights();

            int top = 0;
            Item blood = null;

            foreach (Mobile m in rights.Select(x => x.m_Mobile).Distinct().Take(3))
            {
                if (top == 0)
                    blood = new BloodOfTheDarkFather(5);
                else if (top == 1)
                    blood = new BloodOfTheDarkFather(3);
                else if (top == 2)
                    blood = new BloodOfTheDarkFather(2);

                top++;

                if (m.Backpack == null || !m.Backpack.TryDropItem(m, blood, false))
                {
                    m.BankBox.DropItem(blood);
                }
            }

            base.OnDeath(c);
        }

        public static Mobile FindRandomPlayer(BaseCreature creature)
        {
            List<DamageStore> rights = creature.GetLootingRights();

            for (int i = rights.Count - 1; i >= 0; --i)
            {
                DamageStore ds = rights[i];

                if (!ds.m_HasRight)
                    rights.RemoveAt(i);
            }

            if (rights.Count > 0)
                return rights[Utility.Random(rights.Count)].m_Mobile;

            return null;
        }
This is all i need to do that?Thank you!
 

Quasar

Well-Known Member
Oct 26, 2018
127
10
after you make it constructable and set hits ect just add lines like
AddItem( new PlateChest() );
AddItem( new PlateArms() );
AddItem( new PlateGloves() );
AddItem( new PlateLegs() );

it is usualy way up by the top and not under ondeath, but these items will be stealable
 

Vorspire

Vita-Nex: Core
Admin
ServUO Developer
Jul 29, 2013
1,090
196
32
United Kingdom
core.vita-nex.com
Shard Name
Ultima Shards: Multiverse
Donate
Donate money to this user
You'd be better off overriding OnKilledBy instead of OnDeath for this.
Code:
public override void OnKilledBy( Mobile mob )
{
    if ( mob.Player )
    {
        mob.AddToBackpack( new Longsword() );
    }

    base.OnKilledBy( mob );
}
 
  • Like
Reactions: Insert Coin

Insert Coin

Active Member
Dec 2, 2018
44
5
37
You'd be better off overriding OnKilledBy instead of OnDeath for this.
Code:
public override void OnKilledBy( Mobile mob )
{
    if ( mob.Player )
    {
        mob.AddToBackpack( new Longsword() );
    }

    base.OnKilledBy( mob );
}
Thank you so much,testing it.