Beispiel #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;
 }
Beispiel #2
0
        public void AddAbility(Creature target, int id, int level)
        {
            if (target == null)
                return;

            lock (target.EffectsLock)
            {
                for (int i = 0; i < target.Effects.Count; i++)
                {
                    if (target.Effects[i].AbilityId == id)
                        target.Effects.Remove(target.Effects[i]);
                }
            }

            Ability abi = Data.Data.Abilities[id];

            if (abi == null)
                return;

            abi.level = level;

            AbilityEffectsProvider.ProvideEffects(target, abi);

            lock (target.EffectsLock)
            {
                target.Effects.Add(abi);
            }

            lock (TargetsLock)
                if (!targets.Contains(target))
                    targets.Add(target);
        }
Beispiel #3
0
        public override void OnAttacked(Creature attacker, int damage)
        {
            Npc.Target = attacker;

            BattleController.AddDamage(attacker, damage);
            BattleController.AddAggro(attacker, damage);
        }
Beispiel #4
0
 public SpNpcStatus(Npc npc, int unk1, int unk2, Creature target = null)
 {
     Npc = npc;
     Unk1 = unk1;
     Unk2 = unk2;
     Target = target;
 }
Beispiel #5
0
        public override void Init(Creature creature)
        {
            base.Init(creature);

            MoveController = new NpcMoveController(Npc);
            BattleController = new NpcBattleController(Npc);
        }
Beispiel #6
0
 public virtual void Release()
 {
     Creature = null;
     Npc = null;
     Player = null;
     Random = null;
 }
 public void Release()
 {
     Creature = null;
     Npc = null;
     Projectile = null;
     TargetPosition = null;
 }
Beispiel #8
0
        public static bool IsVisible(Player player, Creature creature)
        {
            if (creature is Player && !Communication.Global.PlayerService.IsPlayerOnline((Player)creature))
                return false;

            if (creature == null)
                return false;

            if (!(creature is Item) && !(creature is Gather) && !(creature is Campfire)
                && creature.LifeStats.IsDead())
                return false;

            if (creature is Gather && ((Gather)creature).CurrentGatherCounter <= 0)
                return false;

            double distance = player.Position.DistanceTo(creature.Position);
            if (distance > VisibleDistance)
                return false;

            if (creature is Npc && distance < 75)
                creature.Position.Z = player.Position.Z + 25;

            PlayerLogic.DistanceToCreatureRecalculated(player, creature, distance);

            return true;
        }
        public CreatureLifeStats(Creature creature)
        {
            _hp = creature.GameStats.HpBase + creature.GameStats.HpStamina;
            _mp = creature.GameStats.MpBase + creature.GameStats.MpStamina;

            Creature = creature;
        }
Beispiel #10
0
        public static float CheckIntersections(Creature creature, short heading, Point3D moveVector, float distance)
        {
            if (distance <= 0f)
                return 0f;

            WorldPosition targetPosition = moveVector.Clone().Add(creature.Position).ToWorldPosition();

            double minDistance = distance;

            List<Creature> around = Global.VisibleService.FindTargets(creature, creature.Position, distance + 40, TargetingAreaType.All);
            for (int x = 0; x < around.Count; x++)
            {
                if (around[x] == creature)
                    continue;

                short diff = Geom.GetAngleDiff(heading, Geom.GetHeading(creature.Position, around[x].Position));
                if (diff > 90)
                    continue;

                double d = Geom.DistanceToLine(around[x].Position, creature.Position, targetPosition);

                if (d > 40)
                    continue;

                d = creature.Position.DistanceTo(around[x].Position) - 40;

                if (d <= 0)
                    return 0f;

                if (d < minDistance)
                    minDistance = d;
            }

            return (float)(minDistance / distance);
        }
Beispiel #11
0
 public SpNpcMove(Creature creature, short speed, float x2, float y2, float z2)
 {
     Creature = creature;
     Speed = speed;
     X2 = x2;
     Y2 = y2;
     Z2 = z2;
 }
        public static void InTheVision(Player player, Creature creature)
        {
            FeedbackService.SendCreatureInfo(player.Connection, creature);

            Npc npc = creature as Npc;
            if (npc != null)
                QuestEngine.ShowIcon(player, npc);
        }
