void RpcItemAdded(On.RoR2.Inventory.orig_RpcItemAdded orig, RoR2.Inventory inventory, ItemIndex itemIndex) { if (Data.modEnabled) { if (Data.mode == DataShop.mode) { if (Data.modEnabled) { if (Data.mode == DataShop.mode) { if (inventoryLocal != null) { if (inventoryLocal == inventory) { //if (!Data.scrapItems.Contains(itemIndex)) { DataShop.AddScrap(characterBody, Data.GetItemTier(Data.allItemsIndexes[itemIndex])); //} } } } } } } orig(inventory, itemIndex); }
// try and setup our character, if we hit an error we set it to false //TODO: Find a way to stop it from checking whilst in main menu/lobby menu private static void GetCharacter() { try { LocalNetworkUser = null; foreach (NetworkUser readOnlyInstance in NetworkUser.readOnlyInstancesList) { //localplayer == you! if (readOnlyInstance.isLocalPlayer) { LocalNetworkUser = readOnlyInstance; LocalPlayer = LocalNetworkUser.master; LocalPlayerInv = LocalPlayer.GetComponent <Inventory>(); LocalHealth = LocalPlayer.GetBody().GetComponent <HealthComponent>(); LocalSkills = LocalPlayer.GetBody().GetComponent <SkillLocator>(); if (LocalHealth.alive) { _CharacterCollected = true; } else { _CharacterCollected = false; } } } } catch (Exception e) { _CharacterCollected = false; } }
private void ResetInv(RoR2.Inventory inv = null) { foreach (GameObject go in TileList) { Destroy(go); } InvData.Clear(); TileList.Clear(); int team_player = 0; int current_player_items = 0; foreach (var player in PlayerCharacterMasterController.instances) { inv = player.master.GetBody().inventory; var inv_order = (List <ItemIndex>)inv.itemAcquisitionOrder; using (List <ItemIndex> .Enumerator enumerator = (inv_order).GetEnumerator()) { while (enumerator.MoveNext()) { ItemIndex current = enumerator.Current; if (current == ItemIndex.DrizzlePlayerHelper) { continue; } ItemData itemdata = new ItemData(inv.GetItemCount(current), current); float overflowcounter = (Camera.main.aspect >= 2.0) ? 23 : 11; float tile_size_offset = (inv_order.Count < overflowcounter) ? tile_size : tile_size * ((overflowcounter) / inv_order.Count); float modified_horizontal_tile_offset = horizontal_tile_offset - (tile_size - tile_size_offset) / 2; GameObject TileSetup = Instantiate(PersonalTile, ExchangeWindow.transform); TileSetup.GetComponent <RectTransform>().anchoredPosition = new Vector2(tile_size_offset * (current_player_items) + modified_horizontal_tile_offset, vertical_tile_offset - team_player * team_offset_size); int TilePos = TileList.Count; TileSetup.GetComponent <Button>().onClick.AddListener(() => RegisterOffer(TilePos, player.master.GetBody())); InvData.Add(itemdata); TileList.Add(TileSetup); current_player_items++; } } team_player++; current_player_items = 0; } }
static void PreventRevivesShuffle(On.RoR2.ShrineRestackBehavior.orig_AddShrineStack orig, ShrineRestackBehavior self, Interactor interactor) { if (NetworkServer.active) { //Remove revives before shuffling so it doesn't add to the shuffle RoR2.Inventory playerInventory = interactor.GetComponent <CharacterBody>().master.inventory; playerInventory.RemoveItem(RoR2Content.Items.ExtraLife, 9999); playerInventory.RemoveItem(RoR2Content.Items.ExtraLifeConsumed, 9999); //Shuffle orig(self, interactor); //Reshuffle if shuffle landed on a revive item while (playerInventory.GetItemCount(RoR2Content.Items.ExtraLife) != 0 || playerInventory.GetItemCount(RoR2Content.Items.ExtraLife) != 0) { playerInventory.ShrineRestackInventory(Run.instance.treasureRng); } } else { orig(self, interactor); } }
private void GenericPickupController_GrantItem(On.RoR2.GenericPickupController.orig_GrantItem orig, RoR2.GenericPickupController self, RoR2.CharacterBody body, RoR2.Inventory inventory) { orig.Invoke(self, body, inventory); //Debug.Log(self.pickupIndex); PickupIndex dio = new PickupIndex(ItemIndex.ExtraLife); if (self.pickupIndex == dio) { //List<PickupIndex> tier3Items = Run.instance.availableTier3DropList; //int rng = random.Next(0, tier3Items.Count); //if (tier3Items[rng] == dio) // rng++; //ItemIndex rngItem = tier3Items[rng].itemIndex; //tier3Items[rng].itemIndex.ToString(); //tier3Items[rng].GetPickupNameToken(); string pickupName = self.GetComponentInChildren <PickupDisplay>().transform.GetChild(1).name.Replace("(Clone)", ""); //Debug.Log(pickupName); ItemDef[] items = typeof(ItemCatalog).GetFieldValue <ItemDef[]>("itemDefs"); ItemDef fakeItem = items[0]; //Debug.Log(items.Length); //Debug.Log(items[0]); foreach (ItemDef item in items) { if (item.pickupModelPath.Contains(pickupName)) { Debug.Log("FOUND!!!!!!!!"); fakeItem = item; break; } } PickupIndex ogItem = new PickupIndex(fakeItem.itemIndex); //Debug.Log("----------"); //Debug.Log(ogItem.GetPickupNameToken()); //Debug.Log(Language.GetString(ogItem.GetPickupNameToken())); //Debug.Log(ogItem.itemIndex); //Debug.Log("----------"); //PickupIndex ogItem = new PickupIndex(ItemIndex.Behemoth); //string rngItemName = Language.GetString(tier3Items[rng].GetPickupNameToken()); //Color32 color = tier3Items[rng].GetPickupColor(); //Color32 colorDark = tier3Items[rng].GetPickupColorDark(); string rngItemName = Language.GetString(ogItem.GetPickupNameToken()); Color32 color = ogItem.GetPickupColor(); Color32 colorDark = ogItem.GetPickupColorDark(); //<color=#307FFF>Lunar Coin</color><style=cEvent> Dropped</style> Chat.AddMessage(String.Format("<style=cEvent>You were expecting </style>{0} {1}", Util.GenerateColoredString(rngItemName, color), Util.GenerateColoredString("BUT IT WAS ME DIO", colorDark))); } }
private void GenericPickupController_GrantItem(On.RoR2.GenericPickupController.orig_GrantItem orig, RoR2.GenericPickupController self, RoR2.CharacterBody body, RoR2.Inventory inventory) { orig.Invoke(self, body, inventory); //Debug.Log(self.pickupIndex); PickupIndex trashDio = new PickupIndex(ItemIndex.Bear); if (self.pickupIndex == trashDio) { List <PickupIndex> tier1Items = Run.instance.availableTier1DropList; int rng = random.Next(0, tier1Items.Count); if (tier1Items[rng] == trashDio) { rng++; } //ItemIndex rngItem = tier3Items[rng].itemIndex; //tier3Items[rng].itemIndex.ToString(); //tier3Items[rng].GetPickupNameToken(); string rngItemName = Language.GetString(tier1Items[rng].GetPickupNameToken()); Color32 color = tier1Items[rng].GetPickupColor(); Color32 colorDark = tier1Items[rng].GetPickupColorDark(); //<color=#307FFF>Lunar Coin</color><style=cEvent> Dropped</style> Chat.AddMessage(String.Format("<style=cEvent>You were expecting </style>{0} {1}", Util.GenerateColoredString(rngItemName, color), Util.GenerateColoredString("BUT IT WAS ME TRASH DIO", colorDark))); } }
bool SetEquipmentInternal(On.RoR2.Inventory.orig_SetEquipmentInternal orig, RoR2.Inventory inventory, EquipmentState equipmentState, uint slot) { bool equipmentChanged = orig(inventory, equipmentState, slot); if (Data.modEnabled) { if (Data.mode == DataShop.mode) { if (inventoryLocal != null) { if (inventoryLocal == inventory) { int stageClearCountNew = Run.instance.stageClearCount; if (stageClearCountOld != stageClearCountNew) { stageClearCountOld = stageClearCountNew; equipmentFoundThisStage.Clear(); equipmentFoundThisStageTwice.Clear(); foreach (EquipmentState equipmentStateOlder in latestEquipment) { if (equipmentStateOlder.equipmentIndex != EquipmentIndex.None && !equipmentFoundThisStage.Contains(equipmentStateOlder.equipmentIndex)) { equipmentFoundThisStage.Add(equipmentStateOlder.equipmentIndex); } } } int slotAdjusted = (int)slot; if (slotAdjusted + 1 > latestEquipment.Count) { for (int appendIndex = 0; appendIndex < slotAdjusted + 1 - latestEquipment.Count; appendIndex++) { latestEquipment.Add(new EquipmentState(EquipmentIndex.None, new Run.FixedTimeStamp(), 0)); } } EquipmentState equipmentStateOld = latestEquipment[slotAdjusted]; if (!EquipmentState.Equals(equipmentStateOld, equipmentState)) { latestEquipment[slotAdjusted] = equipmentState; if (!equipmentFoundThisStage.Contains(latestEquipment[slotAdjusted].equipmentIndex)) { if (Data.allEquipmentIndexes.ContainsKey(equipmentState.equipmentIndex)) { if (DataShop.AddScrap(characterBody, Data.GetItemTier(Data.allEquipmentIndexes[equipmentState.equipmentIndex]))) { equipmentFoundThisStage.Add(equipmentState.equipmentIndex); } } } } } } } } return(equipmentChanged); }