Title

Like if a player carry a special cloak they get +50gold from monsters.

My server doesnt have Luck activated.
 
can't guarantee this will compile without issue, since I can't test, but I know the gold part of the function works

in BaseCreature.cs, under the method public override void OnDeath(Container c)

find OnKilledBy(ds.m_Mobile);

around line 5584, then add below it this

Code:
PlayerMobile pm= ds.m_Mobile as PlayerMobile;

if (c != null && pm.Player && pm.FindItemOnLayer(Layer.Helm) is ItemToFind) // change layer and item
                            {
                                int mTotalgold = 0;
                              
                                //PlayerMobile player = ds.m_Mobile as PlayerMobile;
                          
                                if (c.Items.Count > 0)
                                {
                                    var list2 = new List<Item>(c.Items);
                                    foreach (Item item in list2)
                                    {
                                        if ( item is Gold )
                                        {  
                                            mTotalgold += item.Amount;
                                         }
					

                                    }
         				int HalfGold = (mTotalgold / 2);
					if( HalfGold > 0 )
                   			 {
                            			c.DropItem(new Gold(HalfGold));
                       			 }
   	
                                  
                                    //player.SendMessage(49,"You gain {0} gold from defeating {1}", mTotalgold.ToString("#,0"), this.Name );

                                }
                            }
 
Thank you i will test it, i was adding OnDeath(Container c) method from BaseHire without sucess.

it works :) got 2 questions

How can i stack few bonus from different items there?
Like a helm and a ring for example

How can i make it say the extra gold amount gained?


right now my dragons drop around 900 gold coins + 450 from the bonus

but the message says ''You gain 900 gold from defeating Dragon! "


Well thank you again! i like this small mod.
 
Last edited:
stacking bonuses

change
if (c != null && pm.Player && pm.FindItemOnLayer(Layer.Helm) is ItemToFind)
to
if (c != null)

then where I put this section:
  1. int HalfGold = (mTotalgold / 2);
  2. if( HalfGold > 0 )
  3. {
  4. c.DropItem(new Gold(HalfGold));
  5. }

do a run for each item you want to check

int bonusgoldmultiplier = 0;

if ( pm.Player && pm.FindItemOnLayer(Layer.Helm) is ItemToFind )
bonusgoldmultiplier +=1;
if ( pm.Player && pm.FindItemOnLayer(Layer.Helm) is ItemToFind2 )
bonusgoldmultiplier +=1;

then depending on how you want to do it, if say each item counts for 50%

int HalfGold = (mTotalgold / 2);
if( bonusgoldmultiplier > 0 )
HalfGold = ( HalfGold * bonusgoldmultiplier );

if( HalfGold > 0 )
{
c.DropItem(new Gold(HalfGold));
player.SendMessage(49,"You gain {0} bonus gold", HalfGold.ToString("#,0")); // .ToString("#,0") places commas in the number
}
 
let me know if that works, i wrote it in a bit of a hurry

then depending on how you want to do it, if say each item counts for 50%

from a game developer standpoint, you'll have to decide on two things:
1) The max gold bonus a player can reach
2) How many items do they need to have equipped to reach this max percentage
 
Last edited:
If you code like this rushing it means you are a beast :)


Im getting an error:

Errors:
+ Mobiles/BaseCreature.cs:
CS1023: Line 4883: Embedded statement cannot be a declaration or labeled sta
tement


Code:
PlayerMobile pm = ds.m_Mobile as PlayerMobile;
                        if (c != null)
                         
        int bonusgoldmultiplier = 0;

      if ( pm.Player && pm.FindItemOnLayer(Layer.Ring) is Ava )
         bonusgoldmultiplier +=1;
      if ( pm.Player && pm.FindItemOnLayer(Layer.Gloves) is Avati )
         bonusgoldmultiplier +=1;

          int HalfGold = (mTotalgold / 4);
           if( bonusgoldmultiplier > 0 )
          HalfGold = ( HalfGold * bonusgoldmultiplier );

