-
Notifications
You must be signed in to change notification settings - Fork 4
/
ExpHandler.cs
89 lines (85 loc) · 3.38 KB
/
ExpHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
namespace LunacidAP
{
public class ExpHandler
{
private static ManualLogSource _log;
public ExpHandler(ManualLogSource log)
{
_log = log;
Harmony.CreateAndPatchAll(typeof(ExpHandler));
}
[HarmonyPatch(typeof(CONTROL), "GiveXP")]
[HarmonyPrefix]
private static bool GiveXP_MultiplyIncomingXP(CONTROL __instance, int LEVELED_XP)
{
var givenXP = LEVELED_XP;
givenXP = Mathf.RoundToInt(givenXP * ArchipelagoClient.AP.SlotData.ExperienceMultiplier);
if (__instance.ST)
{
givenXP = Mathf.RoundToInt((float)givenXP * 0.3f);
}
float num = (float)__instance.CURRENT_PL_DATA.PLAYER_LVL + (float)__instance.CURRENT_PL_DATA.XP / 100f;
float mOON_MULT = __instance.GetComponent<SimpleMoon>().MOON_MULT;
givenXP = Mathf.RoundToInt((float)givenXP * Mathf.Lerp(1f, 2f, mOON_MULT / 10f * (__instance.CURRENT_PL_DATA.PLAYER_L / 50f)));
if (num > 50f)
{
__instance.CURRENT_PL_DATA.XP += Mathf.RoundToInt(35f * Mathf.Pow((float)givenXP / num, 1.25f) / Mathf.Pow(num, 0.1f));
}
else
{
__instance.CURRENT_PL_DATA.XP += Mathf.RoundToInt(35f * Mathf.Pow((float)givenXP / num, 1.25f));
}
return false;
}
[HarmonyPatch(typeof(Weapon_scr), "Attack")]
[HarmonyPostfix]
private static void Attack_TryToBuffExp(Weapon_scr __instance)
{
var additionalExp = ArchipelagoClient.AP.SlotData.WExperienceMultiplier - 1; // the "damage" was already done, so this is the remainder
if (__instance.type == 0)
{
if (__instance.special == 6)
{
__instance.WEP_XP += 1f * additionalExp;
}
int num = __instance.WEP_ELEMENT;
if (num > 7)
{
switch (num)
{
case 8:
num = 5;
break;
case 9:
num = 0;
break;
case 10:
num = 2;
break;
case 11:
num = 5;
break;
}
}
if (__instance.gameObject.GetComponent<OBJ_HEALTH>() != null && __instance.gameObject.GetComponent<OBJ_HEALTH>().type < 4 && __instance.WEP_XP > -1f && __instance.WEP_XP < 99f)
{
__instance.WEP_XP += (__instance.WEP_XP += __instance.WEP_GROWTH * __instance.gameObject.GetComponent<OBJ_HEALTH>().Damage_Mult[num] * (__instance.USED_WEP_DAMAGE / __instance.WEP_DAMAGE)) * additionalExp;
}
}
if (__instance.type == 1)
{
if (__instance.WEP_XP > -1f && __instance.WEP_XP < 99f)
{
__instance.WEP_XP += __instance.WEP_GROWTH * (__instance.USED_WEP_DAMAGE / __instance.WEP_DAMAGE) * additionalExp;
}
}
if (__instance.WEP_XP > 99f)
{
__instance.WEP_XP = 99f;
}
}
}
}