コード例 #1
0
 public void ConstructorWithDate()
 {
     try
       {
     var s = new GSSession("token", "secret", new NSDate());
       }
       catch(Exception e)
       {
     Assert.Fail(e.Message);
       }
       Assert.Pass();
 }
コード例 #2
0
ファイル: AuthServices.cs プロジェクト: kevinf93/MuEmu
        public async Task CCharacterList(GSSession session)
        {
            using (var db = new GameContext())
            {
                var acc = session.Player.Account;

                byte y = 0;
                acc.Characters = (from @char in db.Characters
                                  where @char.AccountId == acc.ID
                                  select @char).ToDictionary(x => y++);

                foreach (var @char in acc.Characters)
                {
                    @char.Value.Items = (from item in db.Items
                                         where item.CharacterId == @char.Value.CharacterId
                                         select item).ToList();
                }

                Type a;

                switch (Program.Season)
                {
                case 9:
                    a = typeof(SCharacterListS9);
                    break;

                case 12:
                    a = typeof(SCharacterListS12);
                    break;

                default:
                    a = typeof(SCharacterList);
                    break;
                }

                var b = Activator.CreateInstance(a, (byte)5, (byte)0, acc.Characters, (byte)5, (byte)3);
                await session.SendAsync(b);
            }
        }
コード例 #3
0
ファイル: GameServices.cs プロジェクト: tbs005/MuEmu
        public async Task CPartyDelUser(GSSession session, CPartyDelUser message)
        {
            var party = session.Player.Character.Party;

            if (party == null)
            {
                return;
            }

            var memb = party.Members.ElementAtOrDefault(message.Index);

            if (memb == null)
            {
                return;
            }

            if (memb != party.Master && memb != session.Player)
            {
                return;
            }

            PartyManager.Remove(memb);
        }
コード例 #4
0
ファイル: GameServices.cs プロジェクト: tbs005/MuEmu
        public async Task CMoveItem(GSSession session, CMoveItem message)
        {
            Logger.Debug("Move item {0}:{1} to {2}:{3}", message.sFlag, message.Source, message.tFlag, message.Dest);

            if (session.Player.Character.Inventory.Move(message.sFlag, message.Source, message.tFlag, message.Dest))
            {
                await session.SendAsync(new SMoveItem
                {
                    ItemInfo = message.ItemInfo,
                    Position = message.Dest,
                    Result   = (byte)message.tFlag
                });
            }
            else
            {
                await session.SendAsync(new SMoveItem
                {
                    ItemInfo = message.ItemInfo,
                    Position = 0xff,
                    Result   = (byte)message.tFlag
                });
            }
        }
コード例 #5
0
ファイル: GameServices.cs プロジェクト: tbs005/MuEmu
        public async Task CPartyRequest(GSSession session, CPartyRequest message)
        {
            var trg = Program.server.Clients.FirstOrDefault(x => x.ID == message.Number);

            if (trg == null)
            {
                await session.SendAsync(new SPartyResult(PartyResults.PlayerOffline));

                return;
            }

            if (trg.Player.Character.Party != null)
            {
                await session.SendAsync(new SPartyResult(PartyResults.InAnotherParty));

                return;
            }

            var party = session.Player.Character.Party;

            if ((party != null && party.Master != session.Player) || session.Player.Window != null || trg.Player.Window != null)
            {
                await session.SendAsync(new SPartyResult(PartyResults.Fail));

                return;
            }

            if (Math.Abs(session.Player.Character.Level - trg.Player.Character.Level) > PartyManager.MaxLevelDiff)
            {
                await session.SendAsync(new SPartyResult(PartyResults.RestrictedLevel));

                return;
            }

            message.Number = (ushort)session.ID;
            await trg.SendAsync(message);
        }
コード例 #6
0
        public void CSkillKey(GSSession session, SSkillKey message)
        {
            using (var db = new GameContext())
            {
                var res = db.Config.FirstOrDefault(x => x.SkillKeyId == session.Player.Character.Id);
                if (res == null)
                {
                    db.Config.Add(new MU.DataBase.SkillKeyDto
                    {
                        SkillKeyId = session.Player.Character.Id,
                        SkillKey   = message.SkillKey,
                        QkeyDefine = message.Q_Key,
                        EkeyDefine = message.E_Key,
                        WkeyDefine = message.W_Key,
                        GameOption = message.GameOption,
                        ChatWindow = message.ChatWindow,
                        RkeyDefine = message.R_Key,
                        //                    QWERLevelDefine = message.q
                    });
                }
                else
                {
                    //res.SkillKeyId = session.Player.Character.Id;
                    res.SkillKey   = message.SkillKey;
                    res.QkeyDefine = message.Q_Key;
                    res.EkeyDefine = message.E_Key;
                    res.WkeyDefine = message.W_Key;
                    res.GameOption = message.GameOption;
                    res.ChatWindow = message.ChatWindow;
                    res.RkeyDefine = message.R_Key;
                    db.Config.Update(res);
                }

                db.SaveChanges();
            }
        }
