示例#1
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("name");
     writer.WriteStringValue(Name);
     if (Description != null)
     {
         writer.WritePropertyName("description");
         writer.WriteStringValue(Description);
     }
     if (Skills != null && Skills.Any())
     {
         writer.WritePropertyName("skills");
         writer.WriteStartArray();
         foreach (var item in Skills)
         {
             writer.WriteObjectValue(item);
         }
         writer.WriteEndArray();
     }
     if (CognitiveServicesAccount != null)
     {
         writer.WritePropertyName("cognitiveServices");
         writer.WriteObjectValue(CognitiveServicesAccount);
     }
     if (_etag != null)
     {
         writer.WritePropertyName("@odata.etag");
         writer.WriteStringValue(_etag);
     }
     writer.WriteEndObject();
 }
示例#2
0
            private void UpdateSkills(bool reset = false)
            {
                // We may have loaded settings for all skills from any class.
                // Active skill is just the subset currently in use by the hero.
                // But we still need to persist settings for all skills used to-date.
                // Also need to populate with reference skill info for the pretty UI Icons etc.

                if (!Player.IsInGame && !ModuleManager.IsEnabled || !ZetaDia.IsInGame)
                {
                    return;
                }

                var activeSettings = SkillUtils.Active.Select(s => new SkillSettings(s)).ToList();

                if (Skills == null || !Skills.Any() || reset)
                {
                    Skills = new List <SkillSettings>(activeSettings);
                }
                else
                {
                    Skills.ForEach(s => s.SetReferenceSkill(SkillUtils.GetSkillByPower(s.SNOPower)));
                    Skills.AddRange(activeSettings.Where(b => Skills.All(a => a.SNOPower != b.SNOPower)));
                }

                var availableSkills = Skills.Where(s => Core.Hotbar.ActivePowers.Any(p => s.SNOPower == p)).OrderBy(s => s.Order);

                ActiveSkills = new FullyObservableCollection <SkillSettings>(availableSkills);
            }
示例#3
0
文件: Player.cs 项目: arxae/Realm-Rpg
        public void AddSkill(TrainedSkill skill)
        {
            if (Skills.Any(s => s.Id == skill.Id) == false)
            {
                Skills.Add(skill);
                return;
            }

            Serilog.Log.ForContext <Player>().Warning("Tried adding  {skill} to player {n} ({id}), but was already added", skill.Id, Name, Id);
        }
示例#4
0
 public void AttackTarget()
 {
     if (AttackCooldown < EntityTick)
     {
         AttackCooldown = (ushort)(EntityTick + ATK_CDR);
         if (!Skills.Any(x => x.SkillId == MobSkill.SkillId))
         {
             AddSkill(MobSkill.Copy().Create(this, Target, Server));
         }
     }
 }
