public static void UpdateAvatar(Client gc) { var chr = gc.Character; Map map = MapFactory.GetMap(chr.MapX, chr.MapY); InventoryPacket.getInvenEquip(gc); StatusPacket.getStatusInfo(gc); foreach (Character All in map.Characters) { InventoryPacket.getAvatar(All.Client, chr); } }
public static void AbilityRecover_Req(InPacket lea, Client c) { short Slot = lea.ReadShort(); short Type = lea.ReadShort(); var chr = c.Character; switch (Type) { case 0: // 力量還原本 if (chr.Str < 4) { return; } chr.Str--; chr.AbilityBonus++; chr.Items.Remove(3, (byte)Slot, 1); break; case 1: // 精力還原本 if (chr.Dex < 4) { return; } chr.Dex--; chr.AbilityBonus++; chr.Items.Remove(3, (byte)Slot, 1); break; case 2: // 氣力還原本 if (chr.Vit < 4) { return; } chr.Vit--; chr.AbilityBonus++; chr.Items.Remove(3, (byte)Slot, 1); break; case 3: // 智力還原本 if (chr.Int < 4) { return; } chr.Int--; chr.AbilityBonus++; chr.Items.Remove(3, (byte)Slot, 1); break; } InventoryHandler.UpdateInventory(c, 3); StatusPacket.getStatusInfo(c); }
public void LevelUp() { this.Level++; this.Exp = 0; switch (this.Class) { case 1: // 武士 this.MaxHp += 13; this.MaxMp += 7; break; case 2: // 刺客 this.MaxHp += 9; this.MaxMp += 12; break; case 3: // 道士 this.MaxHp += 7; this.MaxMp += 14; break; case 4: // 力士 // 未知 this.MaxHp += 13; this.MaxMp += 7; break; case 5: // 射手 // 未知 this.MaxHp += 9; this.MaxMp += 12; break; default: this.MaxHp += 10; this.MaxMp += 15; break; } this.Hp = this.MaxHp; this.Mp = this.MaxMp; if (this.Level % 10 != 0) { this.AbilityBonus += 4; } else { this.AbilityBonus += 8; } this.SkillBonus += 2; Map map = MapFactory.GetMap(this.MapX, this.MapY); foreach (Character All in map.Characters) { StatusPacket.LevelUp(All.Client, this, this.Level); } StatusPacket.getStatusInfo(Client); }
public static void Command_Req(InPacket lea, Client gc) { string[] cmd = lea.ReadString(60).Split(new[] { (char)0x20 }, StringSplitOptions.None); if (gc.Account.Master == 0 || cmd.Length < 1) { return; } var chr = gc.Character; Character victim = null; switch (cmd[0]) { case "//notice": if (cmd.Length != 2) { break; } foreach (Character all in MapFactory.AllCharacters) { GamePacket.getNotice(all.Client, 3, cmd[1]); } break; case "//item": if (cmd.Length != 2 && cmd.Length != 3) { break; } short Quantity = 1; if (cmd.Length == 3) { if (int.Parse(cmd[2]) > 100) { Quantity = 100; } else { Quantity = short.Parse(cmd[2]); } } if (InventoryType.getItemType(int.Parse(cmd[1])) == 1 || InventoryType.getItemType(int.Parse(cmd[1])) == 2) { Quantity = 1; } if (InventoryType.getItemType(int.Parse(cmd[1])) == 5) { return; } chr.Items.Add(new Item(int.Parse(cmd[1]), InventoryType.getItemType(int.Parse(cmd[1])), chr.Items.GetNextFreeSlot((InventoryType.ItemType)InventoryType.getItemType(int.Parse(cmd[1]))), Quantity)); InventoryHandler.UpdateInventory(gc, InventoryType.getItemType(int.Parse(cmd[1]))); break; case "//money": if (cmd.Length != 2) { break; } chr.Money = int.Parse(cmd[1]); InventoryPacket.getInvenMoney(gc, chr.Money, int.Parse(cmd[1])); break; case "//levelup": chr.LevelUp(); break; case "//gogo": if (cmd.Length != 3) { break; } MapPacket.warpToMapAuth(gc, true, short.Parse(cmd[1]), short.Parse(cmd[2]), short.Parse(cmd[3]), short.Parse(cmd[4])); break; case "//hp": if (cmd.Length != 2) { break; } short Hp = short.Parse(cmd[1]); if (Hp > short.MaxValue) { Hp = short.MaxValue; } chr.MaxHp = Hp; chr.Hp = Hp; StatusPacket.getStatusInfo(gc); break; case "//mp": short Mp = short.Parse(cmd[1]); if (Mp > short.MaxValue) { Mp = short.MaxValue; } chr.MaxMp = Mp; chr.Mp = Mp; StatusPacket.getStatusInfo(gc); break; case "//heal": chr.Hp = chr.MaxHp; chr.Mp = chr.MaxMp; chr.Fury = chr.MaxFury; StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury); break; case "//warp": if (cmd.Length != 2) { break; } foreach (Character find in MapFactory.AllCharacters) { if (find.Name.Equals(cmd[1])) { victim = find; } } if (victim != null) { chr.MapX = victim.MapX; chr.MapY = victim.MapY; chr.PlayerX = victim.PlayerX; chr.PlayerY = victim.PlayerY; MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY); } break; case "//ban": if (cmd.Length != 2) { break; } foreach (Character find in MapFactory.AllCharacters) { if (find.Name.Equals(cmd[1])) { victim = find; } } if (victim != null) { dynamic datum = new Datum("accounts"); victim.Client.Account.Banned = 7; victim.Client.Dispose(); } break; case "//save": for (int i = 0; i < MapFactory.AllCharacters.Count; i++) { if (chr.CharacterID == MapFactory.AllCharacters[i].CharacterID) { continue; } MapFactory.AllCharacters[i].Client.Dispose(); } //GameServer.IsAlive = false; break; case "//skillhack": break; case "//serverinfo": GamePacket.NormalNotice(gc, 1, "I: P:15101 U:1 E:1.00 D:1.00 M:1.00 G:1.00"); break; case "//come": case "//oxstate": break; case "//now": DateTime now = DateTime.Now; string nowtime = string.Format("Server Time Now : [{0}-{1}-{2} {3}:{4}:{5}]", now.Year, now.Month, now.Day.ToString("00.##"), now.Hour.ToString("00.##"), now.Minute.ToString("00.##"), now.Second.ToString("00.##")); GamePacket.NormalNotice(gc, 4, nowtime); break; case "//user": break; case "//serverdown": break; case "//test": GamePacket.getNotice(gc, 4, "Tes000t"); break; case "//expbuff": GamePacket.getNotice(gc, 1, "!@ExpEvent2@!"); break; case "//processlist": GamePacket.GmProcessList(gc); GamePacket.NormalNotice(gc, 4, "[GM] Process File has saved in game folder."); break; case "//gameinfo": GamePacket.GmGameInfo(gc); GamePacket.NormalNotice(gc, 4, "[GM] GAME_INFO has copied to your clipboard."); //[GM] Game Log has copied to your clipboard. break; default: break; } }
public static void UseSpend_Req(InPacket lea, Client gc) { var chr = gc.Character; byte Type = lea.ReadByte(); byte Slot = lea.ReadByte(); Item Item = chr.Items.getItem(Type, Slot); Map map = MapFactory.GetMap(chr.MapX, chr.MapY); var use = ItemFactory.useData[Item.ItemID]; // 使用回復HP 跟 MP 的物品 switch (Item.ItemID) { case 8841006: // 全部還原本 int Recover = 0; Recover = Recover + (chr.Str - 3); Recover = Recover + (chr.Dex - 3); Recover = Recover + (chr.Vit - 3); Recover = Recover + (chr.Int - 3); chr.Str = 3; chr.Dex = 3; chr.Vit = 3; chr.Int = 3; chr.AbilityBonus += (short)Recover; StatusPacket.getStatusInfo(gc); break; case 8850011: // 回城符 switch (chr.MapX) { case 1: case 2: case 3: case 4: case 5: case 6: case 22: case 23: chr.MapX = 1; chr.MapY = 1; break; case 7: case 8: case 9: chr.MapX = 16; chr.MapY = 1; break; case 10: case 11: case 20: chr.MapX = 10; chr.MapY = 1; break; case 12: case 13: chr.MapX = 12; chr.MapY = 1; break; case 14: case 15: case 17: case 18: case 19: case 21: chr.MapX = 15; chr.MapY = 1; break; case 16: chr.MapX = 16; chr.MapY = 1; break; case 24: case 25: case 26: case 31: case 32: case 33: chr.MapX = 25; chr.MapY = 1; break; case 27: case 28: chr.MapX = 27; chr.MapY = 1; break; default: chr.MapX = 1; chr.MapY = 1; break; } chr.PlayerX = 0; chr.PlayerY = 0; MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY); break; case 8850021: // 清陰符 chr.MapX = 1; chr.MapY = 2; chr.PlayerX = 2955; chr.PlayerY = 1116; MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY); break; case 8850031: // 龍林符(龍林城) chr.MapX = 15; chr.MapY = 2; chr.PlayerX = 3600; chr.PlayerY = 1041; MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY); break; case 8850041: // 冥珠符 chr.MapX = 10; chr.MapY = 3; chr.PlayerX = 1645; chr.PlayerY = 899; MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY); break; case 8850051: // 古樂符 chr.MapX = 25; chr.MapY = 1; chr.PlayerX = 4237; chr.PlayerY = 1230; MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY); break; case 8850061: // 無名符 chr.MapX = 16; chr.MapY = 1; chr.PlayerX = 2005; chr.PlayerY = 1101; MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY); break; case 8850071: // 龍林符(龍林客棧) chr.MapX = 12; chr.MapY = 1; chr.PlayerX = 1040; chr.PlayerY = 782; MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY); break; case 8890011: // 蠟燭 case 8890021: // 火把 InventoryPacket.UseSpendStart(gc, chr, chr.PlayerX, chr.PlayerY, Item.ItemID, (byte)InventoryType.ItemType.Spend3, Slot); break; case 8899017: // 逮巴符 chr.MapX = 27; chr.MapY = 1; chr.PlayerX = 2070; chr.PlayerY = 1330; MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY); break; default: switch (use.Type) { case 0: // 恢復鬼力 if ((chr.MaxMp > chr.Mp + use.Recover)) { chr.Mp += (short)use.Recover; StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury); } else if (chr.MaxMp - chr.Mp < use.Recover) { chr.Mp = chr.MaxMp; StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury); } break; case 1: // 恢復鬼力(%) if ((chr.MaxMp > chr.Mp + chr.MaxMp * use.Recover / 100)) { chr.Mp += (short)(chr.MaxMp * use.Recover / 100); StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury); } else if (chr.MaxMp - chr.Mp < chr.MaxMp * use.Recover / 100) { chr.Mp = chr.MaxMp; StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury); } break; case 2: // 恢復體力 if ((chr.MaxHp > chr.Hp + use.Recover)) { chr.Hp += (short)use.Recover; StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury); } else if (chr.MaxHp - chr.Hp < use.Recover) { chr.Hp = chr.MaxHp; StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury); } break; case 3: // 恢復體力(%) if ((chr.MaxHp > chr.Hp + chr.MaxHp * use.Recover / 100)) { chr.Hp += (short)(chr.MaxHp * use.Recover / 100); StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury); } else if (chr.MaxHp - chr.Hp < chr.MaxHp * use.Recover / 100) { chr.Hp = chr.MaxHp; StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury); } break; default: break; } break; } chr.Items.Remove(Type, Slot, 1); UpdateInventory(gc, Type); }
public static void Command_Req(InPacket lea, Client gc) { string[] cmd = lea.ReadString(60).Split(new[] { (char)0x20 }, StringSplitOptions.None); if (gc.Account.Master == 0 || cmd.Length < 1) { return; } var chr = gc.Character; Character victim = null; switch (cmd[0]) { case "//1": case "//公告": case "//notice": if (cmd.Length != 2) { break; } foreach (Character all in MapFactory.AllCharacters) { GamePacket.getNotice(all.Client, 3, cmd[1]); } break; case "//item": if (cmd.Length != 2 && cmd.Length != 3) { break; } short Quantity = 1; if (cmd.Length == 3) { if (int.Parse(cmd[2]) > 100) { Quantity = 100; } else { Quantity = short.Parse(cmd[2]); } } if (InventoryType.getItemType(int.Parse(cmd[1])) == 1 || InventoryType.getItemType(int.Parse(cmd[1])) == 2) { Quantity = 1; } if (InventoryType.getItemType(int.Parse(cmd[1])) == 5) { return; } chr.Items.Add(new Item(int.Parse(cmd[1]), InventoryType.getItemType(int.Parse(cmd[1])), chr.Items.GetNextFreeSlot((InventoryType.ItemType)InventoryType.getItemType(int.Parse(cmd[1]))), Quantity)); InventoryHandler.UpdateInventory(gc, InventoryType.getItemType(int.Parse(cmd[1]))); break; case "//money": if (cmd.Length != 2) { break; } chr.Money = int.Parse(cmd[1]); InventoryPacket.getInvenMoney(gc, chr.Money, int.Parse(cmd[1])); break; case "//levelup": chr.LevelUp(); break; case "//gogo": if (cmd.Length != 3) { break; } MapPacket.warpToMapAuth(gc, true, short.Parse(cmd[1]), short.Parse(cmd[2]), -1, -1); break; case "//hp": if (cmd.Length != 2) { break; } short Hp = short.Parse(cmd[1]); if (Hp > short.MaxValue) { Hp = short.MaxValue; } chr.MaxHp = Hp; chr.Hp = Hp; StatusPacket.getStatusInfo(gc); break; case "//mp": short Mp = short.Parse(cmd[1]); if (Mp > short.MaxValue) { Mp = short.MaxValue; } chr.MaxMp = Mp; chr.Mp = Mp; StatusPacket.getStatusInfo(gc); break; case "//heal": chr.Hp = chr.MaxHp; chr.Mp = chr.MaxMp; chr.Fury = chr.MaxFury; StatusPacket.UpdateHpMp(gc, chr.Hp, chr.Mp, chr.Fury, chr.MaxFury); break; case "//warp": if (cmd.Length != 2) { break; } foreach (Character find in MapFactory.AllCharacters) { if (find.Name.Equals(cmd[1])) { victim = find; } } if (victim != null) { chr.MapX = victim.MapX; chr.MapY = victim.MapY; chr.PlayerX = victim.PlayerX; chr.PlayerY = victim.PlayerY; MapPacket.warpToMapAuth(gc, true, chr.MapX, chr.MapY, chr.PlayerX, chr.PlayerY); } break; case "//ban": if (cmd.Length != 2) { break; } foreach (Character find in MapFactory.AllCharacters) { if (find.Name.Equals(cmd[1])) { victim = find; } } if (victim != null) { dynamic datum = new Datum("accounts"); victim.Client.Account.Banned = 1; victim.Client.Dispose(); } break; case "//save": for (int i = 0; i < MapFactory.AllCharacters.Count; i++) { if (chr.CharacterID == MapFactory.AllCharacters[i].CharacterID) { continue; } MapFactory.AllCharacters[i].Client.Dispose(); } //GameServer.IsAlive = false; break; case "//選擇正派": Quest Quest = new Quest(60); Quest.QuestState = 0x31; chr.Quests.Add(Quest); QuestPacket.getQuestInfo(gc, chr.Quests.getQuests()); chr.Items.Add(new Item(8990019, 4, chr.Items.GetNextFreeSlot(InventoryType.ItemType.Other4))); break; case "//選擇邪派": Quest = new Quest(64); Quest.QuestState = 0x31; chr.Quests.Add(Quest); QuestPacket.getQuestInfo(gc, chr.Quests.getQuests()); chr.Items.Add(new Item(8990020, 4, chr.Items.GetNextFreeSlot(InventoryType.ItemType.Other4))); break; //case "//test": // PartyPacket.PartyInvite(gc); // break; //case "//test2": // PartyPacket.PartyInvite(gc, 1, 1); // break; //case "//test3": // PartyPacket.PartyInvite(gc, 1 , 0); // break; default: break; } }
public static void Game_Log_Req(InPacket lea, Client gc) { //int re = SearchBytes(lea.Content, new byte[] { 0x0 }); string[] data = lea.ReadString(0x100 /*re*/).Split(new[] { (char)0x20 }, StringSplitOptions.None); int encryptKey = int.Parse(data[1]); string username = data[2]; string password = data[4]; int selectCharacter = lea.ReadByte(); IPAddress hostid = lea.ReadIPAddress(); gc.SetAccount(new Account(gc)); try { gc.Account.Load(username); //var pe = new PasswordEncrypt(encryptKey); //string encryptPassword = pe.encrypt(gc.Account.Password, gc.RetryLoginCount > 0 ? password.ToCharArray() : null); if (password.Equals(gc.Account.Password)) { gc.Dispose(); Log.Error("Login Fail!"); } else { gc.Account.Characters = new List <Character>(); foreach (dynamic datum in new Datums("Characters").PopulateWith("id", "accountId = '{0}' ORDER BY position ASC", gc.Account.ID)) { Character character = new Character(datum.id, gc); character.Load(false); character.IP = hostid; gc.Account.Characters.Add(character); } gc.SetCharacter(gc.Account.Characters[selectCharacter]); } Log.Inform("Password = {0}", password); //Log.Inform("encryptKey = {0}", encryptKey); //Log.Inform("encryptPassword = {0}", encryptPassword); } catch (NoAccountException) { gc.Dispose(); Log.Error("Login Fail!"); } Character chr = gc.Character; chr.CharacterID = gc.CharacterID; MapFactory.AllCharacters.Add(chr); StatusPacket.UpdateHpMp(gc, 0, 0, 0, 0); GamePacket.FW_DISCOUNTFACTION(gc); StatusPacket.getStatusInfo(gc); InventoryPacket.getCharacterEquip(gc); SkillPacket.getSkillInfo(gc, chr.Skills.getSkills()); QuestPacket.getQuestInfo(gc, chr.Quests.getQuests()); GamePacket.getQuickSlot(gc, chr.Keymap); StoragePacket.getStoreInfo(gc); StoragePacket.getStoreMoney(gc); MapPacket.enterMapStart(gc); InventoryPacket.getInvenCash(gc); CashShopPacket.MgameCash(gc); CashShopPacket.GuiHonCash(gc); InventoryPacket.getInvenEquip(gc); InventoryPacket.getInvenEquip1(gc); InventoryPacket.getInvenEquip2(gc); InventoryPacket.getInvenSpend3(gc); InventoryPacket.getInvenOther4(gc); InventoryPacket.getInvenPet5(gc); }
public static void Char_Fury_Req(InPacket lea, Client c) { int Type = lea.ReadInt(); var chr = c.Character; if (Type == 0 || chr.IsFuring == true || chr.Fury != chr.MaxFury) { return; } Map Map = MapFactory.GetMap(chr.MapX, chr.MapY); if (Type == 1) { short UpgradeAttack = (short)(chr.Attack * 0.2); short UpgradeMagic = (short)(chr.Magic * 0.2); short UpgradeDefense = (short)(chr.Defense * 0.2); chr.IsFuring = true; chr.FuryAttack = UpgradeAttack; chr.FuryMagic = UpgradeMagic; chr.FuryDefense = UpgradeDefense; chr.MaxAttack += UpgradeAttack; chr.Attack += UpgradeAttack; chr.MaxMagic += UpgradeMagic; chr.Magic += UpgradeMagic; chr.Defense += UpgradeDefense; StatusPacket.getStatusInfo(c); foreach (Character All in Map.Characters) { StatusPacket.Fury(All.Client, chr, Type); } chr.Fury = 0; chr.FuringType = 1; Delay tmr = null; tmr = new Delay(30000, false, () => { chr.IsFuring = false; chr.MaxAttack -= UpgradeAttack; chr.Attack -= UpgradeAttack; chr.MaxMagic -= UpgradeMagic; chr.Magic -= UpgradeMagic; chr.Defense -= UpgradeDefense; StatusPacket.getStatusInfo(c); foreach (Character All in Map.Characters) { StatusPacket.Fury(All.Client, chr, 0); } }); tmr.Execute(); } else if (Type == 2) { Skill Skill = chr.Skills[2, 0]; if (Skill == null) { return; } int Time = 1; switch (Skill.SkillLevel) { case 1: Time = 30000; break; case 2: Time = 32000; break; case 3: Time = 34000; break; case 4: Time = 36000; break; case 5: Time = 38000; break; case 6: Time = 40000; break; case 7: Time = 42000; break; case 8: Time = 44000; break; case 9: Time = 46000; break; case 10: Time = 48000; break; case 11: Time = 50000; break; case 12: Time = 52000; break; case 13: Time = 53000; break; case 14: Time = 54000; break; case 15: Time = 55000; break; case 16: Time = 56000; break; case 17: Time = 57000; break; case 18: Time = 58000; break; case 19: Time = 59000; break; case 20: Time = 60000; break; } short UpgradeAttack = (short)(chr.Attack * 0.2 * Skill.SkillLevel); short UpgradeMagic = (short)(chr.Magic * 0.2 * Skill.SkillLevel); short UpgradeDefense = (short)(chr.Defense * 0.2 * Skill.SkillLevel); chr.IsFuring = true; chr.FuryAttack = UpgradeAttack; chr.FuryMagic = UpgradeMagic; chr.FuryDefense = UpgradeDefense; chr.MaxAttack += UpgradeAttack; chr.Attack += UpgradeAttack; chr.MaxMagic += UpgradeMagic; chr.Magic += UpgradeMagic; chr.Defense += UpgradeDefense; StatusPacket.getStatusInfo(c); foreach (Character All in Map.Characters) { StatusPacket.Fury(All.Client, chr, Type); } chr.Fury = 0; chr.FuringType = 2; Delay tmr = null; tmr = new Delay(Time, false, () => { chr.IsFuring = false; chr.MaxAttack -= UpgradeAttack; chr.Attack -= UpgradeAttack; chr.MaxMagic -= UpgradeMagic; chr.Magic -= UpgradeMagic; chr.Defense -= UpgradeDefense; StatusPacket.getStatusInfo(c); foreach (Character All in Map.Characters) { StatusPacket.Fury(All.Client, chr, 0); } }); tmr.Execute(); } }