-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUltimateScaling.cs
244 lines (221 loc) · 6.13 KB
/
UltimateScaling.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
using System;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace UltimateScaling
{
// Need one class that extends "Mod"
public class UltimateScaling : Mod
{
// Dictionary of all prefixes that increase or decrease damage
public static Dictionary<int, int> attackPrefixes = new Dictionary<int, int>()
{
{ PrefixID.Broken, -30 },
{ PrefixID.Annoying, -20 },
{ PrefixID.Terrible, -15 },
{ PrefixID.Dull, -15 },
{ PrefixID.Awful, -15 },
{ PrefixID.Damaged, -15 },
{ PrefixID.Frenzying, -15 },
{ PrefixID.Shameful, -10 },
{ PrefixID.Ignorant, -10 },
{ PrefixID.Deranged, -10 },
{ PrefixID.Shoddy, -10 },
{ PrefixID.Manic, -10},
{ PrefixID.Dangerous, 5 },
{ PrefixID.Bulky, 5 },
{ PrefixID.Nasty, 5 },
{ PrefixID.Unpleasant, 5 },
{ PrefixID.Murderous, 7 },
{ PrefixID.Savage, 10 },
{ PrefixID.Pointy, 10 },
{ PrefixID.Sighted, 10 },
{ PrefixID.Deadly, 10 },
{ PrefixID.Staunch, 10 },
{ PrefixID.Mystic, 10 },
{ PrefixID.Intense, 10 },
{ PrefixID.Celestial, 10 },
{ PrefixID.Superior, 10 },
{ PrefixID.Deadly2, 10 },
{ PrefixID.Hurtful, 10 },
{ PrefixID.Sharp, 15 },
{ PrefixID.Powerful, 15 },
{ PrefixID.Masterful, 15 },
{ PrefixID.Furious, 15 },
{ PrefixID.Godly, 15 },
{ PrefixID.Demonic, 15 },
{ PrefixID.Legendary, 15 },
{ PrefixID.Unreal, 15 },
{ PrefixID.Mythical, 15 },
{ PrefixID.Ruthless, 18 }
};
public static Dictionary<int, int> speedPrefixes = new Dictionary<int, int>()
{
{ PrefixID.Sluggish, -20 },
{ PrefixID.Bulky, -15 },
{ PrefixID.Lethargic, -15 },
{ PrefixID.Slow, -15 },
{ PrefixID.Annoying, -15 },
{ PrefixID.Unhappy, -10 },
{ PrefixID.Heavy, -10 },
{ PrefixID.Awkward, -10 },
{ PrefixID.Powerful, -10 },
{ PrefixID.Celestial, -10 },
{ PrefixID.Lazy, -8 },
{ PrefixID.Deadly, 5 },
{ PrefixID.Nimble, 5 },
{ PrefixID.Murderous, 6 },
{ PrefixID.Hasty, 10 },
{ PrefixID.Taboo, 10 },
{ PrefixID.Quick, 10 },
{ PrefixID.Deadly2, 10 },
{ PrefixID.Agile, 10 },
{ PrefixID.Nasty, 10 },
{ PrefixID.Manic, 10 },
{ PrefixID.Legendary, 10 },
{ PrefixID.Unreal, 10 },
{ PrefixID.Mythical, 10 },
{ PrefixID.Light, 15 },
{ PrefixID.Rapid, 15 },
{ PrefixID.Frenzying, 15 }
};
}
// Allows classes to save and share the variables that are made here
public static class ShowDamage
{
private static float boostedDmg = 0f;
public static float BoostedDmg
{
get { return boostedDmg; }
set { boostedDmg = value; }
}
private static bool isBoosted;
public static bool IsBoosted
{
get { return isBoosted; }
set { isBoosted = value; }
}
}
//Extends "ModPlayer" in order to use ModifyWeaponDamage
public class BoostDamage : ModPlayer
{
// Send the item to be checked if it can be boosted
public override void ModifyWeaponDamage(Item item, ref StatModifier damage)
{
if (item.damage > 0)
{
damage.Flat += BoostDmg(item);
}
base.ModifyWeaponDamage(item, ref damage);
}
// Get the Weapon's Damage before the prefix modifier
private static int GetTrueDmg(Item item)
{
if (item == null) return item.damage;
var attackPrefixes = UltimateScaling.attackPrefixes;
int attack = CheckPrefix(attackPrefixes, item);
if (attack > 0)
{
return item.damage + ((item.damage * attack) / 100);
}
return item.damage;
}
// Get the Weapon's 'useItem' speed before the prefix modifier
private static int GetTrueSpeed(Item item)
{
var speedPrefixes = UltimateScaling.speedPrefixes;
int speed = CheckPrefix(speedPrefixes, item);
if (speed > 0)
{
return item.useTime + ((item.useTime * speed) / 100);
}
return item.useTime;
}
// Check the prefix of the item
private static int CheckPrefix(dynamic prefix, Item item)
{
int id = item.prefix;
int value;
if (prefix.ContainsKey(id))
{
bool has = prefix.TryGetValue(id, out value);
if (has)
{
return -value;
}
}
return 0;
}
// Check the sent item to determine total boss kills and if it falls under DPS value to boost
private static float BoostDmg(Item item)
{
if (item == null) return 0f;
List<bool> bosses = new()
{
NPC.downedSlimeKing,
NPC.downedBoss1,
NPC.downedBoss2,
NPC.downedBoss3,
NPC.downedQueenBee,
NPC.downedMechBoss1,
NPC.downedMechBoss2,
NPC.downedMechBoss3,
NPC.downedQueenSlime,
NPC.downedFishron,
NPC.downedPlantBoss,
NPC.downedGolemBoss,
NPC.downedAncientCultist,
NPC.downedEmpressOfLight,
NPC.downedMoonlord
};
float boost = 0.5f;
int total = 0;
int max = bosses.Count;
// Get all bosses that have been downed and add to the 'total'
foreach (bool downed in bosses)
{
if (downed)
{
total++;
}
}
// Exponentially add damage onto the weapon based on world bosses killed
for (int i = 0; i < total; i++)
{
boost *= 1.125f;
}
// Calculate the DPS after adding the boost and if it "outscales" the world progress
if ((GetTrueDmg(item) * boost) * (60 / GetTrueSpeed(item) * boost) >= total * total * total / 1.75)
{
ShowDamage.IsBoosted = false;
return 0f;
}
ShowDamage.BoostedDmg = item.damage * boost;
ShowDamage.IsBoosted = true;
return item.damage * boost;
}
}
// Add Tooltips to show current boost of weapons and add a simple DPS line
public class ShowBoostedDamage : GlobalItem
{
public override void ModifyTooltips(Item item, List<TooltipLine> tooltips)
{
if (item.damage > 0)
{
int dmg = 0;
float dps = item.damage * (60 / item.useTime);
if (ShowDamage.IsBoosted)
{
dmg = (int)ShowDamage.BoostedDmg;
dps = (dmg + item.damage) * (60 / item.useTime);
}
var curBoost = new TooltipLine(Mod, "Boost", "[Boost] +" + $"{dmg} Damage");
var curDPS = new TooltipLine(Mod, "DPS", "[DPS] " + $"{dps}/s");
tooltips.Add(curBoost);
tooltips.Add(curDPS);
}
}
}
}