public static bool IsPartOfSet(this ItemDrop.ItemData itemData, string setName) { return(itemData.m_shared.m_setName == setName); }
static bool Prefix(Player __instance, Inventory ___m_inventory, ref float ___m_timeSinceDeath, float ___m_hardDeathCooldown, ZNetView ___m_nview, List <Player.Food> ___m_foods, Skills ___m_skills) { if (!modEnabled.Value) { return(true); } ___m_nview.GetZDO().Set("dead", true); ___m_nview.InvokeRPC(ZNetView.Everybody, "OnDeath", new object[] { }); Game.instance.GetPlayerProfile().m_playerStats.m_deaths++; Game.instance.GetPlayerProfile().SetDeathPoint(__instance.transform.position); if (createDeathEffects.Value) { Traverse.Create(__instance).Method("CreateDeathEffects").GetValue(); } List <ItemDrop.ItemData> dropItems = new List <ItemDrop.ItemData>(); if (!keepAllItems.Value) { List <Inventory> inventories = new List <Inventory>(); if (quickSlotsAssembly != null) { var extendedInventory = quickSlotsAssembly.GetType("EquipmentAndQuickSlots.InventoryExtensions").GetMethod("Extended", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { ___m_inventory }); inventories = (List <Inventory>)quickSlotsAssembly.GetType("EquipmentAndQuickSlots.ExtendedInventory").GetField("_inventories", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(extendedInventory); } else { inventories.Add(___m_inventory); } for (int i = 0; i < inventories.Count; i++) { Inventory inv = inventories[i]; if (quickSlotsAssembly != null && keepQuickSlotItems.Value && inv == (Inventory)quickSlotsAssembly.GetType("EquipmentAndQuickSlots.PlayerExtensions").GetMethod("GetQuickSlotInventory", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { __instance })) { Dbgl("Skipping quick slot inventory"); continue; } List <ItemDrop.ItemData> keepItems = Traverse.Create(inv).Field("m_inventory").GetValue <List <ItemDrop.ItemData> >(); if (destroyAllItems.Value) { keepItems.Clear(); } else { for (int j = keepItems.Count - 1; j >= 0; j--) { ItemDrop.ItemData item = keepItems[j]; if (keepEquippedItems.Value && item.m_equiped) { continue; } if (keepHotbarItems.Value && item.m_gridPos.y == 0) { continue; } if (item.m_shared.m_questItem) { continue; } if (destroyItemTypes.Value.Length > 0) { string[] destroyTypes = destroyItemTypes.Value.Split(','); if (destroyTypes.Contains(Enum.GetName(typeof(ItemDrop.ItemData.ItemType), item.m_shared.m_itemType))) { keepItems.RemoveAt(j); continue; } } if (keepItemTypes.Value.Length > 0) { string[] keepTypes = keepItemTypes.Value.Split(','); if (keepTypes.Contains(Enum.GetName(typeof(ItemDrop.ItemData.ItemType), item.m_shared.m_itemType))) { continue; } } else if (dropItemTypes.Value.Length > 0) { string[] dropTypes = dropItemTypes.Value.Split(','); if (dropTypes.Contains(Enum.GetName(typeof(ItemDrop.ItemData.ItemType), item.m_shared.m_itemType))) { dropItems.Add(item); keepItems.RemoveAt(j); } continue; } dropItems.Add(item); keepItems.RemoveAt(j); } } Traverse.Create(inv).Method("Changed").GetValue(); } } if (useTombStone.Value && dropItems.Any()) { GameObject gameObject = Instantiate(__instance.m_tombstone, __instance.GetCenterPoint(), __instance.transform.rotation); gameObject.GetComponent <Container>().GetInventory().RemoveAll(); int width = Traverse.Create(___m_inventory).Field("m_width").GetValue <int>(); int height = Traverse.Create(___m_inventory).Field("m_height").GetValue <int>(); Traverse.Create(gameObject.GetComponent <Container>().GetInventory()).Field("m_width").SetValue(width); Traverse.Create(gameObject.GetComponent <Container>().GetInventory()).Field("m_height").SetValue(height); Traverse.Create(gameObject.GetComponent <Container>().GetInventory()).Field("m_inventory").SetValue(dropItems); Traverse.Create(gameObject.GetComponent <Container>().GetInventory()).Method("Changed").GetValue(); TombStone component = gameObject.GetComponent <TombStone>(); PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); component.Setup(playerProfile.GetName(), playerProfile.GetPlayerID()); } else { foreach (ItemDrop.ItemData item in dropItems) { Vector3 position = __instance.transform.position + Vector3.up * 0.5f + UnityEngine.Random.insideUnitSphere * 0.3f; Quaternion rotation = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 360), 0f); ItemDrop.DropItem(item, 0, position, rotation); } } if (!keepFoodLevels.Value) { ___m_foods.Clear(); } bool hardDeath = noSkillProtection.Value || ___m_timeSinceDeath > ___m_hardDeathCooldown; if (hardDeath && reduceSkills.Value) { ___m_skills.OnDeath(); } Game.instance.RequestRespawn(10f); ___m_timeSinceDeath = 0; if (!hardDeath) { __instance.Message(MessageHud.MessageType.TopLeft, "$msg_softdeath", 0, null); } __instance.Message(MessageHud.MessageType.Center, "$msg_youdied", 0, null); __instance.ShowTutorial("death", false); string eventLabel = "biome:" + __instance.GetCurrentBiome().ToString(); Gogan.LogEvent("Game", "Death", eventLabel, 0L); return(false); }
static bool Prefix(Player __instance, Piece.Requirement[] requirements, int qualityLevel) { Inventory pInventory = __instance.GetInventory(); List <Container> nearbyContainers = GetNearbyContainers(__instance.transform.position); foreach (Piece.Requirement requirement in requirements) { if (requirement.m_resItem) { int totalRequirement = requirement.GetAmount(qualityLevel); if (totalRequirement <= 0) { continue; } string reqName = requirement.m_resItem.m_itemData.m_shared.m_name; int totalAmount = pInventory.CountItems(reqName); Dbgl($"have {totalAmount}/{totalRequirement} {reqName} in player inventory"); pInventory.RemoveItem(reqName, Math.Min(totalAmount, totalRequirement)); if (totalAmount < totalRequirement) { foreach (Container c in nearbyContainers) { Inventory cInventory = c.GetInventory(); int thisAmount = Mathf.Min(cInventory.CountItems(reqName), totalRequirement - totalAmount); Dbgl($"Container at {c.transform.position} has {cInventory.CountItems(reqName)}"); if (thisAmount == 0) { continue; } for (int i = 0; i < cInventory.GetAllItems().Count; i++) { ItemDrop.ItemData item = cInventory.GetItem(i); if (item.m_shared.m_name == reqName) { Dbgl($"Got stack of {item.m_stack} {reqName}"); int stackAmount = Mathf.Min(item.m_stack, totalRequirement - totalAmount); if (stackAmount == item.m_stack) { cInventory.RemoveItem(item); } else { item.m_stack -= stackAmount; } totalAmount += stackAmount; Dbgl($"total amount is now {totalAmount}/{totalRequirement} {reqName}"); if (totalAmount >= totalRequirement) { break; } } } cInventory.GetType().GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(cInventory, new object[] { }); if (totalAmount >= totalRequirement) { Dbgl($"consumed enough {reqName}"); break; } } } } } return(false); }
public static void Postfix(InventoryGui __instance, Player player, Recipe recipe, ItemDrop.ItemData item, bool canCraft) { var selectedCraftingItem = __instance.InCraftTab() && recipe.m_item != null; var selectedUpgradeItem = __instance.InUpradeTab() && item != null; if (selectedCraftingItem || selectedUpgradeItem) { var thisItem = selectedCraftingItem ? recipe.m_item.m_itemData : item; if (thisItem.UseMagicBackground()) { var element = __instance.m_recipeList.LastOrDefault(); if (element != null) { var image = element.transform.Find("icon").GetComponent <Image>(); var bgImage = Object.Instantiate(image, image.transform.parent, true); bgImage.name = "MagicItemBG"; bgImage.transform.SetSiblingIndex(image.transform.GetSiblingIndex()); bgImage.sprite = EpicLoot.Assets.GenericItemBgSprite; bgImage.color = thisItem.GetRarityColor(); if (!canCraft) { bgImage.color -= new Color(0, 0, 0, 0.66f); } var nameText = element.transform.Find("name").GetComponent <Text>(); nameText.color = canCraft ? thisItem.GetRarityColor() : new Color(0.66f, 0.66f, 0.66f, 1f); } } } }
public static bool CanCreateEffect(VisEquipment __instance, int itemHash, out Player player, out ItemDrop.ItemData equippedItem, out string itemID) { equippedItem = null; itemID = null; player = __instance.GetComponent <Player>(); if (player == null) { return(false); } var itemPrefab = ObjectDB.instance.GetItemPrefab(itemHash); if (itemPrefab == null) { return(false); } itemID = itemPrefab.name; var itemDrop = itemPrefab.GetComponent <ItemDrop>(); if (itemDrop == null) { return(false); } var itemData = itemDrop.m_itemData; equippedItem = player.GetEquipmentOfType(itemData.m_shared.m_itemType); return(equippedItem != null); }
public static List <MagicItemEffectDefinition> GetAvailableAugments(AugmentRecipe recipe, ItemDrop.ItemData item, MagicItem magicItem, ItemRarity rarity) { var valuelessEffect = false; if (recipe.EffectIndex >= 0 && recipe.EffectIndex < magicItem.Effects.Count) { var currentEffectDef = MagicItemEffectDefinitions.Get(magicItem.Effects[recipe.EffectIndex].EffectType); valuelessEffect = currentEffectDef.GetValuesForRarity(rarity) == null; } return(MagicItemEffectDefinitions.GetAvailableEffects(item.Extended(), item.GetMagicItem(), valuelessEffect ? -1 : recipe.EffectIndex)); }
public static bool HasActiveMagicEffect(Player player, ItemDrop.ItemData itemData, string effectType) { return(HasActiveMagicEffect(player, itemData.GetMagicItem(), effectType)); }
// Token: 0x0600036D RID: 877 RVA: 0x0001D5F4 File Offset: 0x0001B7F4 protected override void UpdateAI(float dt) { base.UpdateAI(dt); if (!this.m_nview.IsOwner()) { return; } if (this.IsSleeping()) { this.UpdateSleep(dt); return; } this.m_aiStatus = ""; Humanoid humanoid = this.m_character as Humanoid; bool flag; bool flag2; this.UpdateTarget(humanoid, dt, out flag, out flag2); if (this.m_avoidLand && !this.m_character.IsSwiming()) { this.m_aiStatus = "Move to water"; base.MoveToWater(dt, 20f); return; } if (((this.DespawnInDay() && EnvMan.instance.IsDay()) || (this.IsEventCreature() && !RandEventSystem.HaveActiveEvent())) && (this.m_targetCreature == null || !flag2)) { base.MoveAwayAndDespawn(dt, true); this.m_aiStatus = "Trying to despawn "; return; } if (this.m_fleeIfNotAlerted && !this.HuntPlayer() && this.m_targetCreature && !base.IsAlerted() && Vector3.Distance(this.m_targetCreature.transform.position, base.transform.position) - this.m_targetCreature.GetRadius() > this.m_alertRange) { base.Flee(dt, this.m_targetCreature.transform.position); this.m_aiStatus = "Avoiding conflict"; return; } if (this.m_fleeIfLowHealth > 0f && this.m_character.GetHealthPercentage() < this.m_fleeIfLowHealth && this.m_timeSinceHurt < 20f && this.m_targetCreature != null) { base.Flee(dt, this.m_targetCreature.transform.position); this.m_aiStatus = "Low health, flee"; return; } if ((this.m_afraidOfFire || this.m_avoidFire) && base.AvoidFire(dt, this.m_targetCreature, this.m_afraidOfFire)) { if (this.m_afraidOfFire) { this.m_targetStatic = null; this.m_targetCreature = null; } this.m_aiStatus = "Avoiding fire"; return; } if (this.m_circleTargetInterval > 0f && this.m_targetCreature) { if (this.m_targetCreature) { this.m_pauseTimer += dt; if (this.m_pauseTimer > this.m_circleTargetInterval) { if (this.m_pauseTimer > this.m_circleTargetInterval + this.m_circleTargetDuration) { this.m_pauseTimer = 0f; } base.RandomMovementArroundPoint(dt, this.m_targetCreature.transform.position, this.m_circleTargetDistance, base.IsAlerted()); this.m_aiStatus = "Attack pause"; return; } } else { this.m_pauseTimer = 0f; } } if (this.m_targetCreature != null) { if (EffectArea.IsPointInsideArea(this.m_targetCreature.transform.position, EffectArea.Type.NoMonsters, 0f)) { base.Flee(dt, this.m_targetCreature.transform.position); this.m_aiStatus = "Avoid no-monster area"; return; } } else { EffectArea effectArea = EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.NoMonsters, 15f); if (effectArea != null) { base.Flee(dt, effectArea.transform.position); this.m_aiStatus = "Avoid no-monster area"; return; } } if (this.m_fleeIfHurtWhenTargetCantBeReached && this.m_targetCreature != null && !this.m_havePathToTarget && this.m_timeSinceHurt < 20f) { this.m_aiStatus = "Hide from unreachable target"; base.Flee(dt, this.m_targetCreature.transform.position); return; } if ((!base.IsAlerted() || (this.m_targetStatic == null && this.m_targetCreature == null)) && this.UpdateConsumeItem(humanoid, dt)) { this.m_aiStatus = "Consume item"; return; } ItemDrop.ItemData itemData = this.SelectBestAttack(humanoid, dt); bool flag3 = itemData != null && Time.time - itemData.m_lastAttackTime > itemData.m_shared.m_aiAttackInterval && Time.time - this.m_lastAttackTime > this.m_minAttackInterval && !base.IsTakingOff(); if ((this.m_character.IsFlying() ? this.m_circulateWhileChargingFlying : this.m_circulateWhileCharging) && (this.m_targetStatic != null || this.m_targetCreature != null) && itemData != null && !flag3 && !this.m_character.InAttack()) { this.m_aiStatus = "Move around target weapon ready:" + flag3.ToString(); if (itemData != null) { this.m_aiStatus = this.m_aiStatus + " Weapon:" + itemData.m_shared.m_name; } Vector3 point = this.m_targetCreature ? this.m_targetCreature.transform.position : this.m_targetStatic.transform.position; base.RandomMovementArroundPoint(dt, point, this.m_randomMoveRange, base.IsAlerted()); return; } if ((!(this.m_targetStatic == null) || !(this.m_targetCreature == null)) && itemData != null) { if (itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.Enemy) { if (this.m_targetStatic) { Vector3 vector = this.m_targetStatic.FindClosestPoint(base.transform.position); if (Vector3.Distance(vector, base.transform.position) >= itemData.m_shared.m_aiAttackRange || !base.CanSeeTarget(this.m_targetStatic)) { this.m_aiStatus = "Move to static target"; base.MoveTo(dt, vector, 0f, base.IsAlerted()); return; } base.LookAt(this.m_targetStatic.GetCenter()); if (base.IsLookingAt(this.m_targetStatic.GetCenter(), itemData.m_shared.m_aiAttackMaxAngle) && flag3) { this.m_aiStatus = "Attacking piece"; this.DoAttack(null, false); return; } base.StopMoving(); return; } else if (this.m_targetCreature) { if (flag || flag2 || (this.HuntPlayer() && this.m_targetCreature.IsPlayer())) { this.m_beenAtLastPos = false; this.m_lastKnownTargetPos = this.m_targetCreature.transform.position; float num = Vector3.Distance(this.m_lastKnownTargetPos, base.transform.position) - this.m_targetCreature.GetRadius(); float num2 = this.m_alertRange * this.m_targetCreature.GetStealthFactor(); if ((flag2 && num < num2) || this.HuntPlayer()) { this.SetAlerted(true); } bool flag4 = num < itemData.m_shared.m_aiAttackRange; if (!flag4 || !flag2 || itemData.m_shared.m_aiAttackRangeMin < 0f || !base.IsAlerted()) { this.m_aiStatus = "Move closer"; Vector3 velocity = this.m_targetCreature.GetVelocity(); Vector3 vector2 = velocity * this.m_interceptTime; Vector3 vector3 = this.m_lastKnownTargetPos; if (num > vector2.magnitude / 4f) { vector3 += velocity * this.m_interceptTime; } if (base.MoveTo(dt, vector3, 0f, base.IsAlerted())) { flag4 = true; } } else { base.StopMoving(); } if (flag4 && flag2 && base.IsAlerted()) { this.m_aiStatus = "In attack range"; base.LookAt(this.m_targetCreature.GetTopPoint()); if (flag3 && base.IsLookingAt(this.m_lastKnownTargetPos, itemData.m_shared.m_aiAttackMaxAngle)) { this.m_aiStatus = "Attacking creature"; this.DoAttack(this.m_targetCreature, false); return; } } } else { this.m_aiStatus = "Searching for target"; if (this.m_beenAtLastPos) { base.RandomMovement(dt, this.m_lastKnownTargetPos); return; } if (base.MoveTo(dt, this.m_lastKnownTargetPos, 0f, base.IsAlerted())) { this.m_beenAtLastPos = true; return; } } } } else if (itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.FriendHurt || itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.Friend) { this.m_aiStatus = "Helping friend"; Character character = (itemData.m_shared.m_aiTargetType == ItemDrop.ItemData.AiTarget.FriendHurt) ? base.HaveHurtFriendInRange(this.m_viewRange) : base.HaveFriendInRange(this.m_viewRange); if (character) { if (Vector3.Distance(character.transform.position, base.transform.position) >= itemData.m_shared.m_aiAttackRange) { base.MoveTo(dt, character.transform.position, 0f, base.IsAlerted()); return; } if (flag3) { base.StopMoving(); base.LookAt(character.transform.position); this.DoAttack(character, true); return; } base.RandomMovement(dt, character.transform.position); return; } else { base.RandomMovement(dt, base.transform.position); } } return; } if (this.m_follow) { base.Follow(this.m_follow, dt); this.m_aiStatus = "Follow"; return; } this.m_aiStatus = string.Concat(new object[] { "Random movement (weapon: ", (itemData != null) ? itemData.m_shared.m_name : "none", ") (targetpiece: ", this.m_targetStatic, ") (target: ", this.m_targetCreature ? this.m_targetCreature.gameObject.name : "none", ")" }); base.IdleMovement(dt); }
private Transform GetAttach(ItemDrop.ItemData item) { return(this.m_attachOther); }
static void Postfix(InventoryGui __instance, ItemDrop.ItemData ___m_dragItem, Inventory ___m_dragInventory, int ___m_dragAmount, ref GameObject ___m_dragGo) { if (Input.GetKeyDown(m_hotkey.Value) && ___m_dragItem != null && ___m_dragInventory.ContainsItem(___m_dragItem)) { Dbgl($"Discarding {___m_dragAmount}/{___m_dragItem.m_stack} {___m_dragItem.m_dropPrefab.name}"); if (returnResources.Value > 0) { Recipe recipe = ObjectDB.instance.GetRecipe(___m_dragItem); if (recipe != null && (returnUnknownResources.Value || Player.m_localPlayer.IsRecipeKnown(___m_dragItem.m_shared.m_name))) { Dbgl($"Recipe stack: {recipe.m_amount} num of stacks: {___m_dragAmount / recipe.m_amount}"); var reqs = recipe.m_resources.ToList(); bool isMagic = false; bool cancel = false; if (epicLootAssembly != null) { isMagic = (bool)epicLootAssembly.GetType("EpicLoot.ItemDataExtensions").GetMethod("IsMagic", BindingFlags.Public | BindingFlags.Static).Invoke(null, new[] { ___m_dragItem }); } if (isMagic) { int rarity = (int)epicLootAssembly.GetType("EpicLoot.ItemDataExtensions").GetMethod("GetRarity", BindingFlags.Public | BindingFlags.Static).Invoke(null, new[] { ___m_dragItem }); List <KeyValuePair <ItemDrop, int> > magicReqs = (List <KeyValuePair <ItemDrop, int> >)epicLootAssembly.GetType("EpicLoot.Crafting.EnchantTabController").GetMethod("GetEnchantCosts", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { ___m_dragItem, rarity }); foreach (var kvp in magicReqs) { if (!returnUnknownResources.Value && ((ObjectDB.instance.GetRecipe(kvp.Key.m_itemData) && !Player.m_localPlayer.IsRecipeKnown(kvp.Key.m_itemData.m_shared.m_name)) || !Traverse.Create(Player.m_localPlayer).Field("m_knownMaterial").GetValue <HashSet <string> >().Contains(kvp.Key.m_itemData.m_shared.m_name))) { Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You don't know all the recipes for this item's materials."); return; } reqs.Add(new Piece.Requirement() { m_amount = kvp.Value, m_resItem = kvp.Key }); } } if (!cancel && ___m_dragAmount / recipe.m_amount > 0) { for (int i = 0; i < ___m_dragAmount / recipe.m_amount; i++) { foreach (Piece.Requirement req in reqs) { int quality = ___m_dragItem.m_quality; for (int j = quality; j > 0; j--) { GameObject prefab = ObjectDB.instance.m_items.FirstOrDefault(item => item.GetComponent <ItemDrop>().m_itemData.m_shared.m_name == req.m_resItem.m_itemData.m_shared.m_name); ItemDrop.ItemData newItem = prefab.GetComponent <ItemDrop>().m_itemData; int numToAdd = Mathf.RoundToInt(req.GetAmount(j) * returnResources.Value); Dbgl($"Returning {numToAdd}/{req.GetAmount(j)} {prefab.name}"); while (numToAdd > 0) { int stack = Mathf.Min(req.m_resItem.m_itemData.m_shared.m_maxStackSize, numToAdd); numToAdd -= stack; if (Player.m_localPlayer.GetInventory().AddItem(prefab.name, stack, req.m_resItem.m_itemData.m_quality, req.m_resItem.m_itemData.m_variant, 0, "") == null) { ItemDrop component = Instantiate(prefab, Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward + Player.m_localPlayer.transform.up, Player.m_localPlayer.transform.rotation).GetComponent <ItemDrop>(); component.m_itemData = newItem.Clone(); component.m_itemData.m_dropPrefab = prefab; component.m_itemData.m_stack = stack; Traverse.Create(component).Method("Save").GetValue(); } } } } } } } } if (___m_dragAmount == ___m_dragItem.m_stack) { Player.m_localPlayer.RemoveFromEquipQueue(___m_dragItem); Player.m_localPlayer.UnequipItem(___m_dragItem, false); ___m_dragInventory.RemoveItem(___m_dragItem); } else { ___m_dragInventory.RemoveItem(___m_dragItem, ___m_dragAmount); } Destroy(___m_dragGo); ___m_dragGo = null; __instance.GetType().GetMethod("UpdateCraftingPanel", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { false }); } }
private void Update() { if (!AedenthornUtils.IgnoreKeyPresses(true) && AedenthornUtils.CheckKeyDown(hotKey.Value)) { Player player = Player.m_localPlayer; Dbgl($"Ka-boom"); Collider[] array = Physics.OverlapSphere(player.transform.position, destroyRadius.Value, destroyMask); for (int i = 0; i < array.Length; i++) { Piece piece = array[i].GetComponentInParent <Piece>(); if (piece) { if (!piece.IsCreator()) { continue; } if (!piece.m_canBeRemoved) { continue; } if (Location.IsInsideNoBuildLocation(piece.transform.position)) { continue; } if (!PrivateArea.CheckAccess(piece.transform.position, 0f, true)) { continue; } if (!Traverse.Create(player).Method("CheckCanRemovePiece", new object[] { piece }).GetValue <bool>()) { continue; } ZNetView component = piece.GetComponent <ZNetView>(); if (component == null) { continue; } if (!piece.CanBeRemoved()) { continue; } WearNTear component2 = piece.GetComponent <WearNTear>(); if (component2) { component2.Remove(); } else { component.ClaimOwnership(); piece.DropResources(); piece.m_placeEffect.Create(piece.transform.position, piece.transform.rotation, piece.gameObject.transform, 1f); player.m_removeEffects.Create(piece.transform.position, Quaternion.identity, null, 1f); ZNetScene.instance.Destroy(piece.gameObject); } ItemDrop.ItemData rightItem = player.GetRightItem(); if (rightItem != null) { player.FaceLookDirection(); Traverse.Create(player).Field("m_zanim").GetValue <ZSyncAnimation>().SetTrigger(rightItem.m_shared.m_attack.m_attackAnimation); } } } } }
public static bool UseMagicBackground(this ItemDrop.ItemData itemData) { return(itemData.IsMagic() || itemData.IsRunestone()); }
public static bool IsMagic(this ItemDrop.ItemData itemData) { return(itemData.Extended()?.GetComponent <MagicItemComponent>() != null); }
private static HotkeyBar.ElementData GetElementForItem(List <HotkeyBar.ElementData> elements, ItemDrop.ItemData item) { var index = item.m_gridPos.y == 0 ? item.m_gridPos.x : Player.m_localPlayer.GetInventory().m_width + item.m_gridPos.x - 5; return(index >= 0 && index < elements.Count ? elements[index] : null); }
public void setColliderParent(Transform obj, string name, bool rightHand) { outline = obj.parent.gameObject.AddComponent <Outline>(); outline.OutlineColor = Color.red; outline.OutlineWidth = 5; outline.OutlineMode = Outline.Mode.OutlineVisible; isRightHand = rightHand; if (isRightHand) { item = Player.m_localPlayer.GetRightItem(); } else { item = Player.m_localPlayer.GetLeftItem(); } attack = item.m_shared.m_attack.Clone(); switch (attack.m_attackAnimation) { case "atgeir_attack": hitTime = 0.81f; break; case "battleaxe_attack": hitTime = 0.87f; break; case "knife_stab": hitTime = 0.49f; break; case "swing_longsword": case "spear_poke": hitTime = 0.63f; break; case "swing_pickaxe": hitTime = 1.3f; break; case "swing_sledge": hitTime = 2.15f; break; case "swing_axe": hitTime = 0.64f; break; default: hitTime = 0.63f; break; } itemIsTool = name == "Hammer"; if (colliderParent == null) { colliderParent = new GameObject(); } try { WeaponColData colliderData = WeaponUtils.getForName(name); colliderParent.transform.parent = obj; colliderParent.transform.localPosition = colliderData.pos; colliderParent.transform.localRotation = Quaternion.Euler(colliderData.euler); colliderParent.transform.localScale = colliderData.scale; colliderDistance = Vector3.Distance(colliderParent.transform.position, obj.parent.position); maxSnapshots = (int)(MAX_SNAPSHOTS_BASE + MAX_SNAPSHOTS_FACTOR * colliderDistance); setScriptActive(true); } catch (InvalidEnumArgumentException) { setScriptActive(false); } }
private bool CanAttach(ItemDrop.ItemData item) { return(this.m_supportedTypes.Contains(item.m_shared.m_itemType)); }
private static void Postfix(InventoryGrid __instance, Player player, ItemDrop.ItemData dragItem, List <InventoryGrid.Element> ___m_elements) { if (__instance.name != "PlayerGrid") { return; } if (EquipmentAndQuickSlots.QuickSlotsEnabled.Value) { var quickSlotBkg = GetOrCreateBackground(__instance, "QuickSlotBkg"); quickSlotBkg.anchoredPosition = new Vector2(480, -173); quickSlotBkg.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 240); quickSlotBkg.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 90); } else { var existingBkg = __instance.transform.parent.Find("QuickSlotBkg"); if (existingBkg != null) { GameObject.Destroy(existingBkg.gameObject); } } if (EquipmentAndQuickSlots.EquipmentSlotsEnabled.Value) { var equipmentBkg = GetOrCreateBackground(__instance, "EquipmentBkg"); equipmentBkg.anchoredPosition = new Vector2(485, 10); equipmentBkg.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 210); equipmentBkg.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 260); } else { var existingBkg = __instance.transform.parent.Find("EquipmentBkg"); if (existingBkg != null) { GameObject.Destroy(existingBkg.gameObject); } } float horizontalSpacing = __instance.m_elementSpace + 10; float verticalSpacing = __instance.m_elementSpace + 10; string[] equipNames = { "Head", "Chest", "Legs", "Shoulders", "Utility" }; Vector2[] equipPositions = { new Vector2(), // Head new Vector2(0, -verticalSpacing), // Chest new Vector2(0, -2 * verticalSpacing), // Legs new Vector2(horizontalSpacing, -0.5f * verticalSpacing), // Shoulders new Vector2(horizontalSpacing, -1.5f * verticalSpacing), // Utility }; var y = EquipmentAndQuickSlots.GetBonusInventoryRowIndex(); for (int i = 0; i < EquipmentAndQuickSlots.EquipSlotCount; ++i) { var x = i; var element = GetElement(___m_elements, x, y); if (!EquipmentAndQuickSlots.EquipmentSlotsEnabled.Value) { element.m_go.SetActive(false); continue; } else { element.m_go.SetActive(true); } var bindingText = element.m_go.transform.Find("binding").GetComponent <Text>(); bindingText.enabled = true; bindingText.horizontalOverflow = HorizontalWrapMode.Overflow; bindingText.text = equipNames[i]; bindingText.rectTransform.anchoredPosition = new Vector2(32, 5); Vector2 offset = new Vector2(692, -20); (element.m_go.transform as RectTransform).anchoredPosition = offset + equipPositions[i]; } for (int i = 0; i < EquipmentAndQuickSlots.QuickUseSlotCount; ++i) { var x = EquipmentAndQuickSlots.QuickUseSlotIndexStart + i; var element = GetElement(___m_elements, x, y); if (EquipmentAndQuickSlots.QuickSlotsEnabled.Value) { element.m_go.SetActive(true); var bindingText = element.m_go.transform.Find("binding").GetComponent <Text>(); bindingText.enabled = true; bindingText.horizontalOverflow = HorizontalWrapMode.Overflow; bindingText.text = EquipmentAndQuickSlots.GetBindingLabel(i); Vector2 offset = new Vector2(310, 0); Vector2 position = (Vector2) new Vector3((float)x * __instance.m_elementSpace, (float)y * -__instance.m_elementSpace); (element.m_go.transform as RectTransform).anchoredPosition = offset + position; } else { element.m_go.SetActive(false); } } }
public static void Postfix() { Dbgl($"ZNetScene Awake"); foreach (KeyValuePair <string, CustomItem> kvp in customItemsOutput) { CustomItem item = kvp.Value; customObject = ObjectDB.instance.GetItemPrefab(item.baseItemName); DontDestroyOnLoad(customObject); ItemDrop.ItemData itemData = customObject.GetComponent <ItemDrop>().m_itemData.Clone(); Recipe recipe = ObjectDB.instance.GetRecipe(customObject.GetComponent <ItemDrop>().m_itemData); item.id = customObject.name; item.name_key = itemData.m_shared.m_name.Substring(1); item.dlc = itemData.m_shared.m_dlc; item.itemType = itemData.m_shared.m_itemType; item.attachOverride = itemData.m_shared.m_attachOverride; item.description_key = itemData.m_shared.m_description.Substring(1); item.maxStackSize = itemData.m_shared.m_maxStackSize; item.maxQuality = itemData.m_shared.m_maxQuality; item.weight = itemData.m_shared.m_weight; item.value = itemData.m_shared.m_value; item.teleportable = itemData.m_shared.m_teleportable; item.questItem = itemData.m_shared.m_questItem; item.equipDuration = itemData.m_shared.m_equipDuration; item.variants = itemData.m_shared.m_variants; item.trophyPos = itemData.m_shared.m_trophyPos; item.buildPieces = itemData.m_shared.m_buildPieces; item.centerCamera = itemData.m_shared.m_centerCamera; item.setName = itemData.m_shared.m_setName; item.setSize = itemData.m_shared.m_setSize; item.setStatusEffect = itemData.m_shared.m_setStatusEffect; item.equipStatusEffect = itemData.m_shared.m_equipStatusEffect; item.movementModifier = itemData.m_shared.m_movementModifier; item.food = itemData.m_shared.m_food; item.foodStamina = itemData.m_shared.m_foodStamina; item.foodBurnTime = itemData.m_shared.m_foodBurnTime; item.foodRegen = itemData.m_shared.m_foodRegen; item.foodColor = itemData.m_shared.m_foodColor; item.armorMaterial = itemData.m_shared.m_armorMaterial; item.helmetHideHair = itemData.m_shared.m_helmetHideHair; item.armor = itemData.m_shared.m_armor; item.armorPerLevel = itemData.m_shared.m_armorPerLevel; item.damageModifiers = itemData.m_shared.m_damageModifiers; item.blockPower = itemData.m_shared.m_blockPower; item.blockPowerPerLevel = itemData.m_shared.m_blockPowerPerLevel; item.deflectionForce = itemData.m_shared.m_deflectionForce; item.deflectionForcePerLevel = itemData.m_shared.m_deflectionForcePerLevel; item.timedBlockBonus = itemData.m_shared.m_timedBlockBonus; item.animationState = itemData.m_shared.m_animationState; item.skillType = itemData.m_shared.m_skillType; item.toolTier = itemData.m_shared.m_toolTier; item.damages = itemData.m_shared.m_damages; item.damagesPerLevel = itemData.m_shared.m_damagesPerLevel; item.attackForce = itemData.m_shared.m_attackForce; item.backstabBonus = itemData.m_shared.m_backstabBonus; item.dodgeable = itemData.m_shared.m_dodgeable; item.blockable = itemData.m_shared.m_blockable; item.attackStatusEffect = itemData.m_shared.m_attackStatusEffect; item.spawnOnHit = itemData.m_shared.m_spawnOnHit; item.spawnOnHitTerrain = itemData.m_shared.m_spawnOnHitTerrain; item.attack = itemData.m_shared.m_attack; item.secondaryAttack = itemData.m_shared.m_secondaryAttack; item.useDurability = itemData.m_shared.m_useDurability; item.destroyBroken = itemData.m_shared.m_destroyBroken; item.canBeReparied = itemData.m_shared.m_canBeReparied; item.maxDurability = itemData.m_shared.m_maxDurability; item.durabilityPerLevel = itemData.m_shared.m_durabilityPerLevel; item.useDurabilityDrain = itemData.m_shared.m_useDurabilityDrain; item.durabilityDrain = itemData.m_shared.m_durabilityDrain; item.holdDurationMin = itemData.m_shared.m_holdDurationMin; item.holdStaminaDrain = itemData.m_shared.m_holdStaminaDrain; item.holdAnimationState = itemData.m_shared.m_holdAnimationState; item.ammoType = itemData.m_shared.m_ammoType; item.aiAttackRange = itemData.m_shared.m_aiAttackRange; item.aiAttackRangeMin = itemData.m_shared.m_aiAttackRangeMin; item.aiAttackInterval = itemData.m_shared.m_aiAttackInterval; item.aiAttackMaxAngle = itemData.m_shared.m_aiAttackMaxAngle; item.aiWhenFlying = itemData.m_shared.m_aiWhenFlying; item.aiWhenWalking = itemData.m_shared.m_aiWhenWalking; item.aiWhenSwiming = itemData.m_shared.m_aiWhenSwiming; item.aiPrioritized = itemData.m_shared.m_aiPrioritized; item.aiTargetType = itemData.m_shared.m_aiTargetType; item.hitEffect = itemData.m_shared.m_hitEffect; item.hitTerrainEffect = itemData.m_shared.m_hitTerrainEffect; item.blockEffect = itemData.m_shared.m_blockEffect; item.startEffect = itemData.m_shared.m_startEffect; item.holdStartEffect = itemData.m_shared.m_holdStartEffect; item.triggerEffect = itemData.m_shared.m_triggerEffect; item.trailStartEffect = itemData.m_shared.m_trailStartEffect; item.consumeStatusEffect = itemData.m_shared.m_consumeStatusEffect; if (recipe != null) { List <string> reqs = new List <string>(); foreach (Piece.Requirement req in recipe.m_resources) { RequirementData rd = new RequirementData(); rd.amount = req.m_amount; rd.amountPerLevel = req.m_amountPerLevel; rd.recover = req.m_recover; rd.name = req.m_resItem.name; reqs.Add(JsonUtility.ToJson(rd)); } item.requirements = reqs; } string file = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "CustomItemsOutput", $"{kvp.Key}.json"); string json = JsonUtility.ToJson(item); File.WriteAllText(file, json); } foreach (KeyValuePair <string, CustomItem> kvp in customItems) { GetCustomGameObject(kvp.Key); Dbgl($"adding strings {kvp.Value.name_key} = {kvp.Value.name} and {kvp.Value.description_key} = {kvp.Value.description}"); Traverse.Create(Localization.instance).Field("m_translations").GetValue <Dictionary <string, string> >()[kvp.Value.name_key] = kvp.Value.name; Traverse.Create(Localization.instance).Field("m_translations").GetValue <Dictionary <string, string> >()[kvp.Value.description_key] = kvp.Value.description; //Dbgl($"adding {customObject.name} to prefabs; in db? {ObjectDB.instance.GetItemPrefab(kvp.Value.id).name}"); //___m_prefabs.Add(customObject); //___m_namedPrefabs[customObject.name.GetStableHashCode()] = customObject; } }
// Token: 0x06000D37 RID: 3383 RVA: 0x000023E2 File Offset: 0x000005E2 public bool UseItem(Humanoid user, ItemDrop.ItemData item) { return(false); }
// Token: 0x06000D18 RID: 3352 RVA: 0x0005D622 File Offset: 0x0005B822 private bool IsItemAllowed(ItemDrop.ItemData item) { return(this.IsItemAllowed(item.m_dropPrefab.name)); }
public static float GetTotalActiveMagicEffectValue(Player player, ItemDrop.ItemData itemData, string effectType, float scale = 1.0f) { return(GetTotalActiveMagicEffectValue(player, itemData.GetMagicItem(), effectType, scale)); }
// Token: 0x06000D0C RID: 3340 RVA: 0x0005D198 File Offset: 0x0005B398 public bool UseItem(Humanoid user, ItemDrop.ItemData item) { return(PrivateArea.CheckAccess(base.transform.position, 0f, true, false) && this.AddItem(user, item)); }
private static bool OtherItemsUseThisEffect(Humanoid humanoid, string equipFx, ItemDrop.ItemData item, FxAttachMode mode) { if (humanoid == null || !humanoid.IsPlayer()) { return(false); } var player = (Player)humanoid; foreach (var equipmentItemData in player.GetEquipment()) { if (equipmentItemData == item) { continue; } if (GetEquipFxName(equipmentItemData, out var equippedItemMode) == equipFx && equippedItemMode == mode) { return(true); } } return(false); }
private static bool Prefix(ref ItemDrop.ItemData __instance, ref int quality, ref float __result) { if (!Configuration.Current.Durability.IsEnabled) { return(true); } // Tools: Axe, How, Cultivator, Hammer, Pickaxe string itemName = __instance.m_shared.m_name.Replace("$item_", ""); string itemType = itemName.Split(new char[] { '_' })[0]; float multiplierForItem = 0; float maxDurability = (__instance.m_shared.m_maxDurability + (float)Mathf.Max(0, quality - 1) * __instance.m_shared.m_durabilityPerLevel); __result = maxDurability; bool modified = false; switch (itemType) { // pickaxes case "pickaxe": modified = true; multiplierForItem = Helper.applyModifierValue(maxDurability, Configuration.Current.Durability.pickaxes); break; // axes case "axe": modified = true; multiplierForItem = Helper.applyModifierValue(maxDurability, Configuration.Current.Durability.axes); break; // hammer case "hammer": modified = true; multiplierForItem = Helper.applyModifierValue(maxDurability, Configuration.Current.Durability.hammer); break; // cultivator case "cultivator": modified = true; multiplierForItem = Helper.applyModifierValue(maxDurability, Configuration.Current.Durability.cultivator); break; // hoe case "hoe": modified = true; multiplierForItem = Helper.applyModifierValue(maxDurability, Configuration.Current.Durability.hoe); break; default: break; } switch (__instance.m_shared.m_itemType) { case ItemDrop.ItemData.ItemType.TwoHandedWeapon: case ItemDrop.ItemData.ItemType.OneHandedWeapon: // WEAPONS if (!modified) // Some tools are considered to be OneHandedWeapons { multiplierForItem = Helper.applyModifierValue(maxDurability, Configuration.Current.Durability.weapons); } break; case ItemDrop.ItemData.ItemType.Bow: // BOW if (!modified) { multiplierForItem = Helper.applyModifierValue(maxDurability, Configuration.Current.Durability.bows); } break; case ItemDrop.ItemData.ItemType.Shield: // Shields if (!modified) { multiplierForItem = Helper.applyModifierValue(maxDurability, Configuration.Current.Durability.shields); } break; case ItemDrop.ItemData.ItemType.Helmet: case ItemDrop.ItemData.ItemType.Chest: case ItemDrop.ItemData.ItemType.Legs: case ItemDrop.ItemData.ItemType.Shoulder: // ARMOR if (!modified && __instance.m_shared.m_itemType != ItemDrop.ItemData.ItemType.Shield) { multiplierForItem = Helper.applyModifierValue(maxDurability, Configuration.Current.Durability.armor); } break; default: break; } if (multiplierForItem != maxDurability) { __result = multiplierForItem; } return(false); }
private static void SetTextureOverrides(VisEquipment __instance, List <GameObject> __result, string itemID, ItemDrop.ItemData equippedItem) { GetTexOverrides(itemID, equippedItem, out var mainTexture, out var chestTex, out var legsTex); if (!string.IsNullOrEmpty(mainTexture)) { foreach (var go in __result) { var skinnedMeshRenderers = go.GetComponentsInChildren <SkinnedMeshRenderer>(true); SetMainTextureOnRenderers(skinnedMeshRenderers, mainTexture); var meshRenderers = go.GetComponentsInChildren <MeshRenderer>(true); SetMainTextureOnRenderers(meshRenderers, mainTexture); } } if (!string.IsNullOrEmpty(chestTex)) { var chestTexAsset = EpicLoot.LoadAsset <Texture>(chestTex); if (chestTexAsset != null) { __instance.m_bodyModel.material.SetTexture("_ChestTex", chestTexAsset); } else { EpicLoot.LogError($"Missing Texture Override Asset: ChestTex={chestTex}"); } } if (!string.IsNullOrEmpty(legsTex)) { var legsTexAsset = EpicLoot.LoadAsset <Texture>(legsTex); if (legsTexAsset != null) { __instance.m_bodyModel.material.SetTexture("_ChestTex", legsTexAsset); } else { EpicLoot.LogError($"Missing Texture Override Asset: LegsTex={legsTex}"); } } }
private static bool DoCheck(Player player, ZDO zdo, string equipKey, string legendaryDataKey, ref ItemDrop.ItemData itemData) { var zdoLegendaryID = zdo.GetString(legendaryDataKey); if (string.IsNullOrEmpty(zdoLegendaryID)) { var hadItem = itemData != null; if (hadItem) { ForceResetVisEquipment(player, itemData); } itemData = null; return(hadItem); } var currentLegendaryID = itemData?.GetMagicItem()?.LegendaryID; if (currentLegendaryID == zdoLegendaryID) { return(false); } var itemHash = zdo.GetInt(equipKey); var itemPrefab = ObjectDB.instance.GetItemPrefab(itemHash); if (itemPrefab?.GetComponent <ItemDrop>()?.m_itemData is ItemDrop.ItemData targetItemData) { itemData = new ExtendedItemData(targetItemData); itemData.m_durability = float.PositiveInfinity; var magicItemComponent = itemData.Extended().AddComponent <MagicItemComponent>(); var stubMagicItem = new MagicItem { Rarity = ItemRarity.Legendary, LegendaryID = zdoLegendaryID }; magicItemComponent.SetMagicItem(stubMagicItem); ForceResetVisEquipment(player, itemData); } return(false); }
/// <summary> /// m_shared.m_name /// </summary> /// <param name="self"></param> /// <returns></returns> public static string TokenName(this ItemDrop.ItemData self) => self.m_shared.m_name;
public static bool Prefix(Inventory __instance, ref ItemDrop.ItemData item, ref bool __result) { // if we're not crafting/looting a rune, ignore this flow var ext = Player.m_localPlayer?.ExtendedPlayer(false); if (ext == null || (ext.craftingRuneItem == null && ext.lootingRuneItem == null)) { return(true); } var rune = item.GetRuneData(); if (rune == null) { return(true); } var inv = SpellsBar.invBarGrid.m_inventory; var qtyStack = item.m_stack; while (qtyStack > 0) { // checking if this item already exists in the inventory (with free stack space) ItemDrop.ItemData itemData = inv.FindFreeStackItem(item.m_shared.m_name, item.m_quality); // if it does if (itemData != null) { // get the free space var freeStack = itemData.m_shared.m_maxStackSize - itemData.m_stack; // get how much can we add to it var toAdd = (qtyStack >= freeStack) ? freeStack : qtyStack; // add that to it itemData.m_stack += toAdd; // subs that much of the item stack qtyStack -= toAdd; } else { // updating its quantity item.m_stack = qtyStack; // if the item does not exist, check for a empty slot Vector2i invPos = inv.FindEmptySlot(inv.TopFirst(item)); // if there is one if (invPos.x >= 0) { // add the item to it item.m_gridPos = invPos; inv.m_inventory.Add(item); // iv was changed inv.Changed(); // we're done, stop here __result = true; return(false); } else { // if there is no empty slot on the spellsbar, let's return true so it goes the normal flow trying to add it to the base inventory return(true); } } } // iv was changed inv.Changed(); // we're done, stop here __result = true; return(false); }
private static void Postfix(ref Player __instance, ref ItemDrop.ItemData item) { item.m_shared.m_foodBurnTime = defaultValue; // reset to default value after execution of EatFood }
public static MagicItem GetMagicItem(this ItemDrop.ItemData itemData) { return(itemData.Extended()?.GetComponent <MagicItemComponent>()?.MagicItem); }