Marty

Initiate
I have read several threads on this. Could someone direct me in the direction of adding justice gains to some type of NPC when killed? I have tried the scrips on here and all seem to give an error.

Thank you in advance :)
 
Only tested this on P58 but you should be able to add something like this into BaseCreature's OnDeath method for a generic implementation or you can carve out what you need to embed into specific individual scripts.

C#:
if (LastKiller != null && LastKiller.Player && (Body.IsHuman || Karma < 2000))
{
    var gainedPath = false;
    var pointsToGain = Fame >= 10000 ? (Fame - 10000) / 500 + 1 : 1;
    pointsToGain = pointsToGain > 20 ? 20 : pointsToGain;

    if (VirtueHelper.Award(LastKiller, VirtueName.Justice, pointsToGain, ref gainedPath))
    {
        LastKiller.SendLocalizedMessage(gainedPath ? 1049367 : 1049363);
        LastKiller.FixedParticles(0x375A, 9, 20, 5027, EffectLayer.Waist);
        LastKiller.PlaySound(0x1F7);
    }
}

vortex.PNG
 
Do I n to d to change it accordingly to us elf or is gargoyle?
Not sure where to add this, I'm sorry, I am lost with C# programming. Can you tell me how i would do it with say the evil mages?
Or is there an admin command to set justice points?
 
Last edited:
You can also do something like this,add a deed that gain the virtue you want in the mob loot,here an example script.

C#:
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Regions;
using Server.Targeting;
using Server.Services.Virtues;

namespace Server.Items
{

    public class HonorDeed : Item
    {

        [Constructable]
        public HonorDeed() : this( null )
        {
        }

        [Constructable]
        public HonorDeed ( string name ) : base ( 0x14F0 )
        {
            Name = "+100 Honor deed";
            Hue = 1691;
        }

        public HonorDeed ( Serial serial ) : base ( serial )
        {
        }

              public override void OnDoubleClick( Mobile from )
              {
              var gainedPath = false;

            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage(1042001);
            }
            else
            {
            VirtueHelper.Award(from, VirtueName.Honor, 100, ref gainedPath);
            this.Delete();
            }

        }
        public override void GetProperties( ObjectPropertyList list )
        {
            base.GetProperties( list );
       
            list.Add( "<BASEFONT COLOR=#FF6DF4>[Double click to raise up Honor virtue.]<BASEFONT COLOR=#FFFFFF>");
        }
        public override void Serialize ( GenericWriter writer)
        {
            base.Serialize ( writer );

            writer.Write ( (int) 0);
        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize ( reader );

            int version = reader.ReadInt();
        }
    }
}

Or try override the OnKilledBy on your mob like:


C#:
public override void OnKilledBy( Mobile from )
{
    base.OnKilledBy(from);
    var gainedPath = false;
  
    if (from is BaseCreature && ((BaseCreature)creature).GetMaster() is PlayerMobile)
            {
               from = ((BaseCreature)creature).GetMaster();
            }
    if (from is PlayerMobile)
       {
            VirtueHelper.Award(from, VirtueName.Honor, 100, ref gainedPath);
            from.PublicOverheadMessage(MessageType.Emote ,1153, true, "Honor +100!!!");
       }
}
And dont forget to add at the top of your creature code:
C#:
using Server.Services.Virtues;
 
Last edited:

Active Shards

Donations

Total amount
$80.00
Goal
$1,000.00
Back