Skip to content

Commit e436bd5

Browse files
committed
Test update
1 parent c6bd750 commit e436bd5

8 files changed

Lines changed: 72 additions & 23 deletions

FTKRandomizer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
<Compile Include="Patches\RandomizeDInitialStats.cs" />
7878
<Compile Include="Patches\LootItems.cs" />
7979
<Compile Include="Patches\RandomizeDShopPrices.cs" />
80+
<Compile Include="Patches\TestRandomModifier.cs" />
8081
<Compile Include="Patches\TownEE.cs" />
8182
<Compile Include="Plugin.cs" />
8283
<Compile Include="Properties\AssemblyInfo.cs" />

Patches/LootItems.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ static bool FillLootDropListPatch(ArrayList _arrayList, int _playerCount, FTK_en
9292

9393
while (
9494
entry == null ||
95-
entry.m_MinLevel > ((int)GameFlow.Instance.AveragePlayerLevel) ||
95+
entry.m_MaxLevel > ((int)GameFlow.Instance.AveragePlayerLevel) ||
96+
entry._goldValue > 20 * Math.Max((int)GameFlow.Instance.AveragePlayerLevel, 1) || // 90, 40, 20 -> bug fix + max level-> 20
9697
FOUND_ITEMS.Contains(item_id)
9798
)
9899
{

Patches/RandomizeAllItemStats.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ static bool Prefix(FTK_weaponStats2DB __instance, ref FTK_weaponStats2 __result,
4545

4646
// the idea is to equally distribute all skills, this way players have a higher probability of finding something that works for them
4747
// Weighted random selection
48+
// but for now I'm going to use a simple random
4849

50+
if(__result.m_IsWeapon)
51+
__result._slots = rand.Next(1, 5);
4952

53+
//__result._dmgtype
5054
// Those will be affected the most, slight damage increase
5155
if (
5256
__result._skilltest == FTK_weaponStats2.SkillType.awareness ||
@@ -62,14 +66,21 @@ static bool Prefix(FTK_weaponStats2DB __instance, ref FTK_weaponStats2 __result,
6266
}
6367
else
6468
{
65-
int minDmg = 5;
66-
int maxDmg = 7;
6769

68-
if (__result._skilltest == FTK_weaponStats2.SkillType.luck) { minDmg = 8; maxDmg = 10; } // luck is fun
70+
// Feb. 27 2025: changing buff to a fixed one instead of random (test 1)
71+
int buff = 3;
72+
int multiplier = 1;
73+
int finalBuff;
6974

70-
var multiplier = System.Math.Max((int)__result.m_ItemRarity, 1);
75+
if (__result._skilltest == FTK_weaponStats2.SkillType.luck) { buff = 5; } // luck is fun
7176

72-
__result._maxdmg += rand.Next(minDmg * multiplier, maxDmg * multiplier);
77+
if(__result.m_ItemRarity == FTK_itemRarityLevel.ID.rare) { multiplier = 2;}
78+
if(__result.m_ItemRarity == FTK_itemRarityLevel.ID.artifact) { multiplier = 3;}
79+
80+
finalBuff = buff * multiplier;
81+
82+
83+
__result._maxdmg += finalBuff;
7384
WeaponDamageDB[item_id] = __result._maxdmg;
7485
}
7586
}

Patches/RandomizeDItemEffects.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ static bool Prefix(Weapon __instance, ref List<FTK_proficiencyTable.ID> __result
5757
SEED += (int)__instance.m_WeaponType;
5858
SEED += (int)__instance.m_WeaponSubType;
5959
SEED += (int)__instance.m_WeaponMaterial;
60-
SEED += (int)ProfDB.Count;
60+
61+
62+
//SEED += ProfDB.Count;
6163
System.Random rand = new System.Random(SEED);
6264

65+
66+
6367
FTK_proficiencyTable.ID assign;
6468

6569
foreach (ProficiencyID key in __instance.m_ProficiencyEffects.Keys)

Patches/RandomizeDShopItems.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static bool Prefix(FTK_progressionTier.ID _tier, ref List<FTK_itembase.ID> __res
6161
entry.m_ItemRarity == FTK_itemRarityLevel.ID.lore ||
6262
entry.m_ItemRarity == FTK_itemRarityLevel.ID.quest ||
6363
entry.m_ItemRarity == FTK_itemRarityLevel.ID.None ||
64-
entry._goldValue <= 1 || entry._goldValue >= 500 || // Super pricy items
64+
entry._goldValue <= 19 || entry._goldValue >= 500 || // Super pricy items
6565
entry.GetLocalizedName().ToLower().Contains("str_") ||
6666
entry.GetLocalizedName().ToLower().Contains("debug") ||
6767
entry.GetLocalizedName().ToLower().Contains("database") ||

Patches/RandomizeDShopPrices.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,9 @@ static bool shopPricesPatch(CharacterOverworld _cow, MiniHexInfo _poi, FTK_itemb
2727
//__instance.m_ID = "bladeGlass03";
2828
int MapSeed = GameLogic.Instance.m_MapGenRandomSeed;
2929
int Turn = GameFlow.Instance.m_RoundCount;
30-
int TI1 = GameLogic.Instance.m_CurrentPlayer.TurnIndex;
31-
int TI2 = GameLogic.Instance.m_CurrentPlayer.m_TurnIndex;
32-
int AveragePlayerLevel = (int)GameFlow.Instance.AveragePlayerLevel;
33-
//Debug.Log($"Round Count: {GameFlow.Instance.m_RoundCount}");
3430

3531
// [Error : Unity Log] NullReferenceException: Object reference not set to an instance of an object
3632

37-
//SEED = Turn * MapSeed +
38-
// Turn * __instance._goldValue +
39-
// Turn * (__instance.m_MaxLevel + Turn + __instance.m_MinLevel + Turn) +
40-
// (Turn + TI1) * MapSeed + (Turn + TI2) * MapSeed;
41-
42-
//SEED = (Turn + TI1) * MapSeed + (Turn + TI2) * MapSeed;
43-
4433
SEED = 0;
4534
SEED += MapSeed + Turn;
4635
SEED += Turn * __instance._goldValue;
@@ -49,10 +38,7 @@ static bool shopPricesPatch(CharacterOverworld _cow, MiniHexInfo _poi, FTK_itemb
4938

5039
rand = new System.Random((int)SEED);
5140

52-
int amount = rand.Next(1, (int)Math.Max(_goldValue / 1.5, 1));
53-
54-
55-
// Use the same Random instance to get the same sequence
41+
int amount = rand.Next(1, (int)Math.Max(_goldValue / 1.5, 3));
5642
if (rand.Next(101) <= 50)
5743
{
5844
newPrice = _goldValue + amount;

Patches/TestRandomModifier.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using GridEditor;
2+
using HarmonyLib;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using static Rewired.ComponentControls.Effects.RotateAroundAxis;
9+
using static StapleQuestProperties;
10+
11+
namespace FTKRandomizer.Patches
12+
{
13+
[HarmonyPatch(typeof(CharacterOverworld))]
14+
[HarmonyPatch(nameof(CharacterOverworld.AddOrRemoveCharacterModifier), new Type[] { typeof(FTK_itembase.ID), typeof(bool) })]
15+
public class TestRandomModifier
16+
{
17+
static bool testTestTest(FTK_itembase.ID _item, bool _add, CharacterOverworld __instance)
18+
{
19+
//int SEED = GameLogic.Instance.m_MapGenRandomSeed;
20+
int SEED = (int)_item;
21+
22+
System.Random rand = new System.Random((int)SEED);
23+
24+
Array values = Enum.GetValues(typeof(FTK_itembase.ID));
25+
FTK_itembase.ID newId = (FTK_itembase.ID)values.GetValue(rand.Next(1, values.Length - 1));
26+
27+
28+
if (_add)
29+
{
30+
if (FTK_characterModifierDB.GetDB().IsContainID(newId.ToString()))
31+
{
32+
__instance.m_CharacterStats.AddCharacterMod(FTK_characterModifier.GetEnum(newId.ToString()));
33+
}
34+
}
35+
else if (FTK_characterModifierDB.GetDB().IsContainID(newId.ToString()))
36+
{
37+
__instance.m_CharacterStats.RemoveCharacterMod(FTK_characterModifier.GetEnum(newId.ToString()));
38+
}
39+
__instance.m_UIPlayMainHud.UpdateHud();
40+
41+
return false;
42+
}
43+
}
44+
}

Plugin.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ void Awake()
4040

4141
harmony.PatchAll(typeof(LootItems));
4242
harmony.PatchAll(typeof(RandomizeDItemEffects));
43+
44+
//harmony.PatchAll(typeof(TestRandomModifier));
4345
}
4446
}
4547

0 commit comments

Comments
 (0)