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); if (mom == null) { return; } 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 { Magic = ((ushort)message.MagicNumber), UserIndex = @char.Player.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; } }
public async Task CMuunRideReq(GSSession session, CMuunItemRideSelect message) { await session.SendAsync(new SMuunRideVP { ViewPort = new MuunRideVPDto[] { new MuunRideVPDto(session.Player.ID, 0xffff) } }); }
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, LastConnection = DateTime.Now, IsConnected = false, ServerCode = 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; } session.PreviousCode = 0xffff; acc.ServerCode = Program.ServerCode; acc.IsConnected = true; acc.LastConnection = DateTime.Now; 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)); }
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 }); }
public async Task CCharacterMapJoin2(GSSession session, CCharacterMapJoin2 Character) { var charDto = session.Player.Account.Characters .Select(x => x.Value) .FirstOrDefault(x => x.Name == Character.Name); if (!MapServerManager.CheckMapServerMove(session, (Maps)charDto.Map)) { return; } 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(); charDto.Friends = (from friend in db.Friends where (friend.FriendId == charDto.CharacterId || friend.CharacterId == charDto.CharacterId) && friend.State == 1 select friend).ToList(); charDto.Memos = (from letter in db.Letters where letter.CharacterId == charDto.CharacterId select letter).ToList(); charDto.MasterInfo = (from mi in db.MasterLevel where mi.MasterInfoId == charDto.CharacterId select mi).FirstOrDefault(); } if (@charDto == null) { return; } 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; //GCSendAllItemInfo //#if (ENABLETEST_MUUN == 1) //g_CMuunSystem.GDReqLoadMuunInvenItem(*lpObj); //#endif await session.SendAsync(new SMuunInventory()); //#if (ENABLETEST_RUMMY == 1) //g_CMuRummyMng.GDReqCardInfo(lpObj); //#endif //this->IsMuRummyEventOn() // packet for skill tree list //await session.Send(new byte[] { 0xC2, 0x00, 0x06, 0xF3, 0x53, 0x00 }); await session.SendAsync(new SPeriodItemCount()); await session.SendAsync(new SGensSendInfoS9()); await session.SendAsync(new SKillCount { KillCount = 1 }); 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; GuildManager.Instance.AddPlayer(session.Player); await session.SendAsync(new SNewQuestInfo()); await session.SendAsync(new SPentagramaJewelInfo { JewelCnt = 0, JewelPos = 0, List = Array.Empty <PentagramaJewelDto>(), Result = 0, }); await session.SendAsync(new SPentagramaJewelInfo { JewelCnt = 0, JewelPos = 1, List = Array.Empty <PentagramaJewelDto>(), Result = 0, }); await session.SendAsync(new SUBFInfo()); await session.SendAsync(new SSendBanner { Type = 3 }); await session.SendAsync(new SMapMoveCheckSum { key = 0x0010 }); //ConnectServer dataSend Program.client.SendAsync(new SCAdd { Server = (byte)Program.ServerCode, btName = @charDto.Name.GetBytes() }); if ((@char.CtlCode & ControlCode.GameMaster) == ControlCode.GameMaster) { @char.Spells.SetBuff(SkillStates.GameMaster, TimeSpan.FromDays(100)); } }
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 = (byte)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) )); } }
public static async void Exception(this GSSession session, Exception exception) { await session.SendAsync(new SNotice(MU.Resources.NoticeType.Blue, exception.Message)); Log.Logger.ForAccount(session).Error(exception, ""); }
public async Task CTalk(GSSession session, CTalk message) { var npcs = ResourceCache.Instance.GetNPCs(); var ObjectIndex = message.Number.ShufleEnding(); var obj = MonstersMng.Instance.GetMonster(ObjectIndex); var @char = session.Player.Character; if (npcs.TryGetValue(obj.Info.Monster, out var npc)) { if (npc.Shop != null) { session.Player.Window = npc.Shop.Storage; await session.SendAsync(new STalk { Result = 0 }); await session.SendAsync(new SShopItemList(npc.Shop.Storage.GetInventory()) { ListType = 0 }); await session.SendAsync(new STax { Type = TaxType.Shop, Rate = 4 }); } else if (npc.Warehouse) { session.Player.Window = session.Player.Account.Vault; session.Player.Character.Inventory.Lock = true; await session.SendAsync(new SNotice(NoticeType.Blue, $"Active Vault: " + (session.Player.Account.ActiveVault + 1))); await session.SendAsync(new STalk { Result = 2 }); await session.SendAsync(new SShopItemList(session.Player.Account.Vault.GetInventory())); await session.SendAsync(new SWarehouseMoney(session.Player.Account.VaultMoney, session.Player.Character.Money)); } else if (npc.GuildMaster) { GuildManager.NPCTalk(session.Player); } else if (npc.EventChips) { EventChips.NPCTalk(session.Player); } else if (npc.MessengerAngel) { BloodCastles.MessengerAngelTalk(session.Player); } else if (npc.KingAngel) { BloodCastles.AngelKingTalk(session.Player); } else if (npc.Window != 0) { await session.SendAsync(new STalk { Result = npc.Window }); if (npc.Window == 3) // ChaosMachine { session.Player.Character.Inventory.Lock = true; session.Player.Window = session.Player.Character.Inventory.ChaosBox; } } else if (npc.Buff != 0) { @char.Spells.SetBuff((SkillStates)npc.Buff, TimeSpan.FromSeconds(120)); } else if (npc.Quest != 0xffff) { var quest = @char.Quests.Find(obj.Info.Monster); if (quest == null) { await session.SendAsync(new SChatTarget(ObjectIndex, "I don't have Quest for you")); return; } var details = quest.Details; Logger.ForAccount(session) .Information("Talk to QuestNPC: {0}, Found Quest:{1}, State:{2}", obj.Info.Name, details.Name, quest.State); await session.SendAsync(new SSetQuest { Index = (byte)quest.Index, State = quest.StateByte }); } } else { Logger.ForAccount(session) .Debug("Talk to unasigned NPC {0}", obj.Info.Monster); await session.SendAsync(new SChatTarget(ObjectIndex, "Have a good day")); } }
public async Task CEventEnterCount(GSSession session, CEventEnterCount message) { await session.SendAsync(new SEventEnterCount { Type = message.Type, Left = 10 }); }
public async Task CUseItem(GSSession session, CUseItem message) { var @char = session.Player.Character; var inv = @char.Inventory; Logger.Debug("CUseItem {0} {1} {2}", message.Source, message.Dest, message.Type); var Source = inv.Get(message.Source); if (Source.BasicInfo.Skill != Spell.None) { if (await @char.Spells.TryAdd(Source.BasicInfo.Skill)) { await inv.Delete(message.Source); } @char.HPorSDChanged(); return; } switch (Source.Number) { case 14 * 512 + 0: // Apple case 14 * 512 + 1: // Small HP Potion case 14 * 512 + 2: // Medium HP Potion case 14 * 512 + 3: // Big HP Potion var AddLife = (Source.SellPrice * 10) - (@char.Level * 2); if (AddLife < 0) { AddLife = 0; } float AddLifeRate = ((Source.Number.Index + 1) * 10.0f) + (Source.Plus * 5.0f); AddLife += (long)(@char.MaxHealth * AddLifeRate / 100.0f); if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } @char.Health += AddLife; break; case 14 * 512 + 4: // Small MP Potion case 14 * 512 + 5: // Medium MP Potion case 14 * 512 + 6: // Big MP Potion var AddMana = (Source.SellPrice * 10) - @char.Level; if (AddMana < 0) { AddMana = 0; } float AddManaRate = ((Source.Number.Index - 3) * 10.0f) + (Source.Plus * 5.0f); AddMana += (uint)(@char.MaxMana * AddManaRate / 100.0f); if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } @char.Mana += AddMana; break; case 14 * 512 + 8: // Antidote if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } await @char.Spells.DelBuff(SkillStates.Ice); await @char.Spells.DelBuff(SkillStates.Poison); break; case 14 * 512 + 46: // Haloween Scroll if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } @char.Spells.SetBuff(SkillStates.HAttackSpeed, TimeSpan.FromMilliseconds(1800)); break; case 14 * 512 + 47: // Haloween Scroll if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } @char.Spells.SetBuff(SkillStates.HAttackPower, TimeSpan.FromMilliseconds(1800)); break; case 14 * 512 + 48: // Haloween Scroll if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } @char.Spells.SetBuff(SkillStates.HDefensePower, TimeSpan.FromMilliseconds(1800)); break; case 14 * 512 + 49: // Haloween Scroll if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } @char.Spells.SetBuff(SkillStates.HMaxLife, TimeSpan.FromMilliseconds(1800)); break; case 14 * 512 + 50: // Haloween Scroll if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } @char.Spells.SetBuff(SkillStates.HMaxMana, TimeSpan.FromMilliseconds(1800)); break; case 14 * 512 + 10: // Town Portal Scroll if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } if (@char.MapID == Maps.Davias) { await @char.WarpTo(22); } else if (@char.MapID == Maps.Noria) { await @char.WarpTo(27); } else if (@char.MapID == Maps.LostTower) { await @char.WarpTo(42); } else if (@char.MapID == Maps.Atlans) { await @char.WarpTo(49); } else if (@char.MapID == Maps.Tarkan) { await @char.WarpTo(57); } else if (@char.MapID == Maps.BloodCastle1) { await @char.WarpTo(22); } else if (@char.MapID == Maps.ChaosCastle1) { await @char.WarpTo(22); } else if (@char.MapID == Maps.Kalima1) { await @char.WarpTo(22); } else if (@char.MapID == Maps.Aida) { await @char.WarpTo(27); } else if (@char.MapID == Maps.Crywolf) { await @char.WarpTo(27); } else { await @char.WarpTo(17); } break; case 14 * 512 + 9: // Ale if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } break; case 14 * 512 + 20: // Remedy Of Love if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } await session.SendAsync(new SItemUseSpecialTime { Number = 1, Time = 90 }); break; case 14 * 512 + 7: // Siege Potion if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } var SS = Source.Plus == 0 ? SkillStates.PotionBless : SkillStates.PotionSoul; var time = TimeSpan.FromSeconds(Source.Plus == 0 ? 120 : 60); @char.Spells.SetBuff(SS, time); if (Source.Plus == 1) { await session.SendAsync(new SItemUseSpecialTime { Number = 2, Time = 60 }); } break; case 14 * 512 + 63: // Fireworks if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } await session.SendAsync(new SCommand(ServerCommandType.Fireworks, (byte)@char.Position.X, (byte)@char.Position.Y)); break; case 14 * 512 + 35: // Small SD Potion case 14 * 512 + 36: // Medium SD Potion case 14 * 512 + 37: // Big SD Potion float addSDRate = @char.MaxShield * (25.0f + (Source.Number.Index - 35) * 10.0f) / 100.0f; @char.Shield += addSDRate; if (Source.Durability == 1) { await inv.Delete(message.Source); } else { Source.Durability--; } await session.SendAsync(new SEffect((ushort)session.ID, ClientEffect.RecoverShield)); break; case 14 * 512 + 13: // Jewel of Bless { var Target = inv.Get(message.Dest); if (Target.Plus >= 7) { break; } await inv.Delete(message.Source); Target.Plus++; } break; case 14 * 512 + 14: // Jewel of Soul { var Target = inv.Get(message.Dest); if (Target.Plus >= 9) { break; } await inv.Delete(message.Source); var soulRate = 50 + (Target.Luck ? 25 : 0); if (new Random().Next(100) < soulRate) { Target.Plus++; } else { if (Target.Plus > 7) { Target.Plus = 0; } else { Target.Plus--; } } } break; case 14 * 512 + 16: // Jewel of Life { var Target = inv.Get(message.Dest); if (Target.Option28 >= 3) { break; } if (!Target.BasicInfo.Option) { break; } await inv.Delete(message.Source); var lifeRate = 50 + (Target.Luck ? 25 : 0); if (new Random().Next(100) < lifeRate) { Target.Option28++; } else { Target.Option28--; } } break; case 13 * 512 + 66: //Invitation of the Santa Town's break; } }
public async Task CPointAdd(GSSession session, CPointAdd message) { var @char = session.Player.Character; var msg = new SPointAdd { Result = (byte)(0x10 | (byte)message.Type), }; switch (message.Type) { case PointAdd.Strength: if (@char.Strength + 1 <= short.MaxValue) { @char.LevelUpPoints--; @char.Strength++; msg.MaxStamina = (ushort)@char.MaxStamina; msg.MaxShield = (ushort)@char.MaxShield; } else { msg.Result = 0; } break; case PointAdd.Agility: if (@char.Agility + 1 <= short.MaxValue) { @char.LevelUpPoints--; @char.Agility++; msg.MaxStamina = (ushort)@char.MaxStamina; msg.MaxShield = (ushort)@char.MaxShield; } else { msg.Result = 0; } break; case PointAdd.Vitality: if (@char.Vitality + 1 <= short.MaxValue) { @char.LevelUpPoints--; @char.Vitality++; msg.MaxLifeAndMana = (ushort)@char.MaxHealth; msg.MaxStamina = (ushort)@char.MaxStamina; msg.MaxShield = (ushort)@char.MaxShield; } else { msg.Result = 0; } break; case PointAdd.Energy: if (@char.Energy + 1 <= short.MaxValue) { @char.LevelUpPoints--; @char.Energy++; msg.MaxLifeAndMana = (ushort)@char.MaxMana; msg.MaxStamina = (ushort)@char.MaxStamina; msg.MaxShield = (ushort)@char.MaxShield; } else { msg.Result = 0; } break; case PointAdd.Command: if (@char.Command + 1 <= short.MaxValue) { @char.LevelUpPoints--; @char.Command++; msg.MaxStamina = (ushort)@char.MaxStamina; msg.MaxShield = (ushort)@char.MaxShield; } else { msg.Result = 0; } break; } await session.SendAsync(msg); }