Tournament Items Modifier

Users who are viewing this thread

Adversarius

Recruit
Hello,

is there a way to give items (helmets, weapons) won in tournaments a positve item modifier?
Like this: campaign.add_modified_item eastern_vendel_helmet lordly_plate

thanks in advance.
 
Hello,

is there a way to give items (helmets, weapons) won in tournaments a positve item modifier?
Like this: campaign.add_modified_item eastern_vendel_helmet lordly_plate

thanks in advance.
AFAIK tournament prizes https://apidoc.bannerlord.com/v/1.0...t_game.html#a1464a9fdef356d13f31a278df7747bd1 are instances of core items. I assume you’d need to create special prize items to avoid modifying other instances of the same core item. However, I’m not a coder, so, I could be entirely wrong. You’d probably get a better answer in the bl-coding channel of Mount & Blade Modding discord.
 
Upvote 0
I found a solution for myself (04.03.23 corrected - now working):

In the class TournamentManager:

C#:
        public void GivePrizeToWinner(TournamentGame tournament, Hero winner, bool isPlayerParticipated)
        {
            if (!isPlayerParticipated)
            {
                tournament.UpdateTournamentPrize(isPlayerParticipated, false);
            }
            if (winner.PartyBelongedTo == MobileParty.MainParty)
            {
                ItemComponent itemComponent = tournament.Prize.ItemComponent;
                ItemModifier itemModifier = null;
                if (itemComponent != null)
                {
                    ItemModifierGroup itemModifierGroup = itemComponent.ItemModifierGroup;
                    itemModifier = ((itemModifierGroup != null) ? itemModifierGroup.GetRandomItemModifierLootScoreBased() : null);
                }
                EquipmentElement rosterElement = new EquipmentElement(tournament.Prize, itemModifier, null, false);
                winner.PartyBelongedTo.ItemRoster.AddToCounts(rosterElement, 1);
                return;
            }
            if (winner.Clan != null)
            {
                GiveGoldAction.ApplyBetweenCharacters(null, winner.Clan.Leader, tournament.Town.MarketData.GetPrice(tournament.Prize, null, false, null), false);
            }
        }
 
Last edited:
Upvote 0
I found a solution for myself:

At the End of GetTournamentPrize()

C#:
            ItemObject prize = this._possibleEliteRewardItemObjectsCache.GetRandomElement<ItemObject>();
            ItemComponent itemComponent = prize.ItemComponent;
            ItemModifier itemModifier = null;
            if (itemComponent != null)
            {
                ItemModifierGroup itemModifierGroup = itemComponent.ItemModifierGroup;
                itemModifier = ((itemModifierGroup != null) ? itemModifierGroup.GetRandomItemModifierLootScoreBased() : null);
            }
            EquipmentElement winPrize = new EquipmentElement(prize, itemModifier, null, false);
            return winPrize.Item;
Congratulations. Thanks for updating this thread with the answer. :smile:
 
Upvote 0
Back
Top Bottom