Weapons with chance to cast friendly summon?

Lemke

Well-Known Member
Sep 26, 2015
89
10
38
Hello guys!Looking at the forums for some example of a weapon with chance to summon friendly creature to help on hit,anyone knows an example?Thank you!
 

Lemke

Well-Known Member
Sep 26, 2015
89
10
38
Thank you,is a great base to start,i tryed to get this working,weapon is loading well with no errors or warning,but when i hit a mob,nothing happens,here the code im using for the full weapon:

C#:
using System;
using Server;
using Server.Network;
using Server.Engines.CannedEvil;
using Server.Items;
using Server.Targeting;
using Server.Engines.XmlSpawner2; /* added for level check */
using Server.Mobiles; /* added for level check */
namespace Server.Items
{
    public class TestWeapon : Katana
    {
        //public override bool IsArtifact { get { return true; } }
        [Constructable]
        public TestWeapon()
        {
            Name = "lolo";
            Hue = 0x76D;
            WeaponAttributes.HitLeechStam = 100;
            WeaponAttributes.HitLeechMana = 50;
            Attributes.RegenStam = 5;
            WeaponAttributes.HitEnergyArea = 75;
            Attributes.WeaponSpeed = 45;
            Attributes.WeaponDamage = 60;
        }

        public override void OnHit(Mobile attacker, IDamageable defender, double damageBonus)
        {
           
            if (defender is BaseCreature)
            {
            //if (Utility.RandomDouble() <= 0.1) //
                //{
                SpawnPixies(attacker);
                //}
            }
            base.OnHit(attacker, defender, damageBonus);
        }

        public void SpawnPixies(Mobile defender)
        {
            Map map = Map;

            if (map == null)
                return;

            //Say(1042154); // You shall never defeat me as long as I have my queen!

            int newPixies = Utility.RandomMinMax(3, 6);

            for (int i = 0; i < newPixies; ++i)
            {
                Pixie pixie = new Pixie();

                //pixie.Team = Team;
                pixie.FightMode = FightMode.Closest;

                bool validLocation = false;
                Point3D loc = Location;

                for (int j = 0; !validLocation && j < 10; ++j)
                {
                    int x = X + Utility.Random(3) - 1;
                    int y = Y + Utility.Random(3) - 1;
                    int z = map.GetAverageZ(x, y);

                    if (validLocation = map.CanFit(x, y, Z, 16, false, false))
                        loc = new Point3D(x, y, Z);
                    else if (validLocation = map.CanFit(x, y, z, 16, false, false))
                        loc = new Point3D(x, y, z);
                }

                pixie.MoveToWorld(loc, map);
                pixie.Combatant = defender;
            }
        }
       
        public TestWeapon(Serial serial)
            : base(serial)
        {
        }

        public override int LabelNumber
        {
            get
            {
                return 1061088;
            }
        }// Blade of Insanity
        public override int ArtifactRarity
        {
            get
            {
                return 11;
            }
        }
        public override int InitMinHits
        {
            get
            {
                return 255;
            }
        }
        public override int InitMaxHits
        {
            get
            {
                return 255;
            }
        }
        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();
        }
    }
}
Any help is much apreciated,thanks in advance!
 
Last edited:

Lemke

Well-Known Member
Sep 26, 2015
89
10
38
Solved!Just:


C#:
if (defender is BaseCreature)
            {
                if (Utility.RandomDouble() < 0.05) //5% chance
                {
                Map map = Map;
               
                EnergyVortex EnergyVortex = new EnergyVortex();

                EnergyVortex.FightMode = FightMode.Evil;
                Point3D loc = Location;
               
                loc = new Point3D( defender.X + 1, defender.Y, defender.Z + 1 );
               
                EnergyVortex.MoveToWorld(loc, map);
                EnergyVortex.Combatant = defender;
                }
            }
 
  • Like
Reactions: Exale