public static int GetStatValue(ZoneCharacter pCharacter, StatsByte pByte) { switch (pByte) { case StatsByte.MinMelee: return pCharacter.MinDamage; case StatsByte.MaxMelee: return pCharacter.MaxDamage; case StatsByte.MinMagic: return pCharacter.MinMagic; case StatsByte.MaxMagic: return pCharacter.MaxMagic; case StatsByte.WDef: return pCharacter.WeaponDef; case StatsByte.MDef: return pCharacter.MagicDef; case StatsByte.Aim: return 5; //TODO load additional equip stats case StatsByte.Evasion: return 5; case StatsByte.StrBonus: return pCharacter.StrBonus; case StatsByte.EndBonus: return pCharacter.EndBonus; default: return 0; } }
public CommandStatus ExecuteCommand(ZoneCharacter character, string[] command) { if (character == null) return CommandStatus.Error; CommandInfo info; if (commands.TryGetValue(command[0].ToLower(), out info)) { if (info.GmLevel > character.Client.Admin) { return CommandStatus.GMLevelTooLow; } else { try { info.Function(character, command); return CommandStatus.Done; } catch (Exception ex) { string wholeCommand = string.Join(" ", command); Log.WriteLine(LogLevel.Exception, "Exception while handling command '{0}': {1}", wholeCommand, ex.ToString()); return CommandStatus.Error; } } } else return CommandStatus.NotFound; }
public Inventory(ZoneCharacter pChar) { InventoryCount = 2; InventoryOwner = pChar; InventoryItems = new Dictionary<byte, Item>(); EquippedItems = new List<Item>(); }
public TradeItem(ZoneCharacter owner,byte InventorySlot,byte Tradeslot,Item pItem) { this.Owner = owner; this.Item = pItem; this.InventorySlot = InventorySlot; this.TradeSlot = Tradeslot; }
public House(ZoneCharacter pOwner, HouseType pType, ushort pItemID = (ushort) 0, string pName = "") { this.Owner = pOwner; this.Type = pType; this.ItemID = pItemID; this.Name = pName; }
public static Packet Animation(ZoneCharacter character, byte id) { Packet packet = new Packet(SH8Type.Emote); packet.WriteUShort(character.MapObjectID); packet.WriteByte(id); return packet; }
public static void SendDetailedCharacterInfo(ZoneCharacter character) { using (var packet = new Packet(SH6Type.DetailedCharacterInfo)) { character.WriteDetailedInfoExtra(packet); character.Client.SendPacket(packet); } }
public static void SendChatBlock(ZoneCharacter character, int seconds) { using (var packet = new Packet(SH2Type.Chatblock)) { packet.WriteInt(seconds); character.Client.SendPacket(packet); } }
public static Packet BeginDisplayRest(ZoneCharacter character) { Packet packet = new Packet(SH8Type.BeginDisplayRest); packet.WriteUShort(character.MapObjectID); packet.WriteUShort(character.House.ItemID); packet.Fill(10, 0xff); return packet; }
public Trade(ZoneCharacter pFrom,ZoneCharacter pTo) { this.pCharFrom = pFrom; this.pCharTo = pTo; this.pCharFrom.Trade = this; this.pCharTo.Trade = this; SendTradeBeginn(); }
public static void SendCharacterChunkEnd(ZoneCharacter character) { using (var packet = new Packet(SH4Type.CharacterInfoEnd)) { packet.WriteUShort(0xFFFF); character.Client.SendPacket(packet); } }
public static bool GetLoggedInCharacter(int ID, out ZoneCharacter pChar) { pChar = ClientManager.Instance.GetClientByCharID(ID).Character; if (pChar != null) { return true; } return false; }
public static void SendSkillLearnt(ZoneCharacter character, ushort skillid) { using (var packet = new Packet(SH18Type.LearnSkill)) { packet.WriteUShort(skillid); packet.WriteByte(0); //unk character.Client.SendPacket(packet); } }
public static MobBreedLocation CreateLocationFromPlayer(ZoneCharacter pCharacter, ushort mobID) { MobBreedLocation mbl = new MobBreedLocation(); mbl.MobID = mobID; mbl.MapID = pCharacter.MapID; mbl.InstanceID = pCharacter.Map.InstanceID; mbl.Position = new Vector2(pCharacter.Position); return mbl; }
public static void SendChangeMap(ZoneCharacter character, ushort mapid, int x, int y) { using (var packet = new Packet(SH6Type.ChangeMap)) { packet.WriteUShort(mapid); packet.WriteInt(x); packet.WriteInt(y); character.Client.SendPacket(packet); } }
public static Packet Equip(ZoneCharacter character, Item equip) { //B2 00 - AB 38 - 07 - 0D 00 04 Packet packet = new Packet(SH7Type.ShowEquip); packet.WriteUShort(character.MapObjectID); packet.WriteUShort(equip.ID); packet.WriteByte(equip.UpgradeStats.Upgrades); packet.Fill(3, 0xff); return packet; }
public TradeReqest(ZoneCharacter pFrom, ushort ToMapObjectID) { if (pFrom.SelectedObject.MapObjectID == ToMapObjectID) { this.CrationTimeStamp = DateTime.Now; this.pToTradeClient = pFrom.SelectedObject as ZoneCharacter; this.pFromTradeClient = pFrom; this.MapID = pFrom.MapID; } }
public Skill(ZoneCharacter c, ushort id) { DatabaseSkill db = new DatabaseSkill(); db.Owner = c.ID; db.SkillID = (short)id; db.Upgrades = 0; db.IsPassive = false; db.Character = c.Character; Program.CharDBManager.GetClient().ExecuteQuery("INSERT INTO Skillist (ID,Owner,SkillID,Upgrades,IsPassive) VALUES ('" + c.Character.ID + "','" + db.SkillID + "','" + db.Upgrades + "','" + Convert.ToInt32(IsPassive) + "')"); skill = db; }
public static Packet SpawnMultiPlayer(List<ZoneCharacter> characters, ZoneCharacter exclude = null) { Packet packet = new Packet(SH7Type.SpawnMultiPlayer); packet.WriteByte(exclude == null ? (byte)characters.Count : (byte)(characters.Count - 1)); foreach (var character in characters) { if (character == exclude) continue; character.WriteCharacterDisplay(packet); } return packet; }
public static void SendChangeZone(ZoneCharacter character, ushort mapid, int x, int y, string ip, ushort port, ushort randomid) { using (var packet = new Packet(SH6Type.ChangeZone)) { packet.WriteUShort(mapid); packet.WriteInt(x); packet.WriteInt(y); packet.WriteString(Settings.Instance.IP, 16); packet.WriteUShort(port); packet.WriteUShort(randomid); character.Client.SendPacket(packet); } }
public static void SendActiveSkillList(ZoneCharacter character) { using (var packet = new Packet(SH4Type.CharacterActiveSkillList)) { var list = character.SkillsActive.Values; packet.WriteByte(0); packet.WriteInt(character.ID); packet.WriteUShort((ushort)list.Count); // Skill count (max 300) foreach (var skill in list) { skill.Write(packet); } character.Client.SendPacket(packet); } }
public static void SendQuestion(ZoneCharacter character, Question question, ushort range) { using (var packet = new Packet(SH15Type.Question)) { packet.WriteString(question.Text, 129); packet.WriteUShort(character.MapObjectID); // Obj id packet.WriteInt(character.Position.X); packet.WriteInt(character.Position.Y); packet.WriteUShort(range); // Distance how far your allowed to run when the question window is closed by Client packet.WriteByte((byte)question.Answers.Count); for (byte i = 0; i < question.Answers.Count; ++i) { packet.WriteByte(i); packet.WriteString(question.Answers[i], 32); } character.Client.SendPacket(packet); } }
private TradeReqest GetTradeRquestByChar(ZoneCharacter pChar) { TradeReqest Request = TradeReqests.Find(r => r.MapID == pChar.MapID && r.pToTradeClient.MapObjectID == pChar.MapObjectID); return Request; }
public void SendCharacterLeftMap(ZoneCharacter character, bool toplayer = true) { using (var removeObjPacket = Handler7.RemoveObject(character)) // Make new packet to remove object from map for others { foreach (var victimObject in character.MapSector.Objects.Values) { if (victimObject == character) continue; // ... if (victimObject is Npc) continue; // NPC's are for noobs. Can't despawn if (victimObject is ZoneCharacter) { // Remove obj for player ZoneCharacter victim = victimObject as ZoneCharacter; victim.Client.SendPacket(removeObjPacket); } if (character != null && toplayer) { // Despawn victimObject for obj using (var removeVictimPacket = Handler7.RemoveObject(victimObject)) { character.Client.SendPacket(removeVictimPacket); } } } } }
private void OnDropResponse(ZoneCharacter character, byte answer) { Item item = (Item)character.Question.Object; switch (answer) { case 0: DropItem(item); break; case 1: break; default: Log.WriteLine(LogLevel.Warn, "Invalid dropitem response."); break; } }
public void SendCharacterEnteredMap(ZoneCharacter character) { //we send all players in region to character List<ZoneCharacter> characters = GetCharactersInRegion(character.MapSector); using (var packet = Handler7.SpawnMultiPlayer(characters, character)) { character.Client.SendPacket(packet); if (character.Mount != null) { character.Mounting(character.Mount.Handle,true); } } //we send character to all players in region using (var packet = Handler7.SpawnSinglePlayer(character)) { foreach (ZoneCharacter charinmap in characters) { if (charinmap == character) continue; charinmap.Client.SendPacket(packet); } } //we send moblist and NPC to local character IEnumerable<MapObject> npcs = Objects.Values.Where(o => o is Npc); IEnumerable<MapObject> monsters = GetObjectsBySectors(character.MapSector.SurroundingSectors).Where(o => o is Mob); List<MapObject> obj = new List<MapObject>(npcs); obj.AddRange(monsters); if (obj.Count > 0) { for (int i = 0; i < obj.Count; i += 255) { using (var packet = Handler7.MultiObjectList(obj, i, i + Math.Min(255, obj.Count - i))) { character.Client.SendPacket(packet); } } } //we send all drops to the character using (var spawndrops = Handler7.ShowDrops(GetDropsBySectors(character.MapSector.SurroundingSectors))) { character.Client.SendPacket(spawndrops); } }
public void AcceptTrade(ZoneCharacter pChar) { if (this.pCharTo == pChar) { this.pToAgree = true; SendTradeAgreeMe(this.pCharTo.Client); SendTradeAgreepTo(this.pCharFrom.Client); } else if(this.pCharFrom == pChar) { this.pFromAgree = true; SendTradeAgreeMe(this.pCharFrom.Client); SendTradeAgreepTo(pCharTo.Client); } if(this.pFromAgree && this.pToAgree && this.pFromLocket && this.pToLocket) { TradeComplett(); } }
public void RemoveItemToHandel(ZoneCharacter pChar,byte pSlot) { if (this.pCharFrom == pChar) { TradeItem item = pFromHandelItemList.Find(d => d.TradeSlot == pSlot); this.pFromHandelItemList.Remove(item); SendItemRemovFromHandel(this.pCharTo.Client, pSlot); SendItemRemoveMe(this.pCharFrom.Client, pSlot); pFromItemCounter--; } else if (this.pCharTo == pCharTo) { TradeItem item = pToHandelItemList.Find(d => d.TradeSlot == pSlot); this.pToHandelItemList.Remove(item); SendItemRemovFromHandel(this.pCharFrom.Client, pSlot); SendItemRemoveMe(this.pCharTo.Client, pSlot); pToItemCounter--; } }
public void TradeLock(ZoneCharacter pChar) { if (this.pCharFrom == pChar) { this.pFromLocket = true; if (this.pFromLocket && this.pToLocket) { SendTradeLock(this.pCharFrom.Client); SendTradeRdy(); } else { SendTradeLock(this.pCharTo.Client); } } else if (this.pCharTo == pCharTo) { this.pToLocket = true; if (this.pFromLocket && this.pToLocket) { SendTradeLock(this.pCharFrom.Client); SendTradeRdy(); } else { SendTradeLock(this.pCharTo.Client); } } }
public void TradeBreak(ZoneCharacter pChar) { if (this.pCharFrom == pChar) { this.SendTradeBreak(this.pCharTo.Client); this.pCharTo.Trade = null; } else if (this.pCharTo == pCharTo) { this.SendTradeBreak(this.pCharFrom.Client); this.pCharFrom = null; } }