if( HalfGold > 0 )
{
c.DropItem(new Gold(HalfGold));
pm.SendMessage(49,"You gain {0} bonus gold", HalfGold.ToString("#,0")); // .ToString("#,0") places commas in the number
}

its Missing braces i think?

Thanks for your support!

Edit:


Code:
                        PlayerMobile pm = ds.m_Mobile as PlayerMobile;
                        if (c != null)
                        {   
        int bonusgoldmultiplier = 0;

      if ( pm.Player && pm.FindItemOnLayer(Layer.Ring) is Ava )
         bonusgoldmultiplier +=1;
      if ( pm.Player && pm.FindItemOnLayer(Layer.Gloves) is Avati )
         bonusgoldmultiplier +=1;
                       
          int HalfGold = (mTotalgold / 4);
           if( bonusgoldmultiplier > 0 )
          HalfGold = ( HalfGold * bonusgoldmultiplier );
                       
if( HalfGold > 0 )
{
c.DropItem(new Gold(HalfGold));
pm.SendMessage(49,"You gain {0} bonus gold", HalfGold.ToString("#,0")); // .ToString("#,0") places commas in the number
}
                        }

I have added braces, now im getting the next error:


Errors:
+ Mobiles/BaseCreature.cs:
CS0103: Line 4890: The name 'mTotalgold' does not exist in the current conte
xt
 
Last edited:
try this, it compiles and should work as expected

Code:
if (c != null)
                        { 
                            PlayerMobile p = ds.m_Mobile as PlayerMobile;
                            int mTotalgold = 0;
                           
                            if (c.Items.Count > 0)
                            {
                                var list2 = new List<Item>(c.Items);
                                foreach (Item item in list2)
                                {
                                    if ( item is Gold )
                                        mTotalgold += item.Amount;
                                }
                               
                                int bonusgoldmultiplier = 0;

                                if ( p.Player && p.FindItemOnLayer(Layer.Ring) is Ava )
                                    bonusgoldmultiplier +=1;
                                if ( p.Player && p.FindItemOnLayer(Layer.Gloves) is Avati )
                                    bonusgoldmultiplier +=1;
                                             
                                int HalfGold = (mTotalgold / 4);
                                if( bonusgoldmultiplier > 0 )
                                  HalfGold = ( HalfGold * bonusgoldmultiplier );
                                             
                                if( HalfGold > 0 )
                                {
                                    c.DropItem(new Gold(HalfGold));
                                    p.SendMessage(49,"You gain {0} bonus gold", HalfGold.ToString("#,0")); // .ToString("#,0") places commas in the number
                                }
                            }
                        }
 
zerodowned, theres an issue,i tested with a naked char and it gets the bonus :/


