ServUO Version
Publish 57
Ultima Expansion
None
I have a problem with this script, I attach a screen with the console errors and paste the code

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

public class ElfCharacter : BaseCreature
{
    private static readonly string[] Greetings = { "Good morning!", "Good evening!" };
    private static readonly string StuckMessage = "I am stuck!";
    private static readonly string HelpMessage = "Help!";

    private DateTime lastActivity;
    private bool isTransformed;

    [Constructable]
    public ElfCharacter() : base(AIType.AI_UseSkill, FightMode.Weakest, 10, 1, 0.15, 0.2)
    {
        Name = "Elf Character";
        Body = 0x190; // Humanoid body
        Hue = 0x30E4; // Pink skin
        HairItemID = 0x203C; // Blond Hair
        HairHue = 0xFAE; // Blond hair hue
        Female = Utility.RandomBool(); // Randomize gender

        Equipment.Add(new Bow());
        Equipment.Add(new Cape());
        Equipment.Add(new Boots());
        Equipment.Add(new Gloves());
        Equipment.Add(new Pants());
        Equipment.Add(new Hat());

        Mount = new Horse();
        Mount.Rider = this;

        SetStr(100);
        SetDex(100);
        SetInt(100);

        lastActivity = DateTime.Now;
        isTransformed = false;
    }

    public override void OnThink()
    {
        base.OnThink();

        if (DateTime.Now > lastActivity.AddMinutes(1))
        {
            lastActivity = DateTime.Now;

            if (IsNearPlayer())
            {
                TimeSpan currentTime = DateTime.Now.TimeOfDay;
                if (currentTime.Hours >= 6 && currentTime.Hours < 18)
                {
                    Say(Greetings[0]);
                }
                else
                {
                    Say(Greetings[1]);
                }
            }
        }
    }

     void  ElfCharacter.OnMovement()
    {
        base.OnMovement();

        if (IsStuck())
        {
            Say(StuckMessage);
            ChangeDirection();
        }
    }

      void ElfCharacter.OnDamaged()
    {
        base.OnDamaged();

        if (Hits < (HitsMax / 2) && !isTransformed)
        {
            Transform();
        }
    }

      void ElfCharacter.OnAttack(Mobile attacker)
    {
        base.OnAttack(attacker);
        Say(HelpMessage);
        Hide();
    }

    private bool IsNearPlayer()
    {
        foreach (var mobile in this.GetMobilesInRange(5))
        {
            if (mobile is PlayerMobile player)
            {
                if (player.Fame >= 10000)
                {
                    player.AddFollower(this);
                }
                if (female && mobile.Female)
                {
                    PerformBow();
                }
                return true;
            }
        }
restituisce false;
    }

privato void Transform()
    {
Logica per trasformarsi in un drago o in un demone
isTransformed = vero;
Imposta qui un nuovo corpo o aspetto...
    }

privato void ChangeDirection()
    {
Logica per cambiare direzione qui...
Ciò potrebbe comportare il controllo dello spazio libero e il movimento verso di esso.
    }

privato vuoto PerformBow()
    {
Logica per eseguire l'azione dell'arco
    }

bool privato IsStuck()
    {
Implementa la logica per verificare se il carattere è bloccato
restituisce false;
    }

public ElfCharacter(Seriale seriale) : base(seriale) { }

    public override void Serialize(GenericWriter writer)
    {
base. Serializzare (scrittore);
scrittore. Scrittura((int)0); Versione
scrittore. Scrivi(ultimaAttività);
scrittore. Write(isTransformed);
    }

public override void Deserialize(lettore GenericReader)
    {
base. Deserializzare(lettore);
int version = lettore. ReadInt();
lastActivity = lettore. ReadDateTime();
isTransformed = lettore. LeggiBool();
    }
}
 

Attachments

  • Desktop 03-08-2024 16-12-27-29.jpg
    Desktop 03-08-2024 16-12-27-29.jpg
    147.8 KB · Views: 11
There is lots wrong with this script, to address the error, not sure why you'd be using the class in the method
Code:
 void  ElfCharacter.OnMovement()
    {
    }

The proper code for overriding the virtual method in the base class would be
Code:
 public override void OnMovement()
    {
    }
 
Back