hopefully fixes latest issues with refactor, might have to look into caching all on game start
This commit is contained in:
parent
555c17d308
commit
dac0960e7b
Binary file not shown.
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "SeeItemValue",
|
"name": "SeeItemValue",
|
||||||
"author": "KcY",
|
"author": "KcY",
|
||||||
"version": "1.4.4",
|
"version": "1.4.6",
|
||||||
"license": "NCSA Open Source",
|
"license": "NCSA Open Source",
|
||||||
"main": "src/mod.js",
|
"main": "src/mod.js",
|
||||||
"akiVersion": "3.2.3",
|
"akiVersion": "3.2.3",
|
@ -103,6 +103,9 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
|
|||||||
{
|
{
|
||||||
result.traderName = "Flea";
|
result.traderName = "Flea";
|
||||||
|
|
||||||
|
result.originalMax = this.getOrigiDura(id);
|
||||||
|
this.debugMode(`Original max is ${result.originalMax}`);
|
||||||
|
|
||||||
// return price if it exists else return 1
|
// return price if it exists else return 1
|
||||||
if (this.livePrice[id])
|
if (this.livePrice[id])
|
||||||
{
|
{
|
||||||
@ -175,28 +178,35 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
|
|||||||
|
|
||||||
private getBestTraderMulti(parentId: string): any
|
private getBestTraderMulti(parentId: string): any
|
||||||
{
|
{
|
||||||
let firstCat = this.handbookTable.Categories.find(x => x.Id === parentId);
|
let firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId);
|
||||||
let secondCat = firstCat.ParentId
|
let secondCat = firstCat?.ParentId
|
||||||
let thirdCat = this.handbookTable.Categories.find(x => x.Id === secondCat).ParentId;
|
let thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId;
|
||||||
|
|
||||||
|
let result = {k1: 1, k2: "Unknown"};
|
||||||
|
|
||||||
if (firstCat.Id || secondCat || thirdCat)
|
if (firstCat.Id || secondCat || thirdCat)
|
||||||
{
|
{
|
||||||
for (let i in this.tradersArr)
|
for (let i in this.tradersArr)
|
||||||
{
|
{
|
||||||
if (this.tradersArr[i].sell_category.includes(firstCat.Id) ||
|
if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) ||
|
||||||
this.tradersArr[i].sell_category.includes(secondCat) ||
|
this.tradersArr[i]?.sell_category?.includes(secondCat) ||
|
||||||
this.tradersArr[i].sell_category.includes(thirdCat))
|
this.tradersArr[i]?.sell_category?.includes(thirdCat))
|
||||||
{
|
{
|
||||||
let multi = (100 - this.tradersArr[i].loyaltyLevels[0].buy_price_coef) / 100;
|
let multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100;
|
||||||
let name = this.tradersArr[i].nickname;
|
let name = this.tradersArr[i]?.nickname;
|
||||||
|
|
||||||
return {k1: multi, k2: name};
|
result.k1 = multi;
|
||||||
|
result.k2 = name;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 1;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,8 @@
|
|||||||
//namespace itemValueMod
|
namespace itemValueMod
|
||||||
//{
|
{
|
||||||
// public struct itemGetter
|
public class ConfigClass
|
||||||
// {
|
{
|
||||||
// public double sPrice { get; set; }
|
public bool TraderPrice { get; set; }
|
||||||
// }
|
public bool DebugMode { get; set; }
|
||||||
//}
|
}
|
||||||
|
}
|
||||||
|
@ -8,6 +8,7 @@ using ItemAttribute = GClass2197;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace itemValueMod
|
namespace itemValueMod
|
||||||
{
|
{
|
||||||
@ -51,6 +52,7 @@ namespace itemValueMod
|
|||||||
string itemId = item.Template._id;
|
string itemId = item.Template._id;
|
||||||
JsonClass jsonClass;
|
JsonClass jsonClass;
|
||||||
bool lockWasTaken = false;
|
bool lockWasTaken = false;
|
||||||
|
double alteredPrice = 1;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -73,16 +75,13 @@ namespace itemValueMod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (jsonClass.price != 1)
|
||||||
double alteredPrice = DurabilityCheck(item, jsonClass);
|
{
|
||||||
|
alteredPrice = DurabilityCheck(item, jsonClass);
|
||||||
Debug.LogError($"price: {alteredPrice}");
|
}
|
||||||
|
|
||||||
double _price = alteredPrice * jsonClass.multiplier;
|
double _price = alteredPrice * jsonClass.multiplier;
|
||||||
|
|
||||||
Debug.LogError($"price: {jsonClass.multiplier}");
|
|
||||||
Debug.LogError($"price: {_price}");
|
|
||||||
|
|
||||||
return Math.Round(_price).ToString();
|
return Math.Round(_price).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,62 +120,93 @@ namespace itemValueMod
|
|||||||
double editedPrice = jsonClass.price;
|
double editedPrice = jsonClass.price;
|
||||||
double originalMax = jsonClass.originalMax;
|
double originalMax = jsonClass.originalMax;
|
||||||
|
|
||||||
Debug.LogError($"price: {jsonClass.price}");
|
DebugMode($" Entered DurabilityCheck() - starting price is: {editedPrice}");
|
||||||
|
|
||||||
|
|
||||||
var medKit = item.GetItemComponent<MedKitComponent>();
|
var medKit = item.GetItemComponent<MedKitComponent>();
|
||||||
if (medKit != null && medKit.HpResource != 0 && medKit.MaxHpResource != 0)
|
if (medKit != null && medKit.HpResource != 0 && medKit.MaxHpResource != 0)
|
||||||
{
|
{
|
||||||
|
DebugMode($" Medkit Check - HpResource is: {medKit.HpResource}");
|
||||||
|
DebugMode($" Medkit Check - MaxHpResource is: {medKit.MaxHpResource}");
|
||||||
|
|
||||||
editedPrice *= medKit.HpResource / medKit.MaxHpResource;
|
editedPrice *= medKit.HpResource / medKit.MaxHpResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugMode($" After Medkit Check - price is: {editedPrice}");
|
||||||
|
|
||||||
var repair = item.GetItemComponent<RepairableComponent>();
|
var repair = item.GetItemComponent<RepairableComponent>();
|
||||||
if (repair != null)
|
if (repair != null)
|
||||||
{
|
{
|
||||||
if (repair.Durability > 0)
|
if (repair.Durability > 0)
|
||||||
{
|
{
|
||||||
|
DebugMode($" repairable Check - Durability is: {repair.Durability}");
|
||||||
|
DebugMode($" Medkit Check - originalMax is: {originalMax}");
|
||||||
|
|
||||||
editedPrice *= repair.Durability / originalMax;
|
editedPrice *= repair.Durability / originalMax;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DebugMode($" repairable Check - Durability is 0");
|
||||||
|
|
||||||
editedPrice = 1;
|
editedPrice = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugMode($" After repairable Check - price is: {editedPrice}");
|
||||||
|
|
||||||
var dogtag = item.GetItemComponent<DogtagComponent>();
|
var dogtag = item.GetItemComponent<DogtagComponent>();
|
||||||
if (dogtag != null && dogtag.Level != 0)
|
if (dogtag != null && dogtag.Level != 0)
|
||||||
{
|
{
|
||||||
|
DebugMode($" dogtag Check - level is: {dogtag.Level}");
|
||||||
|
|
||||||
editedPrice *= dogtag.Level;
|
editedPrice *= dogtag.Level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugMode($" After dogtag Check - price is: {editedPrice}");
|
||||||
|
|
||||||
var repairKit = item.GetItemComponent<RepairKitComponent>();
|
var repairKit = item.GetItemComponent<RepairKitComponent>();
|
||||||
if (repairKit != null)
|
if (repairKit != null)
|
||||||
{
|
{
|
||||||
if (repairKit.Resource > 0)
|
if (repairKit.Resource > 0)
|
||||||
{
|
{
|
||||||
|
DebugMode($" repairkit Check - Resource is: {repairKit.Resource}");
|
||||||
|
DebugMode($" repairkit Check - originalMax is: {originalMax}");
|
||||||
|
|
||||||
editedPrice *= repairKit.Resource / originalMax;
|
editedPrice *= repairKit.Resource / originalMax;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DebugMode($" repairkit Check - Resource is 0");
|
||||||
|
|
||||||
editedPrice = 1;
|
editedPrice = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugMode($" After repairkit Check - price is: {editedPrice}");
|
||||||
|
|
||||||
var resource = item.GetItemComponent<ResourceComponent>();
|
var resource = item.GetItemComponent<ResourceComponent>();
|
||||||
if (resource != null && resource.Value != 0 && resource.MaxResource != 0)
|
if (resource != null && resource.Value != 0 && resource.MaxResource != 0)
|
||||||
{
|
{
|
||||||
|
DebugMode($" resource Check - Resource is: {resource.Value}");
|
||||||
|
DebugMode($" resource Check - MaxResource is: {resource.MaxResource}");
|
||||||
|
|
||||||
editedPrice *= resource.Value / resource.MaxResource;
|
editedPrice *= resource.Value / resource.MaxResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugMode($" After resource Check - price is: {editedPrice}");
|
||||||
|
|
||||||
var foodDrink = item.GetItemComponent<FoodDrinkComponent>();
|
var foodDrink = item.GetItemComponent<FoodDrinkComponent>();
|
||||||
if (foodDrink != null && foodDrink.HpPercent != 0)
|
if (foodDrink != null && foodDrink.HpPercent != 0)
|
||||||
{
|
{
|
||||||
GInterface208 ginterface208_0 = (GInterface208)foodDrink.GetType().GetField("ginterface208_0", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(foodDrink);
|
GInterface208 ginterface208_0 = (GInterface208)foodDrink.GetType().GetField("ginterface208_0", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(foodDrink);
|
||||||
|
|
||||||
|
DebugMode($" foodDrink Check - HpPercent is: {foodDrink.HpPercent}");
|
||||||
|
DebugMode($" foodDrink Check - MaxResource is: {ginterface208_0.MaxResource}");
|
||||||
|
|
||||||
editedPrice *= foodDrink.HpPercent / ginterface208_0.MaxResource;
|
editedPrice *= foodDrink.HpPercent / ginterface208_0.MaxResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugMode($" After foodDrink Check - price is: {editedPrice}");
|
||||||
|
|
||||||
var keys = item.GetItemComponent<KeyComponent>();
|
var keys = item.GetItemComponent<KeyComponent>();
|
||||||
if (keys != null)
|
if (keys != null)
|
||||||
{
|
{
|
||||||
@ -187,19 +217,49 @@ namespace itemValueMod
|
|||||||
double totalMinusUsed = Convert.ToDouble(ginterface212_0.MaximumNumberOfUsage - keys.NumberOfUsages);
|
double totalMinusUsed = Convert.ToDouble(ginterface212_0.MaximumNumberOfUsage - keys.NumberOfUsages);
|
||||||
double multi = totalMinusUsed / ginterface212_0.MaximumNumberOfUsage;
|
double multi = totalMinusUsed / ginterface212_0.MaximumNumberOfUsage;
|
||||||
|
|
||||||
|
DebugMode($" foodDrink Check - totalMinusUsed is: {totalMinusUsed}");
|
||||||
|
DebugMode($" foodDrink Check - multi is: {multi}");
|
||||||
|
|
||||||
editedPrice *= multi;
|
editedPrice *= multi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugMode($" After keys Check - price is: {editedPrice}");
|
||||||
|
|
||||||
var sideEffect = item.GetItemComponent<SideEffectComponent>();
|
var sideEffect = item.GetItemComponent<SideEffectComponent>();
|
||||||
if (sideEffect != null && sideEffect.Value != 0)
|
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;
|
editedPrice *= sideEffect.Value / sideEffect.MaxResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.LogError($"price: {jsonClass.price}");
|
DebugMode($" After sideEffect Check - price is: {editedPrice}");
|
||||||
|
|
||||||
|
DebugMode($"Ending price: {editedPrice}");
|
||||||
|
|
||||||
return editedPrice;
|
return editedPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void DebugMode(String 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
<Version>1.4.4</Version>
|
<Version>1.4.5</Version>
|
||||||
<AssemblyName>KcY-SeeItemValue</AssemblyName>
|
<AssemblyName>KcY-SeeItemValue</AssemblyName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "SeeItemValue",
|
"name": "SeeItemValue",
|
||||||
"author": "KcY",
|
"author": "KcY",
|
||||||
"version": "1.4.4",
|
"version": "1.4.6",
|
||||||
"license": "NCSA Open Source",
|
"license": "NCSA Open Source",
|
||||||
"main": "src/mod.js",
|
"main": "src/mod.js",
|
||||||
"akiVersion": "3.2.3",
|
"akiVersion": "3.2.3",
|
||||||
|
@ -103,6 +103,9 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
|
|||||||
{
|
{
|
||||||
result.traderName = "Flea";
|
result.traderName = "Flea";
|
||||||
|
|
||||||
|
result.originalMax = this.getOrigiDura(id);
|
||||||
|
this.debugMode(`Original max is ${result.originalMax}`);
|
||||||
|
|
||||||
// return price if it exists else return 1
|
// return price if it exists else return 1
|
||||||
if (this.livePrice[id])
|
if (this.livePrice[id])
|
||||||
{
|
{
|
||||||
@ -175,28 +178,35 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
|
|||||||
|
|
||||||
private getBestTraderMulti(parentId: string): any
|
private getBestTraderMulti(parentId: string): any
|
||||||
{
|
{
|
||||||
let firstCat = this.handbookTable.Categories.find(x => x.Id === parentId);
|
let firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId);
|
||||||
let secondCat = firstCat.ParentId
|
let secondCat = firstCat?.ParentId
|
||||||
let thirdCat = this.handbookTable.Categories.find(x => x.Id === secondCat).ParentId;
|
let thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId;
|
||||||
|
|
||||||
|
let result = {k1: 1, k2: "Unknown"};
|
||||||
|
|
||||||
if (firstCat.Id || secondCat || thirdCat)
|
if (firstCat.Id || secondCat || thirdCat)
|
||||||
{
|
{
|
||||||
for (let i in this.tradersArr)
|
for (let i in this.tradersArr)
|
||||||
{
|
{
|
||||||
if (this.tradersArr[i].sell_category.includes(firstCat.Id) ||
|
if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) ||
|
||||||
this.tradersArr[i].sell_category.includes(secondCat) ||
|
this.tradersArr[i]?.sell_category?.includes(secondCat) ||
|
||||||
this.tradersArr[i].sell_category.includes(thirdCat))
|
this.tradersArr[i]?.sell_category?.includes(thirdCat))
|
||||||
{
|
{
|
||||||
let multi = (100 - this.tradersArr[i].loyaltyLevels[0].buy_price_coef) / 100;
|
let multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100;
|
||||||
let name = this.tradersArr[i].nickname;
|
let name = this.tradersArr[i]?.nickname;
|
||||||
|
|
||||||
return {k1: multi, k2: name};
|
result.k1 = multi;
|
||||||
|
result.k2 = name;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 1;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "SeeItemValue",
|
"name": "SeeItemValue",
|
||||||
"author": "KcY",
|
"author": "KcY",
|
||||||
"version": "1.4.4",
|
"version": "1.4.6",
|
||||||
"license": "NCSA Open Source",
|
"license": "NCSA Open Source",
|
||||||
"main": "src/mod.js",
|
"main": "src/mod.js",
|
||||||
"akiVersion": "3.2.3",
|
"akiVersion": "3.2.3",
|
||||||
|
@ -103,6 +103,9 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
|
|||||||
{
|
{
|
||||||
result.traderName = "Flea";
|
result.traderName = "Flea";
|
||||||
|
|
||||||
|
result.originalMax = this.getOrigiDura(id);
|
||||||
|
this.debugMode(`Original max is ${result.originalMax}`);
|
||||||
|
|
||||||
// return price if it exists else return 1
|
// return price if it exists else return 1
|
||||||
if (this.livePrice[id])
|
if (this.livePrice[id])
|
||||||
{
|
{
|
||||||
@ -175,28 +178,35 @@ class SeeItemValue implements IPreAkiLoadMod, IPostAkiLoadMod
|
|||||||
|
|
||||||
private getBestTraderMulti(parentId: string): any
|
private getBestTraderMulti(parentId: string): any
|
||||||
{
|
{
|
||||||
let firstCat = this.handbookTable.Categories.find(x => x.Id === parentId);
|
let firstCat = this.handbookTable?.Categories?.find(x => x.Id === parentId);
|
||||||
let secondCat = firstCat.ParentId
|
let secondCat = firstCat?.ParentId
|
||||||
let thirdCat = this.handbookTable.Categories.find(x => x.Id === secondCat).ParentId;
|
let thirdCat = this.handbookTable?.Categories?.find(x => x.Id === secondCat)?.ParentId;
|
||||||
|
|
||||||
|
let result = {k1: 1, k2: "Unknown"};
|
||||||
|
|
||||||
if (firstCat.Id || secondCat || thirdCat)
|
if (firstCat.Id || secondCat || thirdCat)
|
||||||
{
|
{
|
||||||
for (let i in this.tradersArr)
|
for (let i in this.tradersArr)
|
||||||
{
|
{
|
||||||
if (this.tradersArr[i].sell_category.includes(firstCat.Id) ||
|
if (this.tradersArr[i]?.sell_category?.includes(firstCat.Id) ||
|
||||||
this.tradersArr[i].sell_category.includes(secondCat) ||
|
this.tradersArr[i]?.sell_category?.includes(secondCat) ||
|
||||||
this.tradersArr[i].sell_category.includes(thirdCat))
|
this.tradersArr[i]?.sell_category?.includes(thirdCat))
|
||||||
{
|
{
|
||||||
let multi = (100 - this.tradersArr[i].loyaltyLevels[0].buy_price_coef) / 100;
|
let multi = (100 - this.tradersArr[i]?.loyaltyLevels[0]?.buy_price_coef) / 100;
|
||||||
let name = this.tradersArr[i].nickname;
|
let name = this.tradersArr[i]?.nickname;
|
||||||
|
|
||||||
return {k1: multi, k2: name};
|
result.k1 = multi;
|
||||||
|
result.k2 = name;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 1;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user