Code:
 public override void OnDeath(Container c)
        {
            MeerMage.StopEffect(this, false);

            if (IsBonded)
            {
                int sound = GetDeathSound();

                if (sound >= 0)
                    Effects.PlaySound(this, Map, sound);

                Warmode = false;

                Poison = null;
                Combatant = null;

                Hits = 0;
                Stam = 0;
                Mana = 0;

                IsDeadPet = true;
                ControlTarget = ControlMaster;
                ControlOrder = OrderType.Follow;

                ProcessDeltaQueue();
                SendIncomingPacket();
                SendIncomingPacket();

                List<AggressorInfo> aggressors = Aggressors;

                for (int i = 0; i < aggressors.Count; ++i)
                {
                    AggressorInfo info = aggressors[i];

                    if (info.Attacker.Combatant == this)
                        info.Attacker.Combatant = null;
                }

                List<AggressorInfo> aggressed = Aggressed;

                for (int i = 0; i < aggressed.Count; ++i)
                {
                    AggressorInfo info = aggressed[i];

                    if (info.Defender.Combatant == this)
                        info.Defender.Combatant = null;
                }

                Mobile owner = ControlMaster;

                if (owner == null || owner.Deleted || owner.Map != Map || !owner.InRange(this, 12) || !CanSee(owner) || !InLOS(owner))
                {
                    if (OwnerAbandonTime == DateTime.MinValue)
                        OwnerAbandonTime = DateTime.Now;
                }
                else
                {
                    OwnerAbandonTime = DateTime.MinValue;
                }

                GiftOfLifeSpell.HandleDeath(this);

                CheckStatTimers();
            }
            else
            {
                //When creatures are killed by guards the kill should not be counted towards the player and corpse should be deleted to prevent abuse
                if (LastKiller is BaseGuard)
                {
                    base.OnDeath(c);
                    c.Delete();
                    return;
                }

                if (!Summoned && !m_NoKillAwards)
                {
                    int totalFame = Fame / 300;
                    int totalKarma = -Karma / 300;

                    /*
                    if (Map == Map.Felucca)
                    {
                        totalFame += ((totalFame / 10) * 3);
                        totalKarma += ((totalKarma / 10) * 3);
                    }
                    */

                    List<DamageStore> list = GetLootingRights(DamageEntries, HitsMax);
                    List<Mobile> titles = new List<Mobile>();
                    List<int> fame = new List<int>();
                    List<int> karma = new List<int>();

                    //Maka - KillInfo
                    TrySaveKillInfo(c.Items);

                    bool givenQuestKill = false;
                    bool givenFactionKill = false;
                    bool givenToTKill = false;

                    for (int i = 0; i < list.Count; ++i)
                    {
                        DamageStore ds = list[i];

                        if (!ds.m_HasRight)
                            continue;

                        Party party = Engines.PartySystem.Party.Get(ds.m_Mobile);

                        if (party != null)
                        {
                            int divedFame = totalFame / party.Members.Count;
                            int divedKarma = totalKarma / party.Members.Count;

                            for (int j = 0; j < party.Members.Count; ++j)
                            {
                                PartyMemberInfo info = party.Members[j] as PartyMemberInfo;

                                if (info != null && info.Mobile != null)
                                {
                                    int index = titles.IndexOf(info.Mobile);

                                    if (index == -1)
                                    {
                                        titles.Add(info.Mobile);
                                        fame.Add(divedFame);
                                        karma.Add(divedKarma);
                                    }
                                    else
                                    {
                                        fame[index] += divedFame;
                                        karma[index] += divedKarma;
                                    }
                                }
                            }
                        }
                        else
                        {
                            titles.Add(ds.m_Mobile);
                            fame.Add(totalFame);
                            karma.Add(totalKarma);
                        }

                        // modification to support XmlQuest Killtasks
                        XmlQuest.RegisterKill(this, ds.m_Mobile);

                        OnKilledBy(ds.m_Mobile);
                    
                        //////////////////Goldbonus2////////////////////
                        PlayerMobile pm = ds.m_Mobile as PlayerMobile;
                        /////////////////Goldbonus3/////////////
                        if (c != null)
                        {
                            PlayerMobile p = ds.m_Mobile as PlayerMobile;
                            int mTotalgold = 0;
                       
                            if (c.Items.Count > 0)
                            {
                                var list2 = new List<Item>(c.Items);
                                foreach (Item item in list2)
                                {
                                    if ( item is Gold )
                                        mTotalgold += item.Amount;
                                }
                           
                                int bonusgoldmultiplier = 0;
                                if ( p.Player && p.FindItemOnLayer(Layer.Ring) is Codicia )
                                    bonusgoldmultiplier +=1;
                                if ( p.Player && p.FindItemOnLayer(Layer.Gloves) is Guantescodicia )
                                    bonusgoldmultiplier +=1;
                                         
                                int HalfGold = (mTotalgold / 4);
                                if( bonusgoldmultiplier > 0 )
                                  HalfGold = ( HalfGold * bonusgoldmultiplier );
                                         
                                if( HalfGold > 0 )
                                {
                                    c.DropItem(new Gold(HalfGold));
                                    p.PlaySound ( 55 );
                                    p.SendMessage(49,"You gain  {0} extra gold", HalfGold.ToString("#,0")); // .ToString("#,0") places commas in the number
                                }
                            }
                        }
                        ////////////////////////
                    /*    if (c != null)
                        {
        int bonusgoldmultiplier = 0;
    

      if ( pm.Player && pm.FindItemOnLayer(Layer.Ring) is Codicia )
         bonusgoldmultiplier +=1;
      if ( pm.Player && pm.FindItemOnLayer(Layer.Gloves) is Guantescodicia )
         bonusgoldmultiplier +=1;
                    
          int HalfGold = (mTotalgold / 4);
           if( bonusgoldmultiplier > 0 )
          HalfGold = ( HalfGold * bonusgoldmultiplier );
                    
if( HalfGold > 0 )
{
c.DropItem(new Gold(HalfGold));

pm.SendMessage(49,"You gain {0} EXTRA gold!", HalfGold.ToString("#,0")); // .ToString("#,0") places commas in the number
}
                        }*/
                        /////////////////////////////

                    
                        if (!givenFactionKill)
                        {
                            givenFactionKill = true;
                            Faction.HandleDeath(this, ds.m_Mobile);
                        }

                        if (!givenToTKill && Map == Map.Tokuno)
                        {
                            givenToTKill = true;
                            TreasuresOfTokuno.HandleKill(this, ds.m_Mobile);
                        }

                        if (givenQuestKill)
                            continue;
/////////////Gold bonus UNCOMENT ///////////
                  //      PlayerMobile pm = ds.m_Mobile as PlayerMobile;
///////////////////////////////////////////////////////
                        if (pm != null)
                        {
                            QuestSystem qs = pm.Quest;

                            if (qs != null)
                            {
                                qs.OnKill(this, c);
                                givenQuestKill = true;
                            }
                        }
                    }

                    for (int i = 0; i < titles.Count; ++i)
                    {
                        Titles.AwardFame(titles[i], fame[i], true);
                        Titles.AwardKarma(titles[i], karma[i], true);
                    }
                }

                base.OnDeath(c);

                if (IsInEvent && c is Corpse)
                    c.EventItem = true; //So that players in events can loot the body if configured that way

                if (DeleteCorpseOnDeath)
                    c.Delete();
            }
        }