コード例 #7
0
ファイル: GuildServices.cs プロジェクト: kevinf93/MuEmu
        public async Task CGuildRemoveUser(GSSession session, CGuildRemoveUser message)
        {
            var log   = Logger.ForAccount(session);
            var guild = session.Player.Character.Guild;

            if (guild == null)
            {
                await session.SendAsync(new SGuildRemoveUser(GuildResult.NotExist));

                return;
            }

            if (guild.Master.Player != session.Player)
            {
                await session.SendAsync(new SGuildRemoveUser(GuildResult.NotExistPermission));

                return;
            }

            var memb = guild.Find(message.Name);

            if (memb == null)
            {
                return;
            }

            if (memb.Name == session.Player.Character.Name)
            {
                await session.SendAsync(new SGuildRemoveUser(GuildResult.NotExistPermission));

                return;
            }

            guild.Remove(memb);
            await session.SendAsync(new SGuildRemoveUser(GuildResult.Success));
        }
コード例 #8
0
ファイル: GuildServices.cs プロジェクト: tbs005/MuEmu
 public void CGuildInfoSave(GSSession session, CGuildInfoSave message)
 {
     GuildManager.CreateGuild(session.Player, message.Name, message.Mark, message.Type);
 }
コード例 #9
0
ファイル: Player.cs プロジェクト: tbs005/MuEmu
 public Player(GSSession session)
 {
     Session = session;
     Status  = LoginStatus.NotLogged;
 }
コード例 #10
0
ファイル: EventServices.cs プロジェクト: R3DIANCE/MuEmu
        public async Task CLuckyCoinsRegistre(GSSession session /*, CLuckyCoinsRegistre message*/)
        {
            var coins = await LuckyCoins.Registre(session.Player);

            await session.SendAsync(new SLuckyCoinsCount(coins));
        }
コード例 #11
0
ファイル: GlobalServices.cs プロジェクト: tbs005/MuEmu
 public void LiveClient(GSSession session, CLiveClient message)
 {
 }
コード例 #12
0
        public async Task CAttack(GSSession session, CAttack message)
        {
            var targetId = message.Number;
            var Dir      = message.DirDis & 0x0F;
            var Dis      = (message.DirDis & 0xF0) >> 4;

            session.Player.Character.Direction = message.DirDis;

            if (message.Number >= MonstersMng.MonsterStartIndex) // Is Monster
            {
                try
                {
                    var monster = MonstersMng.Instance.GetMonster(targetId);

                    if (monster.Life <= 0)
                    {
                        return;
                    }

                    session.Player.SendV2Message(new SAction((ushort)session.ID, message.DirDis, message.AttackAction, targetId));
                    if (monster.Type == ObjectType.NPC)
                    {
                        return;
                    }

                    DamageType type;
                    var        attack  = session.Player.Character.Attack(monster, out type);
                    var        eAttack = await session.Player.Character.PentagramAttack(monster);

                    await monster.GetAttacked(session.Player, attack, type, eAttack);
                }
                catch (Exception ex)
                {
                    Logger.ForAccount(session)
                    .Error(ex, "Invalid monster #{0}", targetId);
                }
            }
            else
            {
                try
                {
                    var target = Program.server.Clients.First(x => x.ID == targetId);
                    if (target.Player.Character.Health <= 0.0f)
                    {
                        return;
                    }

                    var rivals = session.Player.Character.Duel == target.Player.Character.Duel;

                    if (!(Program.XMLConfiguration.GamePlay.PVP || rivals))
                    {
                        return;
                    }

                    /*await session.Player
                     *  .SendV2Message(new SAction((ushort)session.ID, message.DirDis, message.AttackAction, targetId));*/

                    var attack = session.Player.Character
                                 .Attack(target.Player.Character, out DamageType type);

                    var eattack = await session.Player.Character
                                  .PentagramAttack(target.Player.Character);

                    await target.Player.Character
                    .GetAttacked((ushort)session.ID, message.DirDis, message.AttackAction, attack, type, Spell.None, eattack);
                }
                catch (Exception ex)
                {
                    Logger.ForAccount(session)
                    .Error(ex, "Invalid player #{0}", targetId);
                }
            }
        }
