Lemke

Member
ServUO Version
Publish 57
Ultima Expansion
Time Of Legends
Added health orbs in base creature,and server is getting random crashes.Any tip?Here the add in method:
C#:
public virtual void AlterMeleeDamageFrom(Mobile from, ref int damage)
        {
            //Custom health orb drop
            if (this == null || Utility.RandomDouble() > 0.05) //chance to drop 5%
                return;

            bool validLocation = false;
            Point3D loc = this.Location;

            for (int j = 0; !validLocation && j < 10; ++j)
            {
                int x = this.X + Utility.Random(4);
                int y = this.Y + Utility.Random(4);
                int z = this.Map.GetAverageZ(x, y);

                if (validLocation = (this.Map.CanFit(x, y, this.Z, 6, false, false) && this.InLOS(new Point3D(x, y, this.Z))))
                    loc = new Point3D(x, y, this.Z);
                else if (validLocation = (this.Map.CanFit(x, y, z, 6, false, false) && this.InLOS(new Point3D(x, y, z))))
                    loc = new Point3D(x, y, z);
            }

            if (!validLocation)
                return;

            //HealthOrb orb = new HealthOrb();
            new HealthOrb().MoveToWorld(loc, this.Map);
            //Custom healthorb drop
Thanks in advance!
 
Sorry,here is:

C#:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Mobiles.BaseCreature.AlterMeleeDamageFrom(Mobile from, Int32& damage) in C:\Users\Administrator\Desktop\UO Universe server\Scripts\Mobiles\Normal\BaseCreature.cs:line 2471
   at Server.AOS.Damage(IDamageable damageable, Mobile from, Int32 damage, Boolean ignoreArmor, Int32 phys, Int32 fire, Int32 cold, Int32 pois, Int32 nrgy, Int32 chaos, Int32 direct, Boolean keepAlive, DamageType type) in C:\Users\Administrator\Desktop\UO Universe server\Scripts\Misc\AOS.cs:line 364
   at Server.Items.BaseWeapon.OnHit(Mobile attacker, IDamageable damageable, Double damageBonus) in C:\Users\Administrator\Desktop\UO Universe server\Scripts\Items\Equipment\Weapons\BaseWeapon.cs:line 2697
   at Server.Items.BaseWeapon.OnSwing(Mobile attacker, IDamageable damageable, Double damageBonus) in C:\Users\Administrator\Desktop\UO Universe server\Scripts\Items\Equipment\Weapons\BaseWeapon.cs:line 1709
   at Server.Items.BaseWeapon.OnSwing(Mobile attacker, IDamageable damageable) in C:\Users\Administrator\Desktop\UO Universe server\Scripts\Items\Equipment\Weapons\BaseWeapon.cs:line 1654
   at Server.Items.Fists.OnSwing(Mobile attacker, IDamageable defender) in C:\Users\Administrator\Desktop\UO Universe server\Scripts\Items\Equipment\Weapons\Fists.cs:line 268
   at Server.Mobile.CombatTimer.OnTick()
 
In fact, I don't know what effect you want to achieve.

Under what circumstances does healthorb appear

What are the trigger conditions
 
Do you mean that when a player or a pet controlled by the player attacks the target creature through melee physics, the target creature has a chance to drop healthorb?
 
C#:
public override void OnGotMeleeAttack(Mobile attacker)
        {
            base.OnGotMeleeAttack(attacker);

            //Custom health orb drop
            if (this == null || Utility.RandomDouble() > 0.05) //chance to drop 5%
                return;

            bool validLocation = false;
            Point3D loc = this.Location;

            for (int j = 0; !validLocation && j < 10; ++j)
            {
                int x = this.X + Utility.Random(4);
                int y = this.Y + Utility.Random(4);
                int z = this.Map.GetAverageZ(x, y);

                if (validLocation = (this.Map.CanFit(x, y, this.Z, 6, false, false) && this.InLOS(new Point3D(x, y, this.Z))))
                    loc = new Point3D(x, y, this.Z);
                else if (validLocation = (this.Map.CanFit(x, y, z, 6, false, false) && this.InLOS(new Point3D(x, y, z))))
                    loc = new Point3D(x, y, z);
            }

            if (!validLocation)
                return;

                //HealthOrb orb = new HealthOrb();
                new HealthOrb().MoveToWorld(loc, this.Map);
                //Custom healthorb drop
        }
GIF 2022-3-19 8-04-39.gif

I removed the probability during the test

The item was replaced with ore
 

Attachments

  • CowServUO.cs
    2.5 KB · Views: 6

Active Shards

Donations

Total amount
$50.00
Goal
$1,000.00
Back