ServUO Version
Publish 58
Ultima Expansion
Endless Journey
I'm trying to make a mount change to a random metal hue when mounted, but I can't seem to find a method for when a player mounts.

I have it set in the constructable, but that only applies to when the item is added. I want it to choose a random metal hue every time it's mounted, so it's never the same color.

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

namespace Server.Mobiles
{
    public class EarlySupporterMount : EtherealMount
    {

        [Constructable]
        public EarlySupporterMount() : base(0x20DD, 0x3EAA, 0x3EA0)
        {
            Name = "Early Supporter Mount";
            LootType = LootType.Blessed;
            Hue = (Utility.RandomMetalHue());
            NonTransparentMountedHue = (Utility.RandomMetalHue());
            Transparent = false;
        }
        
        public override void GetProperties( ObjectPropertyList list )
        {
            base.GetProperties( list );
            list.Add( "Promotional Item" );
        }
        
        public override void OnCast()
        {
                FinishSequence();
        }

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

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int)0); // version

        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

        }

    }

}

Thanks,
 
Override OnDoubleClick and return the base. Just be sure to add checks to make sure it's in their pack and they're able to mount, otherwise if someone snoops them and double clicks or they're not allowed to mount for various reasons it will still change colors.
 
Looking at the base class EtherealMount (in Scripts/Mobiles/Normal/Ethereals.cs) I see a few properties you could set to try, Transparent, TransparentMountedHue, and NonTransparentMountedHue. I'd probably start by trying to modify some of those in your mount and see if it works.

Do you use Visual Studio? If you right-click on a method/class, you can click on "Go to Definition" (F12 is the hotkey in VS2022 I think), and that helps with finding parent classes and implementations and stuff.
 
Override OnDoubleClick and return the base. Just be sure to add checks to make sure it's in their pack and they're able to mount, otherwise if someone snoops them and double clicks or they're not allowed to mount for various reasons it will still change colors.
I tried OnDoubleClick, but when I clicked the mount the spell wouldn't cast. That's probably what you mean by returning the base? Could you elaborate on that, I'm still learning C#.
 
The base.OnDoubleClick(from); is what I am referring to. It allows the original code you're overriding to still be called but includes your added code.
Return Base:
        public override void OnDoubleClick( Mobile from )
        {
            // Option 1: Your code here to call it before the base method.
            base.OnDoubleClick(from);
            // Option 2: Your code here to call it after the base method.
        }
Depending on what you're trying to do you either need to add it before or after the base method. Given what you're trying to do, I don't think it would make much of a difference to have it in either spot.
 
Back