コード例 #13
0
        public void CMagicAttack(GSSession session, CMagicAttack message)
        {
            var @char  = session.Player.Character;
            var target = message.Target;

            MuEmu.Data.SpellInfo spell;
            Spells  spells  = null;
            Monster monster = null;
            Player  player  = null;
            Point   pos;
            int     defense = 0;

            if ([email protected](message.MagicNumber))
            {
                Logger.Error("Invalid Magic, user don't own this spell {0}", message.MagicNumber);
                return;
            }

            spell = @char.Spells.SpellDictionary[message.MagicNumber];
            int eDmg = 0;

            try
            {
                if (target >= MonstersMng.MonsterStartIndex) // Is Monster
                {
                    monster = MonstersMng.Instance.GetMonster(target);
                    spells  = monster.Spells;
                    defense = monster.Defense;
                    pos     = monster.Position;
                    eDmg    = @char.PentagramAttack(monster).Result;
                }
                else
                {
                    player  = Program.server.Clients.First(x => x.ID == target).Player;
                    spells  = player.Character.Spells;
                    defense = player.Character.Defense;
                    pos     = player.Character.Position;
                    eDmg    = @char.PentagramAttack(player.Character).Result;
                }
            }
            catch (Exception)
            {
                Logger.Error("MagicAttack: Invalid target");
                return;
            }

            var mana = @char.Mana - spell.Mana;
            var bp   = @char.Stamina;

            if (mana >= 0 && bp >= 0)
            {
                switch (spell.Number)
                {
                case Spell.Poison:
                    @char.Spells.AttackSend(spell.Number, message.Target, false);
                    spells.SetBuff(SkillStates.Poison, TimeSpan.FromSeconds(60), @char);
                    break;

                case Spell.Ice:
                    @char.Spells.AttackSend(spell.Number, message.Target, false);
                    spells.SetBuff(SkillStates.Ice, TimeSpan.FromSeconds(60), @char);
                    break;

                case Spell.InfinityArrow:
                    if (@char.BaseClass != HeroClass.FaryElf)
                    {
                        return;
                    }
                    spells.SetBuff(SkillStates.InfinityArrow, TimeSpan.FromSeconds(1800), @char);
                    @char.Spells.AttackSend(spell.Number, message.Target, true);
                    break;

                case Spell.Heal:
                case Spell.Heal1:
                case Spell.Heal2:
                case Spell.Heal3:
                case Spell.Heal4:
                case Spell.Heal5:
                    if (@char.BaseClass != HeroClass.FaryElf)
                    {
                        return;
                    }

                    var addLife = @char.EnergyTotal / 5;

                    if (spells.Character == null)
                    {
                        return;
                    }

                    spells.Character.Health += addLife;
                    @char.Spells.AttackSend(spell.Number, message.Target, true);
                    break;

                case Spell.GreaterDefense:
                case Spell.GreaterDefense1:
                case Spell.GreaterDefense2:
                case Spell.GreaterDefense3:
                case Spell.GreaterDefense4:
                case Spell.GreaterDefense5:
                    if (@char.BaseClass != HeroClass.FaryElf)
                    {
                        return;
                    }

                    spells.SetBuff(SkillStates.Defense, TimeSpan.FromSeconds(1800), @char);
                    @char.Spells.AttackSend(spell.Number, message.Target, true);
                    break;

                case Spell.GreaterDamage:
                case Spell.GreaterDamage1:
                case Spell.GreaterDamage2:
                case Spell.GreaterDamage3:
                case Spell.GreaterDamage4:
                case Spell.GreaterDamage5:
                    if (@char.BaseClass != HeroClass.FaryElf)
                    {
                        return;
                    }

                    spells.SetBuff(SkillStates.Attack, TimeSpan.FromSeconds(1800), @char);
                    @char.Spells.AttackSend(spell.Number, message.Target, true);
                    break;

                case Spell.SoulBarrier:
                case Spell.SoulBarrier1:
                case Spell.SoulBarrier2:
                case Spell.SoulBarrier3:
                case Spell.SoulBarrier4:
                case Spell.SoulBarrier5:
                    spells.SetBuff(SkillStates.SoulBarrier, TimeSpan.FromSeconds(60 + @char.EnergyTotal / 40), @char);
                    @char.Spells.AttackSend(spell.Number, message.Target, true);
                    break;

                case Spell.GreaterFortitude:
                case Spell.GreatFortitude1:
                case Spell.GreatFortitude2:
                case Spell.GreatFortitude3:
                case Spell.GreatFortitude4:
                case Spell.GreatFortitude5:
                    spells.SetBuff(SkillStates.SwellLife, TimeSpan.FromSeconds(60 + @char.EnergyTotal / 10), @char);
                    if (@char.Party != null)
                    {
                        foreach (var a in @char.Party.Members)
                        {
                            a.Character.Spells.SetBuff(SkillStates.SwellLife, TimeSpan.FromSeconds(60 + @char.EnergyTotal / 10), @char);
                        }
                    }
                    @char.Spells.AttackSend(spell.Number, message.Target, true);
                    break;

                case Spell.Reflex:
                    spells.SetBuff(SkillStates.SkillDamageDeflection, TimeSpan.FromSeconds(60 + @char.EnergyTotal / 40), @char);
                    @char.Spells.AttackSend(spell.Number, message.Target, true);
                    break;

                case Spell.Sleep:
                    spells.SetBuff(SkillStates.SkillSleep, TimeSpan.FromSeconds(30 + @char.EnergyTotal / 25), @char);
                    @char.Spells.AttackSend(spell.Number, message.Target, true);
                    break;

                default:
                    @char.Spells.AttackSend(spell.Number, message.Target, false);
                    break;
                }

                @char.Mana = mana;
                DamageType type   = DamageType.Regular;
                var        attack = 0.0f;
                switch (spell.Number)
                {
                case Spell.Falling_Slash:
                case Spell.Lunge:
                case Spell.Uppercut:
                case Spell.Cyclone:
                case Spell.Slash:
                case Spell.TwistingSlash:
                case Spell.TwistingSlash1:
                case Spell.TwistingSlash2:
                case Spell.TwistingSlash3:
                case Spell.TwistingSlash4:
                case Spell.TwistingSlash5:
                case Spell.RagefulBlow:
                case Spell.RagefulBlow1:
                case Spell.RagefulBlow2:
                case Spell.RagefulBlow3:
                case Spell.RagefulBlow4:
                case Spell.RagefulBlow5:
                case Spell.DeathStab:
                case Spell.DeathStab1:
                case Spell.DeathStab2:
                case Spell.DeathStab3:
                case Spell.DeathStab4:
                case Spell.DeathStab5:
                case Spell.CrescentMoonSlash:
                case Spell.Impale:
                case Spell.FireBreath:
                    attack = @char.SkillAttack(spell, defense, out type);
                    //else
                    //    @char.SkillAttack(spell, player, out type);
                    break;

                case Spell.Heal:
                case Spell.Heal1:
                case Spell.Heal2:
                case Spell.Heal3:
                case Spell.Heal4:
                case Spell.Heal5:
                case Spell.GreaterDamage:
                case Spell.GreaterDamage1:
                case Spell.GreaterDamage2:
                case Spell.GreaterDamage3:
                case Spell.GreaterDamage4:
                case Spell.GreaterDamage5:
                case Spell.GreaterDefense:
                case Spell.GreaterDefense1:
                case Spell.GreaterDefense2:
                case Spell.GreaterDefense3:
                case Spell.GreaterDefense4:
                case Spell.GreaterDefense5:
                case Spell.GreaterFortitude:
                case Spell.GreatFortitude1:
                case Spell.GreatFortitude2:
                case Spell.GreatFortitude3:
                case Spell.GreatFortitude4:
                case Spell.GreatFortitude5:
                case Spell.SoulBarrier:
                case Spell.SoulBarrier1:
                case Spell.SoulBarrier2:
                case Spell.SoulBarrier3:
                case Spell.SoulBarrier4:
                case Spell.SoulBarrier5:
                case Spell.Teleport:
                case Spell.InfinityArrow:
                    return;

                default:
                    if (spell.IsDamage == 0)
                    {
                        return;
                    }

                    if (@char.BaseClass == HeroClass.Summoner || @char.BaseClass == HeroClass.DarkWizard || @char.BaseClass == HeroClass.MagicGladiator)
                    {
                        attack = @char.MagicAttack(spell, defense, out type);
                    }
                    else
                    {
                        attack = @char.SkillAttack(spell, defense, out type);
                    }

                    if (attack <= 0)
                    {
                        attack = 0;
                        type   = DamageType.Miss;
                    }
                    break;
                }

                if (@char.Spells.CheckCombo(spell.Number))
                {
                    attack += (@char.StrengthTotal + @char.AgilityTotal + @char.EnergyTotal) / 2.0f;
                    @char.Spells.AttackSend(Spell.Combo, target, true);
                }

                player?.Character.GetAttacked((ushort)@char.Player.Session.ID, @char.Direction, 0, (int)attack, type, spell.Number, eDmg);
                monster?.GetAttackedDelayed(@char.Player, (int)attack, type, TimeSpan.FromMilliseconds(500));
            }
        }
