-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.gd
309 lines (246 loc) · 9.29 KB
/
menu.gd
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
extends Control
#refs
onready var label1 = $HBoxContainer/VBoxContainer/HBoxContainer/Label
onready var label2 = $HBoxContainer/VBoxContainer/HBoxContainer2/Label
onready var graph = $HBoxContainer/VBoxContainer/Graph
onready var calc : DotCalc = DotCalc.new()
#main variables
var toSim : int = 0
var simRan : int = 0
var PoBEstimate : float = 0
var BetterPoBEstimate : float = 0
var totalDPS : float = 0
var toGraph : bool = true
#simulation variables
var simulations : int = 10000
var simulationSteps : int = 10000
var simulationDuration : float = 300
var dots = []
var singleAttack = false
var attacktime : float = 1.25
# dot variables
var dotChance : int = 100
var DotBase = {"min": 5000, "max": 10000}
var crit = {"chance": 20, "mult": 1.3}
#var MoreDotChance : int = 60 #no longer valid 3.14+
var Ruthless = {"active": false, "mult": 2.32}
var multistrike = {"repeates": 0, "mult1": 1.2, "mult2": 1.4, "mult3": 1.6}
var maxStacks : int = 1
var duration : float = 7
func _ready():
$HBoxContainer/Inputs/simulations/HBoxContainer/VBoxContainer/SpinBox.value = simulations
$HBoxContainer/Inputs/simulations/HBoxContainer/VBoxContainer2/SpinBox.value = simulationDuration
$HBoxContainer/Inputs/simulations/HBoxContainer/VBoxContainer3/CheckButton.pressed = toGraph
$HBoxContainer/Inputs/AttackTime/HBoxContainer/VBoxContainer/SpinBox.value = attacktime
$HBoxContainer/Inputs/AttackTime/HBoxContainer/VBoxContainer2/CheckButton.pressed = singleAttack
$HBoxContainer/Inputs/DoTBasics/HBoxContainer/VBoxContainer/SpinBox.value = dotChance
$HBoxContainer/Inputs/DoTBasics/HBoxContainer/VBoxContainer2/SpinBox.value = duration
$HBoxContainer/Inputs/DoTBasics/HBoxContainer/VBoxContainer3/SpinBox.value = maxStacks
$HBoxContainer/Inputs/DotBase/HBoxContainer/VBoxContainer/SpinBox.value = DotBase.min
$HBoxContainer/Inputs/DotBase/HBoxContainer/VBoxContainer2/SpinBox.value = DotBase.max
$HBoxContainer/Inputs/Crit/HBoxContainer/VBoxContainer/SpinBox.value = crit.chance
$HBoxContainer/Inputs/Crit/HBoxContainer/VBoxContainer2/SpinBox.value = crit.mult
# $HBoxContainer/Inputs/MoreDot/SpinBox.value = MoreDotChance
$HBoxContainer/Inputs/Ruthless/HBoxContainer/VBoxContainer/checkbox.pressed = Ruthless.active
$HBoxContainer/Inputs/Ruthless/HBoxContainer/VBoxContainer2/SpinBox.value = Ruthless.mult
$HBoxContainer/Inputs/Multistrike/HBoxContainer/VBoxContainer/SpinBox.value = multistrike.repeates
$HBoxContainer/Inputs/Multistrike/HBoxContainer/VBoxContainer2/SpinBox.value = multistrike.mult1
$HBoxContainer/Inputs/Multistrike/HBoxContainer/VBoxContainer3/SpinBox.value = multistrike.mult2
$HBoxContainer/Inputs/Multistrike/HBoxContainer/VBoxContainer4/SpinBox.value = multistrike.mult3
pass
# warning-ignore:unused_argument
func _process(delta) -> void:
if toSim > 0:
var temp = simRan
for i in range(1, min(toSim, simulationSteps)):
if singleAttack:
dots.append(calc.calcDotInstance(i))
else:
dots.append(calc.calcDotSimulation())
totalDPS += dots[-1]
simRan += int(min(toSim, simulationSteps))
toSim -= simulationSteps
if toSim <= 0:
toSim = 0
$HBoxContainer/Inputs/RunSimulation.disabled = false
$HBoxContainer/Inputs/RunSimulation.text = "Run Simulation"
if dots.size() == 0:
temp = 0
else:
temp = totalDPS / dots.size()
if toGraph:
graph.drawGraph(dots)
label1.text = "simulations ran: " + String(simRan)
label1.text += " PoB estimated dps: " + String(PoBEstimate)
label1.text += " average dps: " + String(temp)
label1.text += " percent: " + String(PoBEstimate / temp * 100) + "%"
label2.text = "Better PoB estimated dps: " + String(BetterPoBEstimate)
label2.text += " percent of PoB: " + String(BetterPoBEstimate / PoBEstimate * 100) + "%"
label2.text += " percent of Simulated: " + String(BetterPoBEstimate / temp * 100) + "%"
pass
func calcDotSimulation() -> int:
var timeElapsed = -attacktime
var DotInstances = []
DotInstances.append(Vector2(timeElapsed + duration, calcDotInstance(0)))
var totalDotDamage = 0
var attacknum = 0
while timeElapsed < simulationDuration:
totalDotDamage += calcMaxX(DotInstances, maxStacks, timeElapsed)
timeElapsed += attacktime
attacknum += 1
var instance = Vector2(timeElapsed + duration, calcDotInstance(attacknum))
DotInstances.insert(DotInstances.bsearch_custom(instance, self, "sort_dotval"),instance)
return int(totalDotDamage / timeElapsed)
pass
func calcDotInstance(attacknum : int) -> int:
if rand_range(0, 100) > dotChance:
return 0
var DotRoll : int = int(rand_range(DotBase.min, DotBase.max + 1))
# if rand_range(0, 100) <= MoreDotChance:
# DotRoll = DotRoll * 2
if rand_range(0, 100) <= crit.chance:
# warning-ignore:integer_division
DotRoll = (DotRoll * int(crit.mult * 100)) / 100
if multistrike.repeates > 1:
match attacknum % (multistrike.repeates + 1):
1:
# warning-ignore:integer_division
DotRoll = (DotRoll * int(multistrike.mult1 * 100)) / 100
2:
# warning-ignore:integer_division
DotRoll = (DotRoll * int(multistrike.mult2 * 100)) / 100
3:
# warning-ignore:integer_division
DotRoll = (DotRoll * int(multistrike.mult3 * 100)) / 100
if Ruthless.active and attacknum / (multistrike.repeates + 1) % 3 == 0:
# warning-ignore:integer_division
DotRoll = (DotRoll * int(Ruthless.mult * 100)) / 100
elif Ruthless.active and attacknum % 3 == 0:
# warning-ignore:integer_division
DotRoll = (DotRoll * int(Ruthless.mult * 100)) / 100
return DotRoll
pass
func calcMaxX(dotInstances : Array, X : int, timeElapsed : float) -> float:
var sum : float = 0
var extraTime : float = 0
var todel = []
for i in range(dotInstances.size()):
if dotInstances[i].x <= timeElapsed + extraTime:
todel.append(dotInstances[i])
for num in todel:
dotInstances.erase(num)
if dotInstances.size() < 0:
return 0.0
while extraTime + 0.0001 <= attacktime:
#print(extraTime)
#print(attacktime)
var minTime : float = attacktime - extraTime
var count : int = 0
var dotVal : float = 0
for dot in dotInstances:
count += 1
if count > X:
break
dotVal += dot.y
minTime = min(minTime, dot.x - (timeElapsed + extraTime))
extraTime += minTime
sum += minTime * dotVal
todel = []
for i in range(dotInstances.size()):
if dotInstances[i].x <= timeElapsed + extraTime:
todel.append(dotInstances[i])
for num in todel:
dotInstances.erase(num)
if minTime == 0:
return sum
return sum
pass
func sort_dotval(a, b) -> bool:
if a.y > b.y:
return true
return false
pass
func _on_Simulation_pressed() -> void:
toSim = simulations
calc.setSimVar(simulationDuration)
calc.setAttackVar(attacktime, crit.chance, crit.mult, Ruthless.active, Ruthless.mult)
calc.setAttackVar2(multistrike.repeates, multistrike.mult1, multistrike.mult2, multistrike.mult3)
calc.setDotVar(dotChance, DotBase.min, DotBase.max, maxStacks, duration)
$HBoxContainer/Inputs/RunSimulation.disabled = true
$HBoxContainer/Inputs/RunSimulation.text = "Simulating"
var numstacks = duration / attacktime / maxStacks
PoBEstimate = dotChance * (100 - crit.chance + crit.chance * crit.mult) / (100 * 100)
PoBEstimate = PoBEstimate * min(maxStacks, duration / attacktime)
BetterPoBEstimate = PoBEstimate * (DotBase.min + (DotBase.max - DotBase.min) / pow(2, 1 / (numstacks + 1)))
PoBEstimate = PoBEstimate * (DotBase.min + DotBase.max) / 2
if Ruthless.active:
BetterPoBEstimate = BetterPoBEstimate * (1 + (Ruthless.mult - 1) / pow(3, 1 / (2 * (numstacks + 1))))
PoBEstimate = PoBEstimate * (1 + (Ruthless.mult - 1) / 3)
pass
func _on_ResetSimulation_pressed() -> void:
simRan = 0
totalDPS = 0
dots.clear()
if toGraph:
graph.drawGraph(dots)
pass
func _on_Simulation_changed(value : int) -> void:
simulations = value
pass
func _on_Simulation_Duration_changed(value : float) -> void:
simulationDuration = value
simulationSteps = int(2500000 * attacktime / simulationDuration)
pass
func _on_AttackTime_changed(value : float) -> void:
attacktime = value
simulationSteps = int(2500000 * attacktime / simulationDuration)
pass
func _on_SingleAttack_toggled(button_pressed : bool) -> void:
singleAttack = button_pressed
pass
func _on_DotChance_changed(value : int) -> void:
dotChance = value
pass
func _on_DotDuration_changed(value : float) -> void:
duration = value
pass
func _on_DotStacks_changed(value : int) -> void:
maxStacks = value
pass
func _on_DotBase_Min_changed(value : int) -> void:
DotBase.min = value
pass
func _on_DotBase_Max_changed(value : int) -> void:
DotBase.max = value
pass
func _on_Crit_Chance_changed(value : int) -> void:
crit.chance = value
pass
func _on_Crit_Mult_changed(value : float) -> void:
crit.mult = value
pass
func _on_Ruthless_toggled(button_pressed : bool) -> void:
Ruthless.active = button_pressed
pass
func _on_Ruthless_Mult_changed(value : float) -> void:
Ruthless.mult = value
pass
func _on_Multistrike_Repeates_changed(value : int) -> void:
multistrike.repeates = value
pass
func _on_Multistrike_Mult1_changed(value : float) -> void:
multistrike.mult1 = value
pass
func _on_Multistrike_Mult2_changed(value : float) -> void:
multistrike.mult2 = value
pass
func _on_Multistrike_Mult3_changed(value : float) -> void:
multistrike.mult3 = value
pass
# warning-ignore:unused_argument
func _on_MoreBleed_changed(value : int) -> void:
# MoreDotChance = int(new_text)
pass
func _on_Graph_toggled(button_pressed : bool) -> void:
toGraph = button_pressed
pass