Compare commits
No commits in common. "master" and "1.0.0" have entirely different histories.
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, template);
|
ItemValue.AddItemValue(ref __instance, id, 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, template);
|
ItemValue.AddItemValue(ref __instance, id, 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, template);
|
ItemValue.AddItemValue(ref __instance, id, 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, template);
|
ItemValue.AddItemValue(ref __instance, id, template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,220 +4,261 @@ 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, ItemTemplate template) where T : Item
|
public static void AddItemValue<T>(ref T __instance, string id, ItemTemplate template) where T : Item
|
||||||
{
|
{
|
||||||
|
var atts = new List<ItemAttributeClass>();
|
||||||
|
atts.AddRange(__instance.Attributes);
|
||||||
|
__instance.Attributes = atts;
|
||||||
|
|
||||||
__instance.SetupShit();
|
ItemAttributeClass attr1 = new ItemAttributeClass(EItemAttributeId.MoneySum)
|
||||||
//var atts = new List<ItemAttributeClass>();
|
{
|
||||||
//atts.AddRange(__instance.Attributes);
|
StringValue = new Func<string>(__instance.TraderPrice),
|
||||||
//__instance.Attributes = atts;
|
FullStringValue = new Func<string>(__instance.TraderName),
|
||||||
|
Name = "TRADER",
|
||||||
|
DisplayType = new Func<EItemAttributeDisplayType>(() => EItemAttributeDisplayType.Compact)
|
||||||
|
};
|
||||||
|
|
||||||
//var attr1 = new ItemAttributeClass(EItemAttributeId.MoneySum)
|
__instance.Attributes.Add(attr1);
|
||||||
//{
|
|
||||||
// StringValue = __instance.TraderPrice(template),
|
|
||||||
// FullStringValue = __instance.TraderName,
|
|
||||||
// Name = "TRADER",
|
|
||||||
// DisplayType = () => EItemAttributeDisplayType.Compact
|
|
||||||
//};
|
|
||||||
|
|
||||||
//__instance.Attributes.Add(attr1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ValueExtension
|
public static class ValueExtension
|
||||||
{
|
{
|
||||||
public static ItemFactory ItemFactoryInstance;
|
static public Dictionary<string, JsonClass> itemDictionary = new Dictionary<string, JsonClass>();
|
||||||
|
static object lockObject = new object();
|
||||||
|
|
||||||
public static void SetupShit(this Item item)
|
public static JsonClass GetData(String itemId)
|
||||||
{
|
{
|
||||||
ItemFactoryInstance = Singleton<ItemFactory>.Instance;
|
var json = RequestHandler.GetJson($"/cwx/seeitemvalue/{itemId}");
|
||||||
var itemTemplate = ItemFactoryInstance.ItemTemplates.Values.First(x => x._id == item.TemplateId).Name;
|
var jsonClass = Json.Deserialize<JsonClass>(json);
|
||||||
|
|
||||||
|
itemDictionary.Add(itemId, jsonClass);
|
||||||
|
|
||||||
|
return jsonClass;
|
||||||
|
|
||||||
Debug.LogError($"[itemTemplate] {itemTemplate}");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static Func<string> TraderPrice(this Item item, ItemTemplate template)
|
public static string TraderPrice(this Item item)
|
||||||
//{
|
{
|
||||||
// string itemId = item.Template._id;
|
string itemId = item.Template._id;
|
||||||
// JsonClass jsonClass;
|
JsonClass jsonClass;
|
||||||
// double alteredPrice = 1;
|
bool lockWasTaken = false;
|
||||||
|
double alteredPrice = 1;
|
||||||
|
|
||||||
// if (jsonClass.price != 1)
|
try
|
||||||
// {
|
{
|
||||||
// alteredPrice = DurabilityCheck(item, jsonClass);
|
Monitor.Enter(lockObject, ref lockWasTaken);
|
||||||
// }
|
|
||||||
|
|
||||||
// double _price = alteredPrice * jsonClass.multiplier;
|
if(!itemDictionary.TryGetValue(itemId, out jsonClass))
|
||||||
|
{
|
||||||
|
jsonClass = GetData(item.Template._id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (WebException)
|
||||||
|
{
|
||||||
|
return $"[SeeItemValue] Issue happened whilst getting Item from server";
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (lockWasTaken)
|
||||||
|
{
|
||||||
|
Monitor.Exit(lockObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// return Math.Round(_price).ToString();
|
if (jsonClass.price != 1)
|
||||||
//}
|
{
|
||||||
|
alteredPrice = DurabilityCheck(item, jsonClass);
|
||||||
|
}
|
||||||
|
|
||||||
//public static string TraderName(this Item item)
|
double _price = alteredPrice * jsonClass.multiplier;
|
||||||
//{
|
|
||||||
// string itemId = item.Template._id;
|
|
||||||
// JsonClass jsonClass;
|
|
||||||
|
|
||||||
// return jsonClass.traderName;
|
return Math.Round(_price).ToString();
|
||||||
//}
|
}
|
||||||
|
|
||||||
//public static double DurabilityCheck(this Item item, JsonClass jsonClass)
|
public static string TraderName(this Item item)
|
||||||
//{
|
{
|
||||||
// double editedPrice = jsonClass.price;
|
string itemId = item.Template._id;
|
||||||
// double originalMax = jsonClass.originalMax;
|
JsonClass jsonClass;
|
||||||
|
bool lockWasTaken = false;
|
||||||
|
|
||||||
// DebugMode($" Entered DurabilityCheck() - starting price is: {editedPrice}");
|
try
|
||||||
|
{
|
||||||
|
Monitor.Enter(lockObject, ref lockWasTaken);
|
||||||
|
|
||||||
// var medKit = item.GetItemComponent<MedKitComponent>();
|
if (!itemDictionary.TryGetValue(itemId, out jsonClass))
|
||||||
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// editedPrice *= medKit.HpResource / medKit.MaxHpResource;
|
return jsonClass.traderName;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// DebugMode($" After Medkit Check - price is: {editedPrice}");
|
public static double DurabilityCheck(this Item item, JsonClass jsonClass)
|
||||||
|
{
|
||||||
|
double editedPrice = jsonClass.price;
|
||||||
|
double originalMax = jsonClass.originalMax;
|
||||||
|
|
||||||
// var repair = item.GetItemComponent<RepairableComponent>();
|
DebugMode($" Entered DurabilityCheck() - starting price is: {editedPrice}");
|
||||||
// if (repair != null)
|
|
||||||
// {
|
|
||||||
// if (repair.Durability > 0)
|
|
||||||
// {
|
|
||||||
// DebugMode($" repairable Check - Durability is: {repair.Durability}");
|
|
||||||
// DebugMode($" Medkit Check - originalMax is: {originalMax}");
|
|
||||||
|
|
||||||
// editedPrice *= repair.Durability / originalMax;
|
var medKit = item.GetItemComponent<MedKitComponent>();
|
||||||
// }
|
if (medKit != null && medKit.HpResource != 0 && medKit.MaxHpResource != 0)
|
||||||
// else
|
{
|
||||||
// {
|
DebugMode($" Medkit Check - HpResource is: {medKit.HpResource}");
|
||||||
// DebugMode($" repairable Check - Durability is 0");
|
DebugMode($" Medkit Check - MaxHpResource is: {medKit.MaxHpResource}");
|
||||||
|
|
||||||
// editedPrice = 1;
|
editedPrice *= medKit.HpResource / medKit.MaxHpResource;
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// DebugMode($" After repairable Check - price is: {editedPrice}");
|
DebugMode($" After Medkit Check - price is: {editedPrice}");
|
||||||
|
|
||||||
// var dogtag = item.GetItemComponent<DogtagComponent>();
|
var repair = item.GetItemComponent<RepairableComponent>();
|
||||||
// if (dogtag != null && dogtag.Level != 0)
|
if (repair != null)
|
||||||
// {
|
{
|
||||||
// DebugMode($" dogtag Check - level is: {dogtag.Level}");
|
if (repair.Durability > 0)
|
||||||
|
{
|
||||||
|
DebugMode($" repairable Check - Durability is: {repair.Durability}");
|
||||||
|
DebugMode($" Medkit Check - originalMax is: {originalMax}");
|
||||||
|
|
||||||
// editedPrice *= dogtag.Level;
|
editedPrice *= repair.Durability / originalMax;
|
||||||
// }
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugMode($" repairable Check - Durability is 0");
|
||||||
|
|
||||||
// DebugMode($" After dogtag Check - price is: {editedPrice}");
|
editedPrice = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// var repairKit = item.GetItemComponent<RepairKitComponent>();
|
DebugMode($" After repairable Check - price is: {editedPrice}");
|
||||||
// if (repairKit != null)
|
|
||||||
// {
|
|
||||||
// if (repairKit.Resource > 0)
|
|
||||||
// {
|
|
||||||
// DebugMode($" repairkit Check - Resource is: {repairKit.Resource}");
|
|
||||||
// DebugMode($" repairkit Check - originalMax is: {originalMax}");
|
|
||||||
|
|
||||||
// editedPrice *= repairKit.Resource / originalMax;
|
var dogtag = item.GetItemComponent<DogtagComponent>();
|
||||||
// }
|
if (dogtag != null && dogtag.Level != 0)
|
||||||
// else
|
{
|
||||||
// {
|
DebugMode($" dogtag Check - level is: {dogtag.Level}");
|
||||||
// DebugMode($" repairkit Check - Resource is 0");
|
|
||||||
|
|
||||||
// editedPrice = 1;
|
editedPrice *= dogtag.Level;
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// DebugMode($" After repairkit Check - price is: {editedPrice}");
|
DebugMode($" After dogtag Check - price is: {editedPrice}");
|
||||||
|
|
||||||
// var resource = item.GetItemComponent<ResourceComponent>();
|
var repairKit = item.GetItemComponent<RepairKitComponent>();
|
||||||
// if (resource != null && resource.Value != 0 && resource.MaxResource != 0)
|
if (repairKit != null)
|
||||||
// {
|
{
|
||||||
// DebugMode($" resource Check - Resource is: {resource.Value}");
|
if (repairKit.Resource > 0)
|
||||||
// DebugMode($" resource Check - MaxResource is: {resource.MaxResource}");
|
{
|
||||||
|
DebugMode($" repairkit Check - Resource is: {repairKit.Resource}");
|
||||||
|
DebugMode($" repairkit Check - originalMax is: {originalMax}");
|
||||||
|
|
||||||
// editedPrice *= resource.Value / resource.MaxResource;
|
editedPrice *= repairKit.Resource / originalMax;
|
||||||
// }
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugMode($" repairkit Check - Resource is 0");
|
||||||
|
|
||||||
// DebugMode($" After resource Check - price is: {editedPrice}");
|
editedPrice = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// var foodDrink = item.GetItemComponent<FoodDrinkComponent>();
|
DebugMode($" After repairkit Check - price is: {editedPrice}");
|
||||||
// if (foodDrink != null && foodDrink.HpPercent != 0)
|
|
||||||
// {
|
|
||||||
// GInterface234 ginterface234_0 = (GInterface234)foodDrink.GetType().GetField("ginterface234_0", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(foodDrink);
|
|
||||||
|
|
||||||
// DebugMode($" foodDrink Check - HpPercent is: {foodDrink.HpPercent}");
|
var resource = item.GetItemComponent<ResourceComponent>();
|
||||||
// DebugMode($" foodDrink Check - MaxResource is: {ginterface234_0.MaxResource}");
|
if (resource != null && resource.Value != 0 && resource.MaxResource != 0)
|
||||||
|
{
|
||||||
|
DebugMode($" resource Check - Resource is: {resource.Value}");
|
||||||
|
DebugMode($" resource Check - MaxResource is: {resource.MaxResource}");
|
||||||
|
|
||||||
// editedPrice *= foodDrink.HpPercent / ginterface234_0.MaxResource;
|
editedPrice *= resource.Value / resource.MaxResource;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// DebugMode($" After foodDrink Check - price is: {editedPrice}");
|
DebugMode($" After resource Check - price is: {editedPrice}");
|
||||||
|
|
||||||
// var keys = item.GetItemComponent<KeyComponent>();
|
var foodDrink = item.GetItemComponent<FoodDrinkComponent>();
|
||||||
// if (keys != null)
|
if (foodDrink != null && foodDrink.HpPercent != 0)
|
||||||
// {
|
{
|
||||||
// GInterface238 template = (GInterface238)keys.GetType().GetField("Template", BindingFlags.Public | BindingFlags.Instance).GetValue(keys);
|
GInterface234 ginterface234_0 = (GInterface234)foodDrink.GetType().GetField("ginterface234_0", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(foodDrink);
|
||||||
|
|
||||||
// if (keys.NumberOfUsages > 0)
|
DebugMode($" foodDrink Check - HpPercent is: {foodDrink.HpPercent}");
|
||||||
// {
|
DebugMode($" foodDrink Check - MaxResource is: {ginterface234_0.MaxResource}");
|
||||||
// double totalMinusUsed = Convert.ToDouble(template.MaximumNumberOfUsage - keys.NumberOfUsages);
|
|
||||||
// double multi = totalMinusUsed / template.MaximumNumberOfUsage;
|
|
||||||
|
|
||||||
// DebugMode($" foodDrink Check - totalMinusUsed is: {totalMinusUsed}");
|
editedPrice *= foodDrink.HpPercent / ginterface234_0.MaxResource;
|
||||||
// DebugMode($" foodDrink Check - multi is: {multi}");
|
}
|
||||||
|
|
||||||
// editedPrice *= multi;
|
DebugMode($" After foodDrink Check - price is: {editedPrice}");
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// DebugMode($" After keys Check - price is: {editedPrice}");
|
var keys = item.GetItemComponent<KeyComponent>();
|
||||||
|
if (keys != null)
|
||||||
|
{
|
||||||
|
GInterface238 template = (GInterface238)keys.GetType().GetField("Template", BindingFlags.Public | BindingFlags.Instance).GetValue(keys);
|
||||||
|
|
||||||
// var sideEffect = item.GetItemComponent<SideEffectComponent>();
|
if (keys.NumberOfUsages > 0)
|
||||||
// if (sideEffect != null && sideEffect.Value != 0)
|
{
|
||||||
// {
|
double totalMinusUsed = Convert.ToDouble(template.MaximumNumberOfUsage - keys.NumberOfUsages);
|
||||||
// DebugMode($" sideEffect Check - resource is: {sideEffect.Value}");
|
double multi = totalMinusUsed / template.MaximumNumberOfUsage;
|
||||||
// DebugMode($" sideEffect Check - MaxResource is: {sideEffect.MaxResource}");
|
|
||||||
|
|
||||||
// editedPrice *= sideEffect.Value / sideEffect.MaxResource;
|
DebugMode($" foodDrink Check - totalMinusUsed is: {totalMinusUsed}");
|
||||||
// }
|
DebugMode($" foodDrink Check - multi is: {multi}");
|
||||||
|
|
||||||
// DebugMode($" After sideEffect Check - price is: {editedPrice}");
|
editedPrice *= multi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DebugMode($"Ending price: {editedPrice}");
|
DebugMode($" After keys Check - price is: {editedPrice}");
|
||||||
|
|
||||||
// return editedPrice;
|
var sideEffect = item.GetItemComponent<SideEffectComponent>();
|
||||||
//}
|
if (sideEffect != null && sideEffect.Value != 0)
|
||||||
|
{
|
||||||
|
DebugMode($" sideEffect Check - resource is: {sideEffect.Value}");
|
||||||
|
DebugMode($" sideEffect Check - MaxResource is: {sideEffect.MaxResource}");
|
||||||
|
|
||||||
//public static void DebugMode(String str)
|
editedPrice *= sideEffect.Value / sideEffect.MaxResource;
|
||||||
//{
|
}
|
||||||
// var directory = Directory.GetCurrentDirectory();
|
|
||||||
|
|
||||||
// var modDirectory = new DirectoryInfo(directory + "/user/mods/");
|
DebugMode($" After sideEffect Check - price is: {editedPrice}");
|
||||||
// DirectoryInfo[] dirsInDir = modDirectory.GetDirectories("*" + "SeeItemValue" + "*.*");
|
|
||||||
|
|
||||||
// if (dirsInDir.Length == 1)
|
DebugMode($"Ending price: {editedPrice}");
|
||||||
// {
|
|
||||||
// var json = File.ReadAllText(dirsInDir[0].ToString() + "/src/config.json");
|
|
||||||
|
|
||||||
// var configJson = Json.Deserialize<ConfigClass>(json);
|
return editedPrice;
|
||||||
|
}
|
||||||
|
|
||||||
// if (configJson != null && configJson.DebugMode)
|
public static void DebugMode(String str)
|
||||||
// {
|
{
|
||||||
// Debug.LogError(str);
|
var directory = Directory.GetCurrentDirectory();
|
||||||
// }
|
|
||||||
// }
|
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