コード例 #14
0
ファイル: AuthServices.cs プロジェクト: tbs005/MuEmu
        public async Task CCharacterCreate(GSSession session, CCharacterCreate message)
        {
            var log = Logger.ForAccount(session);

            using (var db = new GameContext())
            {
                var exists = (from @char in db.Characters
                              where string.Equals(@char.Name, message.Name, StringComparison.InvariantCultureIgnoreCase)
                              select @char).Any();

                if (exists)
                {
                    log.Information("Character name {0} is in use", message.Name);
                    await session.SendAsync(new SCharacterCreate(0));

                    return;
                }

                log.Information("Creating character {0} class:{1}", message.Name, message.Class);

                var defaultChar = ResourceCache.Instance.GetDefChar()[message.Class];

                var gate = ResourceCache.Instance.GetGates()
                           .Where(s => s.Value.Map == defaultChar.Map && s.Value.GateType == GateType.Warp)
                           .Select(s => s.Value)
                           .FirstOrDefault();

                var rand = new Random();
                var x    = (byte)rand.Next(gate?.Door.Left ?? 0, gate?.Door.Right ?? 126);
                var y    = (byte)rand.Next(gate?.Door.Top ?? 0, gate?.Door.Bottom ?? 126);

                var newChar = new MU.DataBase.CharacterDto
                {
                    AccountId     = session.Player.Account.ID,
                    Class         = (byte)message.Class,
                    Experience    = 0,
                    GuildId       = null,
                    Level         = defaultChar.Level,
                    LevelUpPoints = 0,
                    Name          = message.Name,
                    Quests        = new List <MU.DataBase.QuestDto>(),
                    Items         = new List <MU.DataBase.ItemDto>(),
                    // Map
                    Map = (byte)defaultChar.Map,
                    X   = x,
                    Y   = y,
                    // Stats
                    Str      = (ushort)defaultChar.Stats.Str,
                    Agility  = (ushort)defaultChar.Stats.Agi,
                    Vitality = (ushort)defaultChar.Stats.Vit,
                    Energy   = (ushort)defaultChar.Stats.Ene,
                    Command  = (ushort)defaultChar.Stats.Cmd,
                };

                db.Characters.Add(newChar);
                db.SaveChanges();

                var position = (byte)session.Player.Account.Characters.Count();

                session.Player.Account.Characters.Add(position, newChar);

                var items = defaultChar.Equipament.Select(eq => new MU.DataBase.ItemDto
                {
                    AccountId     = session.Player.Account.ID,
                    CharacterId   = newChar.CharacterId,
                    SlotId        = eq.Key,
                    DateCreation  = DateTime.Now,
                    Durability    = eq.Value.Durability,
                    HarmonyOption = eq.Value.Harmony.Option,
                    Luck          = eq.Value.Luck,
                    Number        = eq.Value.Number,
                    Option        = eq.Value.Option28,
                    OptionExe     = eq.Value.OptionExe,
                    Plus          = eq.Value.Plus,
                    Skill         = eq.Value.Skill,
                    SocketOptions = string.Join(",", eq.Value.Slots.Select(s => s.ToString())),
                });

                db.Items.AddRange(items.ToArray());
                db.SaveChanges();

                await session.SendAsync(new SCharacterCreate(1,
                                                             message.Name,
                                                             position,
                                                             newChar.Level,
                                                             Array.Empty <byte>(),
                                                             Character.GetClientClass(message.Class)
                                                             ));
            }
        }
