Exemplo n.º 1
0
        /// <summary>
        /// Summon the pet
        /// </summary>
        protected virtual void SummonPet()
        {
            if (PetTemplate != null && PetLevel != 0 && m_pet == null)
            {
                m_pet = new GameNPC(PetTemplate);
                if (m_pet != null)
                {
                    m_pet.CurrentRegion = CurrentRegion;

                    // Summon pet to the left or right of the summoner
                    ushort sideHeading = (ushort)(Heading + 900);
                    if (Util.Random(1) < 1)
                    {
                        sideHeading += 1800;
                    }
                    Point2D point = GetPointFromHeading(sideHeading, PetSummonDistance);
                    m_pet.X = point.X;
                    m_pet.Y = point.Y;
                    m_pet.Z = Z;

                    m_pet.Heading          = Heading;
                    m_pet.Realm            = eRealm.None;
                    m_pet.LoadedFromScript = true;
                    m_pet.MaxDistance      = PetMaxDistance;
                    m_pet.TetherRange      = PetTetherRange;
                    m_pet.RespawnInterval  = -1;
                    m_pet.IsWorthReward    = false;

                    if (PetSize > 0)
                    {
                        m_pet.Size = PetSize;
                    }

                    if (PetLevel > 0)
                    {
                        m_pet.Level = PetLevel;
                    }
                    else
                    {
                        m_pet.Level = (byte)(Level * PetLevel / -100);
                    }

                    m_pet.AutoSetStats();

                    if (m_pet.Brain is StandardMobBrain petBrain && Brain is StandardMobBrain brain && TargetObject is GameLiving living)
                    {
                        petBrain.CanBAF = false;
                        brain.AddAggroListTo(petBrain);
                    }

                    m_pet.AddToWorld();

                    m_resummonTime = CurrentRegion.Time + PetResummonTime;
                }
            }
        }