コード例 #1
0
        public void SendBlackMarketReward(Player player, uint itemId)
        {
            var blackMarketItems = ItemService._BlackMarket_Items;

            foreach (var blackMarketItem in blackMarketItems)
            {
                if (blackMarketItem.ItemId == itemId)
                {
                    Character_mail mail = new Character_mail
                    {
                        Guid              = CharMgr.GenerateMailGuid(),
                        CharacterId       = Convert.ToUInt32(player.CharacterId), //CharacterId
                        SenderName        = "Black Market",
                        ReceiverName      = player.Name,
                        SendDate          = (uint)TCPManager.GetTimeStamp(),
                        Title             = "Black Market Rewards",
                        Content           = "Open it and see...",
                        Money             = 0,
                        Opened            = false,
                        CharacterIdSender = 0  // system
                    };

                    MailItem item = new MailItem(Convert.ToUInt32(1298378521), Convert.ToUInt16(1));
                    if (item != null)
                    {
                        mail.Items.Add(item);
                        CharMgr.AddMail(mail);
                    }
                }
            }
        }
コード例 #2
0
ファイル: MailService.cs プロジェクト: cooler-SAI/ProjectWAR
        public static bool MailItem(uint characterId, uint itemId, ushort count)
        {
            var character = CharMgr.GetCharacter(characterId, true);

            if (character == null)
            {
                return(false);
            }
            var characterName = character?.Name;

            Character_mail mail = new Character_mail
            {
                Guid              = CharMgr.GenerateMailGuid(),
                CharacterId       = characterId, //CharacterId
                SenderName        = "Ikthaleon",
                ReceiverName      = characterName,
                SendDate          = (uint)TCPManager.GetTimeStamp(),
                Title             = "",
                Content           = "",
                Money             = 0,
                Opened            = false,
                CharacterIdSender = 283
            };

            MailItem item = new MailItem(itemId, count);

            if (item != null)
            {
                mail.Items.Add(item);
                CharMgr.AddMail(mail);
            }

            return(true);
        }