コード例 #15
0
 public void CImperialGuardianEnter(GSSession session)
 {
     Program.EventManager.GetEvent <ImperialGuardian>()
     .TryAdd(session.Player);
 }
コード例 #16
0
 public void CCrywolfState(GSSession session)
 {
     Program.EventManager
     .GetEvent <Crywolf>()
     .SendState(session);
 }
コード例 #17
0
 public void CCrywolfBenefit(GSSession session)
 {
     Program.EventManager
     .GetEvent <Crywolf>()
     .SendBenefit(session);
 }
コード例 #18
0
ファイル: MuunServices.cs プロジェクト: fos83/MuEmu
 public async Task CMuunRideReq(GSSession session, CMuunItemRideSelect message)
 {
     await session.SendAsync(new SMuunRideVP { ViewPort = new MuunRideVPDto[] { new MuunRideVPDto(session.Player.ID, 0xffff) } });
 }
コード例 #19
0
ファイル: GuildServices.cs プロジェクト: kevinf93/MuEmu
 public void CGuildInfoSave(GSSession session, CGuildInfoSave message)
 {
     Logger.ForAccount(session).Debug("Create Guild: {0}:{1}", message.Name, message.Type);
     GuildManager.CreateGuild(session.Player, message.Name, message.Mark, message.Type);
 }
コード例 #20
0
ファイル: GuildServices.cs プロジェクト: tbs005/MuEmu
 public void CGuildListAll(GSSession session)
 {
     GuildManager.SendList(session.Player);
 }
