public static void RemoveHouseItems(House house) { house.RemoveConsignmentMerchant(); IList <DBHouseIndoorItem> iobjs = DOLDB <DBHouseIndoorItem> .SelectObjects(DB.Column(nameof(DBHouseIndoorItem.HouseNumber)).IsEqualTo(house.HouseNumber)); GameServer.Database.DeleteObject(iobjs); house.IndoorItems.Clear(); IList <DBHouseOutdoorItem> oobjs = DOLDB <DBHouseOutdoorItem> .SelectObjects(DB.Column(nameof(DBHouseOutdoorItem.HouseNumber)).IsEqualTo(house.HouseNumber)); GameServer.Database.DeleteObject(oobjs); house.OutdoorItems.Clear(); IList <DBHouseHookpointItem> hpobjs = DOLDB <DBHouseHookpointItem> .SelectObjects(DB.Column(nameof(DBHouseHookpointItem.HouseNumber)).IsEqualTo(house.HouseNumber)); GameServer.Database.DeleteObject(hpobjs); foreach (DBHouseHookpointItem item in house.HousepointItems.Values) { if (item.GameObject is GameObject) { (item.GameObject as GameObject).Delete(); } } house.HousepointItems.Clear(); }
public static void RemoveHousePermissions(House house) { // clear the house number for the guild if this is a guild house if (house.DatabaseItem.GuildHouse) { Guild guild = GuildMgr.GetGuildByName(house.DatabaseItem.GuildName); if (guild != null) { guild.GuildHouseNumber = 0; } } house.DatabaseItem.GuildHouse = false; house.DatabaseItem.GuildName = null; IList <DBHousePermissions> pobjs = DOLDB <DBHousePermissions> .SelectObjects(DB.Column(nameof(DBHousePermissions.HouseNumber)).IsEqualTo(house.HouseNumber)); GameServer.Database.DeleteObject(pobjs); house.PermissionLevels.Clear(); IList <DBHouseCharsXPerms> cpobjs = DOLDB <DBHouseCharsXPerms> .SelectObjects(DB.Column(nameof(DBHouseCharsXPerms.HouseNumber)).IsEqualTo(house.HouseNumber)); GameServer.Database.DeleteObject(cpobjs); house.CharXPermissions.Clear(); }
/// <summary> /// Method to save the Patrol Path using the Patrol ID and the Component /// </summary> /// <param name="pathID"></param> /// <param name="path"></param> /// <param name="component"></param> public static void SavePatrolPath(string pathID, PathPoint path, GameKeepComponent component) { if (path == null) { return; } pathID.Replace('\'', '/'); // we must replace the ', found no other way yet GameServer.Database.DeleteObject(DOLDB <DBPath> .SelectObjects(DB.Column(nameof(DBPath.PathID)).IsEqualTo(pathID))); PathPoint root = MovementMgr.FindFirstPathPoint(path); //Set the current pathpoint to the rootpoint! path = root; DBPath dbp = new DBPath(pathID, ePathType.Loop); GameServer.Database.AddObject(dbp); int i = 1; do { DBPathPoint dbpp = new DBPathPoint(path.X, path.Y, path.Z, path.MaxSpeed); int x, y; SaveXY(component, dbpp.X, dbpp.Y, out x, out y); dbpp.X = x; dbpp.Y = y; dbpp.Z = dbpp.Z - component.Z; dbpp.Step = i++; dbpp.PathID = pathID; dbpp.WaitTime = path.WaitTime; GameServer.Database.AddObject(dbpp); path = path.Next; } while (path != null && path != root); }
/// <summary> /// we need to make use of the new poison fields /// </summary> public void ConvertDatabase() { log.Info("Database Version 4 Convert Started"); if (GameServer.Instance.Configuration.DBType == DOL.Database.Connection.ConnectionType.DATABASE_XML) { log.Info("You have an XML database loaded, this converter will only work with MySQL, skipping"); return; } var mobs = DOLDB <Mob> .SelectObjects(DB.Column(nameof(Mob.ClassType)).IsEqualTo("DOL.GS.GameMob")); int count = 0; foreach (Mob mob in mobs) { mob.ClassType = "DOL.GS.GameNPC"; GameServer.Database.SaveObject(mob); count++; } log.Info("Converted " + count + " mobs"); log.Info("Database Version 4 Convert Finished"); }
/// <summary> /// Gets the most usuable position for a banner directly from the database /// </summary> /// <param name="b">The banner object</param> /// <returns>The position object</returns> public static DBKeepPosition GetUsablePosition(GameKeepBanner b) { var filterClassType = DB.Column(nameof(DBKeepPosition.ClassType)).IsNotEqualTo("DOL.GS.Keeps.Banner"); var filterTemplateID = DB.Column(nameof(DBKeepPosition.TemplateID)).IsEqualTo(b.TemplateID); var filterComponentSkin = DB.Column(nameof(DBKeepPosition.ComponentSkin)).IsEqualTo(b.Component.Skin); var filterHeight = DB.Column(nameof(DBKeepPosition.Height)).IsLessOrEqualTo(b.Component.Height); return(DOLDB <DBKeepPosition> .SelectObjects(filterClassType.And(filterTemplateID).And(filterComponentSkin).And(filterHeight)) .OrderByDescending(it => it.Height).FirstOrDefault()); }
/// <summary> /// Method to retrieve the Patrol Path from the Patrol ID and Component /// /// We need this because we store this all using our offset system /// </summary> /// <param name="pathID">The path ID, which is the Patrol ID</param> /// <param name="component">The Component object</param> /// <returns>The Patrol path</returns> public static PathPoint LoadPatrolPath(string pathID, GameKeepComponent component) { SortedList sorted = new SortedList(); pathID.Replace('\'', '/'); // we must replace the ', found no other way yet var dbpath = DOLDB <DBPath> .SelectObject(DB.Column(nameof(DBPath.PathID)).IsEqualTo(pathID)); IList <DBPathPoint> pathpoints = null; ePathType pathType = ePathType.Once; if (dbpath != null) { pathType = (ePathType)dbpath.PathType; } if (pathpoints == null) { pathpoints = DOLDB <DBPathPoint> .SelectObjects(DB.Column(nameof(DBPathPoint.PathID)).IsEqualTo(pathID)); } foreach (DBPathPoint point in pathpoints) { sorted.Add(point.Step, point); } PathPoint prev = null; PathPoint first = null; for (int i = 0; i < sorted.Count; i++) { DBPathPoint pp = (DBPathPoint)sorted.GetByIndex(i); PathPoint p = new PathPoint(pp.X, pp.Y, pp.Z, pp.MaxSpeed, pathType); int x, y; LoadXY(component, pp.X, pp.Y, out x, out y); p.X = x; p.Y = y; p.Z = component.Keep.Z + p.Z; p.WaitTime = pp.WaitTime; if (first == null) { first = p; } p.Prev = prev; if (prev != null) { prev.Next = p; } prev = p; } return(first); }
public static void OnScriptsCompiled(DOLEvent e, object sender, EventArgs args) { // What npctemplate should we use for the zonepoint ? ushort model; NpcTemplate zp; try{ model = (ushort)ServerProperties.Properties.ZONEPOINT_NPCTEMPLATE; zp = new NpcTemplate(DOLDB <DBNpcTemplate> .SelectObjects(DB.Column(nameof(DBNpcTemplate.TemplateId)).IsEqualTo(model)).FirstOrDefault()); if (model <= 0 || zp == null) { throw new ArgumentNullException(); } } catch { return; } // processing all the ZP IList <ZonePoint> zonePoints = GameServer.Database.SelectAllObjects <ZonePoint>(); foreach (ZonePoint z in zonePoints) { if (z.SourceRegion == 0) { continue; } // find target region for the current zonepoint Region r = WorldMgr.GetRegion(z.TargetRegion); if (r == null) { log.Warn("Zonepoint Id (" + z.Id + ") references an inexistent target region " + z.TargetRegion + " - skipping, ZP not created"); continue; } GameNPC npc = new GameNPC(zp); npc.CurrentRegionID = z.SourceRegion; npc.X = z.SourceX; npc.Y = z.SourceY; npc.Z = z.SourceZ; npc.Name = r.Description; npc.GuildName = "ZonePoint (Open)"; if (r.IsDisabled) { npc.GuildName = "ZonePoint (Closed)"; } npc.AddToWorld(); } }
/// <summary> /// Generate an Item random Named for NPC Drop /// </summary> /// <param name="player">Level of Generated Item</param> /// <returns>A Generated NPC Item</returns> public static ItemTemplate GenerateNPCItem(GamePlayer player) { int mediumCraftingLevel = player.GetCraftingSkillValue(player.CraftingPrimarySkill) + 20; int lowLevel = mediumCraftingLevel - 20; int highLevel = mediumCraftingLevel + 20; var craftitem = DOLDB <DBCraftedItem> .SelectObjects(DB.Column(nameof(DBCraftedItem.CraftingSkillType)).IsEqualTo((int)player.CraftingPrimarySkill) .And(DB.Column(nameof(DBCraftedItem.CraftingLevel)).IsGreatherThan(lowLevel).And(DB.Column(nameof(DBCraftedItem.CraftingLevel)).IsLessThan(highLevel)))); int craftrnd = Util.Random(craftitem.Count); ItemTemplate template = GameServer.Database.FindObjectByKey <ItemTemplate>(craftitem[craftrnd].Id_nb); return(template); }
/// <summary> /// Saves the path into the database /// </summary> /// <param name="pathID">The path ID</param> /// <param name="path">The path waypoint</param> public static void SavePath(string pathID, PathPoint path) { if (path == null) { return; } pathID.Replace('\'', '/'); // First delete any path with this pathID from the database var dbpath = DOLDB <DBPath> .SelectObject(DB.Column("PathID").IsEqualTo(pathID)); if (dbpath != null) { GameServer.Database.DeleteObject(dbpath); } GameServer.Database.DeleteObject(DOLDB <DBPathPoint> .SelectObjects(DB.Column("PathID").IsEqualTo(pathID))); // Now add this path and iterate through the PathPoint linked list to add all the path points PathPoint root = FindFirstPathPoint(path); //Set the current pathpoint to the rootpoint! path = root; dbpath = new DBPath(pathID, root.Type); GameServer.Database.AddObject(dbpath); int i = 1; do { DBPathPoint dbpp = new DBPathPoint(path.X, path.Y, path.Z, path.MaxSpeed); dbpp.Step = i++; dbpp.PathID = pathID; dbpp.WaitTime = path.WaitTime; GameServer.Database.AddObject(dbpp); path = path.Next; } while (path != null && path != root); UpdatePathInCache(pathID); }
/// <summary> /// style icon field added this should copy the ID value /// realm 6 should be peace flag and realm changed /// </summary> public void ConvertDatabase() { log.Info("Database Version 2 Convert Started"); log.Info("Converting Styles"); var styles = GameServer.Database.SelectAllObjects <DBStyle>(); foreach (DBStyle style in styles) { style.Icon = style.ID; GameServer.Database.SaveObject(style); } log.Info(styles.Count + " Styles Processed"); log.Info("Converting Mobs"); var mobs = DOLDB <Mob> .SelectObjects(DB.Column("Realm").IsEqualTo(6)); foreach (Mob mob in mobs) { if ((mob.Flags & (uint)GameNPC.eFlags.PEACE) == 0) { mob.Flags ^= (uint)GameNPC.eFlags.PEACE; } Region region = WorldMgr.GetRegion(mob.Region); if (region != null) { Zone zone = region.GetZone(mob.X, mob.Y); if (zone != null) { mob.Realm = (byte)zone.Realm; } } GameServer.Database.SaveObject(mob); } log.Info(mobs.Count + " Mobs Processed"); log.Info("Database Version 2 Convert Finished"); }
public virtual void LoadPositions() { ushort region = CurrentRegionID; if (CurrentRegion is BaseInstance) { region = (CurrentRegion as BaseInstance).Skin; } Battleground bg = GameServer.KeepManager.GetBattleground(region); this.Positions.Clear(); var whereClause = DB.Column(nameof(DBKeepPosition.ComponentSkin)).IsEqualTo(Skin); if (Skin != (int)eComponentSkin.Keep && Skin != (int)eComponentSkin.Tower && Skin != (int)eComponentSkin.Gate) { whereClause = whereClause.And(DB.Column(nameof(DBKeepPosition.ComponentRotation)).IsEqualTo(ComponentHeading)); } if (bg != null && GameServer.Instance.Configuration.ServerType != eGameServerType.GST_PvE) { // Battlegrounds, ignore all but GameKeepDoor whereClause = whereClause.And(DB.Column(nameof(DBKeepPosition.ClassType)).IsEqualTo("DOL.GS.Keeps.GameKeepDoor")); } var DBPositions = DOLDB <DBKeepPosition> .SelectObjects(whereClause); foreach (DBKeepPosition position in DBPositions) { DBKeepPosition[] list = this.Positions[position.TemplateID] as DBKeepPosition[]; if (list == null) { list = new DBKeepPosition[4]; this.Positions[position.TemplateID] = list; } list[position.Height] = position; } }
public static void UpdatePathInCache(string pathID) { log.DebugFormat("Updating path {0} in path cache.", pathID); var dbpath = DOLDB <DBPath> .SelectObject(DB.Column("PathID").IsEqualTo(pathID)); if (dbpath != null) { if (m_pathCache.ContainsKey(pathID)) { m_pathCache[pathID] = dbpath; } else { m_pathCache.Add(dbpath.PathID, dbpath); } } var pathPoints = DOLDB <DBPathPoint> .SelectObjects(DB.Column("PathID").IsEqualTo(pathID)); SortedList <int, DBPathPoint> pList = new SortedList <int, DBPathPoint>(); if (m_pathpointCache.ContainsKey(pathID)) { m_pathpointCache[pathID] = pList; } else { m_pathpointCache.Add(pathID, pList); } foreach (DBPathPoint pathPoint in pathPoints) { m_pathpointCache[pathPoint.PathID].Add(pathPoint.Step, pathPoint); } }
public override void SendCharacterOverview(eRealm realm) { if (realm < eRealm._FirstPlayerRealm || realm > eRealm._LastPlayerRealm) { throw new Exception($"CharacterOverview requested for unknown realm {realm}"); } int firstSlot = (byte)realm * 100; var enableRealmSwitcherBit = GameServer.ServerRules.IsAllowedCharsInAllRealms(m_gameClient) ? 1 : 0; using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.CharacterOverview1126))) { pak.WriteIntLowEndian((uint)enableRealmSwitcherBit); // 0x01 & 0x02 are flags pak.WriteIntLowEndian(0); pak.WriteIntLowEndian(0); pak.WriteIntLowEndian(0); if (m_gameClient.Account.Characters == null || m_gameClient.Account.Characters.Length == 0) { SendTCP(pak); return; } Dictionary <int, DOLCharacters> charsBySlot = new Dictionary <int, DOLCharacters>(); foreach (DOLCharacters c in m_gameClient.Account.Characters) { try { charsBySlot.Add(c.AccountSlot, c); } catch (Exception ex) { log.Error($"SendCharacterOverview - Duplicate char in slot? Slot: {c.AccountSlot}, Account: {c.AccountName}", ex); } } var itemsByOwnerID = new Dictionary <string, Dictionary <eInventorySlot, InventoryItem> >(); if (charsBySlot.Any()) { var filterBySlotPosition = DB.Column(nameof(InventoryItem.SlotPosition)).IsGreaterOrEqualTo((int)eInventorySlot.MinEquipable) .And(DB.Column(nameof(InventoryItem.SlotPosition)).IsLessOrEqualTo((int)eInventorySlot.MaxEquipable)); var allItems = DOLDB <InventoryItem> .SelectObjects(DB.Column(nameof(InventoryItem.OwnerID)).IsIn(charsBySlot.Values.Select(c => c.ObjectId)).And(filterBySlotPosition)); foreach (InventoryItem item in allItems) { try { if (!itemsByOwnerID.ContainsKey(item.OwnerID)) { itemsByOwnerID.Add(item.OwnerID, new Dictionary <eInventorySlot, InventoryItem>()); } itemsByOwnerID[item.OwnerID].Add((eInventorySlot)item.SlotPosition, item); } catch (Exception ex) { log.Error($"SendCharacterOverview - Duplicate item on character? OwnerID: {item.OwnerID}, SlotPosition: {item.SlotPosition}, Account: {m_gameClient.Account.Name}", ex); } } } // send each characters for (int i = firstSlot; i < (firstSlot + 10); i++) { DOLCharacters c = null; if (!charsBySlot.TryGetValue(i, out c)) { pak.WriteByte(0); continue; } Dictionary <eInventorySlot, InventoryItem> charItems = null; if (!itemsByOwnerID.TryGetValue(c.ObjectId, out charItems)) { charItems = new Dictionary <eInventorySlot, InventoryItem>(); } byte extensionTorso = 0; byte extensionGloves = 0; byte extensionBoots = 0; InventoryItem item = null; if (charItems.TryGetValue(eInventorySlot.TorsoArmor, out item)) { extensionTorso = item.Extension; } if (charItems.TryGetValue(eInventorySlot.HandsArmor, out item)) { extensionGloves = item.Extension; } if (charItems.TryGetValue(eInventorySlot.FeetArmor, out item)) { extensionBoots = item.Extension; } string locationDescription = string.Empty; Region region = WorldMgr.GetRegion((ushort)c.Region); if (region != null) { locationDescription = m_gameClient.GetTranslatedSpotDescription(region, c.Xpos, c.Ypos, c.Zpos); } string classname = ""; if (c.Class != 0) { classname = ((eCharacterClass)c.Class).ToString(); } string racename = m_gameClient.RaceToTranslatedName(c.Race, c.Gender); charItems.TryGetValue(eInventorySlot.RightHandWeapon, out InventoryItem rightHandWeapon); charItems.TryGetValue(eInventorySlot.LeftHandWeapon, out InventoryItem leftHandWeapon); charItems.TryGetValue(eInventorySlot.TwoHandWeapon, out InventoryItem twoHandWeapon); charItems.TryGetValue(eInventorySlot.DistanceWeapon, out InventoryItem distanceWeapon); charItems.TryGetValue(eInventorySlot.HeadArmor, out InventoryItem helmet); charItems.TryGetValue(eInventorySlot.HandsArmor, out InventoryItem gloves); charItems.TryGetValue(eInventorySlot.FeetArmor, out InventoryItem boots); charItems.TryGetValue(eInventorySlot.TorsoArmor, out InventoryItem torso); charItems.TryGetValue(eInventorySlot.Cloak, out InventoryItem cloak); charItems.TryGetValue(eInventorySlot.LegsArmor, out InventoryItem legs); charItems.TryGetValue(eInventorySlot.ArmsArmor, out InventoryItem arms); ushort rightHandColor = 0; if (rightHandWeapon != null) { rightHandColor = (ushort)(rightHandWeapon.Emblem != 0 ? rightHandWeapon.Emblem : rightHandWeapon.Color); } ushort helmetColor = 0; if (helmet != null) { helmetColor = (ushort)(helmet.Emblem != 0 ? helmet.Emblem : helmet.Color); } ushort glovesColor = 0; if (gloves != null) { glovesColor = (ushort)(gloves.Emblem != 0 ? gloves.Emblem : gloves.Color); } ushort bootsColor = 0; if (boots != null) { bootsColor = (ushort)(boots.Emblem != 0 ? boots.Emblem : boots.Color); } ushort leftHandWeaponColor = 0; if (leftHandWeapon != null) { leftHandWeaponColor = (ushort)(leftHandWeapon.Emblem != 0 ? leftHandWeapon.Emblem : leftHandWeapon.Color); } ushort torsoColor = 0; if (torso != null) { torsoColor = (ushort)(torso.Emblem != 0 ? torso.Emblem : torso.Color); } ushort cloakColor = 0; if (cloak != null) { cloakColor = (ushort)(cloak.Emblem != 0 ? cloak.Emblem : cloak.Color); } ushort legsColor = 0; if (legs != null) { legsColor = (ushort)(legs.Emblem != 0 ? legs.Emblem : legs.Color); } ushort armsColor = 0; if (arms != null) { armsColor = (ushort)(arms.Emblem != 0 ? arms.Emblem : arms.Color); } pak.WriteByte((byte)c.Level); pak.WritePascalStringIntLE(c.Name, 0x18); pak.WriteIntLowEndian(0x18); pak.WriteByte(1); // always 1 ? pak.WriteByte(c.EyeSize); // seems to be : 0xF0 = eyes, 0x0F = nose pak.WriteByte(c.LipSize); // seems to be : 0xF0 = lips, 0xF = jaw pak.WriteByte(c.EyeColor); // seems to be : 0xF0 = eye color, 0x0F = skin tone pak.WriteByte(c.HairColor); pak.WriteByte(c.FaceType); // seems to be : 0xF0 = face pak.WriteByte(c.HairStyle); // seems to be : 0xF0 = hair pak.WriteByte((byte)((extensionBoots << 4) | extensionGloves)); pak.WriteByte((byte)((extensionTorso << 4) | (c.IsCloakHoodUp ? 0x1 : 0x0))); pak.WriteByte(c.CustomisationStep); //1 = auto generate config, 2= config ended by player, 3= enable config to player pak.WriteByte(c.MoodType); pak.Fill(0x0, 13); pak.WritePascalStringIntLE(locationDescription, 0x18); pak.WritePascalStringIntLE(classname, 0x18); pak.WritePascalStringIntLE(racename, 0x18); pak.WriteShortLowEndian((ushort)c.CurrentModel); pak.WriteByte((byte)c.Region); if (region == null || (int)m_gameClient.ClientType > region.Expansion) { pak.WriteByte(0x00); } else { pak.WriteByte((byte)(region.Expansion + 1)); //0x04-Cata zone, 0x05 - DR zone } pak.WriteShortLowEndian((ushort)(helmet != null ? helmet.Model : 0)); pak.WriteShortLowEndian((ushort)(gloves != null ? gloves.Model : 0)); pak.WriteShortLowEndian((ushort)(boots != null ? boots.Model : 0)); pak.WriteShortLowEndian(rightHandColor); pak.WriteShortLowEndian((ushort)(torso != null ? torso.Model : 0)); pak.WriteShortLowEndian((ushort)(cloak != null ? cloak.Model : 0)); pak.WriteShortLowEndian((ushort)(legs != null ? legs.Model : 0)); pak.WriteShortLowEndian((ushort)(arms != null ? arms.Model : 0)); pak.WriteShortLowEndian(helmetColor); pak.WriteShortLowEndian(glovesColor); pak.WriteShortLowEndian(bootsColor); pak.WriteShortLowEndian(leftHandWeaponColor); pak.WriteShortLowEndian(torsoColor); pak.WriteShortLowEndian(cloakColor); pak.WriteShortLowEndian(legsColor); pak.WriteShortLowEndian(armsColor); //weapon models pak.WriteShortLowEndian((ushort)(rightHandWeapon != null ? rightHandWeapon.Model : 0)); pak.WriteShortLowEndian((ushort)(leftHandWeapon != null ? leftHandWeapon.Model : 0)); pak.WriteShortLowEndian((ushort)(twoHandWeapon != null ? twoHandWeapon.Model : 0)); pak.WriteShortLowEndian((ushort)(distanceWeapon != null ? distanceWeapon.Model : 0)); pak.WriteByte((byte)c.Strength); pak.WriteByte((byte)c.Quickness); pak.WriteByte((byte)c.Constitution); pak.WriteByte((byte)c.Dexterity); pak.WriteByte((byte)c.Intelligence); pak.WriteByte((byte)c.Piety); pak.WriteByte((byte)c.Empathy); // ? pak.WriteByte((byte)c.Charisma); // ? pak.WriteByte((byte)c.Class); pak.WriteByte((byte)c.Realm); // ok? pak.WriteByte((byte)((((c.Race & 0x10) << 2) + (c.Race & 0x0F)) | (c.Gender << 4))); if (c.ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.TwoHanded) { pak.WriteByte(0x02); pak.WriteByte(0x02); } else if (c.ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.Distance) { pak.WriteByte(0x03); pak.WriteByte(0x03); } else { pak.WriteByte((byte)(rightHandWeapon != null ? 0x00 : 0xFF)); pak.WriteByte((byte)(leftHandWeapon != null ? 0x01 : 0xFF)); } pak.WriteByte(0); // SI = 1, Classic = 0 pak.WriteByte((byte)c.Constitution); // ok pak.WriteByte(0); // unknown } SendTCP(pak); } }
public override void SendCharacterOverview(eRealm realm) { if (realm < eRealm._FirstPlayerRealm || realm > eRealm._LastPlayerRealm) { throw new Exception("CharacterOverview requested for unknown realm " + realm); } int firstSlot = (byte)realm * 100; using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.CharacterOverview))) { pak.FillString(m_gameClient.Account.Name, 24); if (m_gameClient.Account.Characters == null) { pak.Fill(0x0, 1880); } else { Dictionary <int, DOLCharacters> charsBySlot = new Dictionary <int, DOLCharacters>(); foreach (DOLCharacters c in m_gameClient.Account.Characters) { try { charsBySlot.Add(c.AccountSlot, c); } catch (Exception ex) { log.Error("SendCharacterOverview - Duplicate char in slot? Slot: " + c.AccountSlot + ", Account: " + c.AccountName, ex); } } var itemsByOwnerID = new Dictionary <string, Dictionary <eInventorySlot, InventoryItem> >(); if (charsBySlot.Any()) { var filterBySlotPosition = DB.Column(nameof(InventoryItem.SlotPosition)).IsGreaterOrEqualTo((int)eInventorySlot.MinEquipable) .And(DB.Column(nameof(InventoryItem.SlotPosition)).IsLessOrEqualTo((int)eInventorySlot.MaxEquipable)); var allItems = DOLDB <InventoryItem> .SelectObjects(DB.Column(nameof(InventoryItem.OwnerID)).IsIn(charsBySlot.Values.Select(c => c.ObjectId)).And(filterBySlotPosition)); foreach (InventoryItem item in allItems) { try { if (!itemsByOwnerID.ContainsKey(item.OwnerID)) { itemsByOwnerID.Add(item.OwnerID, new Dictionary <eInventorySlot, InventoryItem>()); } itemsByOwnerID[item.OwnerID].Add((eInventorySlot)item.SlotPosition, item); } catch (Exception ex) { log.Error("SendCharacterOverview - Duplicate item on character? OwnerID: " + item.OwnerID + ", SlotPosition: " + item.SlotPosition + ", Account: " + m_gameClient.Account.Name, ex); } } } for (int i = firstSlot; i < (firstSlot + 10); i++) { DOLCharacters c = null; if (!charsBySlot.TryGetValue(i, out c)) { pak.Fill(0x0, 188); } else { Dictionary <eInventorySlot, InventoryItem> charItems = null; if (!itemsByOwnerID.TryGetValue(c.ObjectId, out charItems)) { charItems = new Dictionary <eInventorySlot, InventoryItem>(); } byte extensionTorso = 0; byte extensionGloves = 0; byte extensionBoots = 0; InventoryItem item = null; if (charItems.TryGetValue(eInventorySlot.TorsoArmor, out item)) { extensionTorso = item.Extension; } if (charItems.TryGetValue(eInventorySlot.HandsArmor, out item)) { extensionGloves = item.Extension; } if (charItems.TryGetValue(eInventorySlot.FeetArmor, out item)) { extensionBoots = item.Extension; } pak.Fill(0x00, 4); //new heading bytes in from 1.99 relocated in 1.104 pak.FillString(c.Name, 24); pak.WriteByte(0x01); pak.WriteByte((byte)c.EyeSize); pak.WriteByte((byte)c.LipSize); pak.WriteByte((byte)c.EyeColor); pak.WriteByte((byte)c.HairColor); pak.WriteByte((byte)c.FaceType); pak.WriteByte((byte)c.HairStyle); pak.WriteByte((byte)((extensionBoots << 4) | extensionGloves)); pak.WriteByte((byte)((extensionTorso << 4) | (c.IsCloakHoodUp ? 0x1 : 0x0))); pak.WriteByte((byte)c.CustomisationStep); //1 = auto generate config, 2= config ended by player, 3= enable config to player pak.WriteByte((byte)c.MoodType); pak.Fill(0x0, 13); //0 String string locationDescription = string.Empty; Region region = WorldMgr.GetRegion((ushort)c.Region); if (region != null) { locationDescription = m_gameClient.GetTranslatedSpotDescription(region, c.Xpos, c.Ypos, c.Zpos); } pak.FillString(locationDescription, 24); string classname = ""; if (c.Class != 0) { classname = ((eCharacterClass)c.Class).ToString(); } pak.FillString(classname, 24); string racename = m_gameClient.RaceToTranslatedName(c.Race, c.Gender); pak.FillString(racename, 24); pak.WriteByte((byte)c.Level); pak.WriteByte((byte)c.Class); pak.WriteByte((byte)c.Realm); pak.WriteByte((byte)((((c.Race & 0x10) << 2) + (c.Race & 0x0F)) | (c.Gender << 4))); // race max value can be 0x1F pak.WriteShortLowEndian((ushort)c.CurrentModel); pak.WriteByte((byte)c.Region); if (region == null || (int)m_gameClient.ClientType > region.Expansion) { pak.WriteByte(0x00); } else { pak.WriteByte((byte)(region.Expansion + 1)); //0x04-Cata zone, 0x05 - DR zone } pak.WriteInt(0x0); // Internal database ID pak.WriteByte((byte)c.Strength); pak.WriteByte((byte)c.Dexterity); pak.WriteByte((byte)c.Constitution); pak.WriteByte((byte)c.Quickness); pak.WriteByte((byte)c.Intelligence); pak.WriteByte((byte)c.Piety); pak.WriteByte((byte)c.Empathy); pak.WriteByte((byte)c.Charisma); InventoryItem rightHandWeapon = null; charItems.TryGetValue(eInventorySlot.RightHandWeapon, out rightHandWeapon); InventoryItem leftHandWeapon = null; charItems.TryGetValue(eInventorySlot.LeftHandWeapon, out leftHandWeapon); InventoryItem twoHandWeapon = null; charItems.TryGetValue(eInventorySlot.TwoHandWeapon, out twoHandWeapon); InventoryItem distanceWeapon = null; charItems.TryGetValue(eInventorySlot.DistanceWeapon, out distanceWeapon); InventoryItem helmet = null; charItems.TryGetValue(eInventorySlot.HeadArmor, out helmet); InventoryItem gloves = null; charItems.TryGetValue(eInventorySlot.HandsArmor, out gloves); InventoryItem boots = null; charItems.TryGetValue(eInventorySlot.FeetArmor, out boots); InventoryItem torso = null; charItems.TryGetValue(eInventorySlot.TorsoArmor, out torso); InventoryItem cloak = null; charItems.TryGetValue(eInventorySlot.Cloak, out cloak); InventoryItem legs = null; charItems.TryGetValue(eInventorySlot.LegsArmor, out legs); InventoryItem arms = null; charItems.TryGetValue(eInventorySlot.ArmsArmor, out arms); pak.WriteShortLowEndian((ushort)(helmet != null ? helmet.Model : 0)); pak.WriteShortLowEndian((ushort)(gloves != null ? gloves.Model : 0)); pak.WriteShortLowEndian((ushort)(boots != null ? boots.Model : 0)); ushort rightHandColor = 0; if (rightHandWeapon != null) { rightHandColor = (ushort)(rightHandWeapon.Emblem != 0 ? rightHandWeapon.Emblem : rightHandWeapon.Color); } pak.WriteShortLowEndian(rightHandColor); pak.WriteShortLowEndian((ushort)(torso != null ? torso.Model : 0)); pak.WriteShortLowEndian((ushort)(cloak != null ? cloak.Model : 0)); pak.WriteShortLowEndian((ushort)(legs != null ? legs.Model : 0)); pak.WriteShortLowEndian((ushort)(arms != null ? arms.Model : 0)); ushort helmetColor = 0; if (helmet != null) { helmetColor = (ushort)(helmet.Emblem != 0 ? helmet.Emblem : helmet.Color); } pak.WriteShortLowEndian(helmetColor); ushort glovesColor = 0; if (gloves != null) { glovesColor = (ushort)(gloves.Emblem != 0 ? gloves.Emblem : gloves.Color); } pak.WriteShortLowEndian(glovesColor); ushort bootsColor = 0; if (boots != null) { bootsColor = (ushort)(boots.Emblem != 0 ? boots.Emblem : boots.Color); } pak.WriteShortLowEndian(bootsColor); ushort leftHandWeaponColor = 0; if (leftHandWeapon != null) { leftHandWeaponColor = (ushort)(leftHandWeapon.Emblem != 0 ? leftHandWeapon.Emblem : leftHandWeapon.Color); } pak.WriteShortLowEndian(leftHandWeaponColor); ushort torsoColor = 0; if (torso != null) { torsoColor = (ushort)(torso.Emblem != 0 ? torso.Emblem : torso.Color); } pak.WriteShortLowEndian(torsoColor); ushort cloakColor = 0; if (cloak != null) { cloakColor = (ushort)(cloak.Emblem != 0 ? cloak.Emblem : cloak.Color); } pak.WriteShortLowEndian(cloakColor); ushort legsColor = 0; if (legs != null) { legsColor = (ushort)(legs.Emblem != 0 ? legs.Emblem : legs.Color); } pak.WriteShortLowEndian(legsColor); ushort armsColor = 0; if (arms != null) { armsColor = (ushort)(arms.Emblem != 0 ? arms.Emblem : arms.Color); } pak.WriteShortLowEndian(armsColor); //weapon models pak.WriteShortLowEndian((ushort)(rightHandWeapon != null ? rightHandWeapon.Model : 0)); pak.WriteShortLowEndian((ushort)(leftHandWeapon != null ? leftHandWeapon.Model : 0)); pak.WriteShortLowEndian((ushort)(twoHandWeapon != null ? twoHandWeapon.Model : 0)); pak.WriteShortLowEndian((ushort)(distanceWeapon != null ? distanceWeapon.Model : 0)); if (c.ActiveWeaponSlot == (byte)DOL.GS.GameLiving.eActiveWeaponSlot.TwoHanded) { pak.WriteByte(0x02); pak.WriteByte(0x02); } else if (c.ActiveWeaponSlot == (byte)DOL.GS.GameLiving.eActiveWeaponSlot.Distance) { pak.WriteByte(0x03); pak.WriteByte(0x03); } else { byte righthand = 0xFF; byte lefthand = 0xFF; if (rightHandWeapon != null) { righthand = 0x00; } if (leftHandWeapon != null) { lefthand = 0x01; } pak.WriteByte(righthand); pak.WriteByte(lefthand); } if (region == null || region.Expansion != 1) { pak.WriteByte(0x00); } else { pak.WriteByte(0x01); //0x01=char in SI zone, classic client can't "play" } pak.WriteByte((byte)c.Constitution); } } } pak.Fill(0x0, 94); SendTCP(pak); } }
/// <summary> /// we need to make use of the new poison fields /// </summary> public void ConvertDatabase() { log.Info("Database Version 3 Convert Started"); if (GameServer.Instance.Configuration.DBType == DOL.Database.Connection.ConnectionType.DATABASE_XML) { log.Info("You have an XML database loaded, this converter will only work with MySQL, skipping"); return; } var templates = DOLDB <ItemTemplate> .SelectObjects(DB.Column(nameof(ItemTemplate.SpellID)).IsEqualTo(0)); int count = 0; foreach (ItemTemplate template in templates) { SpellLine poisonLine = SkillBase.GetSpellLine(GlobalSpellsLines.Mundane_Poisons); if (poisonLine != null) { IList spells = SkillBase.GetSpellList(poisonLine.KeyName); if (spells != null) { foreach (Spell spl in spells) { if (spl.ID == template.SpellID) { template.PoisonSpellID = template.SpellID; template.SpellID = 0; template.PoisonCharges = template.Charges; template.Charges = 0; template.PoisonMaxCharges = template.MaxCharges; template.MaxCharges = 0; GameServer.Database.SaveObject(template); count++; break; } } } } } log.Info("Converted " + count + " templates"); var items = DOLDB <InventoryItem> .SelectObjects(DB.Column(nameof(InventoryItem.SpellID)).IsEqualTo(0)); count = 0; foreach (InventoryItem item in items) { foreach (ItemTemplate template in templates) { SpellLine poisonLine = SkillBase.GetSpellLine(GlobalSpellsLines.Mundane_Poisons); if (poisonLine != null) { IList spells = SkillBase.GetSpellList(poisonLine.KeyName); if (spells != null) { foreach (Spell spl in spells) { if (spl.ID == template.SpellID) { template.PoisonSpellID = template.SpellID; template.SpellID = 0; template.PoisonCharges = template.Charges; template.Charges = 0; template.PoisonMaxCharges = template.MaxCharges; template.MaxCharges = 0; GameServer.Database.SaveObject(template); count++; break; } } } } } } log.Info("Converted " + count + " items"); log.Info("Database Version 3 Convert Finished"); }
public void OnCommand(GameClient client, string[] args) { if (args.Length == 1) { DisplaySyntax(client); return; } string param = ""; if (args.Length > 2) { param = String.Join(" ", args, 2, args.Length - 2); } GameMerchant targetMerchant = null; if (client.Player.TargetObject != null && client.Player.TargetObject is GameMerchant) { targetMerchant = (GameMerchant)client.Player.TargetObject; } if (args[1].ToLower() != "create" && targetMerchant == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.CommandOverview")); return; } switch (args[1].ToLower()) { #region Create case "create": { string theType = "DOL.GS.GameMerchant"; if (args.Length > 2) { theType = args[2]; } //Create a new merchant GameMerchant merchant = null; foreach (Assembly script in ScriptMgr.GameServerScripts) { try { client.Out.SendDebugMessage(script.FullName); merchant = (GameMerchant)script.CreateInstance(theType, false); if (merchant != null) { break; } } catch (Exception e) { client.Out.SendMessage(e.ToString(), eChatType.CT_System, eChatLoc.CL_PopupWindow); } } if (merchant == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.ErrorCreateInstance", theType)); return; } //Fill the object variables merchant.X = client.Player.X; merchant.Y = client.Player.Y; merchant.Z = client.Player.Z; merchant.CurrentRegion = client.Player.CurrentRegion; merchant.Heading = client.Player.Heading; merchant.Level = 1; merchant.Realm = client.Player.Realm; merchant.Name = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GMCommands.Merchant.NewName"); merchant.Model = 9; //Fill the living variables merchant.CurrentSpeed = 0; merchant.MaxSpeedBase = 200; merchant.GuildName = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "GMCommands.Merchant.NewGuildName"); merchant.Size = 50; merchant.AddToWorld(); merchant.SaveIntoDatabase(); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Create.Created", merchant.ObjectID)); break; } #endregion Create #region Info case "info": { if (args.Length == 2) { if (targetMerchant.TradeItems == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Info.ArtListIsEmpty")); } else { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Info.ArtList", targetMerchant.TradeItems.ItemsListID)); } } break; } #endregion Info #region Save case "save": { targetMerchant.SaveIntoDatabase(); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Save.SavedInDB")); break; } #endregion Save #region SaveList case "savelist": { string currentID = targetMerchant.TradeItems.ItemsListID; var itemList = DOLDB <MerchantItem> .SelectObjects(DB.Column(nameof(MerchantItem.ItemListID)).IsEqualTo(currentID)); foreach (MerchantItem merchantItem in itemList) { MerchantItem item = new MerchantItem(); item.ItemListID = GameServer.Database.Escape(args[2]); item.ItemTemplateID = merchantItem.ItemTemplateID; item.PageNumber = merchantItem.PageNumber; item.SlotPosition = merchantItem.SlotPosition; GameServer.Database.AddObject(item); } DisplayMessage(client, "New MerchantItems list saved as '" + GameServer.Database.Escape(args[2]) + "'"); break; } #endregion SaveList #region Remove case "remove": { targetMerchant.DeleteFromDatabase(); targetMerchant.Delete(); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Remove.RemovedFromDB")); break; } #endregion Remove #region Sell case "sell": { switch (args[2].ToLower()) { #region Add case "add": { if (args.Length == 4) { try { string templateID = args[3]; targetMerchant.TradeItems = new MerchantTradeItems(templateID); targetMerchant.SaveIntoDatabase(); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Sell.Add.Loaded")); } catch (Exception) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.CommandOverview")); return; } } break; } #endregion Add #region Remove case "remove": { if (args.Length == 3) { targetMerchant.TradeItems = null; targetMerchant.SaveIntoDatabase(); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Sell.Remove.Removed")); } break; } #endregion Remove #region Default default: { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.CommandOverview")); return; } #endregion Default } break; } #endregion Sell #region Articles case "articles": { if (args.Length < 3) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.CommandOverview")); return; } switch (args[2].ToLower()) { #region Add case "add": { if (args.Length <= 6) { try { string templateID = args[3]; int page = Convert.ToInt32(args[4]); eMerchantWindowSlot slot = eMerchantWindowSlot.FirstEmptyInPage; if (targetMerchant.TradeItems == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.ListNoFound")); return; } ItemTemplate template = GameServer.Database.FindObjectByKey <ItemTemplate>(templateID); if (template == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.Add.ItemTemplateNoFound", templateID)); return; } if (args.Length == 6) { slot = (eMerchantWindowSlot)Convert.ToInt32(args[5]); } slot = targetMerchant.TradeItems.GetValidSlot(page, slot); if (slot == eMerchantWindowSlot.Invalid) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.Add.PageAndSlotInvalid", page, (MerchantTradeItems.MAX_PAGES_IN_TRADEWINDOWS - 1), slot, (MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS - 1))); return; } var item = DOLDB <MerchantItem> .SelectObject(DB.Column(nameof(MerchantItem.ItemListID)).IsEqualTo(targetMerchant.TradeItems.ItemsListID).And(DB.Column(nameof(MerchantItem.PageNumber)).IsEqualTo(page)).And(DB.Column(nameof(MerchantItem.SlotPosition)).IsEqualTo(slot))); if (item == null) { item = new MerchantItem(); item.ItemListID = targetMerchant.TradeItems.ItemsListID; item.ItemTemplateID = templateID; item.SlotPosition = (int)slot; item.PageNumber = page; GameServer.Database.AddObject(item); } else { item.ItemTemplateID = templateID; GameServer.Database.SaveObject(item); } DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.Add.ItemAdded")); } catch (Exception) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.CommandOverview")); return; } } else { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.CommandOverview")); } break; } #endregion Add #region Remove case "remove": { if (args.Length == 5) { try { int page = Convert.ToInt32(args[3]); int slot = Convert.ToInt32(args[4]); if (page < 0 || page >= MerchantTradeItems.MAX_PAGES_IN_TRADEWINDOWS) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.Remove.PageInvalid", page, (MerchantTradeItems.MAX_PAGES_IN_TRADEWINDOWS - 1))); return; } if (slot < 0 || slot >= MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.Remove.SlotInvalid", slot, (MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS - 1))); return; } if (targetMerchant.TradeItems == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.ListNoFound")); return; } MerchantItem item = DOLDB <MerchantItem> .SelectObject(DB.Column(nameof(MerchantItem.ItemListID)).IsEqualTo(targetMerchant.TradeItems.ItemsListID).And(DB.Column(nameof(MerchantItem.PageNumber)).IsEqualTo(page)).And(DB.Column(nameof(MerchantItem.SlotPosition)).IsEqualTo(slot))); if (item == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.Remove.SlotInPageIsAEmpty", slot, page)); return; } GameServer.Database.DeleteObject(item); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.Remove.SlotInPageCleaned", slot, page)); } catch (Exception) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.CommandOverview")); return; } } else { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.CommandOverview")); } break; } #endregion Remove #region Delete case "delete": { if (args.Length == 3) { try { if (targetMerchant.TradeItems == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.ListNoFound")); return; } DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.Delete.DeletingListTemp")); var merchantitems = DOLDB <MerchantItem> .SelectObjects(DB.Column(nameof(MerchantItem.ItemListID)).IsEqualTo(targetMerchant.TradeItems.ItemsListID)); if (merchantitems.Count > 0) { GameServer.Database.DeleteObject(merchantitems); } DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Articles.Delete.ListDeleted")); } catch (Exception) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.CommandOverview")); return; } } break; } #endregion Delete #region Default default: { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.CommandOverview")); return; } #endregion Default } break; } #endregion Articles #region Type case "type": { string theType = param; if (args.Length > 2) { theType = args[2]; } //Create a new merchant GameMerchant merchant = null; foreach (Assembly script in ScriptMgr.GameServerScripts) { try { client.Out.SendDebugMessage(script.FullName); merchant = (GameMerchant)script.CreateInstance(theType, false); if (merchant != null) { break; } } catch (Exception e) { client.Out.SendMessage(e.ToString(), eChatType.CT_System, eChatLoc.CL_PopupWindow); } } if (merchant == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.ErrorCreateInstance", theType)); return; } //Fill the object variables merchant.X = targetMerchant.X; merchant.Y = targetMerchant.Y; merchant.Z = targetMerchant.Z; merchant.CurrentRegion = targetMerchant.CurrentRegion; merchant.Heading = targetMerchant.Heading; merchant.Level = targetMerchant.Level; merchant.Realm = targetMerchant.Realm; merchant.Name = targetMerchant.Name; merchant.Model = targetMerchant.Model; //Fill the living variables merchant.CurrentSpeed = targetMerchant.CurrentSpeed;; merchant.MaxSpeedBase = targetMerchant.MaxSpeedBase;; merchant.GuildName = targetMerchant.GuildName; merchant.Size = targetMerchant.Size; merchant.Inventory = targetMerchant.Inventory; merchant.EquipmentTemplateID = targetMerchant.EquipmentTemplateID; merchant.TradeItems = targetMerchant.TradeItems; merchant.AddToWorld(); merchant.SaveIntoDatabase(); targetMerchant.Delete(); targetMerchant.DeleteFromDatabase(); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Merchant.Type.Changed", param)); break; } #endregion Type } }
public void HandlePacket(GameClient client, GSPacketIn packet) { if (client == null) { return; } string ipAddress = client.TcpEndpointAddress; byte major; byte minor; byte build; string password; string userName; /// <summary> /// Packet Format Change above 1.115 /// </summary> if (client.Version < GameClient.eClientVersion.Version1115) { packet.Skip(2); //Skip the client_type byte major = (byte)packet.ReadByte(); minor = (byte)packet.ReadByte(); build = (byte)packet.ReadByte(); password = packet.ReadString(20); bool v174; //the logger detection we had is no longer working //bool loggerUsing = false; switch (client.Version) { case GameClient.eClientVersion.Version168: case GameClient.eClientVersion.Version169: case GameClient.eClientVersion.Version170: case GameClient.eClientVersion.Version171: case GameClient.eClientVersion.Version172: case GameClient.eClientVersion.Version173: v174 = false; break; default: v174 = true; break; } if (v174) { packet.Skip(11); } else { packet.Skip(7); } uint c2 = packet.ReadInt(); uint c3 = packet.ReadInt(); uint c4 = packet.ReadInt(); if (v174) { packet.Skip(27); } else { packet.Skip(31); } userName = packet.ReadString(20); } else if (client.Version < GameClient.eClientVersion.Version1126) // 1.125+ only // we support 1.109 and 1.125+ only { // client type packet.Skip(1); //version major = (byte)packet.ReadByte(); minor = (byte)packet.ReadByte(); build = (byte)packet.ReadByte(); // revision packet.Skip(1); // build packet.Skip(2); if (client.Version <= GameClient.eClientVersion.Version1124) { userName = packet.ReadShortPascalStringLowEndian(); password = packet.ReadShortPascalStringLowEndian(); } else { userName = packet.ReadIntPascalStringLowEndian(); password = packet.ReadIntPascalStringLowEndian(); } } else { userName = packet.ReadIntPascalStringLowEndian(); password = packet.ReadIntPascalStringLowEndian(); } /* * if (c2 == 0 && c3 == 0x05000000 && c4 == 0xF4000000) * { * loggerUsing = true; * Log.Warn("logger detected (" + username + ")"); * }*/ // check server status if (GameServer.Instance.ServerStatus == eGameServerStatus.GSS_Closed) { client.IsConnected = false; client.Out.SendLoginDenied(eLoginError.GameCurrentlyClosed); Log.Info(ipAddress + " disconnected because game is closed!"); GameServer.Instance.Disconnect(client); return; } // check connection allowed with serverrules try { if (!GameServer.ServerRules.IsAllowedToConnect(client, userName)) { if (Log.IsInfoEnabled) { Log.Info(ipAddress + " disconnected because IsAllowedToConnect returned false!"); } GameServer.Instance.Disconnect(client); return; } } catch (Exception e) { if (Log.IsErrorEnabled) { Log.Error("Error shutting down Client after IsAllowedToConnect failed!", e); } } // Handle connection EnterLock(userName); try { Account playerAccount; // Make sure that client won't quit lock (client) { GameClient.eClientState state = client.ClientState; if (state != GameClient.eClientState.NotConnected) { Log.DebugFormat("wrong client state on connect {0} {1}", userName, state.ToString()); return; } if (Log.IsInfoEnabled) { Log.Info(string.Format("({0})User {1} logging on! ({2} type:{3} add:{4})", ipAddress, userName, client.Version, (client.ClientType), client.ClientAddons.ToString("G"))); } // check client already connected GameClient findclient = WorldMgr.GetClientByAccountName(userName, true); if (findclient != null) { client.IsConnected = false; if (findclient.ClientState == GameClient.eClientState.Connecting) { if (Log.IsInfoEnabled) { Log.Info("User is already connecting, ignored."); } client.Out.SendLoginDenied(eLoginError.AccountAlreadyLoggedIn); return; } // in login if (findclient.ClientState == GameClient.eClientState.Linkdead) { if (Log.IsInfoEnabled) { Log.Info("User is still being logged out from linkdeath!"); } client.Out.SendLoginDenied(eLoginError.AccountIsInLogoutProcedure); } else { if (Log.IsInfoEnabled) { Log.Info("User already logged in!"); } client.Out.SendLoginDenied(eLoginError.AccountAlreadyLoggedIn); } GameServer.Instance.Disconnect(client); return; } Regex goodName = new Regex("^[a-zA-Z0-9]*$"); if (!goodName.IsMatch(userName) || string.IsNullOrWhiteSpace(userName)) { if (Log.IsInfoEnabled) { Log.Info("Invalid symbols in account name \"" + userName + "\" found!"); } client.IsConnected = false; if (client != null && client.Out != null) { client.Out.SendLoginDenied(eLoginError.AccountInvalid); } else { Log.Warn("Client or Client.Out null on invalid name failure. Disconnecting."); } GameServer.Instance.Disconnect(client); return; } else { playerAccount = GameServer.Database.FindObjectByKey <Account>(userName); client.PingTime = DateTime.Now.Ticks; if (playerAccount == null) { //check autocreate ... if (GameServer.Instance.Configuration.AutoAccountCreation && Properties.ALLOW_AUTO_ACCOUNT_CREATION) { // autocreate account if (string.IsNullOrEmpty(password)) { client.IsConnected = false; client.Out.SendLoginDenied(eLoginError.AccountInvalid); GameServer.Instance.Disconnect(client); if (Log.IsInfoEnabled) { Log.Info("Account creation failed, no password set for Account: " + userName); } return; } // check for account bombing TimeSpan ts; var allAccByIp = DOLDB <Account> .SelectObjects(DB.Column(nameof(Account.LastLoginIP)).IsEqualTo(ipAddress)); int totalacc = 0; foreach (Account ac in allAccByIp) { ts = DateTime.Now - ac.CreationDate; if (ts.TotalMinutes < Properties.TIME_BETWEEN_ACCOUNT_CREATION_SAMEIP && totalacc > 1) { Log.Warn("Account creation: too many from same IP within set minutes - " + userName + " : " + ipAddress); client.IsConnected = false; client.Out.SendLoginDenied(eLoginError.PersonalAccountIsOutOfTime); GameServer.Instance.Disconnect(client); return; } totalacc++; } if (totalacc >= Properties.TOTAL_ACCOUNTS_ALLOWED_SAMEIP) { Log.Warn("Account creation: too many accounts created from same ip - " + userName + " : " + ipAddress); client.IsConnected = false; client.Out.SendLoginDenied(eLoginError.AccountNoAccessThisGame); GameServer.Instance.Disconnect(client); return; } // per timeslice - for preventing account bombing via different ip if (Properties.TIME_BETWEEN_ACCOUNT_CREATION > 0) { ts = DateTime.Now - m_lastAccountCreateTime; if (ts.TotalMinutes < Properties.TIME_BETWEEN_ACCOUNT_CREATION) { Log.Warn("Account creation: time between account creation too small - " + userName + " : " + ipAddress); client.IsConnected = false; client.Out.SendLoginDenied(eLoginError.PersonalAccountIsOutOfTime); GameServer.Instance.Disconnect(client); return; } } m_lastAccountCreateTime = DateTime.Now; playerAccount = new Account(); playerAccount.Name = userName; playerAccount.Password = CryptPassword(password); playerAccount.Realm = 0; playerAccount.CreationDate = DateTime.Now; playerAccount.LastLogin = DateTime.Now; playerAccount.LastLoginIP = ipAddress; playerAccount.LastClientVersion = ((int)client.Version).ToString(); playerAccount.Language = Properties.SERV_LANGUAGE; playerAccount.PrivLevel = 1; if (Log.IsInfoEnabled) { Log.Info("New account created: " + userName); } GameServer.Database.AddObject(playerAccount); // Log account creation AuditMgr.AddAuditEntry(client, AuditType.Account, AuditSubtype.AccountCreate, "", userName); } else { if (Log.IsInfoEnabled) { Log.Info("No such account found and autocreation deactivated!"); } client.IsConnected = false; client.Out.SendLoginDenied(eLoginError.AccountNotFound); GameServer.Instance.Disconnect(client); return; } } else { // check password if (!playerAccount.Password.StartsWith("##")) { playerAccount.Password = CryptPassword(playerAccount.Password); } if (!CryptPassword(password).Equals(playerAccount.Password)) { if (Log.IsInfoEnabled) { Log.Info("(" + client.TcpEndpoint + ") Wrong password!"); } client.IsConnected = false; client.Out.SendLoginDenied(eLoginError.WrongPassword); // Log failure AuditMgr.AddAuditEntry(client, AuditType.Account, AuditSubtype.AccountFailedLogin, "", userName); GameServer.Instance.Disconnect(client); return; } // save player infos playerAccount.LastLogin = DateTime.Now; playerAccount.LastLoginIP = ipAddress; playerAccount.LastClientVersion = ((int)client.Version).ToString(); if (string.IsNullOrEmpty(playerAccount.Language)) { playerAccount.Language = Properties.SERV_LANGUAGE; } GameServer.Database.SaveObject(playerAccount); } } //Save the account table client.Account = playerAccount; // create session ID here to disable double login bug if (WorldMgr.CreateSessionID(client) < 0) { if (Log.IsInfoEnabled) { Log.InfoFormat("Too many clients connected, denied login to " + playerAccount.Name); } client.IsConnected = false; client.Out.SendLoginDenied(eLoginError.TooManyPlayersLoggedIn); client.Disconnect(); return; } client.Out.SendLoginGranted(); client.ClientState = GameClient.eClientState.Connecting; // Log entry AuditMgr.AddAuditEntry(client, AuditType.Account, AuditSubtype.AccountSuccessfulLogin, "", userName); } } catch (DatabaseException e) { if (Log.IsErrorEnabled) { Log.Error("LoginRequestHandler", e); } client.IsConnected = false; client.Out.SendLoginDenied(eLoginError.CannotAccessUserAccount); GameServer.Instance.Disconnect(client); } catch (Exception e) { if (Log.IsErrorEnabled) { Log.Error("LoginRequestHandler", e); } client.Out.SendLoginDenied(eLoginError.CannotAccessUserAccount); GameServer.Instance.Disconnect(client); } finally { ExitLock(userName); } }
/// <summary> /// Force loading of any defined housing and house markers for a specific region /// </summary> /// <param name="regionID"></param> /// <returns></returns> public static string LoadHousingForRegion(ushort regionID) { string result = ""; var regionHousing = DOLDB <DBHouse> .SelectObjects(DB.Column(nameof(DBHouse.RegionID)).IsEqualTo(regionID)); if (regionHousing == null || regionHousing.Count == 0) { return("No housing found for region."); } int houses = 0; int lotmarkers = 0; // re-initialize lists for this region if (!_houseList.ContainsKey(regionID)) { _houseList.Add(regionID, new Dictionary <int, House>()); } else { _houseList[regionID] = new Dictionary <int, House>(); } if (!_idList.ContainsKey(regionID)) { _idList.Add(regionID, 0); } else { _idList[regionID] = 0; } Dictionary <int, House> housesForRegion; _houseList.TryGetValue(regionID, out housesForRegion); if (housesForRegion == null) { result = "LoadHousingForRegion: No dictionary defined for region ID " + regionID; log.WarnFormat(result); return(result); } foreach (DBHouse house in regionHousing) { // if we already loaded this house, that's no bueno, but just skip if (housesForRegion.ContainsKey(house.HouseNumber)) { continue; } if (SpawnLot(house, housesForRegion) == eLotSpawnType.House) { houses++; } else { lotmarkers++; } } string results = "[Housing] Loaded " + houses + " houses and " + lotmarkers + " lotmarkers for region " + regionID + "!"; if (log.IsInfoEnabled) { log.Info(results); } return(results); }
public void HandlePacket(GameClient client, GSPacketIn packet) { try { int unknow1 = packet.ReadByte(); // 1=Money 0=Item (?) int slot = packet.ReadByte(); // Item/money slot ushort housenumber = packet.ReadShort(); // N° of house int unknow2 = (byte)packet.ReadByte(); _position = (byte)packet.ReadByte(); int method = packet.ReadByte(); // 2=Wall 3=Floor int rotation = packet.ReadByte(); // garden items only var xpos = (short)packet.ReadShort(); // x for inside objs var ypos = (short)packet.ReadShort(); // y for inside objs. //Log.Info("U1: " + unknow1 + " - U2: " + unknow2); ChatUtil.SendDebugMessage(client, string.Format("HousingPlaceItem: slot: {0}, position: {1}, method: {2}, xpos: {3}, ypos: {4}", slot, _position, method, xpos, ypos)); if (client.Player == null) { return; } // house must exist House house = HouseMgr.GetHouse(client.Player.CurrentRegionID, housenumber); if (house == null) { client.Player.Out.SendInventorySlotsUpdate(null); return; } if ((slot >= 244) && (slot <= 248)) // money { // check that player has permission to pay rent if (!house.CanPayRent(client.Player)) { client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } long moneyToAdd = _position; switch (slot) { case 248: moneyToAdd *= 1; break; case 247: moneyToAdd *= 100; break; case 246: moneyToAdd *= 10000; break; case 245: moneyToAdd *= 10000000; break; case 244: moneyToAdd *= 10000000000; break; } client.Player.TempProperties.setProperty(HousingConstants.MoneyForHouseRent, moneyToAdd); client.Player.TempProperties.setProperty(HousingConstants.HouseForHouseRent, house); client.Player.Out.SendInventorySlotsUpdate(null); client.Player.Out.SendHousePayRentDialog("Housing07"); return; } // make sure the item dropped still exists InventoryItem orgitem = client.Player.Inventory.GetItem((eInventorySlot)slot); if (orgitem == null) { client.Player.Out.SendInventorySlotsUpdate(null); return; } if (orgitem.Id_nb == "house_removal_deed") { client.Out.SendInventorySlotsUpdate(null); // make sure player has owner permissions if (!house.HasOwnerPermissions(client.Player)) { ChatUtil.SendSystemMessage(client.Player, "You don't own this house!"); return; } client.Player.TempProperties.setProperty(DeedWeak, new WeakRef(orgitem)); client.Player.TempProperties.setProperty(TargetHouse, house); client.Player.Out.SendCustomDialog(LanguageMgr.GetTranslation(client.Account.Language, "WARNING: You are about to delete this house and all indoor and outdoor items attached to it!"), HouseRemovalDialog); return; } if (orgitem.Id_nb.Contains("cottage_deed") || orgitem.Id_nb.Contains("house_deed") || orgitem.Id_nb.Contains("villa_deed") || orgitem.Id_nb.Contains("mansion_deed")) { client.Out.SendInventorySlotsUpdate(null); // make sure player has owner permissions if (!house.HasOwnerPermissions(client.Player)) { ChatUtil.SendSystemMessage(client, "You may not change other peoples houses"); return; } client.Player.TempProperties.setProperty(DeedWeak, new WeakRef(orgitem)); client.Player.TempProperties.setProperty(TargetHouse, house); client.Player.Out.SendMessage("Warning:\n This will remove *all* items from your current house!", eChatType.CT_System, eChatLoc.CL_PopupWindow); client.Player.Out.SendCustomDialog("Are you sure you want to upgrade your House?", HouseUpgradeDialog); return; } if (orgitem.Name == "deed of guild transfer") { // player needs to be in a guild to xfer a house to a guild if (client.Player.Guild == null) { client.Out.SendInventorySlotsUpdate(new[] { slot }); ChatUtil.SendSystemMessage(client, "You must be a member of a guild to do that"); return; } // player needs to own the house to be able to xfer it if (!house.HasOwnerPermissions(client.Player)) { client.Out.SendInventorySlotsUpdate(new[] { slot }); ChatUtil.SendSystemMessage(client, "You do not own this house."); return; } // guild can't already have a house if (client.Player.Guild.GuildOwnsHouse) { client.Out.SendInventorySlotsUpdate(new[] { slot }); ChatUtil.SendSystemMessage(client, "Your Guild already owns a house."); return; } // player needs to be a GM in the guild to xfer his personal house to the guild if (!client.Player.Guild.HasRank(client.Player, Guild.eRank.Leader)) { client.Out.SendInventorySlotsUpdate(new[] { slot }); ChatUtil.SendSystemMessage(client, "You are not the leader of a guild."); return; } if (HouseMgr.HouseTransferToGuild(client.Player, house)) { // This will still take the item even if player answers NO to confirmation. // I'm fixing consignment, not housing, and frankly I'm sick of fixing stuff! :) - tolakram client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); client.Player.Guild.UpdateGuildWindow(); } return; } if (house.CanChangeInterior(client.Player, DecorationPermissions.Remove)) { if (orgitem.Name == "interior banner removal") { house.IndoorGuildBanner = false; ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.InteriorBannersRemoved", null); return; } if (orgitem.Name == "interior shield removal") { house.IndoorGuildShield = false; ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.InteriorShieldsRemoved", null); return; } if (orgitem.Name == "carpet removal") { house.Rug1Color = 0; house.Rug2Color = 0; house.Rug3Color = 0; house.Rug4Color = 0; ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.CarpetsRemoved", null); return; } } if (house.CanChangeExternalAppearance(client.Player)) { if (orgitem.Name == "exterior banner removal") { house.OutdoorGuildBanner = false; ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.OutdoorBannersRemoved", null); return; } if (orgitem.Name == "exterior shield removal") { house.OutdoorGuildShield = false; ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.OutdoorShieldsRemoved", null); return; } } int objType = orgitem.Object_Type; if (objType == 49) // Garden items { method = 1; } else if (orgitem.Id_nb == "housing_porch_deed" || orgitem.Id_nb == "housing_porch_remove_deed" || orgitem.Id_nb == "housing_consignment_deed") { method = 4; } else if (objType >= 59 && objType <= 64) // Outdoor Roof/Wall/Door/Porch/Wood/Shutter/awning Material item type { ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.HouseUseMaterials", null); return; } else if (objType == 56 || objType == 52 || (objType >= 69 && objType <= 71)) // Indoor carpets 1-4 { ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.HouseUseCarpets", null); return; } else if (objType == 57 || objType == 58 || // Exterior banner/shield objType == 66 || objType == 67) // Interior banner/shield { method = 6; } else if (objType == 53 || objType == 55 || objType == 68) { method = 5; } else if (objType == (int)eObjectType.HouseVault) { method = 7; } ChatUtil.SendDebugMessage(client, string.Format("Place Item: method: {0}", method)); int pos; switch (method) { case 1: // GARDEN OBJECT { if (client.Player.InHouse) { client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // no permissions to add to the garden, return if (!house.CanChangeGarden(client.Player, DecorationPermissions.Add)) { client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // garden is already full, return if (house.OutdoorItems.Count >= Properties.MAX_OUTDOOR_HOUSE_ITEMS) { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.GardenMaxObjects", null); client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // create an outdoor item to represent the item being placed var oitem = new OutdoorItem { BaseItem = GameServer.Database.FindObjectByKey <ItemTemplate>(orgitem.Id_nb), Model = orgitem.Model, Position = (byte)_position, Rotation = (byte)rotation }; //add item in db pos = GetFirstFreeSlot(house.OutdoorItems.Keys); DBHouseOutdoorItem odbitem = oitem.CreateDBOutdoorItem(housenumber); oitem.DatabaseItem = odbitem; GameServer.Database.AddObject(odbitem); // remove the item from the player's inventory client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); //add item to outdooritems house.OutdoorItems.Add(pos, oitem); ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.GardenItemPlaced", Properties.MAX_OUTDOOR_HOUSE_ITEMS - house.OutdoorItems.Count); ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.GardenItemPlacedName", orgitem.Name); // update all nearby players foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(house.RegionID, house.Position, WorldMgr.OBJ_UPDATE_DISTANCE)) { player.Out.SendGarden(house); } // save the house house.SaveIntoDatabase(); break; } case 2: // WALL OBJECT case 3: // FLOOR OBJECT { if (client.Player.InHouse == false) { client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // no permission to add to the interior, return if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add)) { client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // not a wall object, return if (!IsSuitableForWall(orgitem) && method == 2) { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.NotWallObject", null); client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // not a floor object, return if (objType != 51 && method == 3) { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.NotFloorObject", null); client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // interior already has max items, return if (house.IndoorItems.Count >= GetMaxIndoorItemsForHouse(house.Model)) { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.IndoorMaxItems", GetMaxIndoorItemsForHouse(house.Model)); client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // create an indoor item to represent the item being placed var iitem = new IndoorItem { Model = orgitem.Model, Color = orgitem.Color, Emblem = orgitem.Emblem, X = xpos, Y = ypos, Size = orgitem.DPS_AF > 3 ? orgitem.DPS_AF : 100, // max size is 255 Position = _position, PlacementMode = method, BaseItem = null }; // figure out proper rotation for item int properRotation = client.Player.Heading / 10; properRotation = properRotation.Clamp(0, 360); if (method == 2 && IsSuitableForWall(orgitem)) { properRotation = 360; if (objType != 50) { client.Out.SendInventorySlotsUpdate(new[] { slot }); } } iitem.Rotation = properRotation; pos = GetFirstFreeSlot(house.IndoorItems.Keys); if (objType == 50 || objType == 51) { //its a housing item, so lets take it! client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); //set right base item, so we can recreate it on take. if (orgitem.Id_nb.Contains("GuildBanner")) { iitem.BaseItem = orgitem.Template; iitem.Size = 50; // Banners have to be reduced in size } else { iitem.BaseItem = GameServer.Database.FindObjectByKey <ItemTemplate>(orgitem.Id_nb); } } DBHouseIndoorItem idbitem = iitem.CreateDBIndoorItem(housenumber); iitem.DatabaseItem = idbitem; GameServer.Database.AddObject(idbitem); house.IndoorItems.Add(pos, iitem); // let player know the item has been placed ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.IndoorItemPlaced", (GetMaxIndoorItemsForHouse(house.Model) - house.IndoorItems.Count)); switch (method) { case 2: ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.IndoorWallPlaced", orgitem.Name); break; case 3: ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.IndoorFloorPlaced", orgitem.Name); break; } // update furniture for all players in the house foreach (GamePlayer plr in house.GetAllPlayersInHouse()) { plr.Out.SendFurniture(house, pos); } break; } case 4: // PORCH { // no permission to add to the garden, return if (!house.CanChangeGarden(client.Player, DecorationPermissions.Add)) { client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } switch (orgitem.Id_nb) { case "housing_porch_deed": // try and add the porch if (house.AddPorch()) { // remove the original item from the player's inventory client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); } else { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.PorchAlready", null); client.Out.SendInventorySlotsUpdate(new[] { slot }); } return; case "housing_porch_remove_deed": var consignmentMerchant = house.ConsignmentMerchant; if (consignmentMerchant != null && (consignmentMerchant.DBItems(client.Player).Count > 0 || consignmentMerchant.TotalMoney > 0)) { ChatUtil.SendSystemMessage(client, "All items and money must be removed from your consigmment merchant in order to remove the porch!"); client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // try and remove the porch if (house.RemovePorch()) { // remove the original item from the player's inventory client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); } else { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.PorchNone", null); client.Out.SendInventorySlotsUpdate(new[] { slot }); } return; case "housing_consignment_deed": { // make sure there is a porch for this consignment merchant! if (!house.Porch) { ChatUtil.SendSystemMessage(client, "Your House needs a Porch first."); client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // try and add a new consignment merchant if (house.AddConsignment(0)) { // remove the original item from the player's inventory client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); } else { ChatUtil.SendSystemMessage(client, "You can not add a Consignment Merchant here."); client.Out.SendInventorySlotsUpdate(new[] { slot }); } return; } default: ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.PorchNotItem", null); client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } } case 5: // HOOKPOINT { if (client.Player.InHouse == false) { client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // no permission to add to the interior, return if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add)) { client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // don't allow non-hookpoint items to be dropped on hookpoints if (IsSuitableForHookpoint(orgitem) == false) { client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // if the hookpoint doesn't exist, prompt player to Log it in the database for us if (house.GetHookpointLocation((uint)_position) == null) { client.Out.SendInventorySlotsUpdate(new[] { slot }); if (client.Account.PrivLevel == (int)ePrivLevel.Admin) { if (client.Player.TempProperties.getProperty <bool>(HousingConstants.AllowAddHouseHookpoint, false)) { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointID", +_position); ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointCloser", null); client.Player.Out.SendCustomDialog(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Player.Housing.HookPointLogLoc"), LogLocation); } else { ChatUtil.SendDebugMessage(client, "use '/house addhookpoints' to allow addition of new housing hookpoints."); } } } else if (house.GetHookpointLocation((uint)_position) != null) { var point = new DBHouseHookpointItem { HouseNumber = house.HouseNumber, ItemTemplateID = orgitem.Id_nb, HookpointID = (uint)_position }; // If we already have soemthing here, do not place more foreach (var hpitem in DOLDB <DBHouseHookpointItem> .SelectObjects(DB.Column(nameof(DBHouseHookpointItem.HouseNumber)).IsEqualTo(house.HouseNumber))) { if (hpitem.HookpointID == point.HookpointID) { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointAlready", null); client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } } if (house.HousepointItems.ContainsKey(point.HookpointID) == false) { house.HousepointItems.Add(point.HookpointID, point); house.FillHookpoint((uint)_position, orgitem.Id_nb, client.Player.Heading, 0); } else { string error = string.Format("Hookpoint already has item on attempt to attach {0} to hookpoint {1} for house {2}!", orgitem.Id_nb, _position, house.HouseNumber); log.ErrorFormat(error); client.Out.SendInventorySlotsUpdate(new[] { slot }); throw new Exception(error); } // add the item to the database GameServer.Database.AddObject(point); // remove the original item from the player's inventory client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointAdded", null); // save the house house.SaveIntoDatabase(); } else { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointNot", null); client.Out.SendInventorySlotsUpdate(new[] { slot }); } // broadcast updates house.SendUpdate(); break; } case 6: { // no permission to change external appearance, return if (!house.CanChangeExternalAppearance(client.Player)) { client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } if (objType == 57) // We have outdoor banner { house.OutdoorGuildBanner = true; ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.OutdoorBannersAdded", null); client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); } else if (objType == 58) // We have outdoor shield { house.OutdoorGuildShield = true; ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.OutdoorShieldsAdded", null); client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); } else if (objType == 66) // We have indoor banner { house.IndoorGuildBanner = true; ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.InteriorBannersAdded", null); client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); } else if (objType == 67) // We have indoor shield { house.IndoorGuildShield = true; ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.InteriorShieldsAdded", null); client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); } else { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.BadShieldBanner", null); client.Out.SendInventorySlotsUpdate(new[] { slot }); } // save the house and broadcast updates house.SaveIntoDatabase(); house.SendUpdate(); break; } case 7: // House vault. { if (client.Player.InHouse == false) { client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // make sure the hookpoint position is valid if (_position > HousingConstants.MaxHookpointLocations) { ChatUtil.SendSystemMessage(client, "This hookpoint position is unknown, error logged."); log.Error("HOUSING: " + client.Player.Name + " working with invalid position " + _position + " in house " + house.HouseNumber + " model " + house.Model); client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // if hookpoint doesn't exist, prompt player to Log it in the database for us if (house.GetHookpointLocation((uint)_position) == null) { client.Out.SendInventorySlotsUpdate(new[] { slot }); if (client.Account.PrivLevel == (int)ePrivLevel.Admin) { if (client.Player.TempProperties.getProperty <bool>(HousingConstants.AllowAddHouseHookpoint, false)) { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointID", +_position); ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointCloser", null); client.Player.Out.SendCustomDialog(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Player.Housing.HookPointLogLoc"), LogLocation); } else { ChatUtil.SendDebugMessage(client, "use '/house addhookpoints' to allow addition of new housing hookpoints."); } } return; } // make sure we have space to add another vult int vaultIndex = house.GetFreeVaultNumber(); if (vaultIndex < 0) { client.Player.Out.SendMessage("You can't add any more vaults to this house!", eChatType.CT_System, eChatLoc.CL_SystemWindow); client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } // If we already have soemthing here, do not place more foreach (var hpitem in DOLDB <DBHouseHookpointItem> .SelectObjects(DB.Column(nameof(DBHouseHookpointItem.HouseNumber)).IsEqualTo(house.HouseNumber))) { if (hpitem.HookpointID == _position) { ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointAlready", null); client.Out.SendInventorySlotsUpdate(new[] { slot }); return; } } // create the new vault and attach it to the house var houseVault = new GameHouseVault(orgitem.Template, vaultIndex); houseVault.Attach(house, (uint)_position, (ushort)((client.Player.Heading + 2048) % 4096)); // remove the original item from the player's inventory client.Player.Inventory.RemoveItem(orgitem); InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count); // save the house and broadcast uodates house.SaveIntoDatabase(); house.SendUpdate(); return; } default: { ChatUtil.SendDebugMessage(client, "Place Item: Unknown method, do nothing."); client.Out.SendInventorySlotsUpdate(null); break; } } } catch (Exception ex) { log.Error("HousingPlaceItemHandler", ex); client.Out.SendMessage("Error processing housing action; the error has been logged!", eChatType.CT_Staff, eChatLoc.CL_SystemWindow); client.Out.SendInventorySlotsUpdate(null); } }
public void OnCommand(GameClient client, string[] args) { if (args.Length < 2) { DisplaySyntax(client); return; } switch (args[1].ToLower()) { #region Create case "create": { if (args.Length < 4) { DisplaySyntax(client); return; } string AccountName = args[2].ToLower(); string Password = args[3]; foreach (char c in AccountName.ToCharArray()) { if ((c < '0' || c > '9') && (c < 'a' || c > 'z')) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.InvalidAccountName")); return; } } if (AccountName.Length < 4 || Password.Length < 4) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.InvalidAccountNameOrPassword")); return; } Account account = GetAccount(AccountName); if (account != null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.AccountNameAlreadyRegistered")); return; } account = new Account { Name = AccountName, Password = PacketHandler.Client.v168.LoginRequestHandler.CryptPassword(Password), PrivLevel = (uint)ePrivLevel.Player, Realm = (int)eRealm.None, CreationDate = DateTime.Now, Language = ServerProperties.Properties.SERV_LANGUAGE }; GameServer.Database.AddObject(account); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.AccountCreated")); } break; #endregion Create #region ChangePassword case "changepassword": { if (args.Length < 4) { DisplaySyntax(client); return; } string accountname = args[2]; string newpass = args[3]; Account acc = GetAccount(accountname); if (acc == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.AccountNotFound", accountname)); return; } acc.Password = LoginRequestHandler.CryptPassword(newpass); GameServer.Database.SaveObject(acc); // Log change AuditMgr.AddAuditEntry(client, AuditType.Account, AuditSubtype.AccountPasswordChange, "", (client.Player != null ? client.Player.Name : "")); } break; #endregion ChangePassword #region Delete case "delete": { if (args.Length < 3) { DisplaySyntax(client); return; } string AccountName = args[2]; Account acc = GetAccount(AccountName); if (acc == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.AccountNotFound", AccountName)); return; } KickAccount(acc); GameServer.Database.DeleteObject(acc); // Log change AuditMgr.AddAuditEntry(client, AuditType.Account, AuditSubtype.AccountDelete, "acct=" + AccountName, (client.Player != null ? client.Player.Name : "")); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.AccountDeleted", acc.Name)); return; } #endregion Delete #region DeleteCharacter case "deletecharacter": { if (args.Length < 3) { DisplaySyntax(client); return; } string charname = args[2]; DOLCharacters cha = GetCharacter(charname); if (cha == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.CharacterNotFound", charname)); return; } KickCharacter(cha); GameServer.Database.DeleteObject(cha); // Log change AuditMgr.AddAuditEntry(client, AuditType.Character, AuditSubtype.CharacterDelete, "char=" + charname, (client.Player != null ? client.Player.Name : "")); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.CharacterDeleted", cha.Name)); return; } #endregion DeleteCharacter #region MoveCharacter case "movecharacter": { if (args.Length < 4) { DisplaySyntax(client); return; } string charname = args[2]; string accountname = args[3]; DOLCharacters cha = GetCharacter(charname); if (cha == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.CharacterNotFound", charname)); return; } Account acc = GetAccount(accountname); if (acc == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.AccountNotFound", accountname)); return; } int firstAccountSlot; switch ((eRealm)cha.Realm) { case eRealm.Albion: firstAccountSlot = 100; break; case eRealm.Midgard: firstAccountSlot = 200; break; case eRealm.Hibernia: firstAccountSlot = 300; break; default: DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.CharNotFromValidRealm")); return; } int freeslot; for (freeslot = firstAccountSlot; freeslot < firstAccountSlot + 8; freeslot++) { bool found = false; foreach (DOLCharacters ch in acc.Characters) { if (ch.Realm == cha.Realm && ch.AccountSlot == freeslot) { found = true; break; } } if (!found) { break; } } if (freeslot == 0) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.AccountHasNoFreeSlots", accountname)); return; } GameClient playingclient = WorldMgr.GetClientByPlayerName(cha.Name, true, false); if (playingclient != null) { playingclient.Out.SendPlayerQuit(true); playingclient.Disconnect(); } cha.AccountName = acc.Name; cha.AccountSlot = freeslot; GameServer.Database.SaveObject(cha); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.CharacterMovedToAccount", cha.Name, acc.Name)); return; } #endregion MoveCharacter #region Status case "status": { if (args.Length < 4) { DisplaySyntax(client); return; } string accountname = args[2]; Account acc = GetAccount(accountname); if (acc == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.AccountNotFound", accountname)); return; } int status; try { status = Convert.ToInt32(args[3]); } catch (Exception) { DisplaySyntax(client); return; } if (status >= 0 && status < 256) { acc.Status = status; GameServer.Database.SaveObject(acc); DisplayMessage(client, "Account " + acc.Name + " Status is now set to : " + acc.Status); } else { DisplaySyntax(client); } return; } #endregion Status #region Unban case "unban": { if (args.Length < 3) { DisplaySyntax(client); return; } string accountname = args[2]; Account acc = GetAccount(accountname); if (acc == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.AccountNotFound", accountname)); return; } var banacc = DOLDB <DBBannedAccount> .SelectObjects(DB.Column("Type").IsEqualTo("A").Or(DB.Column("Type").IsEqualTo("B")).And(DB.Column("Account").IsEqualTo(accountname))); if (banacc.Count == 0) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.AccountNotFound", accountname)); return; } try { GameServer.Database.DeleteObject(banacc); } catch (Exception) { DisplaySyntax(client); return; } DisplayMessage(client, "Account " + accountname + " unbanned!"); return; } #endregion Unban #region AccountName case "accountname": { if (args.Length < 3) { DisplaySyntax(client); return; } string CharName = args[2]; DOLCharacters Char = GetCharacter(CharName); if (Char == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.CharacterNotFound", CharName)); return; } string AccName = GetAccountName(Char.Name); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "AdminCommands.Account.AccNameForChar", Char.Name, AccName)); return; } #endregion AccountName } }
/// <summary> /// load all keeps from the DB /// </summary> /// <returns></returns> public virtual bool Load() { // first check the regions we manage foreach (Region r in WorldMgr.Regions.Values) { if (r.IsFrontier) { m_frontierRegionsList.Add(r.ID); } } // default to NF if no frontier regions found if (m_frontierRegionsList.Count == 0) { m_frontierRegionsList.Add(DEFAULT_FRONTIERS_REGION); } ClothingMgr.LoadTemplates(); //Dinberg - moved this here, battlegrounds must be loaded before keepcomponents are. LoadBattlegroundCaps(); if (!ServerProperties.Properties.LOAD_KEEPS) { return(true); } lock (m_keepList.SyncRoot) { m_keepList.Clear(); var keeps = GameServer.Database.SelectAllObjects <DBKeep>(); foreach (DBKeep datakeep in keeps) { Region keepRegion = WorldMgr.GetRegion(datakeep.Region); if (keepRegion == null) { continue; } AbstractGameKeep keep; if ((datakeep.KeepID >> 8) != 0 || ((datakeep.KeepID & 0xFF) > 150)) { keep = keepRegion.CreateGameKeepTower(); } else { keep = keepRegion.CreateGameKeep(); } keep.Load(datakeep); RegisterKeep(datakeep.KeepID, keep); } // This adds owner keeps to towers / portal keeps foreach (AbstractGameKeep keep in m_keepList.Values) { GameKeepTower tower = keep as GameKeepTower; if (tower != null) { int index = tower.KeepID & 0xFF; GameKeep ownerKeep = GetKeepByID(index) as GameKeep; if (ownerKeep != null) { ownerKeep.AddTower(tower); } tower.Keep = ownerKeep; tower.OwnerKeepID = index; if (tower.OwnerKeepID < 10) { log.WarnFormat("Tower.OwnerKeepID < 10 for KeepID {0}. Doors on this tower will not be targetable! ({0} & 0xFF < 10). Choose a different KeepID to correct this issue.", tower.KeepID); } } } if (ServerProperties.Properties.USE_NEW_KEEPS == 2) { log.ErrorFormat("ServerProperty USE_NEW_KEEPS is actually set to 2 but it is no longer used. Loading as if he were 0 but please set to 0 or 1 !"); } // var keepcomponents = default(IList<DBKeepComponent>); Why was this done this way rather than being strictly typed? IList <DBKeepComponent> keepcomponents = null; if (ServerProperties.Properties.USE_NEW_KEEPS == 0 || ServerProperties.Properties.USE_NEW_KEEPS == 2) { keepcomponents = DOLDB <DBKeepComponent> .SelectObjects(DB.Column(nameof(DBKeepComponent.Skin)).IsLessThan(20)); } else if (ServerProperties.Properties.USE_NEW_KEEPS == 1) { keepcomponents = DOLDB <DBKeepComponent> .SelectObjects(DB.Column(nameof(DBKeepComponent.Skin)).IsGreatherThan(20)); } if (keepcomponents != null) { keepcomponents .GroupBy(x => x.KeepID) .AsParallel() .ForAll(components => { foreach (DBKeepComponent component in components) { AbstractGameKeep keep = GetKeepByID(component.KeepID); if (keep == null) { //missingKeeps = true; continue; } GameKeepComponent gamecomponent = keep.CurrentRegion.CreateGameKeepComponent(); gamecomponent.LoadFromDatabase(component, keep); keep.KeepComponents.Add(gamecomponent); } }); } /*if (missingKeeps && log.IsWarnEnabled) * { * log.WarnFormat("Some keeps not found while loading components, possibly old/new keeptypes."); * }*/ if (m_keepList.Count != 0) { foreach (AbstractGameKeep keep in m_keepList.Values) { if (keep.KeepComponents.Count != 0) { keep.KeepComponents.Sort(); } } } LoadHookPoints(); log.Info("Loaded " + m_keepList.Count + " keeps successfully"); } if (ServerProperties.Properties.USE_KEEP_BALANCING) { UpdateBaseLevels(); } if (ServerProperties.Properties.USE_LIVE_KEEP_BONUSES) { KeepBonusMgr.UpdateCounts(); } return(true); }
public void OnCommand(GameClient client, string[] args) { uint hour = WorldMgr.GetCurrentGameTime() / 1000 / 60 / 60; uint minute = WorldMgr.GetCurrentGameTime() / 1000 / 60 % 60; uint seconde = WorldMgr.GetCurrentGameTime() / 1000 % 60; string name = "(NoName)"; var info = new List <string>(); info.Add(" Current Region : " + client.Player.CurrentRegionID); info.Add(" "); Type regionType = client.Player.CurrentRegion.GetType(); info.Add(" Region ClassType: " + regionType.FullName); info.Add(" "); if (client.Player.TargetObject != null) { if (!string.IsNullOrEmpty(client.Player.TargetObject.Name)) { name = client.Player.TargetObject.Name; } #region Mob /********************* MOB ************************/ if (client.Player.TargetObject is GameNPC) { var target = client.Player.TargetObject as GameNPC; if (target.NPCTemplate != null) { info.Add(" + NPCTemplate: " + "[" + target.NPCTemplate.TemplateId + "] " + target.NPCTemplate.Name); } info.Add(" + Class: " + target.GetType().ToString()); info.Add(" + Brain: " + (target.Brain == null ? "(null)" : target.Brain.GetType().ToString())); if (target.LoadedFromScript) { info.Add(" + Loaded: from Script"); } else { info.Add(" + Loaded: from Database"); } info.Add(" "); if (client.Player.TargetObject is GameMerchant) { var targetM = client.Player.TargetObject as GameMerchant; info.Add(" + Is Merchant "); if (targetM.TradeItems != null) { info.Add(" + Sell List: \n " + targetM.TradeItems.ItemsListID); } else { info.Add(" + Sell List: Not Present !\n"); } info.Add(" "); } if (client.Player.TargetObject is GamePet) { var targetP = client.Player.TargetObject as GamePet; info.Add(" + Is Pet "); info.Add(" + Pet Owner: " + targetP.Owner); info.Add(" "); } if (client.Player.TargetObject is GameMovingObject) { var targetM = client.Player.TargetObject as GameMovingObject; info.Add(" + Is GameMovingObject "); info.Add(" + ( Boats - Siege weapons - Custom Object"); info.Add(" + Emblem: " + targetM.Emblem); info.Add(" "); } info.Add(" + Name: " + name); if (target.GuildName != null && target.GuildName.Length > 0) { info.Add(" + Guild: " + target.GuildName); } info.Add(" + Level: " + target.Level); info.Add(" + Realm: " + GlobalConstants.RealmToName(target.Realm)); info.Add(" + Model: " + target.Model); info.Add(" + Size " + target.Size); info.Add(string.Format(" + Flags: {0} (0x{1})", ((GameNPC.eFlags)target.Flags).ToString("G"), target.Flags.ToString("X"))); info.Add(" "); info.Add(" + Speed(current/max): " + target.CurrentSpeed + "/" + target.MaxSpeedBase); info.Add(" + Health: " + target.Health + "/" + target.MaxHealth); info.Add(" + Endu: " + target.Endurance + "/" + target.MaxEndurance); info.Add(" + Mana: " + target.Mana + "/" + target.MaxMana); info.Add(" + Conc: " + target.Concentration + "/" + target.MaxConcentration); IOldAggressiveBrain aggroBrain = target.Brain as IOldAggressiveBrain; if (aggroBrain != null) { info.Add(" + Aggro level: " + aggroBrain.AggroLevel); info.Add(" + Aggro range: " + aggroBrain.AggroRange); if (target.MaxDistance < 0) { info.Add(" + MaxDistance: " + -target.MaxDistance * aggroBrain.AggroRange / 100); } else { info.Add(" + MaxDistance: " + target.MaxDistance); } } else { info.Add(" + Not aggressive brain"); } if (target.NPCTemplate != null) { info.Add(" + NPCTemplate: " + "[" + target.NPCTemplate.TemplateId + "] " + target.NPCTemplate.Name); } info.Add(" + Roaming Range: " + target.RoamingRange); TimeSpan respawn = TimeSpan.FromMilliseconds(target.RespawnInterval); if (target.RespawnInterval <= 0) { info.Add(" + Respawn: NPC will not respawn"); } else { string days = ""; string hours = ""; if (respawn.Days > 0) { days = respawn.Days + " days "; } if (respawn.Hours > 0) { hours = respawn.Hours + " hours "; } info.Add(" + Respawn: " + days + hours + respawn.Minutes + " minutes " + respawn.Seconds + " seconds"); info.Add(" + SpawnPoint: " + target.SpawnPoint.X + ", " + target.SpawnPoint.Y + ", " + target.SpawnPoint.Z); } if (target.QuestListToGive.Count > 0) { info.Add(" + Quests to give: " + target.QuestListToGive.Count); } if (target.PathID != null && target.PathID.Length > 0) { info.Add(" + Path: " + target.PathID); } if (target.OwnerID != null && target.OwnerID.Length > 0) { info.Add(" + OwnerID: " + target.OwnerID); } info.Add(" "); info.Add($" + {target.Strength} STR / {target.Constitution} CON / {target.Dexterity} DEX / {target.Quickness} QUI"); info.Add($" + {target.Intelligence} INT / {target.Empathy} EMP / {target.Piety} PIE / {target.Charisma} CHR"); info.Add($" + {target.WeaponDps} DPS / {target.WeaponSpd} SPD / {target.ArmorFactor} AF / {target.ArmorAbsorb} ABS"); info.Add($" + {target.BlockChance}% Block / {target.ParryChance}% Parry / {target.EvadeChance}% Evade"); info.Add(" + Damage type: " + target.MeleeDamageType); if (target.LeftHandSwingChance > 0) { info.Add(" + Left Swing %: " + target.LeftHandSwingChance); } if (target.Abilities != null && target.Abilities.Count > 0) { info.Add(" + Abilities: " + target.Abilities.Count); } if (target.Spells != null && target.Spells.Count > 0) { info.Add(" + Spells: " + target.Spells.Count); } if (target.Styles != null && target.Styles.Count > 0) { info.Add(" + Styles: " + target.Styles.Count); } info.Add(" "); if (target.Race > 0) { info.Add(" + Race: " + target.Race); } if (target.BodyType > 0) { info.Add(" + Body Type: " + target.BodyType); } if (target.GetDamageResist(eProperty.Resist_Crush) > 0) { info.Add(" + Resist Crush: " + target.GetDamageResist(eProperty.Resist_Crush)); } if (target.GetDamageResist(eProperty.Resist_Slash) > 0) { info.Add(" + Resist Slash: " + target.GetDamageResist(eProperty.Resist_Slash)); } if (target.GetDamageResist(eProperty.Resist_Thrust) > 0) { info.Add(" + Resist Thrust: " + target.GetDamageResist(eProperty.Resist_Thrust)); } if (target.GetDamageResist(eProperty.Resist_Heat) > 0) { info.Add(" + Resist Heat: " + target.GetDamageResist(eProperty.Resist_Heat)); } if (target.GetDamageResist(eProperty.Resist_Cold) > 0) { info.Add(" + Resist Cold: " + target.GetDamageResist(eProperty.Resist_Cold)); } if (target.GetDamageResist(eProperty.Resist_Matter) > 0) { info.Add(" + Resist Matter: " + target.GetDamageResist(eProperty.Resist_Matter)); } if (target.GetDamageResist(eProperty.Resist_Natural) > 0) { info.Add(" + Resist Natural: " + target.GetDamageResist(eProperty.Resist_Natural)); } if (target.GetDamageResist(eProperty.Resist_Body) > 0) { info.Add(" + Resist Body: " + target.GetDamageResist(eProperty.Resist_Body)); } if (target.GetDamageResist(eProperty.Resist_Spirit) > 0) { info.Add(" + Resist Spirit: " + target.GetDamageResist(eProperty.Resist_Spirit)); } if (target.GetDamageResist(eProperty.Resist_Energy) > 0) { info.Add(" + Resist Energy: " + target.GetDamageResist(eProperty.Resist_Energy)); } info.Add(" + Active weapon slot: " + target.ActiveWeaponSlot); info.Add(" + Visible weapon slot: " + target.VisibleActiveWeaponSlots); if (target.EquipmentTemplateID != null && target.EquipmentTemplateID.Length > 0) { info.Add(" + Equipment Template ID: " + target.EquipmentTemplateID); } if (target.Inventory != null) { info.Add(" + Inventory: " + target.Inventory.AllItems.Count + " items"); } info.Add(" "); info.Add(" + Mob_ID: " + target.InternalID); info.Add(" + Position: " + target.Position.ToString("F0") + ", " + target.Heading); info.Add(" + OID: " + target.ObjectID); info.Add(" + Package ID: " + target.PackageID); /* if (target.Brain != null && target.Brain.IsActive) * { * info.Add(target.Brain.GetType().FullName); * info.Add(target.Brain.ToString()); * info.Add(""); * } */ info.Add(""); info.Add(" ------ State ------"); if (target.IsReturningHome || target.IsReturningToSpawnPoint) { info.Add("IsReturningHome: " + target.IsReturningHome); info.Add("IsReturningToSpawnPoint: " + target.IsReturningToSpawnPoint); info.Add(""); } info.Add("InCombat: " + target.InCombat); info.Add("AttackState: " + target.AttackState); info.Add("LastCombatPVE: " + target.LastAttackedByEnemyTickPvE); info.Add("LastCombatPVP: " + target.LastAttackedByEnemyTickPvP); if (target.InCombat || target.AttackState) { info.Add("RegionTick: " + target.CurrentRegion.Time); } info.Add(""); if (target.TargetObject != null) { info.Add("TargetObject: " + target.TargetObject.Name); info.Add("InView: " + target.TargetInView); } if (target.Brain != null && target.Brain is StandardMobBrain) { Dictionary <GameLiving, long> aggroList = (target.Brain as StandardMobBrain).AggroTable; if (aggroList.Count > 0) { info.Add(""); info.Add("Aggro List:"); foreach (GameLiving living in aggroList.Keys) { info.Add(living.Name + ": " + aggroList[living]); } } } if (target.Attackers != null && target.Attackers.Count > 0) { info.Add(""); info.Add("Attacker List:"); foreach (GameLiving attacker in target.Attackers) { info.Add(attacker.Name); } } if (target.EffectList.Count > 0) { info.Add(""); info.Add("Effect List:"); foreach (IGameEffect effect in target.EffectList) { info.Add(effect.Name + " remaining " + effect.RemainingTime); } } info.Add(""); info.Add(" + Loot:"); var template = DOLDB <LootTemplate> .SelectObjects(DB.Column(nameof(LootTemplate.TemplateName)).IsEqualTo(target.Name)); foreach (LootTemplate loot in template) { ItemTemplate drop = GameServer.Database.FindObjectByKey <ItemTemplate>(loot.ItemTemplateID); string message = ""; if (drop == null) { message += loot.ItemTemplateID + " (Template Not Found)"; } else { message += drop.Name + " (" + drop.Id_nb + ")"; } message += " Chance: " + loot.Chance.ToString(); info.Add("- " + message); } } #endregion Mob #region Player /********************* PLAYER ************************/ if (client.Player.TargetObject is GamePlayer) { var target = client.Player.TargetObject as GamePlayer; info.Add("PLAYER INFORMATION (Client # " + target.Client.SessionID + ")"); info.Add(" - Name : " + target.Name); info.Add(" - Lastname : " + target.LastName); info.Add(" - Realm : " + GlobalConstants.RealmToName(target.Realm)); info.Add(" - Level : " + target.Level); info.Add(" - Class : " + target.CharacterClass.Name); info.Add(" - Guild : " + target.GuildName); info.Add(" "); info.Add(" - Account Name : " + target.AccountName); info.Add(" - IP : " + target.Client.Account.LastLoginIP); info.Add(" - Priv. Level : " + target.Client.Account.PrivLevel); info.Add(" - Client Version: " + target.Client.Account.LastClientVersion); info.Add(" "); info.Add(" - Craftingskill : " + target.CraftingPrimarySkill + ""); info.Add(" - Model ID : " + target.Model); info.Add(" - AFK Message: " + target.TempProperties.getProperty <string>(GamePlayer.AFK_MESSAGE) + ""); info.Add(" "); info.Add(" - Money : " + Money.GetString(target.GetCurrentMoney()) + "\n"); info.Add(" - Speed : " + target.MaxSpeedBase); info.Add(" - XPs : " + target.Experience); info.Add(" - RPs : " + target.RealmPoints); info.Add(" - BPs : " + target.BountyPoints); String sCurrent = ""; String sTitle = ""; int cnt = 0; info.Add(" "); info.Add("SPECCING INFORMATIONS "); info.Add(" - Remaining spec. points : " + target.SkillSpecialtyPoints); sTitle = " - Player specialisations / level: \n"; sCurrent = ""; foreach (Specialization spec in target.GetSpecList()) { sCurrent += " - " + spec.Name + " = " + spec.Level + " \n"; } info.Add(sTitle + sCurrent); sCurrent = ""; sTitle = ""; info.Add(" "); info.Add("CHARACTER STATS "); info.Add(" - Maximum Health : " + target.MaxHealth); info.Add(" - Current AF : " + target.GetModified(eProperty.ArmorFactor)); info.Add(" - Current ABS : " + target.GetModified(eProperty.ArmorAbsorption)); for (eProperty stat = eProperty.Stat_First; stat <= eProperty.Stat_Last; stat++, cnt++) { sTitle += GlobalConstants.PropertyToName(stat); sCurrent += target.GetModified(stat); info.Add(" - " + sTitle + " : " + sCurrent); sCurrent = ""; sTitle = ""; } sCurrent = ""; sTitle = ""; cnt = 0; for (eProperty res = eProperty.Resist_First; res <= eProperty.Resist_Last; res++, cnt++) { sTitle += GlobalConstants.PropertyToName(res); sCurrent += target.GetModified(res); info.Add(" - " + sTitle + " : " + sCurrent); sCurrent = ""; sTitle = ""; } info.Add(" "); info.Add(" "); info.Add(" - Respecs dol : " + target.RespecAmountDOL); info.Add(" - Respecs single : " + target.RespecAmountSingleSkill); info.Add(" - Respecs full : " + target.RespecAmountAllSkill); info.Add(" "); info.Add(" "); info.Add(" --------------------------------------"); info.Add(" ----- Inventory Equiped -----"); info.Add(" --------------------------------------"); ////////////// Inventaire ///////////// info.Add(" ----- Money:"); info.Add(Money.GetShortString(target.GetCurrentMoney())); info.Add(" "); info.Add(" ----- Wearing:"); foreach (InventoryItem item in target.Inventory.EquippedItems) { info.Add(" [" + GlobalConstants.SlotToName(item.Item_Type) + "] " + item.Name); } info.Add(" "); } #endregion Player #region StaticItem /********************* OBJECT ************************/ if (client.Player.TargetObject is GameStaticItem) { var target = client.Player.TargetObject as GameStaticItem; info.Add(" ------- OBJECT ------\n"); info.Add(" Name: " + name); info.Add(" Model: " + target.Model); info.Add(" Emblem: " + target.Emblem); info.Add(" Realm: " + target.Realm); if (target.Owners.LongLength > 0) { info.Add(" "); info.Add(" Owner Name: " + target.Owners[0].Name); } info.Add(" "); info.Add(" OID: " + target.ObjectID); info.Add(" Type: " + target.GetType()); WorldInventoryItem invItem = target as WorldInventoryItem; if (invItem != null) { info.Add(" Count: " + invItem.Item.Count); } info.Add(" "); info.Add(" Location: " + target.Position.ToString("F0")); } #endregion StaticItem #region Door /********************* DOOR ************************/ if (client.Player.TargetObject is GameDoor) { var target = client.Player.TargetObject as GameDoor; string Realmname = ""; string statut = ""; name = target.Name; if (target.Realm == eRealm.None) { Realmname = "None"; } if (target.Realm == eRealm.Albion) { Realmname = "Albion"; } if (target.Realm == eRealm.Midgard) { Realmname = "Midgard"; } if (target.Realm == eRealm.Hibernia) { Realmname = "Hibernia"; } if (target.Realm == eRealm.Door) { Realmname = "All"; } if (target.Locked == 1) { statut = " Locked"; } if (target.Locked == 0) { statut = " Unlocked"; } info.Add(" ------- DOOR ------\n"); info.Add(" "); info.Add(" + Name : " + target.Name); info.Add(" + ID : " + target.DoorID); info.Add(" + Realm : " + (int)target.Realm + " : " + Realmname); info.Add(" + Level : " + target.Level); info.Add(" + Guild : " + target.GuildName); info.Add(" + Health : " + target.Health + " / " + target.MaxHealth); info.Add(" + Statut : " + statut); info.Add(" + Type : " + DoorRequestHandler.m_handlerDoorID / 100000000); info.Add(" "); info.Add(" + Position : " + target.Position.ToString("F0")); info.Add(" + Heading : " + target.Heading); } #endregion Door #region Keep /********************* KEEP ************************/ if (client.Player.TargetObject is GameKeepComponent) { var target = client.Player.TargetObject as GameKeepComponent; name = target.Name; string realm = " other realm"; if ((byte)target.Realm == 0) { realm = " Monster"; } if ((byte)target.Realm == 1) { realm = " Albion"; } if ((byte)target.Realm == 2) { realm = " Midgard"; } if ((byte)target.Realm == 3) { realm = " Hibernia"; } info.Add(" ------- KEEP ------\n"); info.Add(" + Name : " + target.Name); info.Add(" + KeepID : " + target.Keep.KeepID); info.Add(" + Level : " + target.Level); info.Add(" + BaseLevel : " + target.Keep.BaseLevel); info.Add(" + Realm : " + realm); info.Add(" "); info.Add(" + Model : " + target.Model); info.Add(" + Skin : " + target.Skin); info.Add(" + Height : " + target.Height); info.Add(" + ID : " + target.ID); info.Add(" "); info.Add(" + Health : " + target.Health); info.Add(" + IsRaized : " + target.IsRaized); info.Add(" + Status : " + target.Status); info.Add(" "); info.Add(" + Climbing : " + target.Climbing); info.Add(" "); info.Add(" + ComponentX : " + target.ComponentX); info.Add(" + ComponentY : " + target.ComponentY); info.Add(" + ComponentHeading : " + target.ComponentHeading); info.Add(" "); info.Add(" + HookPoints : " + target.HookPoints.Count); info.Add(" + Positions : " + target.Positions.Count); info.Add(" "); info.Add(" + RealmPointsValue : " + target.RealmPointsValue); info.Add(" + ExperienceValue : " + target.ExperienceValue); info.Add(" + AttackRange : " + target.AttackRange); info.Add(" "); if (GameServer.KeepManager.GetFrontierKeeps().Contains(target.Keep)) { info.Add(" + Keep Manager : " + GameServer.KeepManager.GetType().FullName); info.Add(" + Frontiers"); } else if (GameServer.KeepManager.GetBattleground(target.CurrentRegionID) != null) { info.Add(" + Keep Manager : " + GameServer.KeepManager.GetType().FullName); Battleground bg = GameServer.KeepManager.GetBattleground(client.Player.CurrentRegionID); info.Add(" + Battleground (" + bg.MinLevel + " to " + bg.MaxLevel + ", max RL: " + bg.MaxRealmLevel + ")"); } else { info.Add(" + Keep Manager : Not Managed"); } } #endregion Keep client.Out.SendCustomTextWindow("[ " + name + " ]", info); return; } if (client.Player.TargetObject == null) { /*********************** HOUSE *************************/ if (client.Player.InHouse) { #region House House house = client.Player.CurrentHouse as House; name = house.Name; int level = house.Model - ((house.Model - 1) / 4) * 4; TimeSpan due = (house.LastPaid.AddDays(ServerProperties.Properties.RENT_DUE_DAYS).AddHours(1) - DateTime.Now); info.Add(" ------- HOUSE ------\n"); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.Owner", name)); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.Lotnum", house.HouseNumber)); info.Add("Unique ID: " + house.UniqueID); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.Level", level)); info.Add(" "); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.Porch")); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.PorchEnabled", (house.Porch ? " Present" : " Not Present"))); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.PorchRoofColor", Color(house.PorchRoofColor))); info.Add(" "); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.ExteriorMaterials")); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.RoofMaterial", MaterialWall(house.RoofMaterial))); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.WallMaterial", MaterialWall(house.WallMaterial))); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.DoorMaterial", MaterialDoor(house.DoorMaterial))); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.TrussMaterial", MaterialTruss(house.TrussMaterial))); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.PorchMaterial", MaterialTruss(house.PorchMaterial))); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.WindowMaterial", MaterialTruss(house.WindowMaterial))); info.Add(" "); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.ExteriorUpgrades")); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.OutdoorGuildBanner", ((house.OutdoorGuildBanner) ? " Present" : " Not Present"))); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.OutdoorGuildShield", ((house.OutdoorGuildShield) ? " Present" : " Not Present"))); info.Add(" "); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.InteriorUpgrades")); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.IndoorGuildBanner", ((house.IndoorGuildBanner) ? " Present" : " Not Present"))); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.IndoorGuildShield", ((house.IndoorGuildShield) ? " Present" : " Not Present"))); info.Add(" "); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.InteriorCarpets")); if (house.Rug1Color != 0) { info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.Rug1Color", Color(house.Rug1Color))); } if (house.Rug2Color != 0) { info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.Rug2Color", Color(house.Rug2Color))); } if (house.Rug3Color != 0) { info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.Rug3Color", Color(house.Rug3Color))); } if (house.Rug4Color != 0) { info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.Rug4Color", Color(house.Rug4Color))); } info.Add(" "); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.Lockbox", Money.GetString(house.KeptMoney))); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.RentalPrice", Money.GetString(HouseMgr.GetRentByModel(house.Model)))); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.MaxLockbox", Money.GetString(HouseMgr.GetRentByModel(house.Model) * ServerProperties.Properties.RENT_LOCKBOX_PAYMENTS))); info.Add(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.RentDueIn", due.Days, due.Hours)); #endregion House client.Out.SendCustomTextWindow(LanguageMgr.GetTranslation(client.Account.Language, "House.SendHouseInfo.HouseOwner", name), info); } else // No target and not in a house { string realm = " other realm"; if (client.Player.CurrentZone.Realm == eRealm.Albion) { realm = " Albion"; } if (client.Player.CurrentZone.Realm == eRealm.Midgard) { realm = " Midgard"; } if (client.Player.CurrentZone.Realm == eRealm.Hibernia) { realm = " Hibernia"; } info.Add(" Game Time: \t" + hour.ToString() + ":" + minute.ToString()); info.Add(" "); info.Add(" Server Rules: " + GameServer.ServerRules.GetType().FullName); if (GameServer.KeepManager.FrontierRegionsList.Contains(client.Player.CurrentRegionID)) { info.Add(" Keep Manager: " + GameServer.KeepManager.GetType().FullName); info.Add(" Frontiers"); } else if (GameServer.KeepManager.GetBattleground(client.Player.CurrentRegionID) != null) { info.Add(" Keep Manager: " + GameServer.KeepManager.GetType().FullName); Battleground bg = GameServer.KeepManager.GetBattleground(client.Player.CurrentRegionID); info.Add(" Battleground (" + bg.MinLevel + " to " + bg.MaxLevel + ", max RL: " + bg.MaxRealmLevel + ")"); } else { info.Add(" Keep Manager : None for this region"); } info.Add(" "); info.Add(" Server players: " + WorldMgr.GetAllPlayingClientsCount()); info.Add(" "); info.Add(" Region Players:"); info.Add(" All players: " + WorldMgr.GetClientsOfRegionCount(client.Player.CurrentRegion.ID)); info.Add(" "); info.Add(" Alb players: " + WorldMgr.GetClientsOfRegionCount(client.Player.CurrentRegion.ID, eRealm.Albion)); info.Add(" Hib players: " + WorldMgr.GetClientsOfRegionCount(client.Player.CurrentRegion.ID, eRealm.Hibernia)); info.Add(" Mid players: " + WorldMgr.GetClientsOfRegionCount(client.Player.CurrentRegion.ID, eRealm.Midgard)); info.Add(" "); info.Add(" Total objects in region: " + client.Player.CurrentRegion.TotalNumberOfObjects); info.Add(" "); info.Add(" NPC in zone:"); info.Add(" Alb : " + client.Player.CurrentZone.GetNPCsOfZone(eRealm.Albion).Count); info.Add(" Hib : " + client.Player.CurrentZone.GetNPCsOfZone(eRealm.Hibernia).Count); info.Add(" Mid: " + client.Player.CurrentZone.GetNPCsOfZone(eRealm.Midgard).Count); info.Add(" None : " + client.Player.CurrentZone.GetNPCsOfZone(eRealm.None).Count); info.Add(" "); info.Add(" Total objects in zone: " + client.Player.CurrentZone.TotalNumberOfObjects); info.Add(" "); info.Add(" Zone Description: " + client.Player.CurrentZone.Description); info.Add(" Zone Realm: " + realm); info.Add(" Zone ID: " + client.Player.CurrentZone.ID); info.Add(" Zone IsDungeon: " + client.Player.CurrentZone.IsDungeon); info.Add(" Zone SkinID: " + client.Player.CurrentZone.ZoneSkinID); info.Add(" Zone X: " + client.Player.CurrentZone.XOffset); info.Add(" Zone Y: " + client.Player.CurrentZone.YOffset); info.Add(" Zone Width: " + client.Player.CurrentZone.Width); info.Add(" Zone Height: " + client.Player.CurrentZone.Height); info.Add(" Zone DivingEnabled: " + client.Player.CurrentZone.IsDivingEnabled); info.Add(" Zone Waterlevel: " + client.Player.CurrentZone.Waterlevel); info.Add(" "); info.Add(" Region Name: " + client.Player.CurrentRegion.Name); info.Add(" Region Description: " + client.Player.CurrentRegion.Description); info.Add(" Region Skin: " + client.Player.CurrentRegion.Skin); info.Add(" Region ID: " + client.Player.CurrentRegion.ID); info.Add(" Region Expansion: " + client.Player.CurrentRegion.Expansion); info.Add(" Region IsRvR: " + client.Player.CurrentRegion.IsRvR); info.Add(" Region IsFrontier: " + client.Player.CurrentRegion.IsFrontier); info.Add(" Region IsDungeon: " + client.Player.CurrentRegion.IsDungeon); info.Add(" Zone in Region: " + client.Player.CurrentRegion.Zones.Count); info.Add(" Region WaterLevel: " + client.Player.CurrentRegion.WaterLevel); info.Add(" Region HousingEnabled: " + client.Player.CurrentRegion.HousingEnabled); info.Add(" Region IsDisabled: " + client.Player.CurrentRegion.IsDisabled); info.Add(" "); info.Add(" Region ServerIP: " + client.Player.CurrentRegion.ServerIP); info.Add(" Region ServerPort: " + client.Player.CurrentRegion.ServerPort); client.Out.SendCustomTextWindow("[ " + client.Player.CurrentRegion.Description + " ]", info); } } }
/// <summary> /// Restore All Effect From PlayerXEffect Data Table /// </summary> public virtual void RestoreAllEffects() { GamePlayer player = m_owner as GamePlayer; if (player == null || player.DBCharacter == null || GameServer.Database == null) { return; } var effs = DOLDB <PlayerXEffect> .SelectObjects(DB.Column("ChardID").IsEqualTo(player.ObjectId)); if (effs == null) { return; } foreach (PlayerXEffect eff in effs) { GameServer.Database.DeleteObject(eff); } foreach (PlayerXEffect eff in effs.GroupBy(e => e.Var1).Select(e => e.First())) { if (eff.SpellLine == GlobalSpellsLines.Reserved_Spells) { continue; } bool good = true; Spell spell = SkillBase.GetSpellByID(eff.Var1); if (spell == null) { good = false; } SpellLine line = null; if (!Util.IsEmpty(eff.SpellLine)) { line = SkillBase.GetSpellLine(eff.SpellLine, false); if (line == null) { good = false; } } else { good = false; } if (good) { ISpellHandler handler = ScriptMgr.CreateSpellHandler(player, spell, line); GameSpellEffect e; e = new GameSpellEffect(handler, eff.Duration, spell.Frequency); e.RestoredEffect = true; int[] vars = { eff.Var1, eff.Var2, eff.Var3, eff.Var4, eff.Var5, eff.Var6 }; e.RestoreVars = vars; e.Start(player); } } }
public override void SendCharacterOverview(eRealm realm) { int firstAccountSlot; switch (realm) { case eRealm.Albion: firstAccountSlot = 100; break; case eRealm.Midgard: firstAccountSlot = 200; break; case eRealm.Hibernia: firstAccountSlot = 300; break; default: throw new Exception("CharacterOverview requested for unknown realm " + realm); } using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.CharacterOverview))) { pak.FillString(m_gameClient.Account.Name, 24); IList <InventoryItem> items; DOLCharacters[] characters = m_gameClient.Account.Characters; if (characters == null) { pak.Fill(0x0, 1840); } else { for (int i = firstAccountSlot; i < firstAccountSlot + 10; i++) { bool written = false; for (int j = 0; j < characters.Length && written == false; j++) { if (characters[j].AccountSlot == i) { pak.FillString(characters[j].Name, 24); items = DOLDB <InventoryItem> .SelectObjects(DB.Column("OwnerID").IsEqualTo(characters[j].ObjectId).And(DB.Column("SlotPosition").IsGreaterOrEqualTo(10)).And(DB.Column("SlotPosition").IsLessOrEqualTo(37))); byte ExtensionTorso = 0; byte ExtensionGloves = 0; byte ExtensionBoots = 0; foreach (InventoryItem item in items) { switch (item.SlotPosition) { case 22: ExtensionGloves = item.Extension; break; case 23: ExtensionBoots = item.Extension; break; case 25: ExtensionTorso = item.Extension; break; default: break; } } pak.WriteByte(0x01); pak.WriteByte((byte)characters[j].EyeSize); pak.WriteByte((byte)characters[j].LipSize); pak.WriteByte((byte)characters[j].EyeColor); pak.WriteByte((byte)characters[j].HairColor); pak.WriteByte((byte)characters[j].FaceType); pak.WriteByte((byte)characters[j].HairStyle); pak.WriteByte((byte)((ExtensionBoots << 4) | ExtensionGloves)); pak.WriteByte((byte)((ExtensionTorso << 4) | (characters[j].IsCloakHoodUp ? 0x1 : 0x0))); pak.WriteByte((byte)characters[j].CustomisationStep); //1 = auto generate config, 2= config ended by player, 3= enable config to player pak.WriteByte((byte)characters[j].MoodType); pak.Fill(0x0, 13); //0 String Region reg = WorldMgr.GetRegion((ushort)characters[j].Region); if (reg != null) { var description = m_gameClient.GetTranslatedSpotDescription(reg, characters[j].Xpos, characters[j].Ypos, characters[j].Zpos); pak.FillString(description, 24); } else { pak.Fill(0x0, 24); //No known location } if (characters[j].Class == 0) { pak.FillString("", 24); //Class name } else { pak.FillString(((eCharacterClass)characters[j].Class).ToString(), 24); //Class name } //pak.FillString(GamePlayer.RACENAMES[characters[j].Race], 24); pak.FillString(m_gameClient.RaceToTranslatedName(characters[j].Race, characters[j].Gender), 24); pak.WriteByte((byte)characters[j].Level); pak.WriteByte((byte)characters[j].Class); pak.WriteByte((byte)characters[j].Realm); pak.WriteByte((byte)((((characters[j].Race & 0x10) << 2) + (characters[j].Race & 0x0F)) | (characters[j].Gender << 4))); // race max value can be 0x1F pak.WriteShortLowEndian((ushort)characters[j].CurrentModel); pak.WriteByte((byte)characters[j].Region); if (reg == null || (int)m_gameClient.ClientType > reg.Expansion) { pak.WriteByte(0x00); } else { pak.WriteByte((byte)(reg.Expansion + 1)); //0x04-Cata zone, 0x05 - DR zone } pak.WriteInt(0x0); // Internal database ID pak.WriteByte((byte)characters[j].Strength); pak.WriteByte((byte)characters[j].Dexterity); pak.WriteByte((byte)characters[j].Constitution); pak.WriteByte((byte)characters[j].Quickness); pak.WriteByte((byte)characters[j].Intelligence); pak.WriteByte((byte)characters[j].Piety); pak.WriteByte((byte)characters[j].Empathy); pak.WriteByte((byte)characters[j].Charisma); int found = 0; //16 bytes: armor model for (int k = 0x15; k < 0x1D; k++) { found = 0; foreach (InventoryItem item in items) { if (item.SlotPosition == k && found == 0) { pak.WriteShortLowEndian((ushort)item.Model); found = 1; } } if (found == 0) { pak.WriteShort(0x00); } } //16 bytes: armor color for (int k = 0x15; k < 0x1D; k++) { int l; if (k == 0x15 + 3) { //shield emblem l = (int)eInventorySlot.LeftHandWeapon; } else { l = k; } found = 0; foreach (InventoryItem item in items) { if (item.SlotPosition == l && found == 0) { if (item.Emblem != 0) { pak.WriteShortLowEndian((ushort)item.Emblem); } else { pak.WriteShortLowEndian((ushort)item.Color); } found = 1; } } if (found == 0) { pak.WriteShort(0x00); } } //8 bytes: weapon model for (int k = 0x0A; k < 0x0E; k++) { found = 0; foreach (InventoryItem item in items) { if (item.SlotPosition == k && found == 0) { pak.WriteShortLowEndian((ushort)item.Model); found = 1; } } if (found == 0) { pak.WriteShort(0x00); } } if (characters[j].ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.TwoHanded) { pak.WriteByte(0x02); pak.WriteByte(0x02); } else if (characters[j].ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.Distance) { pak.WriteByte(0x03); pak.WriteByte(0x03); } else { byte righthand = 0xFF; byte lefthand = 0xFF; foreach (InventoryItem item in items) { if (item.SlotPosition == (int)eInventorySlot.RightHandWeapon) { righthand = 0x00; } if (item.SlotPosition == (int)eInventorySlot.LeftHandWeapon) { lefthand = 0x01; } } if (righthand == lefthand) { if (characters[j].ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.TwoHanded) { righthand = lefthand = 0x02; } else if (characters[j].ActiveWeaponSlot == (byte)GameLiving.eActiveWeaponSlot.Distance) { righthand = lefthand = 0x03; } } pak.WriteByte(righthand); pak.WriteByte(lefthand); } if (reg == null || reg.Expansion != 1) { pak.WriteByte(0x00); } else { pak.WriteByte(0x01); //0x01=char in ShroudedIsles zone, classic client can't "play" } //pak.WriteByte(0x00); // unk2 pak.WriteByte((byte)characters[j].Constitution); written = true; } } if (written == false) { pak.Fill(0x0, 184); } } // pak.Fill(0x0,184); //Slot 9 // pak.Fill(0x0,184); //Slot 10 } pak.Fill(0x0, 0x82); //Don't know why so many trailing 0's | Corillian: Cuz they're stupid like that ;) SendTCP(pak); } }
public void OnCommand(GameClient client, string[] args) { if (args.Length < 3) { DisplaySyntax(client); return; } GameClient gc = null; if (args[2].StartsWith("#")) { try { var sessionID = Convert.ToUInt32(args[1].Substring(1)); gc = WorldMgr.GetClientFromID(sessionID); } catch { DisplayMessage(client, "Invalid client ID"); } } else { gc = WorldMgr.GetClientByPlayerName(args[2], false, false); } var acc = gc != null ? gc.Account : DOLDB <Account> .SelectObject(DB.Column("Name").IsLike(args[2])); if (acc == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.UnableToFindPlayer"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (client.Account.PrivLevel < acc.PrivLevel) { DisplayMessage(client, "Your privlevel is not high enough to ban this player."); return; } if (client.Account.Name == acc.Name) { DisplayMessage(client, "Your can't ban yourself!"); return; } try { DBBannedAccount b = new DBBannedAccount { DateBan = DateTime.Now, Author = client.Player.Name, Ip = acc.LastLoginIP, Account = acc.Name }; if (args.Length >= 4) { b.Reason = String.Join(" ", args, 3, args.Length - 3); } else { b.Reason = "No Reason."; } switch (args[1].ToLower()) { #region Account case "account": var acctBans = DOLDB <DBBannedAccount> .SelectObjects(DB.Column("Type").IsEqualTo("A").Or(DB.Column("Type").IsEqualTo("B")).And(DB.Column("Account").IsEqualTo(acc.Name))); if (acctBans.Count > 0) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.AAlreadyBanned"), eChatType.CT_Important, eChatLoc.CL_SystemWindow); return; } b.Type = "A"; client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.ABanned", acc.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow); break; #endregion Account #region IP case "ip": var ipBans = DOLDB <DBBannedAccount> .SelectObjects(DB.Column("Type").IsEqualTo("I").Or(DB.Column("Type").IsEqualTo("B")).And(DB.Column("Ip").IsEqualTo(acc.LastLoginIP))); if (ipBans.Count > 0) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.IAlreadyBanned"), eChatType.CT_Important, eChatLoc.CL_SystemWindow); return; } b.Type = "I"; client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.IBanned", acc.LastLoginIP), eChatType.CT_Important, eChatLoc.CL_SystemWindow); break; #endregion IP #region Both case "both": var acctIpBans = DOLDB <DBBannedAccount> .SelectObjects(DB.Column("Type").IsEqualTo("B").And(DB.Column("Account").IsEqualTo(acc.Name)).And(DB.Column("Ip").IsEqualTo(acc.LastLoginIP))); if (acctIpBans.Count > 0) { client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.BAlreadyBanned"), eChatType.CT_Important, eChatLoc.CL_SystemWindow); return; } b.Type = "B"; client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Ban.BBanned", acc.Name, acc.LastLoginIP), eChatType.CT_Important, eChatLoc.CL_SystemWindow); break; #endregion Both #region Default default: { DisplaySyntax(client); return; } #endregion Default } GameServer.Database.AddObject(b); if (log.IsInfoEnabled) { log.Info("Ban added [" + args[1].ToLower() + "]: " + acc.Name + "(" + acc.LastLoginIP + ")"); } return; } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("/ban Exception", e); } } // if not returned here, there is an error DisplaySyntax(client); }
public void Update() { if (log.IsInfoEnabled) { log.Info("Start Searching for records that need update..."); } // Change the Leader Relation if Missing var alliances = DOLDB <DBAlliance> .SelectObjects(DB.Column("LeaderGuildID").IsEqualTo(string.Empty).Or(DB.Column("LeaderGuildID").IsNull())); if (alliances.Any()) { var leadingGuilds = DOLDB <DBGuild> .MultipleSelectObjects(alliances.Select(al => DB.Column("AllianceID").IsEqualTo(al.ObjectId).And(DB.Column("GuildName").IsEqualTo(al.AllianceName)))); var alliancesWithLeader = leadingGuilds.Select((gd, i) => { var al = alliances[i]; DBGuild lead = null; try { lead = gd.SingleOrDefault(gld => al.AllianceName.Equals(gld.GuildName)); } catch (Exception e) { if (log.IsErrorEnabled) { log.ErrorFormat("Wrong records while trying to retrieve Guild Leader (AllianceID: {0}, AllianceName: {1})\n{2}", al.ObjectId, al.AllianceName, e); } } return(new { Alliance = al, Leader = lead }); }).ToArray(); if (log.IsInfoEnabled) { log.InfoFormat("Fixing Alliances without Leader : {0} records found.", alliancesWithLeader.Length); } foreach (var pair in alliancesWithLeader) { if (pair.Leader != null) { pair.Alliance.LeaderGuildID = pair.Leader.GuildID; } else if (log.IsWarnEnabled) { log.WarnFormat("Alliance (ID:{0}, Name:{1}) can't resolve its Leading Guild !", pair.Alliance.ObjectId, pair.Alliance.AllianceName); } } var saved = GameServer.Database.SaveObject(alliancesWithLeader.Select(pair => pair.Alliance)); if (saved && log.IsInfoEnabled) { log.InfoFormat("Finished saving Alliances without Leader successfully!"); } if (!saved && log.IsErrorEnabled) { log.ErrorFormat("Could not save all Alliances without Leader, check logs or records..."); } } if (log.IsInfoEnabled) { log.Info("End of Database Update..."); } }