コード例 #3
0
ファイル: LootChest.cs プロジェクト: cooler-SAI/ProjectWAR
        // Called by Destroy of Object
        public override void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            try
            {
                foreach (var lootBag in LootBags)
                {
                    var character     = CharMgr.GetCharacter(lootBag.Key, false);
                    var characterName = character?.Name;

                    // Forced to have some value here.
                    if (Content == null)
                    {
                        Content = "mail";
                    }
                    if (String.IsNullOrEmpty(Content))
                    {
                        Content = "mail";
                    }

                    Character_mail mail = new Character_mail
                    {
                        Guid         = CharMgr.GenerateMailGuid(),
                        CharacterId  = lootBag.Key, //CharacterId
                        SenderName   = SenderName,
                        ReceiverName = characterName,
                        SendDate     = (uint)TCPManager.GetTimeStamp(),
                        Title        = Title,
                        Content      = Content,
                        Money        = 0,
                        Opened       = false
                    };

                    mail.CharacterIdSender = lootBag.Key;
                    MailItem item = new MailItem((uint)lootBag.Value.Key.Entry, lootBag.Value.Value, 0, 0, (ushort)lootBag.Value.Value.Count);
                    if (item != null)
                    {
                        mail.Items.Add(item);
                        CharMgr.AddMail(mail);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("LootChest", $"Failed to mail loot. {ex.Message} {ex.StackTrace}");
            }



            base.Dispose();
        }
コード例 #4
0
ファイル: AuctionHouse.cs プロジェクト: cooler-SAI/ProjectWAR
        public static void CheckAuctionExpiry(object arg)
        {
            int removeCount = 0;

            long expireTimeStart = TCPManager.GetTimeStamp() - (60 * 60 * 24 * 30);

            lock (Auctions)
            {
                for (int i = 0; i < Auctions.Count; ++i)
                {
                    if (Auctions[i].StartTime >= expireTimeStart)
                    {
                        continue;
                    }

                    Common.Auction auction = Auctions[i];

                    if (auction.Item == null)
                    {
                        auction.Item = ItemService.GetItem_Info(auction.ItemId);
                    }

                    if (auction.Item != null)
                    {
                        // return item to lister
                        Character_mail expireMail = new Character_mail
                        {
                            Guid         = CharMgr.GenerateMailGuid(),
                            CharacterId  = auction.SellerId,
                            ReceiverName = auction.Seller.Name,
                            SendDate     = (uint)TCPManager.GetTimeStamp(),
                            AuctionType  = 3,
                            Content      = auction.Item.Name,
                            Money        = 0,
                            Opened       = false
                        };

                        expireMail.Items.Add(new MailItem(auction.ItemId, auction._Talismans, auction.PrimaryDye, auction.SecondaryDye, auction.Count));

                        CharMgr.AddMail(expireMail);
                    }

                    CharMgr.Database.DeleteObject(auction);
                    Auctions.RemoveAt(i);

                    ++removeCount;

                    --i;
                }

                Log.Info("Auction House", $"Removed {removeCount} expired {(removeCount == 1 ? "auction": "auctions")}.");
            }
        }
コード例 #5
0
ファイル: Standard.cs プロジェクト: cooler-SAI/ProjectWAR
        public override void SendInteract(Player player, InteractMenu menu)
        {
            uint itemid = 0;

            switch (Bannertyp)
            {
            case 0: itemid = (uint)(RealmStandard == Realms.REALMS_REALM_DESTRUCTION ? 187704 : 187701); break;

            case 1: itemid = (uint)(RealmStandard == Realms.REALMS_REALM_DESTRUCTION ? 187705 : 187702); break;

            case 2: itemid = (uint)(RealmStandard == Realms.REALMS_REALM_DESTRUCTION ? 187706 : 187703); break;
            }


            if (player == Owner)
            {
                if (player.ItmInterface.GetItemInSlot(14) == null)
                {
                    player.ItmInterface.CreateItem(ItemService.GetItem_Info(itemid), 1, 14);
                    player.ItmInterface.SendEquipped(player);
                    player.ItmInterface.SendEquipped(null);
                }
                else
                {
                    player.ItmInterface.CreateItem(ItemService.GetItem_Info(itemid), 1);
                }
            }
            else if (player.Realm == RealmStandard)
            {
                Character_mail Mail = new Character_mail();
                Mail.Guid              = CharMgr.GenerateMailGuid();
                Mail.CharacterId       = Owner.CharacterId;
                Mail.CharacterIdSender = player.CharacterId;
                Mail.SenderName        = player.Name;
                Mail.ReceiverName      = Owner.Name;
                Mail.SendDate          = (uint)TCPManager.GetTimeStamp();
                Mail.Title             = "Guild Standard";
                Mail.Content           = "Found your Guild Standard";
                Mail.Money             = 0;
                Mail.Opened            = false;
                Mail.Items.Add(new MailItem(itemid, 1));
                CharMgr.AddMail(Mail);
            }
            else
            {
                player.AddRenown(600, false);
            }


            player.PlantedStandard = null;
            Dispose();
        }
コード例 #6
0
        /// <summary>
        /// Returns an expired mail to its sender.
        /// </summary>
        private static MailResult ReturnMail(Character_mail mail)
        {
            // Can't return auction mail.
            if (mail.AuctionType != 0)
            {
                return(MailResult.TEXT_MAIL_RESULT11);
            }

            Character receiver = CharMgr.GetCharacter(mail.SenderName, false);

            // No one to return mail to.
            if (receiver == null)
            {
                return(MailResult.TEXT_MAIL_RESULT11);
            }

            // If mail is COD, remove the COD requirement and remove the money.
            if (mail.Cr)
            {
                mail.Cr    = false;
                mail.Money = 0;
            }

            CharMgr.DeleteMail(mail);

            Character_mail returnMail = new Character_mail
            {
                // Sender -> Reciever, Reciever -> Sender
                Guid              = CharMgr.GenerateMailGuid(),
                CharacterId       = mail.CharacterIdSender,
                CharacterIdSender = mail.CharacterId,
                SenderName        = mail.ReceiverName,
                ReceiverName      = mail.SenderName,
                Content           = "Your mail expired and has been returned to you.",
                ReadDate          = 0,
                SendDate          = (uint)TCPManager.GetTimeStamp(),
                Opened            = false
            };

            CharMgr.AddMail(returnMail);

            return(MailResult.TEXT_MAIL_UNK);
        }
コード例 #7
0
        public override void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            try
            {
                foreach (KeyValuePair <uint, GoldBag> loot in _lootBags)
                {
                    Character_mail mail = new Character_mail
                    {
                        Guid         = CharMgr.GenerateMailGuid(),
                        CharacterId  = loot.Key,
                        SenderName   = "Public Quest",
                        ReceiverName = loot.Value.plrName,
                        SendDate     = (uint)TCPManager.GetTimeStamp(),
                        Title        = "Public Quest Loot",
                        Content      = "You won a Public Quest Loot Bag",
                        Money        = 0,
                        Opened       = false
                    };

                    //Mail.CharacterIdSender = plr.CharacterId;
                    MailItem item = GenerateBag(loot.Key);
                    if (item != null)
                    {
                        mail.Items.Add(item);
                        CharMgr.AddMail(mail);
                    }
                }
            }
            catch (NullReferenceException)
            {
                Log.Error("GoldChest", "Failed to mail loot.");
            }

            _lootBags = new Dictionary <uint, GoldBag>();

            base.Dispose();
        }