コード例 #21
0
        public async Task CMagicDuration(GSSession session, CMagicDuration message)
        {
            var @char = session.Player.Character;

            if ([email protected](message.MagicNumber))
            {
                Logger.Error("Invalid Magic, user don't own this spell {0}", message.MagicNumber);
                return;
            }

            var magic = @char.Spells.SpellDictionary[message.MagicNumber];

            if (@char.Mana < magic.Mana || @char.Stamina < magic.BP)
            {
                return;
            }

            if ((magic.Number == Spell.Triple_Shot ||
                 magic.Number == Spell.Penetration ||
                 magic.Number == Spell.IceArrow ||
                 magic.Number == Spell.MultiShot))
            {
                if (@char.Inventory.Arrows == null)
                {
                    return;
                }

                if ([email protected](SkillStates.InfinityArrow))
                {
                    var durDown = magic.Number == Spell.Triple_Shot ? 3 : (magic.Number == Spell.MultiShot ? 5 : 0);
                    if (@char.Inventory.Arrows.Durability > durDown)
                    {
                        @char.Inventory.Arrows.Durability -= (byte)durDown;
                    }
                    else
                    {
                        @char.Inventory.Arrows.Durability--;
                    }

                    if (@char.Inventory.Arrows.Durability == 0)
                    {
                        await @char.Inventory.Delete(@char.Inventory.Arrows);
                    }
                }
            }

            @char.Mana    -= magic.Mana;
            @char.Stamina -= magic.BP;

            object msgdef = null;

            msgdef = VersionSelector.CreateMessage <SMagicDuration>(magic.Number, (ushort)session.ID, message.X, message.Y, message.Dir);
            await session.SendAsync(msgdef);

            session.Player.SendV2Message(msgdef);

            var dir = (message.Dir & 0xF0) >> 4;
            var dis = (message.Dir & 0x0F);

            var dirs = new List <Point>
            {
                new Point(-1, -1),
                new Point(0, -1),
                new Point(1, -1),

                new Point(1, 0),
                new Point(1, 1),
                new Point(0, 1),

                new Point(-1, 1),
                new Point(-1, 0)
            };
            DamageType type   = DamageType.Regular;
            int        attack = 0;
            Point      pos    = new Point();
            Monster    mom    = null;
            Player     plr;

            if (message.Target != 0 && message.Target != 0xffff)
            {
                if (message.Target < MonstersMng.MonsterStartIndex)
                {
                    plr    = Program.server.Clients.First(x => x.ID == message.Target).Player;
                    attack = @char.SkillAttack(magic, plr.Character.Defense, out type);
                    pos    = plr.Character.Position;
                    var eDmg = await @char.PentagramAttack(plr.Character);

                    await plr.Character.GetAttacked(@char.Player.ID, message.Dir, 0, attack, type, message.MagicNumber, eDmg);
                }
                else
                {
                    mom    = MonstersMng.Instance.GetMonster(message.Target);
                    attack = @char.SkillAttack(magic, mom.Defense, out type);
                    pos    = mom.Position;
                    var eDmg = await @char.PentagramAttack(mom);

                    await mom.GetAttacked(@char.Player, attack, type, eDmg);
                }
            }

            if (@char.Spells.CheckCombo(message.MagicNumber))
            {
                attack += (@char.StrengthTotal + @char.AgilityTotal + @char.EnergyTotal) / 2;
                @char.Spells.AttackSend(Spell.Combo, message.Target, true);
            }

            switch (message.MagicNumber)
            {
            case Spell.DrainLife:
            {
                if (mom != null)
                {
                    @char.Health += (@char.EnergyTotal / 15.0f) + (mom.Info.Level / 2.5f);
                }
                else
                {
                    @char.Health += (@char.EnergyTotal / 23.0f) + (attack * 0.1f);
                }
                var mg = VersionSelector.CreateMessage <SMagicAttack>(message.MagicNumber, @char.Player.ID, message.Target);
                @char.SendV2Message(mg);
                session.SendAsync(mg).Wait();
            }
            break;

            case Spell.ChainLighting:
            {
                var mvpcopy = @char.MonstersVP.ToList();
                var t1      = mvpcopy
                              .FirstOrDefault(
                    x => (MonstersMng
                          .Instance
                          .GetMonster(x)?
                          .Position
                          .Substract(pos)
                          .Length() ?? 100) < 2);

                var t2 = mvpcopy
                         .Except(new[] { t1 })
                         .FirstOrDefault(
                    x => (MonstersMng
                          .Instance
                          .GetMonster(x)?
                          .Position
                          .Substract(pos)
                          .Length() ?? 100) < 4);

                var l = new List <ushort>()
                {
                    message.Target
                };

                if (t1 != 0)
                {
                    l.Add(t1);
                    var mob  = MonstersMng.Instance.GetMonster(t1);
                    var eDmg = await @char.PentagramAttack(mob);

                    await mob.GetAttacked(@char.Player, attack, type, eDmg);
                }

                if (t2 != 0)
                {
                    l.Add(t2);
                    var mob  = MonstersMng.Instance.GetMonster(t2);
                    var eDmg = await @char.PentagramAttack(mob);

                    await mob.GetAttacked(@char.Player, attack, type, eDmg);
                }

                var obj = new SChainMagic
                {
                    wzMagic   = ((ushort)Spell.ChainLighting).ShufleEnding(),
                    UserIndex = (ushort)session.ID,
                    Targets   = l.ToArray(),
                };
                var mg = VersionSelector.CreateMessage <SMagicAttack>(message.MagicNumber, @char.Player.ID, message.Target);
                @char.SendV2Message(mg);
                session.SendAsync(mg).Wait();
                session.SendAsync(obj).Wait();
                session.Player.SendV2Message(obj);
            }
            break;

            case Spell.RagefulBlow:
            case Spell.RagefulBlow1:
            case Spell.RagefulBlow2:
            case Spell.RagefulBlow3:
            case Spell.RagefulBlow4:
            case Spell.RagefulBlow5:
            {
                var mp = new Point(message.X, message.Y);
                var vp = @char.MonstersVP
                         .ToList()    // clone for preveen collection changes
                         .Select(x => MonstersMng.Instance.GetMonster(x))
                         .Where(x => x.Position.Substract(mp).Length() <= 2.0 && x.Type != ObjectType.NPC);

                foreach (var mob in vp)
                {
                    attack = @char.SkillAttack(magic, mob.Defense, out type);
                    var eDmg = await @char.PentagramAttack(mob);

                    await mob.GetAttacked(@char.Player, attack, type, eDmg);
                }
            }
            break;

            case Spell.TwistingSlash:
            case Spell.TwistingSlash1:
            case Spell.TwistingSlash2:
            case Spell.TwistingSlash3:
            case Spell.TwistingSlash4:
            case Spell.TwistingSlash5:
            {
                var vp = @char.MonstersVP
                         .ToList()    // clone for preveen collection changes
                         .Select(x => MonstersMng.Instance.GetMonster(x))
                         .Where(x => x.Position.Substract(@char.Position).Length() <= 2.0 && x.Type != ObjectType.NPC);

                foreach (var mob in vp)
                {
                    attack = @char.SkillAttack(magic, mob.Defense, out type);
                    var eDmg = await @char.PentagramAttack(mob);

                    await mob.GetAttacked(@char.Player, attack, type, eDmg);
                }
            }
            break;

            case Spell.Decay:
            {
                var mp = new Point(message.X, message.Y);
                var vp = @char.MonstersVP
                         .ToList()    // clone for preveen collection changes
                         .Select(x => MonstersMng.Instance.GetMonster(x))
                         .Where(x => x.Position.Substract(mp).Length() <= 2.0 && x.Type != ObjectType.NPC);
                foreach (var mob in vp)
                {
                    attack = @char.SkillAttack(magic, mob.Defense, out type);
                    var eDmg = await @char.PentagramAttack(mob);

                    await mob.GetAttacked(@char.Player, attack, type, eDmg);

                    mob.Spells.SetBuff(SkillStates.Poison, TimeSpan.FromSeconds(60), @char);
                }
            }
            break;

            case Spell.IceStorm:
            case Spell.IceStorm1:
            case Spell.IceStorm2:
            case Spell.IceStorm3:
            case Spell.IceStorm4:
            case Spell.IceStorm5:
            {
                var mp = new Point(message.X, message.Y);
                var vp = @char.MonstersVP
                         .ToList()    // clone for preveen collection changes
                         .Select(x => MonstersMng.Instance.GetMonster(x))
                         .Where(x => x.Position.Substract(mp).Length() <= 2.0 && x.Type != ObjectType.NPC);
                foreach (var mob in vp)
                {
                    attack = @char.SkillAttack(magic, mob.Defense, out type);
                    var eDmg = await @char.PentagramAttack(mob);

                    await mob.GetAttacked(@char.Player, attack, type, eDmg);

                    mob.Spells.SetBuff(SkillStates.Ice, TimeSpan.FromSeconds(60), @char);
                }
            }
            break;

            case Spell.Neil:
            case Spell.Sahamutt:
            {
                var mp = new Point(message.X, message.Y);
                var vp = @char.MonstersVP
                         .ToList()    // clone for preveen collection changes
                         .Select(x => MonstersMng.Instance.GetMonster(x))
                         .Where(x => x.Position.Substract(mp).Length() <= 2.0 && x.Type != ObjectType.NPC);
                foreach (var mob in vp)
                {
                    attack = @char.MagicAttack(magic, mob.Defense, out type);
                    mob.GetAttackedDelayed(@char.Player, attack, type, TimeSpan.FromMilliseconds(300));
                    //mob.Spells.SetBuff(SkillStates.f, TimeSpan.FromSeconds(60), @char);
                }
            }
            break;
            }
        }
