public virtual void InitStats(uint duration)
        {
            Cypher.Assert(!IsPet());

            m_timer    = duration;
            m_lifetime = duration;

            if (m_type == TempSummonType.ManualDespawn)
            {
                m_type = (duration == 0) ? TempSummonType.DeadDespawn : TempSummonType.TimedDespawn;
            }

            Unit owner = GetSummoner();

            if (owner != null && IsTrigger() && m_spells[0] != 0)
            {
                SetFaction(owner.GetFaction());
                SetLevel(owner.GetLevel());
                if (owner.IsTypeId(TypeId.Player))
                {
                    m_ControlledByPlayer = true;
                }
            }


            if (m_Properties == null)
            {
                return;
            }

            if (owner != null)
            {
                int slot = m_Properties.Slot;
                if (slot > 0)
                {
                    if (!owner.m_SummonSlot[slot].IsEmpty() && owner.m_SummonSlot[slot] != GetGUID())
                    {
                        Creature oldSummon = GetMap().GetCreature(owner.m_SummonSlot[slot]);
                        if (oldSummon != null && oldSummon.IsSummon())
                        {
                            oldSummon.ToTempSummon().UnSummon();
                        }
                    }
                    owner.m_SummonSlot[slot] = GetGUID();
                }
            }

            if (m_Properties.Faction != 0)
            {
                SetFaction(m_Properties.Faction);
            }
            else if (IsVehicle() && owner != null) // properties should be vehicle
            {
                SetFaction(owner.GetFaction());
            }
        }
Exemple #2
0
        public virtual void InitStats(uint duration)
        {
            Cypher.Assert(!IsPet());

            m_timer    = duration;
            m_lifetime = duration;

            if (m_type == TempSummonType.ManualDespawn)
            {
                m_type = (duration == 0) ? TempSummonType.DeadDespawn : TempSummonType.TimedDespawn;
            }

            Unit owner = GetSummonerUnit();

            if (owner != null && IsTrigger() && m_spells[0] != 0)
            {
                SetLevel(owner.GetLevel());
                if (owner.IsTypeId(TypeId.Player))
                {
                    m_ControlledByPlayer = true;
                }
            }


            if (m_Properties == null)
            {
                return;
            }

            if (owner != null)
            {
                int slot = m_Properties.Slot;
                if (slot > 0)
                {
                    if (!owner.m_SummonSlot[slot].IsEmpty() && owner.m_SummonSlot[slot] != GetGUID())
                    {
                        Creature oldSummon = GetMap().GetCreature(owner.m_SummonSlot[slot]);
                        if (oldSummon != null && oldSummon.IsSummon())
                        {
                            oldSummon.ToTempSummon().UnSummon();
                        }
                    }
                    owner.m_SummonSlot[slot] = GetGUID();
                }
            }

            uint faction = m_Properties.Faction;

            if (m_Properties.GetFlags().HasFlag(SummonPropertiesFlags.UseSummonerFaction)) // TODO: Determine priority between faction and flag
            {
                if (owner)
                {
                    faction = owner.GetFaction();
                }
            }

            if (faction != 0)
            {
                SetFaction(faction);
            }
        }