using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using RPGCreationKit; using RPGCreationKit.AI; namespace RPGCreationKit { public class ConsumableItemInLootingUI_DrawDeposit : ConsumableItemInInventoryUI { public override void OnClick(bool takeAll = false) { if (LootingInventoryUI.instance.curIsPickPocket) { // Player is attempting to pickpocket // This is a VERY simple rule, if the weight of the item is over 1 the player will never be able to successfully pickpocket it // You may want to change/alter this for your own projects float chanceForFailure = consumableItemInInventory.item.Weight; float ItemValue = consumableItemInInventory.item.Value; float RandomValue = UnityEngine.Random.value; float RandomMaxValue = (RandomValue * 10f); // Could use Vector3.Dot to make less likely to succeed when infront of the AI Debug.Log("chanceForFailure :"+chanceForFailure); Debug.Log("Random.value :"+RandomValue); Debug.Log("RandomMaxValue :"+RandomMaxValue); if ((chanceForFailure > RandomValue))// && (ItemValue < RandomMaxValue)) { // Failed chance check RckAI ai = LootingInventoryUI.instance.curLootingPoint.inventory.gameObject.GetComponent(); if (ai != null) { ai.TryEngageWithPlayer(); // Engage with player } else { Debug.Log("Failed: Could not find AI"); } LootingInventoryUI.instance.CloseUI(); return; } else { // lets build some float levels to increase attributes slowly. } } // Some palce in the codebase seems to be calling this method after the CloseUI randomly, not sure why or where yet // this is a backup in that case if (LootingInventoryUI.instance.curIsPickPocket && LootingInventoryUI.instance.curLootingPoint == null) { Debug.Log("Find out why this is called!"); return; } if (LootingInventoryUI.instance.isDrawing) { // if the amount is 1, add it one time if (base.consumableItemInInventory.Amount <= 1) { Inventory.PlayerInventory.AddItem(base.consumableItemInInventory.item, base.consumableItemInInventory.metadata, 1, !takeAll); // Remove the item from the current loot inventory LootingInventoryUI.instance.curLootingPoint.inventory.RemoveItem(base.consumableItemInInventory, 1); LootingInventoryUI.instance.SelectNextButton(); // Disable this object pool.usedObjects.Remove(this); pool.ConsumablesPool.usedObjects.Remove(this); gameObject.GetComponent