コード例 #22
0
ファイル: AuthServices.cs プロジェクト: tbs005/MuEmu
        public async Task CCharacterMapJoin2(GSSession session, CCharacterMapJoin2 Character)
        {
            var @charDto = session.Player.Account.Characters
                           .Select(x => x.Value)
                           .FirstOrDefault(x => x.Name == Character.Name.MakeString());

            using (var db = new GameContext())
            {
                @charDto.Spells = (from spell in db.Spells
                                   where spell.CharacterId == @charDto.CharacterId
                                   select spell).ToList();

                @charDto.Quests = (from quest in db.Quests
                                   where quest.CharacterId == @charDto.CharacterId
                                   select quest).ToList();

                charDto.SkillKey = (from config in db.Config
                                    where config.SkillKeyId == @charDto.CharacterId
                                    select config).FirstOrDefault();

                var friendList = from friend in db.Friends
                                 where (friend.FriendId == @charDto.CharacterId || friend.CharacterId == @charDto.CharacterId) && friend.State == 1
                                 select friend;
            }

            if (@charDto == null)
            {
                return;
            }

            await session.SendAsync(new SEventState(MapEvents.GoldenInvasion, false));

            await session.SendAsync(new SCheckSum { Key = session.Player.CheckSum.GetKey(), Padding = 0xff });

            await session.SendAsync(new SCashPoints { CashPoints = 0 });

            session.Player.Character = new Character(session.Player, @charDto);
            var @char = session.Player.Character;
            //FriendListRequest
            await session.SendAsync(new SFriends { MemoCount = 0, Friends = new Data.FriendDto[] { new Data.FriendDto {
                                                                                                       Name = "Yomalex2".GetBytes()
                                                                                                   } } });

            await session.SendAsync(new SKillCount { KillCount = 1 });

            GuildManager.Instance.AddPlayer(session.Player);

            if (charDto.SkillKey != null)
            {
                await session.SendAsync(new SSkillKey {
                    SkillKey   = charDto.SkillKey.SkillKey,
                    ChatWindow = charDto.SkillKey.ChatWindow,
                    E_Key      = charDto.SkillKey.EkeyDefine,
                    GameOption = charDto.SkillKey.GameOption,
                    Q_Key      = charDto.SkillKey.QkeyDefine,
                    R_Key      = charDto.SkillKey.RkeyDefine,
                    W_Key      = charDto.SkillKey.WkeyDefine,
                });
            }
            session.Player.Status = LoginStatus.Playing;
        }
コード例 #23
0
ファイル: AuthServices.cs プロジェクト: kevinf93/MuEmu
        public async Task CServerMove(GSSession session, CServerMove message)
        {
            Logger.ForAccount(session).Information("Server move recv");
            BuxDecode.Decode(message.btAccount);

            if (Program.server.ClientVersion != message.ClientVersion)
            {
                Logger.Error("Bad client version {0} != {1}", Program.server.ClientVersion, message.ClientVersion);
                await session.SendAsync(new SLoginResult(LoginResult.OldVersion));

                session.Disconnect();
                return;
            }

            if (Program.server.ClientSerial != message.ClientSerial)
            {
                Logger.Error("Bad client serial {0} != {1}", Program.server.ClientSerial, message.ClientSerial);
                await session.SendAsync(new SLoginResult(LoginResult.OldVersion));

                session.Disconnect();
                return;
            }

            using (var db = new GameContext())
            {
                var acc = (from account in db.Accounts
                           where string.Equals(account.Account, message.Account, StringComparison.InvariantCultureIgnoreCase)
                           select account)
                          .FirstOrDefault();

                var token = $"{message.AuthCode1:X8}{message.AuthCode2:X8}{message.AuthCode3:X8}{message.AuthCode4:X8}";

                if (acc.AuthToken != token)
                {
                    await session.SendAsync(new SLoginResult(LoginResult.ConnectionError));

                    return;
                }

                session.PreviousCode = (ushort)acc.ServerCode;
                acc.ServerCode       = Program.ServerCode;
                acc.IsConnected      = true;
                acc.LastConnection   = DateTime.Now;
                db.Accounts.Update(acc);
                db.SaveChanges();

                byte y = 0;
                session.Player.SetAccount(acc);
                var _acc = session.Player.Account;
                _acc.Characters = (from @char in db.Characters
                                   where @char.AccountId == acc.AccountId
                                   select @char).ToDictionary(x => y++);

                foreach (var @char in _acc.Characters)
                {
                    @char.Value.Items = (from item in db.Items
                                         where item.CharacterId == @char.Value.CharacterId
                                         select item).ToList();
                }
            }

            await CCharacterMapJoin2(session, new Auth.CCharacterMapJoin2 {
                Name = message.Character
            });
        }
