Carlos_ar

Member
ServUO Version
Publish 57
Ultima Expansion
Endless Journey
I'm not trying to reinvent the wheel... in fact I REALLY like the point systems in the game. What I want to do is just make an additional point tracker.

I based mine off of the Virtue Artifact System. I added the appropriate lines in PointsSystem.cs, SeasonalEventSystem.cs, etc... basically everywhere it threw an error telling me there was no reference there. After fixing a few exceptions I got it to compile.

I'm using the Heritage Sovereigns (thanks for those!) and dropping them in players' packs based on points... this seems like a fun thing to do.

For testing purposes I have it at near 100% drop rate but nothing is happening. So I'm guessing I missed something important lol. There is also no entry for the point value on the [props of the players. Do I need to add something to the player mobiles?

using Server.Engines.Points;
using Server.Engines.SeasonalEvents;
using Server.Items;
using Server.Mobiles;
using System;

namespace Server.Misc
{
public class AwardSovereignSystem : PointsSystem
{
public static bool Enabled => SeasonalEventSystem.IsActive(EventType.AwardSovereign);

private static readonly Type[] m_AwardSovereign = new Type[]
{
typeof( HeritageSovereign )
};

public static Type[] Artifacts => m_AwardSovereign;

public override PointsType Loyalty => PointsType.Sovereign;
public override TextDefinition Name => m_Name;
public override bool AutoAdd => true;
public override double MaxPoints => double.MaxValue;
public override bool ShowOnLoyaltyGump => true;

private readonly TextDefinition m_Name = new TextDefinition("Sovereign Reward System");

private bool CheckLocation(Mobile m)
{
Region r = m.Region;

if (m is BaseCreature && ((BaseCreature)m).IsChampionSpawn)
return false;

if (r.IsPartOf<Regions.HouseRegion>() || Multis.BaseBoat.FindBoatAt(m, m.Map) != null)
return false;

if (r.IsPartOf("Covetous") || r.IsPartOf("Deceit") || r.IsPartOf("Despise") || r.IsPartOf("Destard") ||
r.IsPartOf("Hythloth") || r.IsPartOf("Shame") || r.IsPartOf("Wrong"))return false;

return (r.IsPartOf("Trammel") || r.IsPartOf("Felucca") || r.IsPartOf("Ilshenar") || r.IsPartOf("Malas") ||
r.IsPartOf("Tokuno") || r.IsPartOf("TerMur"));
}

public override void SendMessage(PlayerMobile from, double old, double points, bool quest)
{
// No message here
}

public override TextDefinition GetTitle(PlayerMobile from)
{
return new TextDefinition("Sovereign Reward System");
}

public override void ProcessKill(Mobile victim, Mobile damager)
{
PlayerMobile pm = damager as PlayerMobile;
BaseCreature bc = victim as BaseCreature;

if (!Enabled || pm == null || bc == null || !CheckLocation(bc) || !CheckLocation(pm) || !damager.InRange(victim, 18) || !damager.Alive || bc.GivenSpecialArtifact)
return;

if (bc.Controlled || bc.Owners.Count > 0 || bc.Fame <= 0)
return;

int luck = Math.Max(0, pm.RealLuck);
AwardPoints(pm, (int)Math.Max(0, (bc.Fame * (1 + Math.Sqrt(luck) / 1))));

double vapoints = GetPoints(pm);
const double A = 0.000863316841;
const double B = 0.00000425531915;

double chance = A * Math.Pow(10, B * vapoints);

double roll = Utility.RandomDouble();

if (chance > roll)
{
Item i = null;

try
{
i = Activator.CreateInstance(m_AwardSovereign[Utility.Random(m_AwardSovereign.Length)]) as Item;
}
catch (Exception e)
{
Diagnostics.ExceptionLogging.LogException(e);
}

if (i != null)
{
damager.PlaySound(0x5B4);
pm.SendLocalizedMessage(1062317); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.

if (!pm.PlaceInBackpack(i))
{
if (pm.BankBox != null && pm.BankBox.TryDropItem(damager, i, false))
pm.SendLocalizedMessage(1079730); // The item has been placed into your bank box.
else
{
pm.SendLocalizedMessage(1072523); // You find an artifact, but your backpack and bank are too full to hold it.
i.MoveToWorld(pm.Location, pm.Map);
}
}

bc.GivenSpecialArtifact = true;
SetPoints(pm, 0);
}
}
}
}
}

In Pointsystem.CS I have under public static void Configure() - AwardSovereign = new AwardSovereignSystem();
Then under public static List<PointsSystem> Systems { get; set; } I have - public static AwardSovereignSystem AwardSovereign { get; set; }
Then under public static void Configure() I have - AwardSovereign = new AwardSovereignSystem();
And finally in SeasonEventSystem.cs under public enum EventType I have - AwardSovereign

