Example #1
0
 public Abnormal(Creature.Creature creature, Abnormality abnormality, Creature.Creature caster = null)
 {
     Creature = creature;
     Caster = caster ?? creature;
     Abnormality = abnormality;
     TimeoutUts = Funcs.GetCurrentMilliseconds() + abnormality.Time;
 }
Example #2
0
        public void Release()
        {
            for (int i = 0; i < Effects.Count; i++)
                Effects[i].Release();
            Effects.Clear();
            Effects = null;

            Creature = null;
            Caster = null;
        }
Example #3
0
        public Attack(Creature.Creature creature, UseSkillArgs args, Action onStageEnd, Action onFinish)
        {
            if (creature.Attack != null)
                creature.Attack.Release();

            Args = args;

            Creature = creature;
            OnStageEnd = onStageEnd;
            OnFinish = onFinish;
        }
Example #4
0
        public override void Release()
        {
            base.Release();

            if (Creature == null)
            {
                return;
            }

            if (Args != null)
            {
                Args.Release();
            }
            Args = null;

            Creature   = null;
            OnStageEnd = null;
            OnFinish   = null;
        }
Example #5
0
        public Projectile(Creature.Creature owner, ProjectileSkill projectileSkill)
        {
            Player.Player player = owner as Player.Player;
            Npc.Npc       npc    = owner as Npc.Npc;

            Parent = owner;

            if (npc != null)
            {
                TargetPosition = new WorldPosition();
                npc.Target.Position.CopyTo(TargetPosition);
            }
            else
            {
                TargetPosition = owner.Attack.Args.TargetPosition;
            }

            Position = new WorldPosition
            {
                Heading = owner.Position.Heading,
                X       = owner.Position.X,
                Y       = owner.Position.Y,
                Z       = owner.Position.Z + projectileSkill.DetachHeight,
            };

            double angle = Position.Heading * Math.PI / 32768;

            Position.X += projectileSkill.DetachDistance * (float)Math.Cos(angle);
            Position.Y += projectileSkill.DetachDistance * (float)Math.Sin(angle);

            Instance        = owner.Instance;
            ProjectileSkill = projectileSkill;
            GameStats       = new CreatureBaseStats {
                HpBase = 1
            };

            if (player != null)
            {
                Skill   = Data.Skills[0][player.TemplateId][ProjectileSkill.Id];
                SkillId = Skill.Id;
            }
            else if (npc != null)
            {
                Skill   = Data.Skills[npc.NpcTemplate.HuntingZoneId][npc.NpcTemplate.Id][ProjectileSkill.Id];
                SkillId = Skill.Id + 0x40000000 + (npc.NpcTemplate.HuntingZoneId << 16);
            }

            Lifetime = Skill.ProjectileData.LifeTime != 0
                           ? Skill.ProjectileData.LifeTime
                           : 1000;

            if (projectileSkill.FlyingDistance <= 0f)
            {
                TargetPosition = null;
            }
            else if (Skill != null)
            {
                if (TargetPosition.IsNull())
                {
                    TargetPosition = Position.Clone();

                    TargetPosition.X += projectileSkill.FlyingDistance * (float)Math.Cos(angle);
                    TargetPosition.Y += projectileSkill.FlyingDistance * (float)Math.Sin(angle);
                }

                Speed = (int)(projectileSkill.FlyingDistance * 1000 / Lifetime);
            }

            if (Skill != null)
            {
                if (Skill.TargetingList != null)
                {
                    for (int i = 0; i < Skill.TargetingList.Count; i++)
                    {
                        if (Skill.TargetingList[i].AreaList == null)
                        {
                            continue;
                        }

                        for (int j = 0; j < Skill.TargetingList[i].AreaList.Count; j++)
                        {
                            if (Skill.TargetingList[i].AreaList[j].MaxRadius > AttackDistance)
                            {
                                AttackDistance = Skill.TargetingList[i].AreaList[j].MaxRadius;
                                return;
                            }
                        }
                    }
                }
            }
        }
Example #6
0
        public override void Release()
        {
            ObservedCreature = null;

            Inventory.Release();
            Inventory = null;

            PlayerData = null;

            try
            {
                Visible.Stop();
                Visible.Release();
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
                //Already stoped
            }
            Visible = null;

            Skills = null;

            Quests = null;

            if (CurrentDialog != null)
                CurrentDialog.Release();

            if (Pet != null)
                Pet.Release();
            Pet = null;

            MarkedCreatures = null;

            TeleportLoadMapEvent = null;

            try
            {
                SystemWindowsTimer.Stop();
                SystemWindowsTimer.Dispose();
            }
                // ReSharper disable EmptyGeneralCatchClause
            catch
                // ReSharper restore EmptyGeneralCatchClause
            {
            }
            SystemWindowsTimer = null;

            BlockersInChat = null;

            Friends = null;

            base.Release();
        }
Example #7
0
 /// <summary>
 /// Registers a creature into the world
 /// </summary>
 /// <param name="creature">The creature</param>
 public void AddCreature(Creature.Creature creature)
 {
     Creatures.AddFirst(creature);
 }
Example #8
0
        public override void Release()
        {
            base.Release();

            if (Creature == null)
                return;

            if (Args != null)
                Args.Release();
            Args = null;

            Creature = null;
            OnStageEnd = null;
            OnFinish = null;
        }