I am smacking myself with figuring this out. I am using this code in my script. Triggers when an npc is killed, @ his on death.

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

            Mobile m = FindMostRecentDamager( false );

            if ( m != null && m.Player )
            {
                bool gainedPath = false;

                //int theirTotal = PlayerMobile.SkillsTotal( m );
                //int ourTotal = PlayerMobile.SkillsTotal( this );
                
                int theirTotal = (int)(m.SkillsTotal);
                int ourTotal = (int)(this.SkillsTotal);

                int pointsToGain = (int)(1 + ((theirTotal - ourTotal) / 50));

                if ( pointsToGain < 1 )
                    pointsToGain = 1;
                else if ( pointsToGain > 4 )
                    pointsToGain = 4;

                if ( VirtueHelper.Award( m, VirtueName.Justice, pointsToGain, ref gainedPath ) )
                {
                    if ( gainedPath )
                        m.SendLocalizedMessage( 1049367 ); // You have gained a path in Justice!
                    else
                        m.SendLocalizedMessage( 1049363 ); // You have gained in Justice.

                    m.FixedParticles( 0x375A, 9, 20, 5027, EffectLayer.Waist );
                    m.PlaySound( 0x1F7 );
                }
            }
        }

Had it working on an older distro of ServUO and it's the SAME code used in the playermobile but for some reason it gives this error.

Errors:
+ Custom/Mobiles/PK Gang/HKMobile.cs:
CS0103: Line 155: The name 'VirtueHelper' does not exist in the current context
CS0103: Line 155: The name 'VirtueName' does not exist in the current context

Any thoughts why?
 
Are you missing a "using" statement at the top?

Grizelda the Hag uses VirtueHelper and it has just these at the top:

Code:
using System;
using Server.Items;
using Server.Mobiles;

If your script doesn't have one of those, try adding it and see how it goes.
 
  • Like
Reactions: ExX
Thanks Falkor I had those but didn't know there was a new (new to me since being back) service refrence for Virtues. Thank you Visam!
 
It's new to me as well. My ServUO version is about a year old and I'm just going to stick with it so I don't have to re-do all the custom tweaks I've made. I'm not worried about having all the latest features from "real" UO and I keep current with bug fixes for older systems.
 
  • Like
Reactions: ExX
Good idea, my old server was from sept 2015 so I thought coming back it was worth the big upgrade with 4 years difference. Happy to say I am about 75% done with fixing all my old custom files and getting them to work properly. Then I get the fun of re-incorporating all the new stuff into the world, drop tables, rares, etc. :D
 
Back