Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
d2f4f000f8 |
Binary file not shown.
@ -15,7 +15,7 @@ namespace itemValueMod
|
|||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void PatchPostFix(ref Item __instance, string id, ItemTemplate template)
|
private static void PatchPostFix(ref Item __instance, string id, ItemTemplate template)
|
||||||
{
|
{
|
||||||
ItemValue.AddItemValue(ref __instance, id, template);
|
ItemValue.AddItemValue(ref __instance, template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ namespace itemValueMod
|
|||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void PatchPostFix(ref BulletClass __instance, string id, AmmoTemplate template)
|
private static void PatchPostFix(ref BulletClass __instance, string id, AmmoTemplate template)
|
||||||
{
|
{
|
||||||
ItemValue.AddItemValue(ref __instance, id, template);
|
ItemValue.AddItemValue(ref __instance, template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ namespace itemValueMod
|
|||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void PatchPostFix(ref GrenadeClass __instance, string id, ThrowableWeaponClass template)
|
private static void PatchPostFix(ref GrenadeClass __instance, string id, ThrowableWeaponClass template)
|
||||||
{
|
{
|
||||||
ItemValue.AddItemValue(ref __instance, id, template);
|
ItemValue.AddItemValue(ref __instance, template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ namespace itemValueMod
|
|||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void PatchPostFix(ref ItemContainerClass __instance, string id, SecureContainerTemplateClass template)
|
private static void PatchPostFix(ref ItemContainerClass __instance, string id, SecureContainerTemplateClass template)
|
||||||
{
|
{
|
||||||
ItemValue.AddItemValue(ref __instance, id, template);
|
ItemValue.AddItemValue(ref __instance, template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,261 +4,220 @@ using EFT.InventoryLogic;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Net;
|
|
||||||
using System.Threading;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Comfort.Common;
|
||||||
|
|
||||||
namespace itemValueMod
|
namespace itemValueMod
|
||||||
{
|
{
|
||||||
public class ItemValue
|
public class ItemValue
|
||||||
{
|
{
|
||||||
public static void AddItemValue<T>(ref T __instance, string id, ItemTemplate template) where T : Item
|
public static void AddItemValue<T>(ref T __instance, ItemTemplate template) where T : Item
|
||||||
{
|
{
|
||||||
var atts = new List<ItemAttributeClass>();
|
|
||||||
atts.AddRange(__instance.Attributes);
|
|
||||||
__instance.Attributes = atts;
|
|
||||||
|
|
||||||
ItemAttributeClass attr1 = new ItemAttributeClass(EItemAttributeId.MoneySum)
|
__instance.SetupShit();
|
||||||
{
|
//var atts = new List<ItemAttributeClass>();
|
||||||
StringValue = new Func<string>(__instance.TraderPrice),
|
//atts.AddRange(__instance.Attributes);
|
||||||
FullStringValue = new Func<string>(__instance.TraderName),
|
//__instance.Attributes = atts;
|
||||||
Name = "TRADER",
|
|
||||||
DisplayType = new Func<EItemAttributeDisplayType>(() => EItemAttributeDisplayType.Compact)
|
|
||||||
};
|
|
||||||
|
|
||||||
__instance.Attributes.Add(attr1);
|
//var attr1 = new ItemAttributeClass(EItemAttributeId.MoneySum)
|
||||||
|
//{
|
||||||
|
// StringValue = __instance.TraderPrice(template),
|
||||||
|
// FullStringValue = __instance.TraderName,
|
||||||
|
// Name = "TRADER",
|
||||||
|
// DisplayType = () => EItemAttributeDisplayType.Compact
|
||||||
|
//};
|
||||||
|
|
||||||
|
//__instance.Attributes.Add(attr1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ValueExtension
|
public static class ValueExtension
|
||||||
{
|
{
|
||||||
static public Dictionary<string, JsonClass> itemDictionary = new Dictionary<string, JsonClass>();
|
public static ItemFactory ItemFactoryInstance;
|
||||||
static object lockObject = new object();
|
|
||||||
|
|
||||||
public static JsonClass GetData(String itemId)
|
public static void SetupShit(this Item item)
|
||||||
{
|
{
|
||||||
var json = RequestHandler.GetJson($"/cwx/seeitemvalue/{itemId}");
|
ItemFactoryInstance = Singleton<ItemFactory>.Instance;
|
||||||
var jsonClass = Json.Deserialize<JsonClass>(json);
|
var itemTemplate = ItemFactoryInstance.ItemTemplates.Values.First(x => x._id == item.TemplateId).Name;
|
||||||
|
|
||||||
itemDictionary.Add(itemId, jsonClass);
|
|
||||||
|
|
||||||
|
|
||||||
|
Debug.LogError($"[itemTemplate] {itemTemplate}");
|
||||||
|
|
||||||
return jsonClass;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string TraderPrice(this Item item)
|
//public static Func<string> TraderPrice(this Item item, ItemTemplate template)
|
||||||
{
|
//{
|
||||||
string itemId = item.Template._id;
|
// string itemId = item.Template._id;
|
||||||
JsonClass jsonClass;
|
// JsonClass jsonClass;
|
||||||
bool lockWasTaken = false;
|
// double alteredPrice = 1;
|
||||||
double alteredPrice = 1;
|
|
||||||
|
|
||||||
try
|
// if (jsonClass.price != 1)
|
||||||
{
|
// {
|
||||||
Monitor.Enter(lockObject, ref lockWasTaken);
|
// alteredPrice = DurabilityCheck(item, jsonClass);
|
||||||
|
// }
|
||||||
|
|
||||||
if(!itemDictionary.TryGetValue(itemId, out jsonClass))
|
// double _price = alteredPrice * jsonClass.multiplier;
|
||||||
{
|
|
||||||
jsonClass = GetData(item.Template._id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (WebException)
|
|
||||||
{
|
|
||||||
return $"[SeeItemValue] Issue happened whilst getting Item from server";
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (lockWasTaken)
|
|
||||||
{
|
|
||||||
Monitor.Exit(lockObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonClass.price != 1)
|
// return Math.Round(_price).ToString();
|
||||||
{
|
//}
|
||||||
alteredPrice = DurabilityCheck(item, jsonClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
double _price = alteredPrice * jsonClass.multiplier;
|
//public static string TraderName(this Item item)
|
||||||
|
//{
|
||||||
|
// string itemId = item.Template._id;
|
||||||
|
// JsonClass jsonClass;
|
||||||
|
|
||||||
return Math.Round(_price).ToString();
|
// return jsonClass.traderName;
|
||||||
}
|
//}
|
||||||
|
|
||||||
public static string TraderName(this Item item)
|
//public static double DurabilityCheck(this Item item, JsonClass jsonClass)
|
||||||
{
|
//{
|
||||||
string itemId = item.Template._id;
|
// double editedPrice = jsonClass.price;
|
||||||
JsonClass jsonClass;
|
// double originalMax = jsonClass.originalMax;
|
||||||
bool lockWasTaken = false;
|
|
||||||
|
|
||||||
try
|
// DebugMode($" Entered DurabilityCheck() - starting price is: {editedPrice}");
|
||||||
{
|
|
||||||
Monitor.Enter(lockObject, ref lockWasTaken);
|
|
||||||
|
|
||||||
if (!itemDictionary.TryGetValue(itemId, out jsonClass))
|
// var medKit = item.GetItemComponent<MedKitComponent>();
|
||||||
{
|
// if (medKit != null && medKit.HpResource != 0 && medKit.MaxHpResource != 0)
|
||||||
jsonClass = GetData(item.Template._id);
|
// {
|
||||||
}
|
// DebugMode($" Medkit Check - HpResource is: {medKit.HpResource}");
|
||||||
}
|
// DebugMode($" Medkit Check - MaxHpResource is: {medKit.MaxHpResource}");
|
||||||
catch (WebException)
|
|
||||||
{
|
|
||||||
return $"[SeeItemValue] Issue happened whilst getting Item from server";
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (lockWasTaken)
|
|
||||||
{
|
|
||||||
Monitor.Exit(lockObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsonClass.traderName;
|
// editedPrice *= medKit.HpResource / medKit.MaxHpResource;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static double DurabilityCheck(this Item item, JsonClass jsonClass)
|
// DebugMode($" After Medkit Check - price is: {editedPrice}");
|
||||||
{
|
|
||||||
double editedPrice = jsonClass.price;
|
|
||||||
double originalMax = jsonClass.originalMax;
|
|
||||||
|
|
||||||
DebugMode($" Entered DurabilityCheck() - starting price is: {editedPrice}");
|
// var repair = item.GetItemComponent<RepairableComponent>();
|
||||||
|
// if (repair != null)
|
||||||
|
// {
|
||||||
|
// if (repair.Durability > 0)
|
||||||
|
// {
|
||||||
|
// DebugMode($" repairable Check - Durability is: {repair.Durability}");
|
||||||
|
// DebugMode($" Medkit Check - originalMax is: {originalMax}");
|
||||||
|
|
||||||
var medKit = item.GetItemComponent<MedKitComponent>();
|
// editedPrice *= repair.Durability / originalMax;
|
||||||
if (medKit != null && medKit.HpResource != 0 && medKit.MaxHpResource != 0)
|
// }
|
||||||
{
|
// else
|
||||||
DebugMode($" Medkit Check - HpResource is: {medKit.HpResource}");
|
// {
|
||||||
DebugMode($" Medkit Check - MaxHpResource is: {medKit.MaxHpResource}");
|
// DebugMode($" repairable Check - Durability is 0");
|
||||||
|
|
||||||
editedPrice *= medKit.HpResource / medKit.MaxHpResource;
|
// editedPrice = 1;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
DebugMode($" After Medkit Check - price is: {editedPrice}");
|
// DebugMode($" After repairable Check - price is: {editedPrice}");
|
||||||
|
|
||||||
var repair = item.GetItemComponent<RepairableComponent>();
|
// var dogtag = item.GetItemComponent<DogtagComponent>();
|
||||||
if (repair != null)
|
// if (dogtag != null && dogtag.Level != 0)
|
||||||
{
|
// {
|
||||||
if (repair.Durability > 0)
|
// DebugMode($" dogtag Check - level is: {dogtag.Level}");
|
||||||
{
|
|
||||||
DebugMode($" repairable Check - Durability is: {repair.Durability}");
|
|
||||||
DebugMode($" Medkit Check - originalMax is: {originalMax}");
|
|
||||||
|
|
||||||
editedPrice *= repair.Durability / originalMax;
|
// editedPrice *= dogtag.Level;
|
||||||
}
|
// }
|
||||||
else
|
|
||||||
{
|
|
||||||
DebugMode($" repairable Check - Durability is 0");
|
|
||||||
|
|
||||||
editedPrice = 1;
|
// DebugMode($" After dogtag Check - price is: {editedPrice}");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugMode($" After repairable Check - price is: {editedPrice}");
|
// var repairKit = item.GetItemComponent<RepairKitComponent>();
|
||||||
|
// if (repairKit != null)
|
||||||
|
// {
|
||||||
|
// if (repairKit.Resource > 0)
|
||||||
|
// {
|
||||||
|
// DebugMode($" repairkit Check - Resource is: {repairKit.Resource}");
|
||||||
|
// DebugMode($" repairkit Check - originalMax is: {originalMax}");
|
||||||
|
|
||||||
var dogtag = item.GetItemComponent<DogtagComponent>();
|
// editedPrice *= repairKit.Resource / originalMax;
|
||||||
if (dogtag != null && dogtag.Level != 0)
|
// }
|
||||||
{
|
// else
|
||||||
DebugMode($" dogtag Check - level is: {dogtag.Level}");
|
// {
|
||||||
|
// DebugMode($" repairkit Check - Resource is 0");
|
||||||
|
|
||||||
editedPrice *= dogtag.Level;
|
// editedPrice = 1;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
DebugMode($" After dogtag Check - price is: {editedPrice}");
|
// DebugMode($" After repairkit Check - price is: {editedPrice}");
|
||||||
|
|
||||||
var repairKit = item.GetItemComponent<RepairKitComponent>();
|
// var resource = item.GetItemComponent<ResourceComponent>();
|
||||||
if (repairKit != null)
|
// if (resource != null && resource.Value != 0 && resource.MaxResource != 0)
|
||||||
{
|
// {
|
||||||
if (repairKit.Resource > 0)
|
// DebugMode($" resource Check - Resource is: {resource.Value}");
|
||||||
{
|
// DebugMode($" resource Check - MaxResource is: {resource.MaxResource}");
|
||||||
DebugMode($" repairkit Check - Resource is: {repairKit.Resource}");
|
|
||||||
DebugMode($" repairkit Check - originalMax is: {originalMax}");
|
|
||||||
|
|
||||||
editedPrice *= repairKit.Resource / originalMax;
|
// editedPrice *= resource.Value / resource.MaxResource;
|
||||||
}
|
// }
|
||||||
else
|
|
||||||
{
|
|
||||||
DebugMode($" repairkit Check - Resource is 0");
|
|
||||||
|
|
||||||
editedPrice = 1;
|
// DebugMode($" After resource Check - price is: {editedPrice}");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugMode($" After repairkit Check - price is: {editedPrice}");
|
// var foodDrink = item.GetItemComponent<FoodDrinkComponent>();
|
||||||
|
// if (foodDrink != null && foodDrink.HpPercent != 0)
|
||||||
|
// {
|
||||||
|
// GInterface234 ginterface234_0 = (GInterface234)foodDrink.GetType().GetField("ginterface234_0", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(foodDrink);
|
||||||
|
|
||||||
var resource = item.GetItemComponent<ResourceComponent>();
|
// DebugMode($" foodDrink Check - HpPercent is: {foodDrink.HpPercent}");
|
||||||
if (resource != null && resource.Value != 0 && resource.MaxResource != 0)
|
// DebugMode($" foodDrink Check - MaxResource is: {ginterface234_0.MaxResource}");
|
||||||
{
|
|
||||||
DebugMode($" resource Check - Resource is: {resource.Value}");
|
|
||||||
DebugMode($" resource Check - MaxResource is: {resource.MaxResource}");
|
|
||||||
|
|
||||||
editedPrice *= resource.Value / resource.MaxResource;
|
// editedPrice *= foodDrink.HpPercent / ginterface234_0.MaxResource;
|
||||||
}
|
// }
|
||||||
|
|
||||||
DebugMode($" After resource Check - price is: {editedPrice}");
|
// DebugMode($" After foodDrink Check - price is: {editedPrice}");
|
||||||
|
|
||||||
var foodDrink = item.GetItemComponent<FoodDrinkComponent>();
|
// var keys = item.GetItemComponent<KeyComponent>();
|
||||||
if (foodDrink != null && foodDrink.HpPercent != 0)
|
// if (keys != null)
|
||||||
{
|
// {
|
||||||
GInterface234 ginterface234_0 = (GInterface234)foodDrink.GetType().GetField("ginterface234_0", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(foodDrink);
|
// GInterface238 template = (GInterface238)keys.GetType().GetField("Template", BindingFlags.Public | BindingFlags.Instance).GetValue(keys);
|
||||||
|
|
||||||
DebugMode($" foodDrink Check - HpPercent is: {foodDrink.HpPercent}");
|
// if (keys.NumberOfUsages > 0)
|
||||||
DebugMode($" foodDrink Check - MaxResource is: {ginterface234_0.MaxResource}");
|
// {
|
||||||
|
// double totalMinusUsed = Convert.ToDouble(template.MaximumNumberOfUsage - keys.NumberOfUsages);
|
||||||
|
// double multi = totalMinusUsed / template.MaximumNumberOfUsage;
|
||||||
|
|
||||||
editedPrice *= foodDrink.HpPercent / ginterface234_0.MaxResource;
|
// DebugMode($" foodDrink Check - totalMinusUsed is: {totalMinusUsed}");
|
||||||
}
|
// DebugMode($" foodDrink Check - multi is: {multi}");
|
||||||
|
|
||||||
DebugMode($" After foodDrink Check - price is: {editedPrice}");
|
// editedPrice *= multi;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
var keys = item.GetItemComponent<KeyComponent>();
|
// DebugMode($" After keys Check - price is: {editedPrice}");
|
||||||
if (keys != null)
|
|
||||||
{
|
|
||||||
GInterface238 template = (GInterface238)keys.GetType().GetField("Template", BindingFlags.Public | BindingFlags.Instance).GetValue(keys);
|
|
||||||
|
|
||||||
if (keys.NumberOfUsages > 0)
|
// var sideEffect = item.GetItemComponent<SideEffectComponent>();
|
||||||
{
|
// if (sideEffect != null && sideEffect.Value != 0)
|
||||||
double totalMinusUsed = Convert.ToDouble(template.MaximumNumberOfUsage - keys.NumberOfUsages);
|
// {
|
||||||
double multi = totalMinusUsed / template.MaximumNumberOfUsage;
|
// DebugMode($" sideEffect Check - resource is: {sideEffect.Value}");
|
||||||
|
// DebugMode($" sideEffect Check - MaxResource is: {sideEffect.MaxResource}");
|
||||||
|
|
||||||
DebugMode($" foodDrink Check - totalMinusUsed is: {totalMinusUsed}");
|
// editedPrice *= sideEffect.Value / sideEffect.MaxResource;
|
||||||
DebugMode($" foodDrink Check - multi is: {multi}");
|
// }
|
||||||
|
|
||||||
editedPrice *= multi;
|
// DebugMode($" After sideEffect Check - price is: {editedPrice}");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugMode($" After keys Check - price is: {editedPrice}");
|
// DebugMode($"Ending price: {editedPrice}");
|
||||||
|
|
||||||
var sideEffect = item.GetItemComponent<SideEffectComponent>();
|
// return editedPrice;
|
||||||
if (sideEffect != null && sideEffect.Value != 0)
|
//}
|
||||||
{
|
|
||||||
DebugMode($" sideEffect Check - resource is: {sideEffect.Value}");
|
|
||||||
DebugMode($" sideEffect Check - MaxResource is: {sideEffect.MaxResource}");
|
|
||||||
|
|
||||||
editedPrice *= sideEffect.Value / sideEffect.MaxResource;
|
//public static void DebugMode(String str)
|
||||||
}
|
//{
|
||||||
|
// var directory = Directory.GetCurrentDirectory();
|
||||||
|
|
||||||
DebugMode($" After sideEffect Check - price is: {editedPrice}");
|
// var modDirectory = new DirectoryInfo(directory + "/user/mods/");
|
||||||
|
// DirectoryInfo[] dirsInDir = modDirectory.GetDirectories("*" + "SeeItemValue" + "*.*");
|
||||||
|
|
||||||
DebugMode($"Ending price: {editedPrice}");
|
// if (dirsInDir.Length == 1)
|
||||||
|
// {
|
||||||
|
// var json = File.ReadAllText(dirsInDir[0].ToString() + "/src/config.json");
|
||||||
|
|
||||||
return editedPrice;
|
// var configJson = Json.Deserialize<ConfigClass>(json);
|
||||||
}
|
|
||||||
|
|
||||||
public static void DebugMode(String str)
|
// if (configJson != null && configJson.DebugMode)
|
||||||
{
|
// {
|
||||||
var directory = Directory.GetCurrentDirectory();
|
// Debug.LogError(str);
|
||||||
|
// }
|
||||||
var modDirectory = new DirectoryInfo(directory + "/user/mods/");
|
// }
|
||||||
DirectoryInfo[] dirsInDir = modDirectory.GetDirectories("*" + "SeeItemValue" + "*.*");
|
//}
|
||||||
|
|
||||||
if (dirsInDir.Length == 1)
|
|
||||||
{
|
|
||||||
var json = File.ReadAllText(dirsInDir[0].ToString() + "/src/config.json");
|
|
||||||
|
|
||||||
var configJson = Json.Deserialize<ConfigClass>(json);
|
|
||||||
|
|
||||||
if (configJson != null && configJson.DebugMode)
|
|
||||||
{
|
|
||||||
Debug.LogError(str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user