Beispiel #13
0
        protected int MoveStyle; // 1 normal : 2 run (when see player if agressive)

        #endregion Fields

        #region Constructors

        public SpNpcMove(Creature creature, float x, float y, float z, int style)
        {
            Creature = creature;
            Creature.Position.X = x;
            Creature.Position.Y = y;
            Creature.Position.Z = z;
            MoveStyle = style;
        }
Beispiel #14
0
        public NpcMoveController(Creature creature)
        {
            Creature = creature;
            Npc = creature as Npc;

            TargetPosition = new Point3D();
            MoveVector = new Point3D();
        }
Beispiel #15
0
        public static void OnAttack(Creature creature, Creature target)
        {
            creature.Ai.OnAttack(target);

            Player player = creature as Player;
            if (player != null)
                ObserverService.AddObserved(player, target);
        }
Beispiel #16
0
        public override void Init(Creature creature)
        {
            base.Init(creature);

            NextRegenUts = Funcs.GetCurrentMilliseconds() + 1000;
            NextDistressUts = Funcs.GetCurrentMilliseconds() + 60000;
            LastBattleUts = 0;
        }
Beispiel #17
0
        public virtual void Init(Creature creature)
        {
            Creature = creature;
            Npc = creature as Npc;
            Player = creature as Player;

            Random = new Random((int) (DateTime.Now.Ticks + Funcs.Random().Next(int.MinValue, (int) Math.Abs(creature.Position.X))));
        }
Beispiel #18
0
        public static void UpdateCreatureStats(Creature creature)
        {
            StatsService.UpdateStats(creature);

            Player player = creature as Player;
            if (player != null)
                FeedbackService.StatsUpdated(player);
        }
Beispiel #19
0
        public List<Npc> FindNpcs(Creature creature, float x, float y, float z, double distance, bool findVillagers = false)
        {
            double verticalDistance = distance * 2;

            return creature.VisibleNpcs.Select(npc =>
                                               npc.Position.DistanceTo(x, y) <= distance
                                               && Math.Abs(z - npc.Position.Z) < verticalDistance
                                               /*&& (!npc.NpcTemplate.IsVillager || findVillagers)*/);
        }
Beispiel #20
0
        public static void MpChanged(Creature creature, int diff, Creature attacker = null)
        {
            ObserverService.NotifyMpChanged(creature);

            if (creature is Player)
            {
                FeedbackService.MpChanged(creature as Player, diff, attacker);
                PartyService.SendLifestatsToPartyMembers(((Player)creature).Party);
            }
        }
Beispiel #21
0
        public static void HpChanged(Creature creature, int diff, Creature attacker = null)
        {
            if (creature is Player)
            {
                FeedbackService.HpMpSpChanged(creature as Player);
                //PartyService.SendLifestatsToPartyMembers(((Player)creature).Party);
            }

            ObserverService.NotifyHpMpSpChanged(creature);
        }
Beispiel #22
0
        public override void OnAttack(Creature target)
        {
            if (Player.Controller is DeathController)
                return;

            if (!(Player.Controller is BattleController))
                Global.ControllerService.SetController(Player, new BattleController());
            
            ((BattleController) Player.Controller).AddTarget(target);
        }
Beispiel #23
0
        public IAi CreateAi(Creature creature)
        {
            if (creature is Player)
                return new PlayerAi();

            if (creature is Npc)
                return new NpcAi();

            return new DefaultAi();
        }
Beispiel #24
0
        public void AttackStageEnd(Creature creature)
        {
            //Global.Global.VisibleService.Send(creature, new SpAttack(creature, creature.Attack));
            /*Player player = creature as Player;
            if (player != null)
                Global.Global.SkillEngine.UseSkill((creature as Player).Connection, creature.Attack.Args);

            Npc npc = creature as Npc;
            if (npc != null)
                Global.Global.SkillEngine.UseSkill(npc, null);*/
        }