I realized through trial and error that the 'Trammel" region is apparently not a region so I changed that to something more specific to see if it would work and it didn't so I'm still missing something.
 
Last edited:
If you are giving it everywhere:

first I would remove all of this.
C#:
private bool CheckLocation(Mobile m)
{
    Region r = m.Region;

    if (m is BaseCreature && ((BaseCreature)m).IsChampionSpawn)
        return false;

    if (r.IsPartOf<Regions.HouseRegion>() || Multis.BaseBoat.FindBoatAt(m, m.Map) != null)
        return false;

    if (r.IsPartOf("Covetous") || r.IsPartOf("Deceit") || r.IsPartOf("Despise") || r.IsPartOf("Destard") ||
    r.IsPartOf("Hythloth") || r.IsPartOf("Shame") || r.IsPartOf("Wrong"))return false;

    return (r.IsPartOf("Trammel") || r.IsPartOf("Felucca") || r.IsPartOf("Ilshenar") || r.IsPartOf("Malas") ||
    r.IsPartOf("Tokuno") || r.IsPartOf("TerMur"));
}

then change
C#:
if (!Enabled || pm == null || bc == null || !CheckLocation(bc) || !CheckLocation(pm) || !damager.InRange(victim, 18) || !damager.Alive || bc.GivenSpecialArtifact)
return;

to
C#:
if (!Enabled || pm == null || bc == null || !damager.InRange(victim, 18) || !damager.Alive || bc.GivenSpecialArtifact)
return;

______________________________________________________________________



OR if you still want to prevent points from champ spawn, or inside a player's house:

Change
C#:
private bool CheckLocation(Mobile m)
{
    Region r = m.Region;

    if (m is BaseCreature && ((BaseCreature)m).IsChampionSpawn)
        return false;

    if (r.IsPartOf<Regions.HouseRegion>() || Multis.BaseBoat.FindBoatAt(m, m.Map) != null)
        return false;

    if (r.IsPartOf("Covetous") || r.IsPartOf("Deceit") || r.IsPartOf("Despise") || r.IsPartOf("Destard") ||
    r.IsPartOf("Hythloth") || r.IsPartOf("Shame") || r.IsPartOf("Wrong"))return false;

    return (r.IsPartOf("Trammel") || r.IsPartOf("Felucca") || r.IsPartOf("Ilshenar") || r.IsPartOf("Malas") ||
    r.IsPartOf("Tokuno") || r.IsPartOf("TerMur"));
}

to

C#:
private bool CheckLocation(Mobile m)
{
    Region r = m.Region;

    if (m is BaseCreature && ((BaseCreature)m).IsChampionSpawn)
        return false;

    if (r.IsPartOf<Regions.HouseRegion>() || Multis.BaseBoat.FindBoatAt(m, m.Map) != null)
        return false;

    return true;
}

and keep this the same:
C#:
if (!Enabled || pm == null || bc == null || !CheckLocation(bc) || !CheckLocation(pm) || !damager.InRange(victim, 18) || !damager.Alive || bc.GivenSpecialArtifact)
return;
 
I will give this a try. Thanks again. Sincerely.


Ok... it compiled no problem, no surprise there :)

Still no points accumulating though.
 
Try
C#:
if (!Enabled || pm == null || bc == null || !CheckLocation(bc) || !CheckLocation(pm) || !damager.InRange(victim, 18) || !damager.Alive || bc.GivenSpecialArtifact)
return;

removing !Enabled

C#:
if (pm == null || bc == null || !CheckLocation(bc) || !CheckLocation(pm) || !damager.InRange(victim, 18) || !damager.Alive || bc.GivenSpecialArtifact)
return;
 
Try
C#:
if (!Enabled || pm == null || bc == null || !CheckLocation(bc) || !CheckLocation(pm) || !damager.InRange(victim, 18) || !damager.Alive || bc.GivenSpecialArtifact)
return;

removing !Enabled

C#:
if (pm == null || bc == null || !CheckLocation(bc) || !CheckLocation(pm) || !damager.InRange(victim, 18) || !damager.Alive || bc.GivenSpecialArtifact)
return;
SUCCESS! Thankee Sai, you, Sir, are awesome!
 
SUCCESS! Thankee Sai, you, Sir, are awesome!
!Enabled is handled by the Seasons system. Something in there was probably done incorrectly. Now we are simply avoiding all that and you can even remove your custom code from SeasonSystem and everything should still work fine.
 
Oh, that makes sense. I can 'see' it once it's working. An AH-HA! Moment... Like when you hear a riddle and the pieces don't quite fit until you hear the answer.

Thank you so much for your time!
 
  • Like
Reactions: Dan

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back