public override bool AddToWorld() { House house = HouseMgr.GetHouse(HouseNumber); if (house == null) { log.ErrorFormat("CM: Can't find house #{0}!", HouseNumber); return(false); } SetInventoryTemplate(); var houseCM = DOLDB <HouseConsignmentMerchant> .SelectObject(DB.Column(nameof(HouseConsignmentMerchant.HouseNumber)).IsEqualTo(HouseNumber)); if (houseCM != null) { TotalMoney = houseCM.Money; } else { log.ErrorFormat("CM: Can't find HouseConsignmentMerchant entry for CM on lot {0}!", HouseNumber); return(false); } base.AddToWorld(); house.ConsignmentMerchant = this; SetEmblem(); CheckInventory(); return(true); }
/// <summary> /// Not Livelike but looks better - adds the owners guild emblem to the consignment merchants cloak /// </summary> public virtual void SetEmblem() { if (Inventory == null) { return; } House house = HouseMgr.GetHouse(HouseNumber); if (house == null) { return; } if (house.DatabaseItem.GuildHouse) { var guild = DOLDB <DBGuild> .SelectObject(DB.Column(nameof(DBGuild.GuildName)).IsEqualTo(house.DatabaseItem.GuildName)); int emblem = guild.Emblem; InventoryItem cloak = Inventory.GetItem(eInventorySlot.Cloak); if (cloak != null) { cloak.Emblem = emblem; BroadcastLivingEquipmentUpdate(); } } }
static Doppelganger() { DBNpcTemplate chthonian = DOLDB <DBNpcTemplate> .SelectObject(DB.Column("Name").IsEqualTo("chthonian crawler")); if (chthonian != null) { m_petTemplate = new NpcTemplate(chthonian); } }
public static bool HasPermission(GamePlayer player, string command) { var obj = DOLDB <DBSinglePermission> .SelectObject(DB.Column(nameof(DBSinglePermission.Command)).IsEqualTo(command).And(DB.Column(nameof(DBSinglePermission.PlayerID)).IsEqualTo(player.ObjectId).Or(DB.Column(nameof(DBSinglePermission.PlayerID)).IsEqualTo(player.AccountName)))); if (obj == null) { return(false); } return(true); }
public static bool removePermissionAccount(GamePlayer player, string command) { var obj = DOLDB <DBSinglePermission> .SelectObject(DB.Column(nameof(DBSinglePermission.Command)).IsEqualTo(command).And(DB.Column(nameof(DBSinglePermission.PlayerID)).IsEqualTo(player.AccountName))); if (obj == null) { return(false); } GameServer.Database.DeleteObject(obj); return(true); }
public void SaveAggroToFaction(string charID) { var dbfactionAggroLevel = DOLDB <DBFactionAggroLevel> .SelectObject(DB.Column("CharacterID").IsEqualTo(charID).And(DB.Column("FactionID").IsEqualTo(ID))); if (dbfactionAggroLevel == null) { dbfactionAggroLevel = new DBFactionAggroLevel(); dbfactionAggroLevel.AggroLevel = (int)m_playerxFaction[charID]; dbfactionAggroLevel.CharacterID = charID; dbfactionAggroLevel.FactionID = this.ID; GameServer.Database.AddObject(dbfactionAggroLevel); } else { dbfactionAggroLevel.AggroLevel = (int)m_playerxFaction[charID]; GameServer.Database.SaveObject(dbfactionAggroLevel); } }
/// <summary> /// Get the item in the specified page and slot /// </summary> /// <param name="page">The item page</param> /// <param name="slot">The item slot</param> /// <returns>Item template or null</returns> public virtual ItemTemplate GetItem(int page, eMerchantWindowSlot slot) { try { slot = GetValidSlot(page, slot); if (slot == eMerchantWindowSlot.Invalid) { return(null); } ItemTemplate item; lock (m_usedItemsTemplates.SyncRoot) { item = m_usedItemsTemplates[(int)slot + (page * MAX_ITEM_IN_TRADEWINDOWS)] as ItemTemplate; if (item != null) { return(item); } } if (m_itemsListID != null && m_itemsListID.Length > 0) { var itemToFind = DOLDB <MerchantItem> .SelectObject(DB.Column("ItemListID").IsEqualTo(m_itemsListID).And(DB.Column("PageNumber").IsEqualTo(page)).And(DB.Column("SlotPosition").IsEqualTo((int)slot))); if (itemToFind != null) { item = GameServer.Database.FindObjectByKey <ItemTemplate>(itemToFind.ItemTemplateID); } } return(item); } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("Loading merchant items list (" + m_itemsListID + ") page (" + page + ") slot (" + slot + "): ", e); } return(null); } }
/// <summary> /// Talk to the NPC. /// </summary> /// <param name="source"></param> /// <param name="str"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { if (!base.WhisperReceive(source, text) || !(source is GamePlayer)) { return(false); } GamePlayer player = source as GamePlayer; if ((text.ToLower() == "king" || text.ToLower() == "exit") && GlobalConstants.IsExpansionEnabled((int)eClientExpansion.DarknessRising)) { uint throneRegionID = 0; string teleportThroneID = "error"; string teleportExitID = "error"; switch (Realm) { case eRealm.Albion: throneRegionID = 394; teleportThroneID = "AlbThroneRoom"; teleportExitID = "AlbThroneExit"; break; case eRealm.Midgard: throneRegionID = 360; teleportThroneID = "MidThroneRoom"; teleportExitID = "MidThroneExit"; break; case eRealm.Hibernia: throneRegionID = 395; teleportThroneID = "HibThroneRoom"; teleportExitID = "HibThroneExit"; break; } if (throneRegionID == 0) { log.ErrorFormat("Can't find King for player {0} speaking to {1} of realm {2}!", player.Name, Name, Realm); player.Out.SendMessage("Server error, can't find throne room.", DOL.GS.PacketHandler.eChatType.CT_Staff, DOL.GS.PacketHandler.eChatLoc.CL_SystemWindow); return(false); } Teleport teleport = null; if (player.CurrentRegionID == throneRegionID) { teleport = DOLDB <Teleport> .SelectObject(DB.Column("TeleportID").IsEqualTo(teleportExitID)); if (teleport == null) { log.ErrorFormat("Can't find throne room exit TeleportID {0}!", teleportExitID); player.Out.SendMessage("Server error, can't find exit to this throne room. Moving you to your last bind point.", DOL.GS.PacketHandler.eChatType.CT_Staff, DOL.GS.PacketHandler.eChatLoc.CL_SystemWindow); player.MoveToBind(); } } else { teleport = DOLDB <Teleport> .SelectObject(DB.Column("TeleportID").IsEqualTo(teleportThroneID)); if (teleport == null) { log.ErrorFormat("Can't find throne room TeleportID {0}!", teleportThroneID); player.Out.SendMessage("Server error, can't find throne room teleport location.", DOL.GS.PacketHandler.eChatType.CT_Staff, DOL.GS.PacketHandler.eChatLoc.CL_SystemWindow); } } if (teleport != null) { SayTo(player, "Very well ..."); player.MoveTo((ushort)teleport.RegionID, teleport.X, teleport.Y, teleport.Z, (ushort)teleport.Heading); } return(true); } if (text.ToLower() == "do") { if (player.Inventory.CountItemTemplate("Personal_Bind_Recall_Stone", eInventorySlot.Min_Inv, eInventorySlot.Max_Inv) == 0) { SayTo(player, "Very well then. Here's your Personal Bind Recall Stone, may it serve you well."); player.ReceiveItem(this, "Personal_Bind_Recall_Stone"); } return(false); } return(true); }
/// <summary> /// Begin salvaging an inventory item /// </summary> /// <param name="item"></param> /// <param name="player"></param> /// <returns></returns> public static int BeginWork(GamePlayer player, InventoryItem item) { SalvageYield salvageYield = null; if (!IsAllowedToBeginWork(player, item)) { return(0); } int salvageLevel = CraftingMgr.GetItemCraftLevel(item) / 100; if (salvageLevel > 9) { salvageLevel = 9; // max 9 } var whereClause = WhereClause.Empty; if (item.SalvageYieldID == 0) { whereClause = DB.Column(nameof(SalvageYield.ObjectType)).IsEqualTo(item.Object_Type).And(DB.Column(nameof(SalvageYield.SalvageLevel)).IsEqualTo(salvageLevel)); } else { whereClause = DB.Column(nameof(SalvageYield.ID)).IsEqualTo(item.SalvageYieldID); } if (ServerProperties.Properties.USE_SALVAGE_PER_REALM) { whereClause = whereClause.And(DB.Column(nameof(SalvageYield.Realm)).IsEqualTo((int)eRealm.None).Or(DB.Column(nameof(SalvageYield.Realm)).IsEqualTo(item.Realm))); } salvageYield = DOLDB <SalvageYield> .SelectObject(whereClause); ItemTemplate material = null; if (salvageYield != null && string.IsNullOrEmpty(salvageYield.MaterialId_nb) == false) { material = GameServer.Database.FindObjectByKey <ItemTemplate>(salvageYield.MaterialId_nb); if (material == null) { player.Out.SendMessage("Can't find material (" + material.Id_nb + ") needed to salvage this item!", eChatType.CT_Important, eChatLoc.CL_SystemWindow); log.ErrorFormat("Salvage Error for ID: {0}: Material not found: {1}", salvageYield.ID, material.Id_nb); } } if (material == null) { if (salvageYield == null && item.SalvageYieldID > 0) { player.Out.SendMessage("This items salvage recipe (" + item.SalvageYieldID + ") not implemented yet.", eChatType.CT_Important, eChatLoc.CL_SystemWindow); log.ErrorFormat("SalvageYield ID {0} not found for item: {1}", item.SalvageYieldID, item.Name); } else if (salvageYield == null) { player.Out.SendMessage("Salvage recipe not found for this item.", eChatType.CT_System, eChatLoc.CL_SystemWindow); log.ErrorFormat("Salvage Lookup Error: ObjectType: {0}, Item: {1}", item.Object_Type, item.Name); } return(0); } if (player.IsMoving || player.IsStrafing) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.InterruptSalvage"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return(0); } if (player.IsStealthed) { player.Stealth(false); } player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.BeginSalvage", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow); // clone the yield entry and update values to work with this salvage (not saved to the DB) SalvageYield yield = salvageYield.Clone() as SalvageYield; if (item.SalvageYieldID == 0 || yield.Count == 0) { // Calculated salvage values int count = GetMaterialYield(player, item, yield, material); if (count < 1) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.NoSalvage", item.Name + ". The material returned amount is zero"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return(0); } } player.Out.SendTimerWindow(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.Salvaging", item.Name), yield.Count); player.CraftTimer = new RegionTimer(player) { Callback = new RegionTimerCallback(Proceed) }; player.CraftTimer.Properties.setProperty(AbstractCraftingSkill.PLAYER_CRAFTER, player); player.CraftTimer.Properties.setProperty(SALVAGED_ITEM, item); player.CraftTimer.Properties.setProperty(SALVAGE_YIELD, yield); player.CraftTimer.Start(yield.Count * 1000); return(1); }
/// <summary> /// Begin salvaging a siege weapon /// </summary> /// <param name="player"></param> /// <param name="siegeWeapon"></param> /// <returns></returns> public static int BeginWork(GamePlayer player, GameSiegeWeapon siegeWeapon) { if (siegeWeapon == null) { return(0); } // Galenas siegeWeapon.ReleaseControl(); siegeWeapon.RemoveFromWorld(); bool error = false; var recipe = DOLDB <DBCraftedItem> .SelectObject(DB.Column(nameof(DBCraftedItem.Id_nb)).IsEqualTo(siegeWeapon.ItemId)); if (recipe == null) { player.Out.SendMessage("Error retrieving salvage data!", eChatType.CT_Important, eChatLoc.CL_SystemWindow); log.Error("Salvage Siege Error: DBCraftedItem is null for" + siegeWeapon.ItemId); return(1); } var rawMaterials = DOLDB <DBCraftedXItem> .SelectObjects(DB.Column(nameof(DBCraftedXItem.CraftedItemId_nb)).IsEqualTo(recipe.Id_nb)); if (rawMaterials == null || rawMaterials.Count == 0) { player.Out.SendMessage("No raw materials provided for this siege weapon!", eChatType.CT_Important, eChatLoc.CL_SystemWindow); log.Error("Salvage Siege Error: No Raw Materials found for " + siegeWeapon.ItemId); return(1); } if (player.IsCrafting) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.IsAllowedToBeginWork.EndCurrentAction"), eChatType.CT_System, eChatLoc.CL_SystemWindow); return(0); } InventoryItem item; ItemTemplate template; foreach (DBCraftedXItem material in rawMaterials) { template = GameServer.Database.FindObjectByKey <ItemTemplate>(material.IngredientId_nb); if (template == null) { player.Out.SendMessage("Missing raw material " + material.IngredientId_nb + "!", eChatType.CT_Important, eChatLoc.CL_SystemWindow); log.Error("Salvage Siege Error: Raw Material not found " + material.IngredientId_nb); return(1); } item = GameInventoryItem.Create(template); item.Count = material.Count; if (!player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item)) { error = true; break; } InventoryLogging.LogInventoryAction("(salvage)", player, eInventoryActionType.Craft, item.Template, item.Count); } if (error) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.NoRoom"), eChatType.CT_System, eChatLoc.CL_SystemWindow); } return(1); }
public override LootList GenerateLoot(GameNPC mob, GameObject killer) { LootList loot = base.GenerateLoot(mob, killer); List <LootOTD> lootOTDs = null; try { if (m_mobOTDList.ContainsKey(mob.Name.ToLower())) { lootOTDs = m_mobOTDList[mob.Name.ToLower()]; } if (lootOTDs != null) { foreach (GameObject gainer in mob.XPGainers.Keys) { GamePlayer player = null; if (gainer is GamePlayer) { player = gainer as GamePlayer; } else if (gainer is GameNPC) { IControlledBrain brain = ((GameNPC)gainer).Brain as IControlledBrain; if (brain != null) { player = brain.GetPlayerOwner(); } } if (player != null) { foreach (LootOTD drop in lootOTDs) { if (drop.MinLevel <= player.Level) { var hasDrop = DOLDB <CharacterXOneTimeDrop> .SelectObject(DB.Column(nameof(CharacterXOneTimeDrop.CharacterID)).IsEqualTo(player.QuestPlayerID).And(DB.Column(nameof(CharacterXOneTimeDrop.ItemTemplateID)).IsEqualTo(drop.ItemTemplateID))); if (hasDrop == null) { ItemTemplate item = GameServer.Database.FindObjectByKey <ItemTemplate>(drop.ItemTemplateID); if (item != null) { if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, GameInventoryItem.Create(item))) { CharacterXOneTimeDrop charXDrop = new CharacterXOneTimeDrop(); charXDrop.CharacterID = player.QuestPlayerID; charXDrop.ItemTemplateID = drop.ItemTemplateID; GameServer.Database.AddObject(charXDrop); player.Out.SendMessage(string.Format("You receive {0} from {1}!", item.GetName(1, false), mob.GetName(1, false)), eChatType.CT_Loot, eChatLoc.CL_SystemWindow); InventoryLogging.LogInventoryAction(mob, player, eInventoryActionType.Loot, item); } else { // do not drop, player will have to try again player.Out.SendMessage("Your inventory is full and a one time drop cannot be added!", eChatType.CT_Important, eChatLoc.CL_SystemWindow); log.DebugFormat("OTD Failed, Inventory full: {0} from mob {1} for player {2}.", drop.ItemTemplateID, drop.MobName, player.Name); break; } } else { log.ErrorFormat("Error trying to drop ItemTemplate {0} from {1}. Item not found.", drop.ItemTemplateID, drop.MobName); } } } } } } } } catch (Exception ex) { log.Error("LootGeneratorOneTimeDrop exception for mob " + mob.Name + ":", ex); } return(loot); }