public override void OnTick()
        {
            TimeSpan ts       = DateTime.Now.Subtract(LastSpawn);
            int      compteur = (int)ts.TotalSeconds;

            if (Frequency == 0)
            {
                Console.WriteLine("BaseSpawner frequency = 0, {0},{1},{2},{3},{4}", ci.ToString(), X, Y, Z, MapId);
                return;
            }
            if (compteur / Frequency > howMuch)
            {
                compteur = howMuch * Frequency;
            }
            while (compteur > 0)
            {
                if (CurrentAmount < howMuch)
                {
                    BaseCreature bc = (BaseCreature)ci.Invoke(null);
                    bc.InitStats();
                    bc.SpawnerLink = this;
                    bc.Orientation = this.Orientation;
                    //	if ( bc.AIEngine != null && bc.AIEngine.CustomBehaviours != null && bc.AIEngine.CustomBehaviours.Contains( CustomBehavioursTypes.Stay ) )
                    World.Add(bc, X, Y, Z, MapId);
                    /*else*/
                    //	World.Add( bc, realx, realy, realz, MapId );
                    Bind(bc);
                    bc.ZoneId = ZoneId;
                    LastSpawn = DateTime.Now;
                    compteur -= Frequency;
                    bc.OnAddToWorld();
                }
                else
                {
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public void Summon(Mobile c)
        {
            if (c.Summon != null)
            {
                c.Summon.Delete();
                if (World.allMobiles.Contains(c.Summon))
                {
                    World.Remove(c.Summon, c);
                }
            }
            ConstructorInfo ci = World.MobilePool(mountId);
            BaseCreature    bc = (BaseCreature)ci.Invoke(null);

            bc.Faction    = c.Faction;
            bc.AIEngine   = new SummonedAI(c, bc);
            bc.SummonedBy = c;
            c.Summon      = bc;
            bc.Level      = c.Level;
            bc.Stamina    = bc.Str = bc.Iq = bc.Spirit = bc.HitPoints = bc.BaseHitPoints = bc.Agility = bc.BaseMana = 0;
            bc.InitStats();
            //	bc.AIEngine = new SummonedAI( c, bc );
            if (c.Classe == Classes.Warlock)
            {
                #region Fel Intellect
                if (bc.Id == 416 || bc.Id == 1863 || bc.Id == 1860 || bc.Id == 417)
                {
                    if (c.HaveTalent(Talents.FelIntellect))
                    {
                        AuraEffect ae = (AuraEffect)c.GetTalentEffect(Talents.FelIntellect);
                        float      bm = (float)bc.BaseMana;
                        bm         += bm * ((float)ae.S1) / 100f;
                        bc.BaseMana = bc.Mana = (int)bm;
                    }
                }
                #endregion
                #region Fel Stamina
                if (bc.Id == 416 || bc.Id == 1863 || bc.Id == 1860 || bc.Id == 417)
                {
                    if (c.HaveTalent(Talents.FelStamina))
                    {
                        AuraEffect ae = (AuraEffect)c.GetTalentEffect(Talents.FelStamina);
                        float      bm = (float)bc.BaseHitPoints;
                        bm += bm * ((float)ae.S1) / 100f;
                        bc.BaseHitPoints = bc.HitPoints = (int)bm;
                    }
                }
                #endregion
            }

            World.Add(bc, c.X, c.Y, c.Z, c.MapId);
            if (c is Character)
            {
                //	c.SendSmallUpdate( new int[] { (int)UpdateFields.UNIT_FIELD_CHARM, (int)UpdateFields.UNIT_FIELD_SUMMON }, new object[] { bc.Guid, bc.Guid } );

                Character ch     = c as Character;
                int       offset = 4;
                Converter.ToBytes(1, c.tempBuff, ref offset);
                Converter.ToBytes((byte)0, c.tempBuff, ref offset);
                c.PrepareUpdateData(c.tempBuff, ref offset, UpdateType.UpdateFull, false);
                //				bc.PrepareUpdateData( c.tempBuff, ref offset , UpdateType.UpdateFull, false );
                ch.Send(OpCodes.SMSG_UPDATE_OBJECT, c.tempBuff, offset);
                ch.ItemsUpdate();

                if (bc.Id == 89 || bc.Id == 416 || bc.Id == 1863 || bc.Id == 1860 || bc.Id == 304 || bc.Id == 417)
                {
                    ch.SendPetActionBar();
                }
            }
        }