Vert-I-Go

Member
ServUO Version
Publish Unknown
Ultima Expansion
High Seas
Ok its really not fame on kil but same concept its experience on kill but same method. I get a crash I added exp to base creature so when a player kills a mobile they gain exp which levels them up I am trying to get pets to also gain exp to level up a custom leveling system but having issues with crashing here is code on death which i have that is crashing. I didnt post the entire section just the begining of section the OnDeath title and the // commented sections taken out that were causing the crash. if i take out the // parts then it crashs not really sure how to fix this. Attached my BaseCreature.cs everything else works great.

C#:
public override void OnDeath( Container c )
{


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

                        if ( !ds.m_HasRight )
                            continue;

                        //BasePet bp = ds.m_Mobile as BasePet;

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

                        if ( party != null )
                        {
                            int divedFame = totalFame / party.Members.Count;
                            int divedKarma = totalKarma / party.Members.Count;
                            int divedExp = totalExp / 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 );
                                        expeirence.Add( divedExp );
                                    }
                                    else
                                    {
                                        fame[ index ] += divedFame;
                                        karma[ index ] += divedKarma;
                                        expeirence[ index ] += divedExp;
                                    }

                                    
                                }
                            }
                        }
                        else
                        {
                            titles.Add( ds.m_Mobile );
                            levels.Add( ds.m_Mobile );
                            fame.Add( totalFame );
                            karma.Add( totalKarma );
                            expeirence.Add(totalExp);
                            //if ( bp.Controlled = true )
                            //{
                                //expeirence.Add(totalExp);
                            //}
                        }
 

Attachments

  • BaseCreature.cs
    150.7 KB · Views: 4
Code:
BasePet bp = ds.m_Mobile as BasePet;
....

if (bp != null && bp.Controlled)
 expeirence.Add(totalExp);
or even better:

Code:
else
                        {
                            titles.Add( ds.m_Mobile );
                            levels.Add( ds.m_Mobile );
                            fame.Add( totalFame );
                            karma.Add( totalKarma );
                            //expeirence.Add(totalExp);

                            if ( ds.m_Mobile is BasePet pet && pet.Controlled)
                                expeirence.Add(totalExp);
                        }
 
Last edited:
Thats stopped the crashing but the controlled pet isnt gaining any exp hmmmz but thanks for helping me stop the crash ;) now to figure out how to get the pet to gain exp lol oh forgot its not basepet had to change that its basialy BaseCreature. but in the server I added exp like fame and karma so players gain exp like they would fame and karma when killing mobiles.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back