コード例 #8
0
        public void SendMail(Character receiver, string subject, string message, uint money, bool cashOnDelivery, List <ushort> itemSlots = null)
        {
            Player sender = (Player)_Owner;

            Character_mail cMail = new Character_mail
            {
                Guid              = CharMgr.GenerateMailGuid(),
                CharacterId       = receiver.CharacterId,
                CharacterIdSender = sender.CharacterId,
                SenderName        = sender.Info.Name,
                ReceiverName      = receiver.Name,
                SendDate          = (uint)TCPManager.GetTimeStamp(),
                Title             = subject,
                Content           = message,
                Money             = money,
                Cr     = cashOnDelivery,
                Opened = false
            };

            if (itemSlots != null)
            {
                foreach (ushort itmslot in itemSlots)
                {
                    Item itm = sender.ItmInterface.GetItemInSlot(itmslot);
                    // This should never happen, double check.
                    if (itm != null && itm.Info != null)
                    {
                        cMail.Items.Add(new MailItem(itm.Info.Entry, itm.GetTalismans(), itm.GetPrimaryDye(), itm.GetSecondaryDye(), itm.Count));
                        sender.ItmInterface.DeleteItem(itmslot, itm.Count);
                        itm.Owner = null;
                    }
                }
            }

            SendResult(MailResult.TEXT_MAIL_RESULT4);

            CharMgr.AddMail(cMail);

            _nextSend = (uint)TCPManager.GetTimeStamp() + 5;
        }
コード例 #9
0
        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();
            }
        }
コード例 #10
0
        /// <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();
        }
コード例 #11
0
ファイル: AuctionHouse.cs プロジェクト: cooler-SAI/ProjectWAR
        public static void BuyOutAuction(Player buyer, ulong auctionId, uint price)
        {
            Common.Auction auction;

            bool cancel = false;

            lock (Auctions)
                auction = Auctions.Find(info => info.AuctionId == auctionId);

            if (auction == null)
            {
                buyer.SendLocalizeString(auctionId.ToString(), ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_AUCTION_ITEM_NO_LONGER_EXISTS);
                return;
            }

            if (auction.SellPrice != price)
            {
                if (price == 0 && auction.SellerId == buyer.CharacterId) // cancel?
                {
                    cancel = true;
                }
                else
                {
                    buyer.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_AUCTION_UNKNOWN_ERROR);
                    return;
                }
            }
            else if (!buyer.RemoveMoney(auction.SellPrice))
            {
                buyer.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_AUCTION_NOT_ENOUGH_MONEY);
                return;
            }

            // Remove live auction
            lock (Auctions)
                Auctions.Remove(auction);
            auction.Dirty = true;
            CharMgr.Database.DeleteObject(auction);

            // SendMail to seller
            if (!cancel) // seller dosent need this if hes canceling
            {
                if (auction.Seller != null)
                {
                    Character_mail sellerMail = new Character_mail
                    {
                        Guid         = CharMgr.GenerateMailGuid(),
                        CharacterId  = auction.SellerId,
                        ReceiverName = auction.Seller.Name,
                        SendDate     = (uint)TCPManager.GetTimeStamp(),
                        AuctionType  = 2,
                        Content      = auction.Item.Name,
                        Money        = (uint)(auction.SellPrice * AUCTION_HOUSE_TAX_MULT),
                        Opened       = false
                    };
                    // Complete

                    CharMgr.AddMail(sellerMail);
                }
            }

            // SendMail to buyer
            Character_mail buyerMail = new Character_mail
            {
                Guid         = CharMgr.GenerateMailGuid(),
                CharacterId  = buyer.CharacterId,
                ReceiverName = buyer.Name,
                SendDate     = (uint)TCPManager.GetTimeStamp(),
                AuctionType  = cancel ? (byte)3 : (byte)5,
                Content      = auction.Item.Name,
                Money        = 0,
                Opened       = false
            };

            buyerMail.Items.Add(new MailItem(auction.ItemId, auction._Talismans, auction.PrimaryDye, auction.SecondaryDye, auction.Count));

            CharMgr.AddMail(buyerMail);

            // Send a list
            if (cancel)
            {
                SendAuctions(buyer, "", buyer.Name, 0, 0, 0, 0, new List <byte>(), new List <byte>(), 0);
                buyer.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_SAY, GameData.Localized_text.TEXT_AUCTION_CANCEL_SUCCESSFUL);
            }
            else
            {
                SendAuctions(buyer, "", "", 0, 0, 0, 0, new List <byte>(), new List <byte>(), 0);
                buyer.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_SAY, GameData.Localized_text.TEXT_AUCTION_BUYOUT_SUCCESSFUL);
            }
        }
