using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using RPGCreationKit; using RPGCreationKit.AI; namespace RPGCreationKit { public class AmmoItemInLootingUI_DrawDeposit : AmmoItemInInventoryUI { public override void OnClick(bool takeAll = false) { if (LootingInventoryUI.instance.curIsPickPocket && LootingInventoryUI.instance.curLootingPoint != null) { // Player is attempting to pickpocket Vector3 forward = Inventory.PlayerInventory.transform.TransformDirection(Vector3.forward); Vector3 toOther = LootingInventoryUI.instance.curLootingPoint.transform.position - transform.position; float A = (1f - ((float)ammoItemInInventory.item.Value / 100f)); float B = (float)EntityAttributes.PlayerAttributes.attributes.Dexterity / 100f; float C = (1f - ((float)ammoItemInInventory.item.Weight / 100f)); float D = (((Vector3.Dot(forward, toOther)) + 360) / 720); float ChanceForSuccess = ((A+B+C+D)/4); if (base.ammoItemInInventory.isEquipped) ChanceForSuccess = (ChanceForSuccess/2); float RandomChance = (Random.value); if (ChanceForSuccess < RandomChance) { RckAI ai = LootingInventoryUI.instance.curLootingPoint.inventory.gameObject.GetComponent(); ai.TryEngageWithPlayer(); // Engage with player - Lets get faction instead of every fucker in the area. LootingInventoryUI.instance.CloseUI(); return; } else { // Reward Player EntityAttributes.PlayerAttributes.attributes.DexterityPoints += 1; A = (float)EntityAttributes.PlayerAttributes.attributes.DexterityPoints; B = (float)EntityAttributes.PlayerAttributes.attributes.Dexterity; while (A >= (B*3)) { EntityAttributes.PlayerAttributes.attributes.Dexterity += 1; float E = (A-(B*3f)); EntityAttributes.PlayerAttributes.attributes.DexterityPoints = (int)D; A = (float)EntityAttributes.PlayerAttributes.attributes.DexterityPoints; B = (float)EntityAttributes.PlayerAttributes.attributes.Dexterity; } } } // 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) { return; } if (LootingInventoryUI.instance.isDrawing) { // if the amount is 1, add it one time if (base.ammoItemInInventory.Amount <= 1) { Inventory.PlayerInventory.AddItem(base.ammoItemInInventory.item, base.ammoItemInInventory.metadata, 1, !takeAll); if (base.ammoItemInInventory.isEquipped) LootingInventoryUI.instance.curLootingPoint.equipment.Unequip(base.ammoItemInInventory); // Remove the item from the current loot inventory LootingInventoryUI.instance.curLootingPoint.inventory.RemoveItem(base.ammoItemInInventory, 1); LootingInventoryUI.instance.SelectNextButton(); // Disable this object pool.usedObjects.Remove(this); pool.AmmosPool.usedObjects.Remove(this); gameObject.GetComponent