Could be this the problem? : Have that method twice

Code:
PlayerMobile pm = ds.m_Mobile as PlayerMobile;                    
                        /////////////////Goldbonus3/////////////
                        if (c != null)
                        {
                            PlayerMobile p = ds.m_Mobile as PlayerMobile;                 
                            int mTotalgold = 0;

Had to uncomment this line:
Code:
/////////////Gold bonus uncomment///////////
                  //      PlayerMobile pm = ds.m_Mobile as PlayerMobile;
///////////////////////////////////////////////////////

Edit: I feel like it is not checking if the player wear the items;


Code:
 Item Rill = p.FindItemOnLayer(Layer.Ring);
                                if ( p.Player && Rill != null && Rill is  Avat )
                                    bonusgoldmultiplier +=1;

Added that, but still have same problem
 
Last edited:
Perfect, thank you so muchhhhhhhhhhhhh


EDIT!
OH no es its me again, i noticed that if a player hits a mob it will drop the extra gold even if he leaves, shouldnt be that way... i would prefer to make player to deal certain amount of damage before getting the gold.

Maybe i can add something like this?


Code:
            List<DamageEntry> rights = DamageEntries;
         
            for (int i = 0; i < rights.Count; ++i)
            {
                DamageEntry de = rights[i];

                                     
                if (de.HasExpired || !de.Damager.Player)
                {
                    DamageEntries.RemoveAt(i);
                    continue;
                }

if (de.DamageGiven > 200)

dont know how to continue lol :)
 
Last edited:
Back