public bool Load(Item_Info info, ushort slotId, ushort count) { Info = info; if (info == null) { return(false); } if (count <= 0) { count = 1; } _SlotId = slotId; _ModelId = info.ModelId; _Count = count; Player player = Owner as Player; if (player != null) { if (CharSaveInfo == null) { CreateCharSaveInfo(player.CharacterId); } if (info.SpellId != 0) { player.AbtInterface.AssignItemCooldown(this); } } return(true); }
public void Createitem(Item.Type type, Item item) { Transform createParent = null; switch (type) { case Item.Type.建筑单位: createParent = building_Item_Create; break; case Item.Type.步兵单位: createParent = people_Item_Create; break; case Item.Type.装甲单位: createParent = tank_Item_Create; break; case Item.Type.飞行单位: createParent = plane_Item_Create; break; } Resources_Management.Instance.Load <GameObject>("UI/Unit", createParent, (itemToggle) => { Item_Info info = itemToggle.GetComponent <Item_Info>();//找到当前组件下的脚本,进行传参赋值 info.NameData(item); all_ItemObj.Add(itemToggle); all_Item_Script.Add(info); }); }
static public List <Creature_vendor> GetVendorItems(uint Entry) { if (!_Vendors.ContainsKey(Entry)) { Log.Info("WorldMgr", "Loading Vendors of " + Entry + " ..."); IList <Creature_vendor> IVendors = Database.SelectObjects <Creature_vendor>("Entry=" + Entry); List <Creature_vendor> Vendors = new List <Creature_vendor>(); Vendors.AddRange(IVendors); _Vendors.Add(Entry, Vendors); foreach (Creature_vendor Info in Vendors.ToArray()) { if ((Info.Info = GetItem_Info(Info.ItemId)) == null) { Vendors.Remove(Info); continue; } foreach (KeyValuePair <uint, UInt16> Kp in Info.ItemsReq) { Item_Info Req = GetItem_Info(Kp.Key); if (Req != null) { Info.ItemsReqInfo.Add(Kp.Value, Req); } } } Log.Success("LoadCreatureVendors", "Loaded " + Vendors.Count + " Vendors of " + Entry); } return(_Vendors[Entry]); }
public void SendMail(Character_mail Mail) { if (Mail == null) { return; } PacketOut Out = new PacketOut((byte)Opcodes.F_MAIL); Out.WriteByte(0x0D); Out.WriteByte(0); BuildPreMail(Out, Mail); Out.WriteUInt16((ushort)(Mail.Content.Length + 1)); Out.WriteStringBytes(Mail.Content); Out.WriteByte(0); Out.WriteByte((byte)Mail.Items.Count); foreach (KeyValuePair <uint, ushort> item in Mail.Items) { Item_Info Req = WorldMgr.GetItem_Info(item.Key); Item.BuildItem(ref Out, null, Req, 0, item.Value); } GetPlayer().SendPacket(Out); }
public bool AddSeed(Item_Info seedInfo) { if (_stage != STAGE_EMPTY) { _ownerInterface.GetPlayer().SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_CULTIVATION_PLOT_STILL_HAS_PLANTS); return(false); } _seedItemID = seedInfo.Entry; _seedLvl = seedInfo.Unk27[14]; if (_seedLvl >= 150) { SetStageTime(60); } else if (_seedLvl >= 100) { SetStageTime(40); } else if (_seedLvl >= 50) { SetStageTime(30); } else { SetStageTime(20); } UpdateStage(); AddBonuses(TYPE_SEED, seedInfo.Crafts.Split(';')); return(true); }
public bool AddTalisman(uint entry, byte SlotId) { if (CharSaveInfo == null) { return(false); } Item_Info info = ItemService.GetItem_Info(entry); if (info.Type != 23) { return(false); } if (Info.ObjectLevel < info.MinRank) { return(false); } foreach (Talisman tali in CharSaveInfo._Talismans) { if (tali.Slot == SlotId && tali.Fused == 1 || info.Crafts == ItemService.GetItem_Info(tali.Entry).Crafts&& tali.Slot != SlotId) { return(false); } } CharSaveInfo._Talismans.Add(new Talisman(entry, SlotId, 1, 0)); return(true); }
public void SendMessage(UInt16 Oid, string NameSender, string Text, SystemData.ChatLogFilters Filter) { if (Text.IndexOf("<LINK") >= 0 && Text.IndexOf("ITEM:") > 0) { int Pos = Text.IndexOf("ITEM:") + 5; int LastPos = Text.IndexOf(" ", Pos) - 1; string Value = Text.Substring(Pos, LastPos - Pos); uint ItemId = uint.Parse(Value); Item_Info Info = WorldMgr.GetItem_Info(ItemId); if (Info != null) { } } PacketOut Out = new PacketOut((byte)Opcodes.F_CHAT); Out.WriteUInt16(Oid); Out.WriteByte((byte)Filter); Out.Fill(0, 4); Out.WritePascalString(NameSender); Out.WriteByte(0); Out.WritePascalString(Text); Out.WriteByte(0); SendPacket(Out); }
static public void LoadQuestsRelation() { LoadQuestCreatureStarter(); LoadQuestCreatureFinisher(); foreach (Quest_Objectives Obj in _Objectives.Values) { Quest Q = GetQuest(Obj.Entry); if (Q == null) { continue; } GenerateObjectif(Obj, Q); Obj.num = (byte)(Q.Objectives.Count + 1); Obj.Quest = Q; Q.Objectives.Add(Obj); } foreach (Quest Q in _Quests.Values) { if (Q.Choice.Length <= 0) { continue; } // [5154,12],[128,1] string[] Rewards = Q.Choice.Split('['); foreach (string Reward in Rewards) { if (Reward.Length <= 0) { continue; } string sItemID = Reward.Substring(0, Reward.IndexOf(',')); string sCount = Reward.Substring(sItemID.Length + 1, Reward.IndexOf(']') - sItemID.Length - 1); uint ItemID = uint.Parse(sItemID); uint Count = uint.Parse(sCount); Item_Info Info = GetItem_Info(ItemID); if (Info == null) { continue; } if (!Q.Rewards.ContainsKey(Info)) { Q.Rewards.Add(Info, Count); } else { Q.Rewards[Info] += Count; } } } }
private void SendItem(Player Plr, UInt16 Slot, Item_Info Info) { PacketOut Out = new PacketOut((byte)Opcodes.F_GET_ITEM); Out.WriteByte(1); Out.Fill(0, 3); Item.BuildItem(ref Out, null, Info, Slot, 1); Plr.SendPacket(Out); }
static public bool CanUse(Item_Info Info, Player Plr, bool IgnoreLevel, bool IgnoreSkills, bool IgnoreRace, bool IgnoreCareer, bool IgnoreRenown) { if (!IgnoreSkills) { uint Skills = Info.Skills << 1; long PlayerSkill = Plr._Value.Skills; if (Skills != 0 && (PlayerSkill &= Skills) != Skills) { return(false); } } if (!IgnoreCareer) { int Career = (int)Info.Career; int PlayerCareer = 1 << (Plr._Info.CareerLine - 1); if (Career != 0 && (Career & PlayerCareer) == 0) { return(false); } } if (!IgnoreRace) { int Race = (int)Info.Race; int PlayerRace = 1 << (Plr._Info.Race - 1); if (Race != 0 && (Race & PlayerRace) == 0) { return(false); } } if (!IgnoreLevel) { if (Plr.Level < Info.MinRank) { return(false); } } if (!IgnoreRenown) { if (Plr.Renown < Info.MinRenown) { return(false); } } return(true); }
public void NotifyItemEvent(byte eventID, Item_Info myItemInfo) { if (_buffCombatSubs[eventID - 1].Count == 0) { return; } foreach (var buff in _buffCombatSubs[eventID - 1]) { buff.InvokeItemEvent(eventID, myItemInfo); } }
public bool AddWater(Item_Info waterInfo) { if (_waterItemID != 0 || _stage != STAGE_SEEDLING || _seedItemID == 0) { _ownerInterface.GetPlayer().SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_CULTIVATION_CANT_APPLY_TO_PLOT_NOW); return(false); } _waterItemID = waterInfo.Entry; AddBonuses(TYPE_WATER, waterInfo.Crafts.Split(';')); return(true); }
public bool AddNutrients(Item_Info nutrientInfo) { if (_nutrientItemID != 0 || _stage != STAGE_FLOWERING || _seedItemID == 0) { _ownerInterface.GetPlayer().SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_CULTIVATION_CANT_APPLY_TO_PLOT_NOW); return(false); } _nutrientItemID = nutrientInfo.Entry; AddBonuses(TYPE_NUTRIENTS, nutrientInfo.Crafts.Split(';')); return(true); }
public bool Load(CharacterItem itemSaveInfo) { Info = ItemService.GetItem_Info(itemSaveInfo.Entry); if (Info == null) { Log.Error("ItemInterface", "Load : info==null,entry=" + itemSaveInfo.Entry); return(false); } CharSaveInfo = itemSaveInfo; return(true); }
public void InvokeItemEvent(byte eventID, Item_Info itmInfo) { if (BuffState != (byte)EBuffState.Running) { return; } BuffCommandInfo myCommand = EventCommands.Find(evtpair => evtpair.Item1 == eventID).Item2; if (myCommand == null) { return; } BuffEffectInvoker.InvokeItemCommand(this, myCommand, itmInfo); }
public void SendMessage(UInt16 Oid, string NameSender, string Text, SystemData.ChatLogFilters Filter) { PacketOut Out = new PacketOut((byte)Opcodes.F_CHAT); Out.WriteUInt16(Oid); Out.WriteByte((byte)Filter); Out.Fill(0, 4); Out.WritePascalString(NameSender); Out.WriteUInt16((ushort)(Text.Length + 1)); Out.WriteStringBytes(Text); Out.WriteByte(0); int a = Text.IndexOf("<LINK"); int b = Text.IndexOf("ITEM:"); if (a >= 0 && b > 0) { Out.WriteByte(1); long p = Out.Position; Out.WriteByte(0); int Count = 0; while (a >= 0 && b >= 0) { int Pos = b + 5; int LastPos = Text.IndexOf(" ", Pos) - 1; string Value = Text.Substring(Pos, LastPos - Pos); uint ItemId = uint.Parse(Value); Item_Info Info = WorldMgr.GetItem_Info(ItemId); if (Info != null) { ++Count; Out.WriteByte(3); Item.BuildItem(ref Out, null, Info, 0, 1); } a = Text.IndexOf("<LINK", Pos); b = Text.IndexOf("ITEM:", Pos); } Out.Position = p; Out.WriteByte((byte)Count); Out.Position = Out.Length; } SendPacket(Out); }
public bool Load(Character_items Item) { if (Item == null) { return(false); } Info = WorldMgr.GetItem_Info(Item.Entry); if (Info == null) { Log.Error("ItemInterface", "Load : Info==null,Entry=" + Item.Entry); return(false); } CharItem = Item; return(true); }
public bool Load(uint Entry, UInt16 SlotId, UInt16 Count) { Info = WorldMgr.GetItem_Info(Entry); if (Info == null) { return(false); } if (Count <= 0) { Count = 1; } _SlotId = SlotId; _ModelId = Info.ModelId; _Count = Count; return(true); }
public bool Load(Item_Info Info, UInt16 SlotId, UInt16 Count) { this.Info = Info; if (Info == null) { return(false); } if (Count <= 0) { Count = 1; } _SlotId = SlotId; _ModelId = Info.ModelId; _Count = Count; return(true); }
public ActionResult Menu() { DateTime d1, d2; List <Item_Info> i = new List <Item_Info>(); var email = (String)Session["email"]; var passw = (String)Session["passw"]; /*var email = "n"; * var passw = "n";*/ var l = s.ListOfBarcodes(email, passw); foreach (var b in l) { Item_Info ii = new Item_Info(); var d = DateTime.Now; int y = d.Year; int m = d.Month; int dd = d.Day; string ds = string.Format("{0}/{1}/{2}", m, dd, y); d1 = DateTime.Parse(ds); d2 = DateTime.Parse(b.EXPIRYDATE); if (d1 <= d2) { if ((d2 - d1).Days <= 7) { ii.BARCODE_NO = b.barcode; ii.BRAND = b.brand; ii.EXPIRY_DATE = b.EXPIRYDATE; ii.item_img = b.itemImg; i.Add(ii); } } } return(View(i)); }
// GET api/task/5 //[HttpGet] //[Route("api/Task/GetOrderedItems")] public JsonResult GetOrderedItems(string OrderId) { List <OrderedItemInfo> itemList = new List <OrderedItemInfo>(); using (var context = new OrderListEntities()) { var items = context.Items.Where(x => x.OrderId == OrderId).ToList(); foreach (var item in items) { OrderedItemInfo itemInfo = new OrderedItemInfo(); Item_Info info = new Item_Info(); //itemInfo.Item_Details = new List<Item_Info>(); var items_Desc = context.Item_Catalog.Where(x => x.Item_DCode == item.Item_DCode).ToList(); foreach (var item_Desc in items_Desc) { info.Item_Name = item_Desc.Item_Name; info.Item_Desc = item_Desc.Item_Desc; info.InStock = item_Desc.InStock; info.CategoryId = item_Desc.CategoryId; info.Item_DCode = item_Desc.Item_DCode; itemInfo.Item_Details.Add(info); } itemInfo.RentAmt = item.RentAmt; itemInfo.SecurityDeposit = item.SecurityDeposit; itemInfo.Item_DCode = item.Item_DCode; itemInfo.Quantity = item.Quantity; itemInfo.Tenure = item.Tenure; itemInfo.DealerName = item.DealerName; itemInfo.TotalRent = item.TotalRent; itemList.Add(itemInfo); } } return(Json(itemList, JsonRequestBehavior.AllowGet)); }
public ActionResult Inventory() { List <Item_Info> i = new List <Item_Info>(); var email = (String)Session["email"]; var passw = (String)Session["passw"]; /*var email = "nn"; * var passw = "nn";*/ var l = s.ListOfBarcodes(email, passw); foreach (var b in l) { Item_Info ii = new Item_Info(); ii.BARCODE_NO = b.barcode; ii.BRAND = b.brand; ii.EXPIRY_DATE = b.EXPIRYDATE; ii.item_img = b.itemImg; i.Add(ii); } return(View(i)); }
void SaveItem(Item_Info NewItem, GameObject _Item) { if(_Item) { Item_Data Item = _Item.GetComponent<Item_Data>(); NewItem.m_eItemModType = (int)Item.m_eItemModType; NewItem.m_eItemType = (int)Item.m_eItemType; NewItem.m_eRarity = (int)Item.m_eRarity; NewItem.m_fItemMod = Item.m_fItemMod; NewItem.m_iItemLevel = Item.m_iItemLevel; NewItem.m_bIsNull = false; } else { NewItem.m_bIsNull = true; } }
// variable itemEquipedToK checks if this ToK was triggered by equiping item. If it is true it was, otherwise it is false public void AddTok(ushort Entry, bool itemEquipedToK = false) { if (HasTok(Entry)) { return; } if (!_loaded) { Log.Error("ToKSystem", "Tried to add ToK when system wasn't loaded.\n" + Environment.StackTrace); return; } Tok_Info Info = TokService.GetTok(Entry); if (Info == null) { return; } if (Info.Realm != 0 && Info.Realm != _Owner.GetPlayer().Info.Realm) { return; } SendTok(Entry, true); Character_tok Tok = new Character_tok { TokEntry = Entry, CharacterId = GetPlayer().CharacterId, Count = 1 }; _tokUnlocks.Add(Entry, Tok); GetPlayer().AddXp(Info.Xp, false, false); // This checks if ToK we are adding is a part of larger ToK, for example title // "Sovereign Trinket" is part of title "The Sovereign" if (itemEquipedToK) { // Selects item we equiped from DB Item_Info tokItemUnlock2 = WorldMgr.Database.SelectObject <Item_Info>("career=" + GetPlayer().Info.CareerFlags + " AND TokUnlock=" + Entry); if (tokItemUnlock2 != null && tokItemUnlock2.TokUnlock != 0 && tokItemUnlock2.TokUnlock2 != 0) { // Selects secondary ToK we want to setup if we completed full set IList <Item_Info> tokItems = WorldMgr.Database.SelectObjects <Item_Info>("career=" + GetPlayer().Info.CareerFlags + " AND TokUnlock2 = " + tokItemUnlock2.TokUnlock2); int count = tokItems.Count(); // If there is more than 0 items with complete set unlock we proceed if (count > 0) { foreach (Item_Info tokItem in tokItems) { if (HasTok(tokItem.TokUnlock)) { count--; } } // If we have all required unlocks count = 0 and we can proceed if (count == 0) { // Tok is send to player SendTok((ushort)tokItemUnlock2.TokUnlock2, true); Character_tok Tok2 = new Character_tok { TokEntry = (ushort)tokItemUnlock2.TokUnlock2, CharacterId = GetPlayer().CharacterId, Count = 1 }; Tok_Info InfoSetTok = TokService.GetTok((ushort)tokItemUnlock2.TokUnlock2); // ToK is added to the book _tokUnlocks.Add((ushort)tokItemUnlock2.TokUnlock2, Tok2); GetPlayer().AddXp(InfoSetTok.Xp, false, false); // Adding reward from final ToK - Title SendTok((ushort)InfoSetTok.Rewards, true); Character_tok Tok2Title = new Character_tok { TokEntry = (ushort)InfoSetTok.Rewards, CharacterId = GetPlayer().CharacterId, Count = 1 }; Tok_Info TokInfoTitle = TokService.GetTok((ushort)InfoSetTok.Rewards); _tokUnlocks.Add((ushort)InfoSetTok.Rewards, Tok2Title); GetPlayer().AddXp(TokInfoTitle.Xp, false, false); //ToKs saved in DB :) CharMgr.Database.AddObject(Tok2); CharMgr.Database.AddObject(Tok2Title); } } } } if (Info.Rewards > 0) { // this will be used for future additions like the tome tactics and gear to buy if (Info.Rewards == 1) { GetPlayer().ItmInterface.CreateItem(80001, 1); // Betial Token } } GetPlayer().Info.Toks = _tokUnlocks.Values.ToList(); CharMgr.Database.AddObject(Tok); }
public LootInfo(Item_Info Item) { this.Item = Item; }
public void SaveInvenroty() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "Inventory.dat"); Inventory_Item_Info Inventory_Info = new Inventory_Item_Info(); for(int i = 0; i < Inventory.Inven.m_goAllItems.Count; ++i) { Item_Info NewItem = new Item_Info(); SaveItem(NewItem, Inventory.Inven.m_goAllItems[i]); Inventory_Info.AllItems.Add(NewItem); } bf.Serialize(file, Inventory_Info); file.Close(); }
public void Harvest() { Player harvester = _ownerInterface.GetPlayer(); if (_stage != STAGE_FLOWERED) { harvester.SendLocalizeString(ChatLogFilters.CHATLOGFILTERS_CRAFTING, Localized_text.TEXT_CULTIVATION_PLOT_NOT_FINISHED_GROWING); return; } if (ItemService.GetItem_Info(_seedItemID).Rarity == 3) { harvester.ItmInterface.CreateItem(_seedItemID, 1, true); } Item_Info mainItem = ItemService.GetItem_Info(uint.Parse(ItemService.GetItem_Info(_seedItemID).Craftresult.Split(';')[0])); Item_Info subItem = ItemService.GetItem_Info(uint.Parse(ItemService.GetItem_Info(_seedItemID).Craftresult.Split(';')[1])); if (harvester.ItmInterface.GetTotalFreeInventorySlot(mainItem) < 4) { harvester.SendLocalizeString(ChatLogFilters.CHATLOGFILTERS_CRAFTING, Localized_text.TEXT_CULTIVATION_CANT_HARVEST_SEED_BACKPACK_FULL); return; } switch (_result) { case 0: if (harvester.ItmInterface.CreateItem(84918, 1, true) != ItemResult.RESULT_OK) { return; } harvester.SendLocalizeString(ItemService.GetItem_Info(84918).Name, ChatLogFilters.CHATLOGFILTERS_CRAFTING, Localized_text.TEXT_CRAFT_RECIPE_CRITFAILURE); break; case 1: if (harvester.ItmInterface.CreateItem(mainItem, 2, 0, true) != ItemResult.RESULT_OK) { return; } harvester.SendLocalizeString(new [] { "2", mainItem.Name }, ChatLogFilters.CHATLOGFILTERS_CRAFTING, Localized_text.TEXT_CRAFT_CULTIVATION_HARVEST); break; case 2: if (harvester.ItmInterface.CreateItem(mainItem, 3, 0, true) != ItemResult.RESULT_OK) { return; } harvester.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_CRAFTING, Localized_text.TEXT_CRAFT_CRITICALSUCCESS); harvester.SendLocalizeString(new[] { "3", mainItem.Name }, ChatLogFilters.CHATLOGFILTERS_CRAFTING, Localized_text.TEXT_CRAFT_CULTIVATION_HARVEST); break; case 3: if (harvester.ItmInterface.CreateItem(uint.Parse(ItemService.GetItem_Info(_seedItemID).Craftresult.Split(';')[0]), 2, true) != ItemResult.RESULT_OK) { return; } if (harvester.ItmInterface.CreateItem(subItem, 1, 0, true) != ItemResult.RESULT_OK) { harvester.ItmInterface.DeleteItem(ushort.Parse(ItemService.GetItem_Info(_seedItemID).Craftresult.Split(';')[0]), 2); return; } uint dyepigment = 199901; byte seedlvl = CultivationInterface.GetCraft(9, ItemService.GetItem_Info(_seedItemID).Crafts); if (seedlvl < 50) { harvester.ItmInterface.CreateItem(dyepigment, 1, true); } else if (seedlvl < 100) { harvester.ItmInterface.CreateItem(dyepigment += 1, 1, true); } else if (seedlvl < 150) { harvester.ItmInterface.CreateItem(dyepigment += 2, 1, true); } else if (seedlvl < 200) { harvester.ItmInterface.CreateItem(dyepigment += 3, 1, true); } else { if (50 > (float)StaticRandom.Instance.NextDouble() * 100f) { harvester.ItmInterface.CreateItem(dyepigment += 4, 1, true); } else { harvester.ItmInterface.CreateItem(dyepigment += 5, 1, true); } } harvester.SendLocalizeString(new[] { "2", mainItem.Name }, ChatLogFilters.CHATLOGFILTERS_CRAFTING, Localized_text.TEXT_CRAFT_CULTIVATION_HARVEST); harvester.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_CRAFTING, Localized_text.TEXT_CRAFT_SPECIALMOMENT); harvester.SendLocalizeString(new[] { "1", subItem.Name }, ChatLogFilters.CHATLOGFILTERS_CRAFTING, Localized_text.TEXT_CRAFT_CULTIVATION_HARVEST); harvester.SendLocalizeString(new[] { "1", ItemService.GetItem_Info(dyepigment).Name }, ChatLogFilters.CHATLOGFILTERS_CRAFTING, Localized_text.TEXT_CRAFT_CULTIVATION_HARVEST); break; } Reset(); }
GameObject LoadItem(Item_Info _Item) { GameObject tNewItem = null; if(_Item.m_bIsNull) { } else { tNewItem = Instantiate(m_goItem) as GameObject; tNewItem.transform.SetParent(Inventory.Inven.transform); Item_Data ItemScript = tNewItem.GetComponent<Item_Data>(); ItemScript.m_eItemModType = (Item_Data.ItemMod)_Item.m_eItemModType; ItemScript.m_eItemType = (Item_Data.ItemType)_Item.m_eItemType; ItemScript.m_eRarity = (Item_Data.ItemRarity)_Item.m_eRarity; ItemScript.m_fItemMod = _Item.m_fItemMod; ItemScript.m_iItemLevel = _Item.m_iItemLevel; ItemScript.forceDisplay(); } return(tNewItem); }
/// <summary> /// Rewards players based on their contribution, converting it to XP, RP, Influence and Medallions. /// </summary> internal void HandleLockReward(Realms realm, float winnerRewardScale, string lockMessage, int zoneId, int tier) { /* * Some general notes on this. * * The ticker, if kicked consistently by a player during the course of one hour, will grant contribution which converts to 3000 RP over 60 minutes. * Rewards are based on a player's contribution performance relative to the best player on their realm. * The RP from a lock cannot exceed Tier * 5000, and by extension, the XP cannot exceed Tier * 15000, * the Influence cannot exceed Tier * 500 and there can be no more than 6 medallions issued. * * The rewards are scaled by the proximity of a zone to the enemy fortress. * * The rewards are also scaled by the relative Campaign scaler, which cripples rewards for players * refusing to fight in the most hotly contested zone. * * For the losing side, the reward is also scaled by the % of rewards, linked to the Victory Point pool. * * To receive the max losing reward, the top contributor on the losing realm must have contribution greater than 1/3 of the top attacker contribution. */ string zoneName; if (zoneId == 0) { zoneName = _region.ZonesInfo[0].Name + " and " + _region.ZonesInfo[1].Name; } else { zoneName = ZoneService.GetZone_Info((ushort)zoneId).Name; } uint xpCap = (uint)(tier * 19000); uint rpCap = (uint)(tier * 10000); ushort infCap = (ushort)(tier * 2000); #region Init winner rewards Dictionary <uint, ContributionInfo> winnerContrib = GetContributorsFromRealm(realm); uint winMaxContrib = GetMaxContribution(winnerContrib); //Log.Info(zoneName, $"Winner contributor count : {winnerContrib.Count} Max contribution: {winMaxContrib}"); uint winRP = (uint)(winMaxContrib * 1.5 * winnerRewardScale * BattleFrontConstants.LOCK_REWARD_SCALER); uint winXP = winRP * 4; ushort winInf = (ushort)(winRP * 0.25f); ushort winMedallionCount = (ushort)Math.Min(20, winRP / (450 * tier)); //Log.Info(zoneName, $"Lock XP: {winXP} RP: {winRP} Inf: {winInf} Medals: {winMedallionCount}"); #endregion #region Init loser rewards Dictionary <uint, ContributionInfo> loserContrib = GetContributorsFromRealm(realm == Realms.REALMS_REALM_ORDER ? Realms.REALMS_REALM_DESTRUCTION : Realms.REALMS_REALM_ORDER); uint loserMaxContrib = GetMaxContribution(loserContrib); //Log.Info(zoneName, $"Loser contributor count : {loserContrib.Count} Max contribution: {loserMaxContrib}"); uint lossRP = (uint)(winRP * LoserShare * Math.Min(1f, (loserMaxContrib * 3) / (float)winMaxContrib)); uint lossXP = lossRP * 5; ushort lossInf = (ushort)(lossRP * 0.35f); ushort lossMedallionCount = (ushort)Math.Min(15, winMedallionCount * LoserShare); //Log.Info(zoneName, $"Lock XP: {lossXP} RP: {lossRP} Inf: {lossInf} Medallions: {lossMedallionCount}"); #endregion Item_Info medallionInfo = ItemService.GetItem_Info((uint)(208399 + tier)); Item_Info T3Token = ItemService.GetItem_Info(2165); Item_Info T4Token = ItemService.GetItem_Info(2166); ushort tokenCount = 2; foreach (var kV in PlayerContributions) { Player plr = Player.GetPlayer(kV.Key); Character chara = plr != null ? plr.Info : CharMgr.GetCharacter(kV.Key, false); if (chara == null) { continue; } if (plr != null) { plr.SendLocalizeString(lockMessage, ChatLogFilters.CHATLOGFILTERS_RVR, Localized_text.CHAT_TAG_DEFAULT); plr.SendLocalizeString(lockMessage, realm == Realms.REALMS_REALM_ORDER ? ChatLogFilters.CHATLOGFILTERS_C_ORDER_RVR_MESSAGE : ChatLogFilters.CHATLOGFILTERS_C_DESTRUCTION_RVR_MESSAGE, Localized_text.CHAT_TAG_DEFAULT); // AAO multiplier needs to be multiplied with 20 to get the AAO that player sees. // AAO mult is the global value for the server to grab the difference in size of the teams while AAOBonus is the players individual bonus int aaoBuff = Convert.ToInt32(plr.AAOBonus); if (aaoBuff < 0.1) { tokenCount = 1; } if (aaoBuff >= 2) { tokenCount = 3; } if (aaoBuff >= 3) { tokenCount = 4; } if (aaoBuff >= 4) { tokenCount = 5; } } ContributionInfo contrib = kV.Value; if (chara.Realm == (int)realm) { if (winRP == 0) { continue; } float contributionFactor = Math.Min(1f, contrib.BaseContribution / (winMaxContrib * 0.7f)); string contributionDesc; if (contributionFactor > 0.75f) { contributionDesc = "valiant"; } else if (contributionFactor > 0.5f) { contributionDesc = "stalwart"; } else if (contributionFactor > 0.25f) { contributionDesc = "modest"; } else { contributionDesc = "small"; } plr?.SendClientMessage($"Your realm has captured {zoneName}, and you have been rewarded for your {contributionDesc} effort!", ChatLogFilters.CHATLOGFILTERS_RVR); if (plr != null) { if (plr.Region == _region) { plr.AddXp(Math.Min(xpCap, (uint)(winXP * contributionFactor)), false, false); if (plr.AAOBonus > 1) { plr.AddRenown(Math.Min(rpCap, (uint)(winRP * contributionFactor + (tokenCount * 100))), false, RewardType.ZoneKeepCapture, zoneName); if (plr.CurrentArea != null) { ushort influenceId = realm == Realms.REALMS_REALM_ORDER ? (ushort)plr.CurrentArea.OrderInfluenceId : (ushort)plr.CurrentArea.DestroInfluenceId; plr.AddInfluence(influenceId, Math.Min(infCap, (ushort)(winInf * contributionFactor + (tokenCount * 100)))); } } else { plr.AddRenown(Math.Min(rpCap, (uint)(winRP * contributionFactor)), false, RewardType.ZoneKeepCapture, zoneName); if (plr.CurrentArea != null) { ushort influenceId = realm == Realms.REALMS_REALM_ORDER ? (ushort)plr.CurrentArea.OrderInfluenceId : (ushort)plr.CurrentArea.DestroInfluenceId; plr.AddInfluence(influenceId, Math.Min(infCap, (ushort)(winInf * contributionFactor))); } } } else { plr.AddPendingXP(Math.Min(xpCap, (uint)(winXP * contributionFactor))); plr.AddPendingRenown(Math.Min(rpCap, (uint)(winRP * contributionFactor))); } } else if (chara.Value != null) { chara.Value.PendingXp += Math.Min(xpCap, (uint)(winXP * contributionFactor)); chara.Value.PendingRenown += Math.Min(rpCap, (uint)(winRP * contributionFactor)); CharMgr.Database.SaveObject(chara.Value); } ushort resultantCount = (ushort)(winMedallionCount * contributionFactor); /* * if (plr != null && plr.AAOBonus > 1 && plr.Region == Region) * { * resultantCount = Convert.ToUInt16(resultantCount * ((AgainstAllOddsMult * 20)/100)); * } */ if (contributionFactor > 0 && plr != null) { if ((tier == 2 || tier == 3) && plr.ItmInterface.CreateItem(T3Token, tokenCount) == ItemResult.RESULT_OK) { plr.SendLocalizeString(new[] { T3Token.Name, tokenCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X); } if (tier == 4 && plr.ItmInterface.CreateItem(T4Token, tokenCount) == ItemResult.RESULT_OK) { plr.SendLocalizeString(new[] { T4Token.Name, tokenCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X); } } if (resultantCount > 0) { if (plr != null && plr.Region == _region && plr.ItmInterface.CreateItem(medallionInfo, resultantCount) == ItemResult.RESULT_OK) { plr.SendLocalizeString(new[] { medallionInfo.Name, resultantCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X); } else { Character_mail medallionMail = new Character_mail { Guid = CharMgr.GenerateMailGuid(), CharacterId = chara.CharacterId, CharacterIdSender = chara.CharacterId, SenderName = chara.Name, ReceiverName = chara.Name, SendDate = (uint)TCPManager.GetTimeStamp(), Title = "Medallion Reward", Content = "You've received a medallion reward for your realm's victory in a recent battle in which you were a participant.", Money = 0, Opened = false }; medallionMail.Items.Add(new MailItem(medallionInfo.Entry, resultantCount)); if (tier == 2 || tier == 3) { medallionMail.Items.Add(new MailItem(T3Token.Entry, tokenCount)); } if (tier == 4) { medallionMail.Items.Add(new MailItem(T4Token.Entry, tokenCount)); } CharMgr.AddMail(medallionMail); } } } else { if (lossRP == 0) { continue; } float scaleFactor = Math.Min(1f, contrib.BaseContribution / (loserMaxContrib * 0.7f)); string contributionDesc; if (scaleFactor > 0.75f) { contributionDesc = "valiant"; } else if (scaleFactor > 0.5f) { contributionDesc = "stalwart"; } else if (scaleFactor > 0.25f) { contributionDesc = "modest"; } else { contributionDesc = "small"; } plr?.SendClientMessage($"Though your realm lost {zoneName}, you have been rewarded for your {contributionDesc} effort in defense.", ChatLogFilters.CHATLOGFILTERS_RVR); if (plr != null) { if (plr.Region == _region) { plr.AddXp((uint)Math.Min(xpCap * 0.9f, lossXP * scaleFactor), false, false); if (plr.AAOBonus > 1) { plr.AddRenown((uint)Math.Min(rpCap * 0.9f, lossRP * scaleFactor + (tokenCount * 100)), false, RewardType.ObjectiveDefense, zoneName); if (plr.CurrentArea != null) { ushort influenceId = realm == Realms.REALMS_REALM_ORDER ? (ushort)plr.CurrentArea.OrderInfluenceId : (ushort)plr.CurrentArea.DestroInfluenceId; plr.AddInfluence(influenceId, (ushort)Math.Min(infCap * 0.9f, lossInf * scaleFactor + (tokenCount * 100))); } } else { plr.AddRenown((uint)Math.Min(rpCap * 0.9f, lossRP * scaleFactor), false, RewardType.ObjectiveDefense, zoneName); if (plr.CurrentArea != null) { ushort influenceId = realm == Realms.REALMS_REALM_ORDER ? (ushort)plr.CurrentArea.OrderInfluenceId : (ushort)plr.CurrentArea.DestroInfluenceId; plr.AddInfluence(influenceId, (ushort)Math.Min(infCap * 0.9f, lossInf * scaleFactor)); } } } else { plr.AddPendingXP((uint)Math.Min(xpCap * 0.9f, lossXP * scaleFactor)); plr.AddPendingRenown((uint)Math.Min(rpCap * 0.9f, lossRP * scaleFactor)); } } else if (chara.Value != null) { chara.Value.PendingXp += (uint)Math.Min(xpCap * 0.9f, lossXP * scaleFactor); chara.Value.PendingRenown += (uint)Math.Min(rpCap * 0.9f, lossRP * scaleFactor); CharMgr.Database.SaveObject(chara.Value); } ushort resultantCount = (ushort)(lossMedallionCount * scaleFactor); /* * if (plr != null && plr.AAOBonus > 1 && plr.Region == Region) * { * resultantCount = Convert.ToUInt16(resultantCount * ((AgainstAllOddsMult * 20)/100)); * } */ if (scaleFactor > 0 && plr != null) { if ((tier == 2 || tier == 3) && plr.ItmInterface.CreateItem(T3Token, tokenCount) == ItemResult.RESULT_OK) { plr.SendLocalizeString(new[] { T3Token.Name, tokenCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X); } if (tier == 4 && plr.ItmInterface.CreateItem(T4Token, tokenCount) == ItemResult.RESULT_OK) { plr.SendLocalizeString(new[] { T4Token.Name, tokenCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X); } } if (resultantCount > 0) { if (plr != null && plr.Region == _region && plr.ItmInterface.CreateItem(medallionInfo, resultantCount) == ItemResult.RESULT_OK) { plr.SendLocalizeString(new[] { medallionInfo.Name, resultantCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X); } else { Character_mail medallionMail = new Character_mail { Guid = CharMgr.GenerateMailGuid(), CharacterId = chara.CharacterId, CharacterIdSender = chara.CharacterId, SenderName = chara.Name, ReceiverName = chara.Name, SendDate = (uint)TCPManager.GetTimeStamp(), Title = "Medallion Reward", Content = "You've received a medallion reward for your participation in a recent battle.", Money = 0, Opened = false }; medallionMail.Items.Add(new MailItem(medallionInfo.Entry, resultantCount)); if (tier == 2 || tier == 3) { medallionMail.Items.Add(new MailItem(T3Token.Entry, tokenCount)); } if (tier == 4) { medallionMail.Items.Add(new MailItem(T4Token.Entry, tokenCount)); } CharMgr.AddMail(medallionMail); } } } } PlayerContributions.Clear(); }
static public void BuildItem(ref PacketOut Out, Item Itm, Item_Info Info, ushort SlotId, ushort Count) { SlotId = SlotId == 0 ? (Itm == null ? SlotId : Itm.SlotId) : SlotId; Count = Count == 0 ? (Itm == null ? Count : Itm.Count) : Count; Info = Info == null ? (Itm == null ? null : Itm.Info) : Info; if (SlotId != 0) { Out.WriteUInt16(SlotId); } Out.WriteByte(0); Out.WriteUInt32((uint)(Info != null ? Info.Entry : 0)); if (Info == null) { return; } Out.WriteUInt32(Info.ModelId); Out.WriteUInt16(Info.SlotId); Out.WriteByte(Info.Type); Out.WriteByte(Info.MinRank); Out.WriteByte((byte)(Info.MinRank + 1)); // 1.3.5 Out.WriteByte(Info.MinRenown); // 1.3.5 Out.WriteByte(Info.MinRenown); Out.WriteByte(Info.MinRenown); Out.WriteByte(Info.Rarity); Out.WriteByte(Info.Bind); Out.WriteByte(Info.Race); Out.WriteUInt32(Info.Career); Out.WriteUInt32(0); Out.WriteUInt32(Info.SellPrice); Out.WriteUInt16((UInt16)(Count > 0 ? Count : 1)); Out.WriteUInt32(0); Out.WriteUInt32(Info.Skills); Out.WriteUInt16(Info.Dps > 0 ? Info.Dps : Info.Armor); Out.WriteUInt16(Info.Speed); Out.WritePascalString(Info.Name); Out.WriteByte((byte)Info._Stats.Count); foreach (KeyValuePair <byte, UInt16> Key in Info._Stats) { Out.WriteByte(Key.Key); Out.WriteUInt16(Key.Value); Out.Fill(0, 5); } Out.WriteByte(0); Out.WriteByte(0); // SpellCounts // (uint32)Entry, uint16 X, uint16 Y Out.WriteByte(0); // Artisana Info , 3 bytes pour chaque artisana Out.WriteByte(0); Out.WriteByte(Info.TalismanSlots); for (int i = 0; i < Info.TalismanSlots; ++i) { Out.WriteUInt32(0); // Entry; } Out.WritePascalString(Info.Description); Out.WriteByte(0); Out.WriteByte(0); Out.WriteByte(0); Out.WriteByte(0); Out.WriteUInt16(0x0302); Out.Fill(0, 8); Out.WriteByte(0); // Type , Culture, etc etc Out.WriteByte(0); // Type, Recipian , Soil , etc etc Out.Fill(0, 11); }
public static LootContainer GetScenarioLoot(Player player, int scenTier, ZoneMgr zone) { List <LootInfo> lootList = new List <LootInfo>(); int corpseLevel = scenTier * 10; int corpseRenown = scenTier * 10; // Scenario zones all have a war_world.zone_infos.type value of 1. // Note - if "1" refers to "instance" instead of "scenario", there could be problems // with players receiving scenario-restricted loot for a PVP kill made in an instance List <Loot_Group> lootGroups = CreatureService.GetLootGroupsByEvent(1); // This will be our narrowed down list of loot groups that are relevant to the kill in question. List <Loot_Group> candidateLootGroups = new List <Loot_Group>(); // Whittle down the loot groups into a new candidate list, based on the killed player's career, // and whether the kill occurred in the correct zone (if any) and whether the player has the required quest (if any) foreach (Loot_Group lg in lootGroups) { if (lg == null) { continue; } if (lg.ReqActiveQuest > 0) { Character_quest quest = player.QtsInterface.GetQuest(lg.ReqActiveQuest); if (quest == null || quest.IsDone()) { continue; } } if (lg.SpecificZone != 0 && zone.Info.ZoneId != lg.SpecificZone) { continue; } candidateLootGroups.Add(lg); } // Generate items from remaining loot groups foreach (Loot_Group lg in candidateLootGroups) { if (lg == null) { continue; } // roll for drops. for (int groupIndex = 0; groupIndex < lg.DropCount; groupIndex++) { float roll = (float)StaticRandom.Instance.Next(0, 10000) / 10000; if (roll <= lg.DropChance) { // Assemble valid drops from the group List <Loot_Group_Item> candidateItems = new List <Loot_Group_Item>(); foreach (Loot_Group_Item lgi in lg.LootGroupItems) { if (lgi == null) { continue; } if (corpseLevel < lgi.MinRank || corpseLevel > lgi.MaxRank) { continue; } if (corpseRenown < lgi.MinRenown || corpseRenown > lgi.MaxRenown) { continue; } Item_Info itemDef = ItemService.GetItem_Info(lgi.ItemID); if (itemDef.Realm != 0 && itemDef.Realm != (byte)player.Realm) { continue; } candidateItems.Add(lgi); } // If the loot group requires that the dropped loot be usable by a member of // the killer's party, then remove non-compatible loot from the candidate list. if (lg.ReqGroupUsable) { List <Player> members; if (player.PriorityGroup != null) { members = player.PriorityGroup.GetPlayerListCopy(); } else { members = new List <Player> { player }; } for (int itemIndex = 0; itemIndex < candidateItems.Count; ++itemIndex) { bool valid = false; Item_Info curItem = ItemService.GetItem_Info(candidateItems[itemIndex].ItemID); foreach (Player member in members) { if (!ItemsInterface.CanUse(curItem, member, true, false)) { continue; } // Usable by at least one member valid = true; break; } if (!valid) { candidateItems.RemoveAt(itemIndex); --itemIndex; } } } // Now roll for an item from the candidate item list, and add it to the loots. if (candidateItems.Count > 0) { Item_Info winningItem = ItemService.GetItem_Info(candidateItems[StaticRandom.Instance.Next(0, candidateItems.Count)].ItemID); lootList.Add(new LootInfo(winningItem)); } } } } return(lootList.Count <= 0 ? null : new LootContainer { LootInfo = lootList }); }
/*private const float DROP_BONUS_CHAMP = 0.2f; * private const float DROP_BONUS_HERO = 0.04f; * * private const float RARITY_COMMON_GEAR = 20f; * * private static readonly float[] RARITIES = { 5f, 0.4f, 0.02f }; * * private const byte MAX_EASE_IN_LEVEL = 7;*/ public static LootContainer GenerateLoot(Unit corpse, Unit looter, float dropMod) { // Declare kill event constants for bitfields const byte KILL_EVENT_SCENARIO = 1; const byte KILL_EVENT_RVR = 2; const byte KILL_EVENT_PVE = 4; // If the killer isn't a player or a pet, don't bother looting. Player player = null; if (looter == null) { return(null); } if (looter.IsPet()) { player = (looter as Pet).Owner; } else if (looter.IsPlayer()) { player = looter as Player; } if (player == null) { return(null); } // Initialize lootgroups we'll be searching through List <Loot_Group> lootGroups; Player deadPlayer = corpse as Player; // If the corpse is a player, and you've made it this far, this was a PVP kill if (deadPlayer != null) { List <LootInfo> lootList = new List <LootInfo>(); uint corpseCareer = (uint)Math.Pow(2, deadPlayer.Info.CareerLine - 1); uint corpseLevel = deadPlayer.AdjustedLevel; uint corpseRenown = deadPlayer.AdjustedRenown; // Scenario zones all have a war_world.zone_infos.type value of 1. // Note - if "1" refers to "instance" instead of "scenario", there could be problems // with players receiving scenario-restricted loot for a PVP kill made in an instance lootGroups = CreatureService.GetLootGroupsByEvent(deadPlayer.Zone.Info.Type == 1 ? KILL_EVENT_SCENARIO : KILL_EVENT_RVR); // This will be our narrowed down list of loot groups that are relevant to the kill in question. List <Loot_Group> candidateLootGroups = new List <Loot_Group>(); // Whittle down the loot groups into a new candidate list, based on the killed player's career, // and whether the kill occurred in the correct zone (if any) and whether the player has the required quest (if any) foreach (Loot_Group lg in lootGroups) { if (lg == null) { continue; } if (lg.ReqActiveQuest > 0) { Character_quest quest = player.QtsInterface.GetQuest(lg.ReqActiveQuest); if (quest == null || quest.IsDone()) { continue; } } if ((corpseCareer & lg.CreatureID) != corpseCareer) { continue; } if (lg.SpecificZone != 0 && deadPlayer.Zone.Info.ZoneId != lg.SpecificZone) { continue; } candidateLootGroups.Add(lg); } // Generate items from remaining loot groups foreach (Loot_Group lg in candidateLootGroups) { if (lg == null) { continue; } // roll for drops. for (int groupIndex = 0; groupIndex < lg.DropCount; groupIndex++) { float roll = (float)StaticRandom.Instance.Next(0, 10000) / 10000; if (roll <= lg.DropChance) { // Assemble valid drops from the group List <Loot_Group_Item> candidateItems = new List <Loot_Group_Item>(); // This whole if is horrible spaghetti, we need to add each new medallion type here if (Constants.DoomsdaySwitch > 0 && lg.Entry == 1 && WorldMgr.WorldSettingsMgr.GetMedallionsSetting() == 1 && looter.GetPlayer().ScnInterface.Scenario == null && deadPlayer.Level > 15) { foreach (Loot_Group_Item lgi in lg.LootGroupItems) { if (lgi == null) { continue; } if (deadPlayer.Level < 41 && deadPlayer.RenownRank < 41 && corpseRenown < looter.GetPlayer().RenownRank&& looter.RenownRank > 40) { if (lgi.ItemID == 208470 || lgi.ItemID == 208470 || lgi.ItemID == 208470) { candidateItems.Add(lgi); } } else { if (corpseLevel < lgi.MinRank || corpseLevel > lgi.MaxRank) { continue; } if (corpseRenown < lgi.MinRenown || corpseRenown > lgi.MaxRenown) { continue; } Item_Info itemDef = ItemService.GetItem_Info(lgi.ItemID); if (itemDef.Realm != 0 && itemDef.Realm != (byte)player.Realm) { continue; } candidateItems.Add(lgi); } } } else { foreach (Loot_Group_Item lgi in lg.LootGroupItems) { if (lgi == null) { continue; } if (corpseLevel < lgi.MinRank || corpseLevel > lgi.MaxRank) { continue; } if (corpseRenown < lgi.MinRenown || corpseRenown > lgi.MaxRenown) { continue; } Item_Info itemDef = ItemService.GetItem_Info(lgi.ItemID); if (itemDef.Realm != 0 && itemDef.Realm != (byte)player.Realm) { continue; } candidateItems.Add(lgi); } } // If the loot group requires that the dropped loot be usable by a member of // the killer's party, then remove non-compatible loot from the candidate list. if (lg.ReqGroupUsable) { List <Player> members; if (player.PriorityGroup != null) { members = player.PriorityGroup.GetPlayerListCopy(); } else { members = new List <Player> { player }; } for (int itemIndex = 0; itemIndex < candidateItems.Count; ++itemIndex) { bool valid = false; Item_Info curItem = ItemService.GetItem_Info(candidateItems[itemIndex].ItemID); foreach (Player member in members) { if (!ItemsInterface.CanUse(curItem, member, true, false)) { continue; } // Usable by at least one member valid = true; break; } if (!valid) { candidateItems.RemoveAt(itemIndex); --itemIndex; } } } // Now roll for an item from the candidate item list, and add it to the loots. if (candidateItems.Count > 0) { Item_Info winningItem = ItemService.GetItem_Info(candidateItems[StaticRandom.Instance.Next(0, candidateItems.Count)].ItemID); lootList.Add(new LootInfo(winningItem)); } } } } // Generate money as normal, and pass the generated loot back to the system. uint money = corpseLevel * 5 + corpseRenown * 5; if (lootList.Count > 0 || money > 0) { LootContainer lt = new LootContainer { Money = money, LootInfo = lootList }; //corpse.EvtInterface.Notify(EventName.ON_GENERATE_LOOT, looter, Lt); return(lt); } } else if (corpse.IsCreature()) { Creature deadCreature = corpse.GetCreature(); List <LootInfo> Loots = new List <LootInfo>(); // All creatures are by definition PVE kills lootGroups = CreatureService.GetLootGroupsByEvent(KILL_EVENT_PVE); // This will be our narrowed down list of loot groups that are relevant to the kill in question. List <Loot_Group> candidateLootGroups = new List <Loot_Group>(); // Whittle down the loot groups into a new candidate list, based on the killed creature's ID, // or the CreatureSubType if the loot group's CreatureID is 0. foreach (Loot_Group lg in lootGroups) { if (lg == null) { continue; } if (lg.ReqActiveQuest != 0 && !player.QtsInterface.HasQuest(lg.ReqActiveQuest)) { continue; } if (lg.SpecificZone != 0 && deadCreature.Zone.Info.ZoneId != lg.SpecificZone) { continue; } if (lg.CreatureID != 0) { if (deadCreature.Entry == lg.CreatureID) { candidateLootGroups.Add(lg); } } else { if (lg.CreatureSubType == 0 || CreatureService.GetCreatureProto(deadCreature.Entry).CreatureSubType == lg.CreatureSubType) { candidateLootGroups.Add(lg); } } } // Generate items from remaining loot groups foreach (Loot_Group lg in candidateLootGroups) { try { if (lg == null) { continue; } // roll for drops. for (int groupIndex = 0; groupIndex < lg.DropCount; groupIndex++) { float roll = (float)StaticRandom.Instance.Next(0, 10000) / 10000; if (roll <= lg.DropChance) { // Assemble valid drops from the group List <Loot_Group_Item> candidateItems = new List <Loot_Group_Item>(); int effectiveLevel = Math.Min(Program.Config.RankCap, deadCreature.Level); if (lg.LootGroupItems != null) { foreach (Loot_Group_Item lgi in lg.LootGroupItems) { try { if (lgi == null) { continue; } if (effectiveLevel < lgi.MinRank || effectiveLevel > lgi.MaxRank) { continue; } Item_Info itemDef = ItemService.GetItem_Info(lgi.ItemID); if (itemDef.Realm != 0 && itemDef.Realm != (byte)player.Realm) { continue; } candidateItems.Add(lgi); } catch { continue; } } } // If the loot group requires that the dropped loot be usable by a member of // the killer's party, then remove non-compatible loot from the candidate list. if (lg.ReqGroupUsable) { List <Player> members; if (player.PriorityGroup != null) { members = player.PriorityGroup.GetPlayerListCopy(); } else { members = new List <Player> { player } }; for (int itemIndex = 0; itemIndex < candidateItems.Count; ++itemIndex) { bool valid = false; Item_Info curItem = ItemService.GetItem_Info(candidateItems[itemIndex].ItemID); foreach (Player member in members) { if (!ItemsInterface.CanUse(curItem, member, true, false)) { continue; } valid = true; break; } if (!valid) { candidateItems.RemoveAt(itemIndex); --itemIndex; } } } // Now roll for an item from the candidate item list, and add it to the loots. if (candidateItems.Count > 0) { Item_Info winningItem = ItemService.GetItem_Info(candidateItems[StaticRandom.Instance.Next(0, candidateItems.Count)].ItemID); Loots.Add(new LootInfo(winningItem)); } } } } catch { continue; } } // Generate money as normal, and pass the generated loot back to the system. uint money = corpse.Level * (uint)7 + corpse.Rank * (uint)50; if (Loots.Count > 0 || money > 0) { LootContainer lt = new LootContainer { Money = money, LootInfo = Loots }; //corpse.EvtInterface.Notify(EventName.ON_GENERATE_LOOT, looter, Lt); return(lt); } } else if (corpse.IsGameObject()) { // This will generate gameobject loot. Currently this only shows loot // if a player needs an item it holds for a quest. If an object has // been looted already or has no loot this will return null. // Todo: Currently object loot always is 100%. Make this support non quest related loot. GameObject gameObj = corpse.GetGameObject(); List <GameObject_loot> gameObjectLoots = GameObjectService.GetGameObjectLoots(gameObj.Spawn.Entry); if (gameObjectLoots.Count <= 0 || gameObj.Looted) { return(null); } QuestsInterface Interface = looter.QtsInterface; if (Interface == null) { return(null); } List <LootInfo> lootInfo = new List <LootInfo>(); foreach (GameObject_loot loot in gameObjectLoots) { foreach (KeyValuePair <ushort, Character_quest> kp in Interface.Quests) { if (kp.Value.Done || kp.Value.IsDone()) { continue; } foreach (Character_Objectives obj in kp.Value._Objectives) { if (obj.IsDone() || obj.Objective.Item == null || obj.Objective.Item.Entry != loot.ItemId) { continue; } lootInfo.Add(new LootInfo(loot.Info)); break; } } } LootContainer lt = new LootContainer { Money = 0, LootInfo = lootInfo }; return(lt); } return(null); }
internal void TickContribution(long curTimeSeconds) { foreach (KeyValuePair <uint, ContributionInfo> kV in PlayerContributions) { var x = kV.Value; if (kV.Value.ActiveTimeEnd > curTimeSeconds) { kV.Value.BaseContribution += (uint)(125 * _tier * RENOWN_CONTRIBUTION_FACTOR); } else if (curTimeSeconds - kV.Value.ActiveTimeEnd > CONTRIB_ELAPSE_INTERVAL) { _toRemove.Add(kV); } } if (_toRemove.Count > 0) { Item_Info medallionInfo = ItemService.GetItem_Info((uint)(208399 + _tier)); uint rpCap = (uint)(_tier * 7000); uint maxContrib = GetMaxContribution(PlayerContributions); foreach (var kVr in _toRemove) { // Convert contribution to XP/RP based on current loss rates. float contributionFactor = Math.Min(1f, kVr.Value.BaseContribution / (maxContrib * 0.7f)); uint rp = (uint)(Math.Min(rpCap, maxContrib * 1.5f * LoserShare * contributionFactor)); uint xp = rp * 5; ushort medallionCount = (ushort)Math.Min(12, rp / (450 * _tier)); Player player = Player.GetPlayer(kVr.Key); if (player != null) { player.SendClientMessage("You have received a reward for your contributions to a recent battle.", ChatLogFilters.CHATLOGFILTERS_RVR); if (player.Region == _region) { player.AddXp(xp, false, false); player.AddRenown(rp, false); if (medallionCount > 0 && player.ItmInterface.CreateItem(medallionInfo, medallionCount) == ItemResult.RESULT_OK) { player.SendLocalizeString(new[] { medallionInfo.Name, medallionCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X); } } else { player.AddPendingXP(xp); player.AddPendingRenown(rp); if (medallionCount > 0) { Character_mail medallionMail = new Character_mail { Guid = CharMgr.GenerateMailGuid(), CharacterId = player.CharacterId, CharacterIdSender = player.CharacterId, SenderName = player.Name, ReceiverName = player.Name, SendDate = (uint)TCPManager.GetTimeStamp(), Title = "Medallion Reward", Content = "You've received a medallion reward for your participation in a recent battle.", Money = 0, Opened = false }; medallionMail.Items.Add(new MailItem(medallionInfo.Entry, medallionCount)); CharMgr.AddMail(medallionMail); } } } else { Character chara = CharMgr.GetCharacter(kVr.Key, false); if (chara != null && chara.Value != null) { chara.Value.PendingXp += xp; chara.Value.PendingRenown += rp; CharMgr.Database.SaveObject(chara.Value); if (medallionCount > 0) { Character_mail medallionMail = new Character_mail { Guid = CharMgr.GenerateMailGuid(), CharacterId = chara.CharacterId, CharacterIdSender = chara.CharacterId, SenderName = chara.Name, ReceiverName = chara.Name, SendDate = (uint)TCPManager.GetTimeStamp(), Title = "Medallion Reward", Content = "You've received a medallion reward for your participation in a recent battle.", Money = 0, Opened = false }; medallionMail.Items.Add(new MailItem(medallionInfo.Entry, medallionCount)); CharMgr.AddMail(medallionMail); } } } PlayerContributions.Remove(kVr.Key); } _toRemove.Clear(); } }