示例#5
0
 public bool IsAbleToUseArmor(WowArmor item)
 {
     return(item.ArmorType switch
     {
         ArmorType.PLATE => Skills.Any(e => e.Contains("Plate Mail") || e.Contains("Plattenpanzer")),
         ArmorType.MAIL => Skills.Any(e => e.Contains("Mail") || e.Contains("Panzer")),
         ArmorType.LEATHER => Skills.Any(e => e.Contains("Leather") || e.Contains("Leder")),
         ArmorType.CLOTH => Skills.Any(e => e.Contains("Cloth") || e.Contains("Stoff")),
         ArmorType.TOTEMS => Skills.Any(e => e.Contains("Totem") || e.Contains("Totem")),
         ArmorType.LIBRAMS => Skills.Any(e => e.Contains("Libram") || e.Contains("Buchband")),
         ArmorType.IDOLS => Skills.Any(e => e.Contains("Idol") || e.Contains("Götzen")),
         ArmorType.SIGILS => Skills.Any(e => e.Contains("Sigil") || e.Contains("Siegel")),
         ArmorType.SHIEDLS => Skills.Any(e => e.Contains("Shield") || e.Contains("Schild")),
         ArmorType.MISCELLANEOUS => true,
         _ => false,
     });
示例#6
0
        public void AddSkill(string name, int level, int adept)
        {
            if (Skills.Any(x => x.Skill.EqualsIgnoreCase(name)))
            {
                throw new InvalidDataException($"Skill {name} is already found on Class {Name}");
            }

            ClassSkillAdeptData data = new ClassSkillAdeptData
            {
                Skill = name,
                Level = level,
                Adept = adept
            };

            Skills.Add(data);
        }
示例#7
0
        private bool IsSkillsValid()
        {
            SkillsErrors = null;

            if (Skills.Any(s => s.SkillId == 0 || s.SkillLevelId == 0))
            {
                SkillsErrors += "Fill all the fields of your skills.\r\n";
            }
            if (Skills.GroupBy(x => x.SkillId).Any(group => group.Count() > 1))
            {
                SkillsErrors += "Remove identical skills.\r\n";
            }

            SkillsErrors = SkillsErrors?.Trim();

            return(SkillsErrors == null);
        }
示例#8
0
        private async void SaveSkillsMethod()
        {
            if (!Skills.Any(s => string.IsNullOrWhiteSpace(s.Name) || s.Name.Length < 2 || s.Name.Length > 50))
            {
                using (var _database = new ITManagerEntities())
                {
                    var skills = await _database.ProfessionalSkills.ToListAsync();

                    foreach (var skill in skills)
                    {
                        var _skill = Skills.FirstOrDefault(s => s.Id == skill.Id);
                        if (_skill != null)
                        {
                            skill.Name = _skill.Name;
                        }
                        else
                        {
                            _database.ProfessionalSkills.Remove(skill);
                        }
                    }

                    foreach (var skill in Skills.Where(s => s.Id == 0))
                    {
                        _database.ProfessionalSkills.Add(new ProfessionalSkill
                        {
                            Name = skill.Name
                        });
                    }

                    await _database.SaveChangesAsync();

                    FillSkills();
                }
                Errors = string.Empty;
            }
            else
            {
                Errors = "All skills must contains from 2 to 50 symbols.";
            }
        }
示例#9
0
 public void Update(List <CaracteristicViewModel> Caracs)
 {
     foreach (var item in Caracs)
     {
         if (BaseAttributes.Any(b => b.Name.ToLower() == item.Name.ToLower()))
         {
             BaseAttributes.FirstOrDefault(b => b.Name.ToLower() == item.Name.ToLower()).Setvalue(item.Score);
         }
         else if (Skills.Any(s => s.Name.ToLower() == item.Name.ToLower()))
         {
             Skills.FirstOrDefault(s => s.Name.ToLower() == item.Name.ToLower()).Setvalue(item.Score);
         }
         else if (Stats.Any(s => s.Name.ToLower() == item.Name.ToLower()))
         {
             Stats.FirstOrDefault(s => s.Name.ToLower() == item.Name.ToLower()).Setvalue(item.Score);
         }
         else if (SpendablePoints.Any(s => s.Name.ToLower() == item.Name.ToLower()))
         {
             SpendablePoints.FirstOrDefault(s => s.Name.ToLower() == item.Name.ToLower()).Setvalue(item.Score);
         }
     }
 }
示例#10
0
        public bool Add(Skill skill, Entity source)
        {
            if (skill.ShortName != Name)
            {
                return(false);
            }
            if (Skills.Any(sk => skill.Id == sk.Key.Id && skill.IsHotDot == sk.Key.IsHotDot && sk.Value.Contains(source)))
            {
                return(false);
            }

            if (Skills.ContainsKey(skill))
            {
                Skills[skill].Add(source);
                _playerDealtUnrelieable = true;
            }
            else
            {
                Skills.Add(skill, new List <Entity> {
                    source
                });
            }
            return(true);
        }
示例#11
0
 public bool IsKnown(int skillId)
 {
     return(Skills.Any(s => s.Id == skillId));
 }
示例#12
0
        /// <summary>
        /// Hit the Target Character.
        /// </summary>
        /// <param name="targetSession"></param>
        /// <param name="npcMonsterSkill"></param>
        private void TargetHit(ClientSession targetSession, NpcMonsterSkill npcMonsterSkill)
        {
            if (Monster != null && (((DateTime.Now - LastEffect).TotalMilliseconds >= 1000 + Monster.BasicCooldown * 200 && !Skills.Any()) || npcMonsterSkill != null))
            {
                int damage  = 0;
                int hitmode = 0;
                if (npcMonsterSkill != null)
                {
                    damage = GenerateDamage(targetSession.Character, npcMonsterSkill.Skill, ref hitmode);
                }
                else
                {
                    damage = GenerateDamage(targetSession.Character, null, ref hitmode);
                }

                if (npcMonsterSkill != null)
                {
                    if (CurrentMp < npcMonsterSkill.Skill.MpCost)
                    {
                        FollowTarget(targetSession);
                        return;
                    }
                    npcMonsterSkill.LastSkillUse = DateTime.Now;
                    this.CurrentMp -= npcMonsterSkill.Skill.MpCost;
                    Map.Broadcast($"ct 3 {MapMonsterId} 1 {Target} {npcMonsterSkill.Skill.CastAnimation} {npcMonsterSkill.Skill.CastEffect} {npcMonsterSkill.Skill.SkillVNum}");
                }
                LastMove = DateTime.Now;

                // deal 0 damage to GM with GodMode
                if (targetSession.Character.HasGodMode)
                {
                    damage = 0;
                }
                if (targetSession.Character.IsSitting)
                {
                    targetSession.Character.IsSitting = false;
                    Map.Broadcast(targetSession.Character.GenerateRest());
                    Thread.Sleep(500);
                }
                if (npcMonsterSkill != null && npcMonsterSkill.Skill.CastEffect != 0)
                {
                    Map.Broadcast(GenerateEff(npcMonsterSkill.Skill.CastEffect), MapX, MapY);
                    Thread.Sleep(npcMonsterSkill.Skill.CastTime * 100);
                }
                Path = new List <GridPos>();
                targetSession.Character.LastDefence = DateTime.Now;
                targetSession.Character.GetDamage(damage);

                Map.Broadcast(null, ServerManager.Instance.GetUserMethod <string>(Target, "GenerateStat"), ReceiverType.OnlySomeone, "", Target);

                if (npcMonsterSkill != null)
                {
                    Map.Broadcast($"su 3 {MapMonsterId} 1 {Target} {npcMonsterSkill.SkillVNum} {npcMonsterSkill.Skill.Cooldown} {npcMonsterSkill.Skill.AttackAnimation} {npcMonsterSkill.Skill.Effect} {this.MapX} {this.MapY} {(targetSession.Character.Hp > 0 ? 1 : 0)} { (int)(targetSession.Character.Hp / targetSession.Character.HPLoad() * 100) } {damage} {hitmode} 0");
                }
                else
                {
                    Map.Broadcast($"su 3 {MapMonsterId} 1 {Target} 0 {Monster.BasicCooldown} 11 {Monster.BasicSkill} 0 0 {(targetSession.Character.Hp > 0 ? 1 : 0)} { (int)(targetSession.Character.Hp / targetSession.Character.HPLoad() * 100) } {damage} {hitmode} 0");
                }

                LastEffect = DateTime.Now;
                if (targetSession.Character.Hp <= 0)
                {
                    Thread.Sleep(1000);
                    ServerManager.Instance.AskRevive(targetSession.Character.CharacterId);
                    RemoveTarget();
                }
                if (npcMonsterSkill != null && (npcMonsterSkill.Skill.Range > 0 || npcMonsterSkill.Skill.TargetRange > 0))
                {
                    foreach (Character characterInRange in Map.GetCharactersInRange(npcMonsterSkill.Skill.TargetRange == 0 ? this.MapX : targetSession.Character.MapX, npcMonsterSkill.Skill.TargetRange == 0 ? this.MapY : targetSession.Character.MapY, npcMonsterSkill.Skill.TargetRange).Where(s => s.CharacterId != Target && s.Hp > 0))
                    {
                        if (characterInRange.IsSitting)
                        {
                            characterInRange.IsSitting = false;
                            Map.Broadcast(characterInRange.GenerateRest());
                            Thread.Sleep(500);
                        }
                        if (characterInRange.HasGodMode)
                        {
                            damage  = 0;
                            hitmode = 1;
                        }
                        bool alreadyDead2 = characterInRange.Hp <= 0;
                        characterInRange.GetDamage(damage);
                        characterInRange.LastDefence = DateTime.Now;
                        Map.Broadcast(null, characterInRange.GenerateStat(), ReceiverType.OnlySomeone, "", characterInRange.CharacterId);
                        Map.Broadcast($"su 3 {MapMonsterId} 1 {characterInRange.CharacterId} 0 {Monster.BasicCooldown} 11 {Monster.BasicSkill} 0 0 {(characterInRange.Hp > 0 ? 1 : 0)} { (int)(characterInRange.Hp / characterInRange.HPLoad() * 100) } {damage} {hitmode} 0");
                        if (characterInRange.Hp <= 0 && !alreadyDead2)
                        {
                            damage = characterInRange.HasGodMode ? 0 : damage;
                        }
                        bool alreadyDead = characterInRange.Hp <= 0;
                        characterInRange.GetDamage(damage);
                        characterInRange.LastDefence = DateTime.Now;
                        characterInRange.Session.SendPacket(characterInRange.GenerateStat());

                        Map.Broadcast($"su 3 {MapMonsterId} 1 {characterInRange.CharacterId} 0 {Monster.BasicCooldown} 11 {Monster.BasicSkill} 0 0 {(characterInRange.Hp > 0 ? 1 : 0)} { (int)(characterInRange.Hp / characterInRange.HPLoad() * 100) } {damage} {hitmode} 0");
                        if (characterInRange.Hp <= 0 && !alreadyDead)
                        {
                            Thread.Sleep(1000);
                            ServerManager.Instance.AskRevive(characterInRange.CharacterId);
                            RemoveTarget();
                        }
                    }
                }
            }
        }
示例#13
0
 public bool?ShouldUseSkill(ScriptInterface bot)
 {
     return(Skills.Any(s => s.Rule.ShouldUse(bot)));
 }
示例#14
0
 public List <string> GetSkills()
 {
     return((Skills != null && Skills.Any()) ? Skills.Trim().Split('^', ',').ToList() : new List <string>());
 }
示例#15
0
 private bool CanExecuteEscalateToExpert(object param)
 {
     return(Skills.Any(s => s.HasSelectedTopic));
 }
示例#16
0
        internal void MonsterLife()
        {
            // Respawn
            if (!Alive && Respawn)
            {
                double timeDeath = (DateTime.Now - Death).TotalSeconds;
                if (timeDeath >= Monster.RespawnTime / 10)
                {
                    DamageList = new Dictionary <long, long>();
                    Alive      = true;
                    Target     = -1;
                    CurrentHp  = Monster.MaxHP;
                    CurrentMp  = Monster.MaxMP;
                    MapX       = FirstX;
                    MapY       = FirstY;
                    Path       = new List <MapCell>();
                    Map.Broadcast(GenerateIn3());
                    Map.Broadcast(GenerateEff(7), 10);
                }
                return;
            }
            else if (Target == -1)
            {
                // Normal Move Mode
                if (!Alive)
                {
                    return;
                }
                if (IsMoving && Monster.Speed > 0)
                {
                    double time = (DateTime.Now - LastMove).TotalMilliseconds;

                    if (Path.Where(s => s != null).ToList().Count > 0)
                    {
                        int timetowalk = 1000 / (2 * Monster.Speed);
                        if (time > timetowalk)
                        {
                            short mapX = Path.ElementAt(0).X;
                            short mapY = Path.ElementAt(0).Y;
                            Path.RemoveAt(0);
                            LastMove = DateTime.Now;
                            Map.Broadcast($"mv 3 {this.MapMonsterId} {this.MapX} {this.MapY} {Monster.Speed}");

                            Task.Factory.StartNew(async() =>
                            {
                                await Task.Delay(timetowalk);
                                MapX = mapX;
                                MapY = mapY;
                            });
                            return;
                        }
                    }
                    else if (time > _movetime)
                    {
                        _movetime = _random.Next(400, 3200);
                        byte point  = (byte)_random.Next(2, 4);
                        byte fpoint = (byte)_random.Next(0, 2);

                        byte xpoint = (byte)_random.Next(fpoint, point);
                        byte ypoint = (byte)(point - xpoint);

                        short mapX = FirstX;
                        short mapY = FirstY;
                        if (Map.GetFreePosition(ref mapX, ref mapY, xpoint, ypoint))
                        {
                            Task.Factory.StartNew(async() =>
                            {
                                await Task.Delay(1000 * (xpoint + ypoint) / (2 * Monster.Speed));
                                this.MapX = mapX;
                                this.MapY = mapY;
                            });
                            LastMove = DateTime.Now.AddSeconds((xpoint + ypoint) / (2 * Monster.Speed));

                            string movePacket = $"mv 3 {this.MapMonsterId} {mapX} {mapY} {Monster.Speed}";
                            Map.Broadcast(movePacket);
                        }
                    }
                }
                if (Monster.IsHostile)
                {
                    Character character = ServerManager.Instance.Sessions.FirstOrDefault(s => s != null && s.Character != null && s.Character.Hp > 0 && !s.Character.InvisibleGm && !s.Character.Invisible && s.Character.MapId == MapId && Map.GetDistance(new MapCell()
                    {
                        X = MapX, Y = MapY
                    }, new MapCell()
                    {
                        X = s.Character.MapX, Y = s.Character.MapY
                    }) < 10)?.Character;
                    if (character != null)
                    {
                        Target = character.CharacterId;
                        if (!Monster.NoAggresiveIcon)
                        {
                            character.Session.SendPacket(GenerateEff(5000));
                        }
                    }
                }
            }
            else
            {
                ClientSession targetSession = Map.GetSessionByCharacterId(Target);

                if (targetSession == null || targetSession.Character.Invisible)
                {
                    Target = -1;
                    Path   = ServerManager.GetMap(MapId).StraightPath(new MapCell()
                    {
                        X = this.MapX, Y = this.MapY, MapId = this.MapId
                    }, new MapCell()
                    {
                        X = FirstX, Y = FirstY, MapId = this.MapId
                    });
                    if (!Path.Any())
                    {
                        Path = ServerManager.GetMap(MapId).JPSPlus(new MapCell()
                        {
                            X = this.MapX, Y = this.MapY, MapId = this.MapId
                        }, new MapCell()
                        {
                            X = FirstX, Y = FirstY, MapId = this.MapId
                        });
                    }
                }
                NpcMonsterSkill npcMonsterSkill = null;
                if (_random.Next(10) > 8)
                {
                    npcMonsterSkill = Skills.Where(s => (DateTime.Now - s.LastUse).TotalMilliseconds >= 100 * s.Skill.Cooldown).OrderBy(rnd => _random.Next()).FirstOrDefault();
                }

                int damage = 500;

                if (targetSession != null && targetSession.Character.Hp > 0 && ((npcMonsterSkill != null && CurrentMp - npcMonsterSkill.Skill.MpCost >= 0 && Map.GetDistance(new MapCell()
                {
                    X = this.MapX, Y = this.MapY
                }, new MapCell()
                {
                    X = targetSession.Character.MapX, Y = targetSession.Character.MapY
                }) < npcMonsterSkill.Skill.Range) || (Map.GetDistance(new MapCell()
                {
                    X = this.MapX, Y = this.MapY
                }, new MapCell()
                {
                    X = targetSession.Character.MapX, Y = targetSession.Character.MapY
                }) <= Monster.BasicRange)))
                {
                    if (((DateTime.Now - LastEffect).TotalMilliseconds >= 1000 + Monster.BasicCooldown * 200 && !Skills.Any()) || npcMonsterSkill != null)
                    {
                        if (npcMonsterSkill != null)
                        {
                            npcMonsterSkill.LastUse = DateTime.Now;
                            CurrentMp -= npcMonsterSkill.Skill.MpCost;
                            Map.Broadcast($"ct 3 {MapMonsterId} 1 {Target} {npcMonsterSkill.Skill.CastAnimation} {npcMonsterSkill.Skill.CastEffect} {npcMonsterSkill.Skill.SkillVNum}");
                        }
                        LastMove = DateTime.Now;

                        // deal 0 damage to GM with GodMode
                        damage = targetSession.Character.HasGodMode ? 0 : 100;
                        if (targetSession.Character.IsSitting)
                        {
                            targetSession.Character.IsSitting = false;
                            Map.Broadcast(targetSession.Character.GenerateRest());
                            Thread.Sleep(500);
                        }
                        if (npcMonsterSkill != null && npcMonsterSkill.Skill.CastEffect != 0)
                        {
                            Map.Broadcast(GenerateEff(npcMonsterSkill.Skill.CastEffect));
                            Thread.Sleep(npcMonsterSkill.Skill.CastTime * 100);
                        }
                        Path = new List <MapCell>();
                        targetSession.Character.LastDefence = DateTime.Now;
                        targetSession.Character.GetDamage(damage);

                        Map.Broadcast(null, ServerManager.Instance.GetUserMethod <string>(Target, "GenerateStat"), ReceiverType.OnlySomeone, "", Target);

                        if (npcMonsterSkill != null)
                        {
                            Map.Broadcast($"su 3 {MapMonsterId} 1 {Target} {npcMonsterSkill.SkillVNum} {npcMonsterSkill.Skill.Cooldown} {npcMonsterSkill.Skill.AttackAnimation} {npcMonsterSkill.Skill.Effect} {this.MapX} {this.MapY} {(targetSession.Character.Hp > 0 ? 1 : 0)} { (int)(targetSession.Character.Hp / targetSession.Character.HPLoad() * 100) } {damage} 0 0");
                        }
                        else
                        {
                            Map.Broadcast($"su 3 {MapMonsterId} 1 {Target} 0 {Monster.BasicCooldown} 11 {Monster.BasicSkill} 0 0 {(targetSession.Character.Hp > 0 ? 1 : 0)} { (int)(targetSession.Character.Hp / targetSession.Character.HPLoad() * 100) } {damage} 0 0");
                        }

                        LastEffect = DateTime.Now;
                        if (targetSession.Character.Hp <= 0)
                        {
                            Thread.Sleep(1000);
                            ServerManager.Instance.AskRevive(targetSession.Character.CharacterId);
                            Path = ServerManager.GetMap(MapId).StraightPath(new MapCell()
                            {
                                X = this.MapX, Y = this.MapY, MapId = this.MapId
                            }, new MapCell()
                            {
                                X = FirstX, Y = FirstY, MapId = this.MapId
                            });
                            if (!Path.Any())
                            {
                                Path = ServerManager.GetMap(MapId).JPSPlus(new MapCell()
                                {
                                    X = this.MapX, Y = this.MapY, MapId = this.MapId
                                }, new MapCell()
                                {
                                    X = FirstX, Y = FirstY, MapId = this.MapId
                                });
                            }
                        }
                        if (npcMonsterSkill != null && (npcMonsterSkill.Skill.Range > 0 || npcMonsterSkill.Skill.TargetRange > 0))
                        {
                            foreach (Character chara in ServerManager.GetMap(MapId).GetListPeopleInRange(npcMonsterSkill.Skill.TargetRange == 0 ? this.MapX : targetSession.Character.MapX, npcMonsterSkill.Skill.TargetRange == 0 ? this.MapY : targetSession.Character.MapY, (byte)(npcMonsterSkill.Skill.TargetRange + npcMonsterSkill.Skill.Range)).Where(s => s.CharacterId != Target && s.Hp > 0))
                            {
                                if (chara.IsSitting)
                                {
                                    chara.IsSitting = false;
                                    Map.Broadcast(chara.GenerateRest());
                                    Thread.Sleep(500);
                                }
                                damage = chara.HasGodMode ? 0 : 100;
                                bool AlreadyDead2 = chara.Hp <= 0;
                                chara.GetDamage(damage);
                                chara.LastDefence = DateTime.Now;
                                Map.Broadcast(null, chara.GenerateStat(), ReceiverType.OnlySomeone, "", chara.CharacterId);
                                Map.Broadcast($"su 3 {MapMonsterId} 1 {chara.CharacterId} 0 {Monster.BasicCooldown} 11 {Monster.BasicSkill} 0 0 {(chara.Hp > 0 ? 1 : 0)} { (int)(chara.Hp / chara.HPLoad() * 100) } {damage} 0 0");
                                if (chara.Hp <= 0 && !AlreadyDead2)
                                {
                                    Thread.Sleep(1000);
                                    ServerManager.Instance.AskRevive(chara.CharacterId);
                                }
                            }
                        }
                    }
                }
                else
                {
                    int distance = 0;
                    if (targetSession != null)
                    {
                        distance = Map.GetDistance(new MapCell()
                        {
                            X = this.MapX, Y = this.MapY
                        }, new MapCell()
                        {
                            X = targetSession.Character.MapX, Y = targetSession.Character.MapY
                        });
                    }
                    if (IsMoving)
                    {
                        short maxDistance = 22;
                        if (Path.Count() == 0 && targetSession != null && distance > 1 && distance < maxDistance)
                        {
                            short xoffset = (short)_random.Next(-1, 1);
                            short yoffset = (short)_random.Next(-1, 1);

                            Path = ServerManager.GetMap(MapId).StraightPath(new MapCell()
                            {
                                X = this.MapX, Y = this.MapY, MapId = this.MapId
                            }, new MapCell()
                            {
                                X = (short)(targetSession.Character.MapX + xoffset), Y = (short)(targetSession.Character.MapY + yoffset), MapId = this.MapId
                            });
                            if (!Path.Any())
                            {
                                Path = ServerManager.GetMap(MapId).JPSPlus(new MapCell()
                                {
                                    X = this.MapX, Y = this.MapY, MapId = this.MapId
                                }, new MapCell()
                                {
                                    X = (short)(targetSession.Character.MapX + xoffset), Y = (short)(targetSession.Character.MapY + yoffset), MapId = this.MapId
                                });
                            }
                        }
                        if (DateTime.Now > LastMove && Monster.Speed > 0 && Path.Count > 0)
                        {
                            short mapX;
                            short mapY;
                            int   maxindex = Path.Count > Monster.Speed / 2 ? Monster.Speed / 2 : Path.Count;
                            mapX = Path.ElementAt(maxindex - 1).X;
                            mapY = Path.ElementAt(maxindex - 1).Y;
                            double waitingtime = (double)(Map.GetDistance(new MapCell()
                            {
                                X = mapX, Y = mapY, MapId = MapId
                            }, new MapCell()
                            {
                                X = MapX, Y = MapY, MapId = MapId
                            })) / (double)(Monster.Speed);
                            Map.Broadcast($"mv 3 {this.MapMonsterId} {mapX} {mapY} {Monster.Speed}");
                            LastMove = DateTime.Now.AddSeconds((waitingtime > 1 ? 1 : waitingtime));
                            Task.Factory.StartNew(async() =>
                            {
                                await Task.Delay((int)((waitingtime > 1 ? 1 : waitingtime) * 1000));
                                this.MapX = mapX;
                                this.MapY = mapY;
                            });

                            for (int j = maxindex; j > 0; j--)
                            {
                                Path.RemoveAt(0);
                            }
                        }
                        if (Path.Count() == 0 && (targetSession == null || MapId != targetSession.Character.MapId || distance > maxDistance))
                        {
                            Path = ServerManager.GetMap(MapId).StraightPath(new MapCell()
                            {
                                X = this.MapX, Y = this.MapY, MapId = this.MapId
                            }, new MapCell()
                            {
                                X = FirstX, Y = FirstY, MapId = this.MapId
                            });
                            if (!Path.Any())
                            {
                                Path = ServerManager.GetMap(MapId).JPSPlus(new MapCell()
                                {
                                    X = this.MapX, Y = this.MapY, MapId = this.MapId
                                }, new MapCell()
                                {
                                    X = FirstX, Y = FirstY, MapId = this.MapId
                                });
                            }
                            Target = -1;
                        }
                    }
                }
            }
        }
示例#17
0
        private void AddSkillMethod(string skillName)
        {
            string errors = null;

            if (IsValid(ValidatesProperties, out errors))
            {
                Errors = errors;
                using (var _database = new ITManagerEntities())
                {
                    if (!_database.ProfessionalSkills.Any(s => s.Name == SkillName) && !Skills.Any(s => s.Name == SkillName))
                    {
                        Skills.Add(new Models.UserPageModel.ProfessionalSkill
                        {
                            Name = skillName
                        });
                    }
                    else
                    {
                        Errors = "This skill is already exists.";
                    }
                }
            }
            else
            {
                Errors = errors;
            }

            Errors = Errors?.Trim();
        }
示例#18
0
 public bool HasSkill(string name) => Skills.Any(x => x.SkillName == name);
        /// <summary>
        /// Hit the Target Character.
        /// </summary>
        /// <param name="targetSession"></param>
        /// <param name="npcMonsterSkill"></param>
        private void TargetHit(ClientSession targetSession, NpcMonsterSkill npcMonsterSkill)
        {
            if (Monster != null && (((DateTime.Now - LastEffect).TotalMilliseconds >= 1000 + Monster.BasicCooldown * 200 && !Skills.Any()) || npcMonsterSkill != null))
            {
                int hitmode = 0;
                int damage  = npcMonsterSkill != null?GenerateDamage(targetSession.Character, npcMonsterSkill.Skill, ref hitmode) : GenerateDamage(targetSession.Character, null, ref hitmode);

                if (npcMonsterSkill != null)
                {
                    if (CurrentMp < npcMonsterSkill.Skill.MpCost)
                    {
                        FollowTarget(targetSession);
                        return;
                    }
                    npcMonsterSkill.LastSkillUse = DateTime.Now;
                    CurrentMp -= npcMonsterSkill.Skill.MpCost;
                    Map.Broadcast($"ct 3 {MapMonsterId} 1 {Target} {npcMonsterSkill.Skill.CastAnimation} {npcMonsterSkill.Skill.CastEffect} {npcMonsterSkill.Skill.SkillVNum}");
                }
                LastMove = DateTime.Now;

                // deal 0 damage to GM with GodMode
                if (targetSession.Character.HasGodMode)
                {
                    damage = 0;
                }
                if (targetSession.Character.IsSitting)
                {
                    targetSession.Character.IsSitting = false;
                    Map.Broadcast(targetSession.Character.GenerateRest());
                    Thread.Sleep(500);
                }
                int castTime = 0;
                if (npcMonsterSkill != null && npcMonsterSkill.Skill.CastEffect != 0)
                {
                    Map.Broadcast(GenerateEff(npcMonsterSkill.Skill.CastEffect), MapX, MapY);
                    castTime = npcMonsterSkill.Skill.CastTime * 100;
                }
                Observable.Timer(TimeSpan.FromMilliseconds(castTime))
                .Subscribe(
                    o =>
                {
                    TargetHit2(targetSession, npcMonsterSkill, damage, hitmode);
                });
            }
        }
示例#20
0
 public bool HasSkill(Subject subject)
 {
     return(Skills.Any(s => s.Subject == subject));
 }
 // Methods
 public bool AddSkillCanExecute()
 {
     return(!Skills.Any(p => p.Skill.Name == Scope.Resolve <ISelectedItem>().SelectedSkill?.Name));
 }