コード例 #12
0
        /// <summary>
        /// To answer and close a ticket (answer will be sent as an ingame mail)
        /// </summary>
        /// <param name="plr"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        public static bool Answer(Player plr, ref List <string> values)
        {
            if (values.Count < 2)
            {
                plr.SendClientMessage("Usage: .ticket answer <bugtrackerID> <message>");
                return(true);
            }

            string reportID = GetString(ref values);
            string message  = GetTotalString(ref values).Trim();

            if (string.IsNullOrEmpty(message))
            {
                plr.SendClientMessage("you need to specify a message to send");
                return(true);
            }

            if (string.IsNullOrEmpty(reportID))
            {
                plr.SendClientMessage("you need to specify the ticketID");
                return(true);
            }

            Bug_report report = CharMgr.GetReport(reportID);

            if (report == null)
            {
                plr.SendClientMessage("The Specified report does not exist");
                return(true);
            }

            if (report.Assigned != plr.Client._Account.Username)
            {
                plr.SendClientMessage("You cannot answer a ticket not assigned to you(username), assign it to yourself first if you want to answer this ticket");
                return(true);
            }

            if (CharMgr.GetCharacter(report.CharacterId, false) == null)
            {
                plr.SendClientMessage("The player who created this ticket is deleted or has not logged in for over the preload period, as such we cannot send a mail to the character.");
                return(true);
            }

            else
            {
                plr.SendClientMessage("You have answered ticket: " + reportID);

                GMCommandLog log = new GMCommandLog
                {
                    PlayerName = plr.Client._Account.Username,
                    AccountId  = (uint)plr.Client._Account.AccountId,
                    Command    = $"Answered Ticket: {reportID} from characterID: {report.CharacterId}. Containing message: {report.Message} {report.FieldSting} with the following reply: {message}",
                    Date       = DateTime.Now
                };

                Character      chara      = CharMgr.GetCharacter(report.CharacterId, false);
                Character_mail ticketMail = new Character_mail
                {
                    Guid              = CharMgr.GenerateMailGuid(),
                    CharacterId       = chara.CharacterId,
                    CharacterIdSender = chara.CharacterId,
                    SenderName        = chara.Name,
                    ReceiverName      = chara.Name,
                    SendDate          = (uint)TCPManager.GetTimeStamp(),
                    Title             = "Answered Ticket",
                    Content           = $"Your ticket has been answered by: {report.Assigned} with the following message: \n \n {message}",
                    Money             = 0,
                    Opened            = false
                };

                CharMgr.AddMail(ticketMail);
                CharMgr.Database.AddObject(log);

                lock (CharMgr._report)
                {
                    CharMgr._report.Remove(report);
                    CharMgr.Database.DeleteObject(report);
                    CharMgr.Database.ForceSave();
                }
                return(true);
            }
        }