private static void OnGrantEquipment(On.RoR2.GenericPickupController.orig_GrantEquipment orig, GenericPickupController self, CharacterBody body, Inventory inventory) { #region Sharedequipment var equip = PickupCatalog.GetPickupDef(self.pickupIndex).equipmentIndex; if (!BlackList.HasEquipment(equip) && NetworkServer.active && IsValidEquipmentPickup(self.pickupIndex) && GeneralHooks.IsMultiplayer()) { foreach (var player in PlayerCharacterMasterController.instances.Select(p => p.master) .Where(p => !p.IsDeadAndOutOfLivesServer() || ShareSuite.DeadPlayersGetItems.Value)) { SyncToolbotEquip(player, ref equip); // Sync Mul-T Equipment, but perform primary equipment pickup only for clients if (player.inventory == inventory) { continue; } player.inventory.SetEquipmentIndex(equip); self.NetworkpickupIndex = PickupCatalog.FindPickupIndex(equip); } } orig(self, body, inventory); #endregion }
private static PickupIndex?GetRandomItemOfTier(ItemTier tier, PickupIndex orDefault) { switch (tier) { case ItemTier.Tier1: return(PickRandomOf(BlackList.AvailableTier1DropList)); case ItemTier.Tier2: return(PickRandomOf(BlackList.AvailableTier2DropList)); case ItemTier.Tier3: return(PickRandomOf(BlackList.AvailableTier3DropList)); case ItemTier.Lunar: if (ShareSuite.LunarItemsRandomized.Value) { return(PickRandomOf(BlackList.AvailableLunarDropList)); } break; case ItemTier.Boss: if (ShareSuite.BossItemsRandomized.Value) { return(PickRandomOf(BlackList.AvailableBossDropList)); } break; default: break; } var pickupDef = PickupCatalog.GetPickupDef(orDefault); if (BlackList.HasItem(pickupDef.itemIndex)) { return(null); } else { return(orDefault); } }
public static void SendRichPickupMessage(CharacterMaster player, PickupDef pickupDef) { var body = player.hasBody ? player.GetBody() : null; if (!GeneralHooks.IsMultiplayer() || body == null || !ShareSuite.RichMessagesEnabled.Value) { SendPickupMessage(player, pickupDef.pickupIndex); return; } var pickupColor = pickupDef.baseColor; var pickupName = Language.GetString(pickupDef.nameToken); var playerColor = GetPlayerColor(player.playerCharacterMasterController); if (BlackList.HasItem(pickupDef.itemIndex) || !ItemSharingHooks.IsValidItemPickup(pickupDef.pickupIndex)) { var singlePickupMessage = $"<color=#{playerColor}>{body.GetUserName()}</color> <color=#{GrayColor}>picked up</color> " + $"<color=#{ColorUtility.ToHtmlStringRGB(pickupColor)}>" + $"{pickupName ?? "???"}</color> <color=#{GrayColor}>for themself. </color>" + $"<color=#{NotSharingColor}>(Item Set to NOT be Shared)</color>"; Chat.SendBroadcastChat(new Chat.SimpleChatMessage { baseToken = singlePickupMessage }); return; } var pickupMessage = $"<color=#{playerColor}>{body.GetUserName()}</color> <color=#{GrayColor}>picked up</color> " + $"<color=#{ColorUtility.ToHtmlStringRGB(pickupColor)}>" + $"{pickupName ?? "???"}</color> <color=#{GrayColor}>for themself</color>" + $"{ItemPickupFormatter(body)}<color=#{GrayColor}>.</color>"; Chat.SendBroadcastChat(new Chat.SimpleChatMessage { baseToken = pickupMessage }); }
private static void OnGrantItem(On.RoR2.GenericPickupController.orig_GrantItem orig, GenericPickupController self, CharacterBody body, Inventory inventory) { var item = PickupCatalog.GetPickupDef(self.pickupIndex); var itemDef = ItemCatalog.GetItemDef(item.itemIndex); var randomizedPlayerDict = new Dictionary <CharacterMaster, PickupDef>(); if ((ShareSuite.RandomizeSharedPickups.Value || !BlackList.HasItem(item.itemIndex)) && NetworkServer.active && IsValidItemPickup(self.pickupIndex) && GeneralHooks.IsMultiplayer()) { if (ShareSuite.RandomizeSharedPickups.Value) { randomizedPlayerDict.Add(body.master, item); } foreach (var player in PlayerCharacterMasterController.instances.Select(p => p.master)) { // Ensure character is not original player that picked up item if (player.inventory == inventory) { continue; } // Do not reward dead players if not required if (!ShareSuite.DeadPlayersGetItems.Value && player.IsDeadAndOutOfLivesServer()) { continue; } if (ShareSuite.RandomizeSharedPickups.Value) { var pickupIndex = GetRandomItemOfTier(itemDef.tier, item.pickupIndex); if (pickupIndex == null) { // Could not find any not blacklisted item in that tier. You get nothing! Good day, sir! continue; } var giveItem = PickupCatalog.GetPickupDef(pickupIndex.Value); player.inventory.GiveItem(giveItem.itemIndex); // Alternative: Only show pickup text for yourself // var givePickupDef = PickupCatalog.GetPickupDef(givePickupIndex); // Chat.AddPickupMessage(body, givePickupDef.nameToken, givePickupDef.baseColor, 1); // Legacy -- old normal pickup message handler //SendPickupMessage(player, giveItem); randomizedPlayerDict.Add(player, giveItem); } // Otherwise give everyone the same item else { player.inventory.GiveItem(item.itemIndex); } } ChatHandler.SendRichRandomizedPickupMessage(body.master, item, randomizedPlayerDict); orig(self, body, inventory); return; } ChatHandler.SendRichPickupMessage(body.master, item); orig(self, body, inventory); }
private void InitConfig() { ModIsEnabled = Config.Bind( "Settings", "ModEnabled", true, "Toggles whether or not the mod is enabled. If turned off while in-game, it will unhook " + "everything and reset the game to it's default behaviors." ); ModIsEnabled.SettingChanged += ReloadHooks; MoneyIsShared = Config.Bind( "Settings", "MoneyShared", true, "Toggles money sharing between teammates. Every player gains money together and spends it " + "from one central pool of money." ); WhiteItemsShared = Config.Bind( "Settings", "WhiteItemsShared", true, "Toggles item sharing for common (white color) items." ); GreenItemsShared = Config.Bind( "Settings", "GreenItemsShared", true, "Toggles item sharing for rare (green color) items." ); RedItemsShared = Config.Bind( "Settings", "RedItemsShared", true, "Toggles item sharing for legendary (red color) items." ); EquipmentShared = Config.Bind( "Settings", "EquipmentShared", false, "Toggles item sharing for equipment." ); LunarItemsShared = Config.Bind( "Settings", "LunarItemsShared", false, "Toggles item sharing for Lunar (blue color) items." ); BossItemsShared = Config.Bind( "Settings", "BossItemsShared", true, "Toggles item sharing for boss (yellow color) items." ); RichMessagesEnabled = Config.Bind( "Settings", "RichMessagesEnabled", true, "Toggles detailed item pickup messages with information on who picked the item up and" + " who all received the item." ); RandomizeSharedPickups = Config.Bind( "Balance", "RandomizeSharedPickups", false, "When enabled each player (except the player who picked up the item) will get a randomized item of the same rarity." ); LunarItemsRandomized = Config.Bind( "Balance", "LunarItemsRandomized", true, "Toggles randomizing Lunar items in RandomizeSharedPickups mode." ); BossItemsRandomized = Config.Bind( "Balance", "BossItemsRandomized", false, "Toggles randomizing Boss items in RandomizeSharedPickups mode." ); PrinterCauldronFixEnabled = Config.Bind( "Balance", "PrinterCauldronFix", true, "Toggles 3D printer and Cauldron item dupe fix by giving the item directly instead of" + " dropping it on the ground." ); DeadPlayersGetItems = Config.Bind( "Balance", "DeadPlayersGetItems", false, "Toggles whether or not dead players should get copies of picked up items." ); OverridePlayerScalingEnabled = Config.Bind( "Balance", "OverridePlayerScaling", true, "Toggles override of the scalar of interactables (chests, shrines, etc) that spawn in the world to your configured credit." ); InteractablesCredit = Config.Bind( "Balance", "InteractablesCredit", 1d, "If player scaling via this mod is enabled, the amount of players the game should think are playing in terms of chest spawns." ); OverrideBossLootScalingEnabled = Config.Bind( "Balance", "OverrideBossLootScaling", true, "Toggles override of the scalar of boss loot drops to your configured balance." ); BossLootCredit = Config.Bind( "Balance", "BossLootCredit", 1, "Specifies the amount of boss items dropped when the boss drop override is true." ); OverrideVoidFieldLootScalingEnabled = Config.Bind( "Balance", "OverrideVoidLootScaling", true, "Toggles override of the scalar of Void Field loot drops to your configured balance." ); VoidFieldLootCredit = Config.Bind( "Balance", "VoidFieldLootCredit", 1, "Specifies the amount of Void Fields items dropped when the Void Field scaling override is true." ); MoneyScalarEnabled = Config.Bind( "Settings", "MoneyScalarEnabled", false, "Toggles the money scalar, set MoneyScalar to an amount to fine-tune the amount of gold " + "you recieve." ); MoneyScalar = Config.Bind( "Settings", "MoneyScalar", 1D, "Modifies player count used in calculations of gold earned when money sharing is on." ); ItemBlacklist = Config.Bind( "Settings", "ItemBlacklist", "53,60,82,86", "Items (by index) that you do not want to share, comma separated. Please find the item indices at: https://github.com/risk-of-thunder/R2Wiki/wiki/Item-&-Equipment-IDs-and-Names" ); ItemBlacklist.SettingChanged += (o, e) => BlackList.Recalculate(); EquipmentBlacklist = Config.Bind( "Settings", "EquipmentBlacklist", "", "Equipment (by index) that you do not want to share, comma separated. Please find the indices at: https://github.com/risk-of-thunder/R2Wiki/wiki/Item-&-Equipment-IDs-and-Names" ); EquipmentBlacklist.SettingChanged += (o, e) => BlackList.Recalculate(); }