Beispiel #25
0
        public static void AttackStageEnd(Creature creature)
        {
            //FeedbackService.AttackStageEnd(creature);
            Player player = creature as Player;
            if (player != null)
                Global.SkillEngine.UseSkill(player.Connection, creature.Attack.Args);

            Npc npc = creature as Npc;
            if (npc != null)
                Global.SkillEngine.UseSkill(npc, null);
        }
Beispiel #26
0
        public void Send(Creature creature, ISendPacket packet)
        {
            Player player = creature as Player;
            if (player != null)
            {
                if (player.Connection != null)
                    packet.Send(player.Connection);
            }

            creature.VisiblePlayers.Each(p => packet.Send(p.Connection));
        }
Beispiel #27
0
        public void MarkTarget(IConnection connection, Creature target, int skillId)
        {
            Player player = connection.Player;

            if (player.Attack == null || player.Attack.Args.SkillId != skillId)
                return;

            player.Attack.Args.Targets.Add(target);

            new SpMarkTarget(target, skillId).Send(connection);
        }
Beispiel #28
0
        public CreatureBaseStats InitStats(Creature creature)
        {
            Player player = creature as Player;
            if (player != null)
                return GetBaseStats(player).Clone();

            Npc npc = creature as Npc;
            if (npc != null)
                return NpcStats[npc.NpcTemplate.HuntingZoneId][npc.NpcTemplate.Id].Clone();

            Log.Error("StatsService: Unknown type: {0}.", creature.GetType().Name);
            return new CreatureBaseStats();
        }
        public void ResetChanges(Creature creature)
        {
            IsBlockFrontAttacks = false;

            //Power
            ChangeOfPower = 0;

            //Endurance
            ChangeOfEndurance = 0;

            //ImpactFactor
            ChangeOfImpactFactor = 0;

            //BalanceFactor
            ChangeOfBalanceFactor = 0;

            //Movement
            ChangeOfMovement = 0;
            MovementModificator = 0;
            MovementPercentModificator = 0;

            //AttackSpeed
            ChangeOfAttackSpeed = 0;
            AttackSpeedModificator = 0;
            AttackSpeedPercentModificator = 0;

            Player.Player player = creature as Player.Player;
            if (player != null)
            {
                MovementModificator += player.MovementByAdminCommand;

                if (player.PlayerMode != PlayerMode.Armored && player.Mount == 0)
                    MovementModificator += (short) (170 - player.GameStats.Movement);

                if (player.Attack != null && !player.Attack.IsFinished
                    && player.Attack.Args.GetSkill(player).BaseId == 20100
                    && (player.PlayerData.Class == PlayerClass.Berserker || player.PlayerData.Class == PlayerClass.Lancer))
                {
                    IsBlockFrontAttacks = true;
                }
            }

            creature.Effects.ForEach(effect => effect.SetImpact(this));

            ChangeOfMovement = (short)(MovementModificator +
                                        creature.GameStats.Movement * MovementPercentModificator);

            ChangeOfAttackSpeed = (short)(AttackSpeedModificator +
                                           creature.GameStats.AttackSpeed * AttackSpeedPercentModificator);
        }
        public void RemoveObserved(Player player, Creature creature)
        {
            if (player == creature)
                return;

            if (!creature.ObserversList.Contains(player))
                return;

            creature.ObserversList.Remove(player);
            new SpRemoveHpBar(creature).Send(player);

            if (player.ObservedCreature == creature)
                player.ObservedCreature = null;
        }
Beispiel #31
0
        public CreatureBaseStats InitStats(Data.Structures.Creature.Creature creature)
        {
            Player player = creature as Player;

            if (player != null)
            {
                return(GetBaseStats(player).Clone());
            }

            Npc npc = creature as Npc;

            if (npc != null)
            {
                return(GetNpcStats(npc));
            }

            Log.Error("StatsService: Unknown type: {0}.", creature.GetType().Name);
            return(new CreatureBaseStats());
        }
 public void Release()
 {
     Creature = null;
 }
Beispiel #33
0
 public void NotifyHpMpSpChanged(Data.Structures.Creature.Creature creature)
 {
     //SpNpcHpMp packet = new SpNpcHpMp(creature);
     //creature.ObserversList.Each(player => packet.Send(player.Connection));
 }