コード例 #24
0
ファイル: AuthServices.cs プロジェクト: tbs005/MuEmu
        public async Task CIDAndPass(GSSession session, CIDAndPass message)
        {
            BuxDecode.Decode(message.btAccount);
            BuxDecode.Decode(message.btPassword);

            if (Program.server.ClientVersion != message.ClientVersion)
            {
                Logger.Error("Bad client version {0} != {1}", Program.server.ClientVersion, message.ClientVersion);
                await session.SendAsync(new SLoginResult(LoginResult.OldVersion));

                session.Disconnect();
                return;
            }

            if (Program.server.ClientSerial != message.ClientSerial)
            {
                Logger.Error("Bad client serial {0} != {1}", Program.server.ClientSerial, message.ClientSerial);
                await session.SendAsync(new SLoginResult(LoginResult.OldVersion));

                session.Disconnect();
                return;
            }

            using (var db = new GameContext())
            {
                var acc = (from account in db.Accounts
                           where string.Equals(account.Account, message.Account, StringComparison.InvariantCultureIgnoreCase)
                           select account)
                          .FirstOrDefault();

                if (acc == null)
                {
                    Logger.Information("Account {0} Don't exists", message.Account);
                    if (!Program.AutoRegistre)
                    {
                        await session.SendAsync(new SLoginResult(LoginResult.Fail));

                        return;
                    }
                    else
                    {
                        acc = new MU.DataBase.AccountDto
                        {
                            Account    = message.Account,
                            Password   = message.Password,
                            Characters = new List <MU.DataBase.CharacterDto>(),
                            VaultCount = 1,
                            VaultMoney = 0
                        };
                        db.Accounts.Add(acc);
                        db.SaveChanges();
                        Logger.Information("Account Created");
                    }
                }

                if (acc.Password != message.Password)
                {
                    await session.SendAsync(new SLoginResult(LoginResult.ConnectionError));

                    return;
                }

                if (acc.IsConnected == true)
                {
                    await session.SendAsync(new SLoginResult(LoginResult.IsConnected));

                    return;
                }

                acc.ServerCode  = Program.ServerCode;
                acc.IsConnected = true;
                db.Accounts.Update(acc);
                db.SaveChanges();

                //acc.Characters = (from @char in db.Characters
                //                  where @char.AccountId == acc.AccountId
                //                  select @char).ToList();

                //foreach(var @char in acc.Characters)
                //{
                //    @char.Items = (from item in db.Items
                //                   where item.CharacterId == @char.CharacterId
                //                   select item).ToList();
                //}

                session.Player.SetAccount(acc);
            }

            await session.SendAsync(new SLoginResult(LoginResult.Ok));
        }
コード例 #25
0
ファイル: EventServices.cs プロジェクト: R3DIANCE/MuEmu
 public void CCrywolfBenefit(GSSession session)
 {
     session.SendAsync(new SCrywolfBenefit());
 }
コード例 #26
0
 public async Task CAttackS5E2(GSSession session, CAttackS5E2 message)
 {
     await CAttack(session, new CAttack { AttackAction = message.AttackAction, DirDis = message.DirDis, wzNumber = message.Number });
 }
コード例 #27
0
ファイル: EventServices.cs プロジェクト: R3DIANCE/MuEmu
        public void CKanturuStateInfo(GSSession session)
        {
            var kanturu = Program.EventManager.GetEvent <Kanturu>();

            kanturu.NPCTalk(session.Player);
        }
コード例 #28
0
 public void CMagicAttackS9(GSSession session, CMagicAttackS9 message) => CMagicAttack(session, new CMagicAttack {
     MagicNumber = message.MagicNumber, Target = message.Target
 });
コード例 #29
0
ファイル: AntiHackServices.cs プロジェクト: kevinf93/MuEmu
 public void AHCheck(GSSession session, CAHCheck message)
 {
 }
コード例 #30
0
 protected GSCommandHandlerBase(ISession session, Dictionary <string, string> request) : base(session)
 {
     _errorCode = GSError.NoError;
     _session   = (GSSession)session.GetInstance();
 }
コード例 #31
0
 public static ILogger ForAccount(this ILogger logger, GSSession session)
 {
     return(logger.ForAccount(session.ID, session.Player?.Account?.Nickname ?? ""));
 }