-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.lua
More file actions
3219 lines (2768 loc) · 139 KB
/
Copy pathplayer.lua
File metadata and controls
3219 lines (2768 loc) · 139 KB
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local function shouldBounce(other)
return other:is(Wall) or other:is(ModLoader.ModShapes.NewWall)
end
Player = Object:extend()
Player:implement(GameObject)
Player:implement(Physics)
Player:implement(Unit)
function Player:init(args)
self:init_game_object(args)
self:init_unit()
if self.passives then
for k, v in pairs(self.passives) do
self[v.passive] = v.level
if self.leader and ModLoader.isXModded(v.passive) then
if v.passive.init then v.passive:init(self) end
end
end
end
self.color = character_colors[self.character]
self:set_as_rectangle(9, 9, 'dynamic', 'player')
self.visual_shape = 'rectangle'
self.classes = character_classes[self.character]
self.damage_dealt = 0
if self.hero then self.color = self.hero:getColor() end
if self.hero then self.classes = self.hero.classes end
self.sorcerer = table.any(self.classes, function(v) return v == "sorcerer" end)
if self.sorcerer then self.sorcerer_count = 0 end
if self.hero and self.hero.init then
self.hero:init(self)
if self.hero.act_cooldown and self.hero.act_cooldown > 0 then
self.t:every(self.hero.act_cooldown, function()
if self.hero.act ~= nil then self.hero:act(self) end
-- fix this in class revamp
self:repeatIfNecessary(true)
end, nil, nil, "act")
end
end
self:calculate_stats(true)
if self.leader then
self.previous_positions = {}
self.followers = {}
self.t:every(0.01, function()
table.insert(self.previous_positions, 1, {x = self.x, y = self.y, r = self.r})
if #self.previous_positions > 256 then self.previous_positions[257] = nil end
end)
end
if self.ouroboros_technique_r then
self.t:after(0.01, function()
self.t:every((self.ouroboros_technique_r == 1 and 0.5) or (self.ouroboros_technique_r == 2 and 0.33) or (self.ouroboros_technique_r == 3 and 0.25), function()
if self.leader and (state.mouse_control and table.all(self.mouse_control_v_buffer, function(v) return v >= 0.5 end)) or (self.move_right_pressed and love.timer.getTime() - self.move_right_pressed > 1) then
local target = self:get_closest_object_in_shape(Circle(self.x, self.y, 96), main.current.enemies)
if target then
local units = self:get_all_units()
local unit = random:table(units)
unit:barrage(unit:angle_to_object(target), 1)
else
local units = self:get_all_units()
local cx, cy = 0, 0
for _, unit in ipairs(units) do
cx = cx + unit.x
cy = cy + unit.y
end
cx = cx/#units
cy = cy/#units
local unit = random:table(units)
unit:barrage(unit:angle_from_point(cx, cy), 1)
end
end
end)
end)
end
if self.centipede then self.centipede_mvspd_m = (self.centipede == 1 and 1.1) or (self.centipede == 2 and 1.2) or (self.centipede == 3 and 1.3) end
if self.amplify then self.amplify_area_dmg_m = (self.amplify == 1 and 1.2) or (self.amplify == 2 and 1.35) or (self.amplify == 3 and 1.5) end
if self.ballista and launches_projectiles(self.character) then
self.ballista_dmg_m = (self.ballista == 1 and 1.2) or (self.ballista == 2 and 1.35) or (self.ballista == 3 and 1.5)
end
if self.chronomancy then
if table.any(self.classes, function(v) return v == 'mage' end) then
self.chronomancy_aspd_m = (self.chronomancy == 1 and 1.15) or (self.chronomancy == 2 and 1.25) or (self.chronomancy == 3 and 1.35)
end
end
if self.leader and self.awakening then
main.current.t:after(0.1, function()
local units = self:get_all_units()
local mages = {}
for _, unit in ipairs(units) do
if table.any(unit.classes, function(v) return v == 'mage' end) then
table.insert(mages, unit)
end
end
local mage = random:table(mages)
if mage then
local runs = 0
while table.any(non_attacking_characters, function(v) return v == mage.character end) and runs < 1000 do mage = random:table(mages); runs = runs + 1 end
mage.awakening_aspd_m = (self.awakening == 1 and 1.5) or (self.awakening == 2 and 1.75) or (self.awakening == 3 and 2)
mage.awakening_dmg_m = (self.awakening == 1 and 1.5) or (self.awakening == 2 and 1.75) or (self.awakening == 3 and 2)
end
end)
end
if self.leader and self.divine_punishment then
main.current.t:every(5, function()
local units = self:get_all_units()
local mages = {}
for _, unit in ipairs(units) do
if table.any(unit.classes, function(v) return v == 'mage' end) then
table.insert(mages, unit)
end
end
local leader = main.current.player:get_leader()
local enemies = main.current.main:get_objects_by_classes(main.current.enemies)
if #enemies > 0 then
thunder1:play{volume = 0.3}
camera:shake(4, 0.5)
end
for _, enemy in ipairs(enemies) do
enemy:hit(10*#mages)
LightningLine{group = main.current.effects, src = {x = enemy.x, y = enemy.y - 32}, dst = enemy, color = blue[0], duration = 0.2}
_G[random:table{'spark1', 'spark2', 'spark3'}]:play{pitch = random:float(0.9, 1.1), volume = 0.3}
end
end, nil, nil, 'divine_punishment')
end
if self.unwavering_stance and table.any(self.classes, function(v) return v == 'warrior' end) then
self.unwavering_stance_def_m = 1
self.t:every(5, function()
self.unwavering_stance_def_m = self.unwavering_stance_def_m + ((self.unwavering_stance == 1 and 0.04) or (self.unwavering_stance == 2 and 0.08) or (self.unwavering_stance == 3 and 0.12))
end)
end
if self.magnify then
self.magnify_area_size_m = (self.magnify == 1 and 1.2) or (self.magnify == 2 and 1.35) or (self.magnify == 3 and 1.5)
end
if self.unleash and table.any(self.classes, function(v) return v == 'nuker' end) then
self.unleash_area_dmg_m = 1
self.unleash_area_size_m = 1
self.t:every(1, function()
self.unleash_area_dmg_m = self.unleash_area_dmg_m + 0.01
self.unleash_area_size_m = self.unleash_area_size_m + 0.01
if self.dot_area then
self.dot_area:scale(self.unleash_area_size_m)
end
end)
end
if self.reinforce then
main.current.t:after(0.1, function()
local units = self:get_all_units()
local any_enchanter = false
for _, unit in ipairs(units) do
if table.any(unit.classes, function(v) return v == 'enchanter' end) then
any_enchanter = true
break
end
end
if any_enchanter then
local v = (self.reinforce == 1 and 1.1) or (self.reinforce == 2 and 1.2) or (self.reinforce == 3 and 1.3) or 1
self.reinforce_dmg_m = v
self.reinforce_def_m = v
self.reinforce_aspd_m = v
end
end)
end
if self.enchanted then
main.current.t:after(0.1, function()
local units = self:get_all_units()
local enchanter_amount = 0
for _, unit in ipairs(units) do
if table.any(unit.classes, function(v) return v == 'enchanter' end) then
enchanter_amount = enchanter_amount + 1
end
end
if enchanter_amount >= 2 then
local unit = random:table(units)
local runs = 0
if unit then
while table.any(non_attacking_characters, function(v) return v == unit.character end) and runs < 1000 do unit = random:table(units); runs = runs + 1 end
unit.enchanted_aspd_m = (self.enchanted == 1 and 1.33) or (self.enchanted == 2 and 1.66) or (self.enchanted == 3 and 1.99)
end
end
end)
end
if self.payback then
self.payback_dmg_m = 1
end
if self.hex_master then
self.hex_duration_m = 1.25
end
if self.unrelenting_stance then
self.unrelenting_stance_def_m = 1
end
if self.leader and self.immolation then
main.current.t:after(0.1, function()
local units = self:get_all_units()
local unit_1 = random:table_remove(units)
local unit_2 = random:table_remove(units)
local unit_3 = random:table_remove(units)
if unit_1 then unit_1.t:every(2, function() unit_1:hit(0.05*unit_1.max_hp) end) end
if unit_2 then unit_2.t:every(2, function() unit_2:hit(0.05*unit_2.max_hp) end) end
if unit_3 then unit_3.t:every(2, function() unit_3:hit(0.05*unit_3.max_hp) end) end
local units = self:get_all_units()
for _, unit in ipairs(units) do
unit.immolation_dmg_m = 1
unit.t:every(2, function() unit.immolation_dmg_m = unit.immolation_dmg_m + 0.08 end)
end
end)
end
if self.leader and self.shoot_5 then
main.current.t:after(0.1, function()
main.current.t:every(0.33, function()
local units = main.current.player:get_all_units()
local unit = units[5]
if unit then
local target = unit:get_closest_object_in_shape(Circle(unit.x, unit.y, 96), main.current.enemies)
if target then
unit:barrage(unit:angle_to_object(target), 1, nil, nil, true)
else
unit:barrage(random:float(0, 2*math.pi), 1, nil, nil, true)
end
end
end)
end)
end
if self.leader and self.death_6 then
main.current.t:after(0.1, function()
main.current.t:every(3, function()
flagellant1:play{pitch = random:float(0.95, 1.05), volume = 0.4}
local units = main.current.player:get_all_units()
local unit = units[6]
if unit then
hit2:play{pitch = random:float(0.95, 1.05), volume = 0.4}
unit:hit(0.1*unit.max_hp)
end
end)
end)
end
if self.character == 'flagellant' and self.level == 3 then
self.hp = 2*self.max_hp
end
if self.leader then
self.t:after(1, function()
local units = self:get_all_units()
for _, unit in ipairs(units) do
if table.any(unit.classes, function(v) return v == 'psyker' end) then
Projectile{group = main.current.main, x = unit.x + 24*math.cos(unit.r), y = unit.y + 24*math.sin(unit.r), color = fg[0], v = 200, dmg = unit.dmg, character = 'psyker', parent = unit}
end
end
local psykers = {}
for _, unit in ipairs(units) do
if table.any(unit.classes, function(v) return v == 'psyker' end) then
table.insert(psykers, unit)
end
end
for i = 1, ((main.current.psyker_level == 2 and 4) or (main.current.psyker_level == 1 and 2) or (main.current.psyker_level == 0 and 0) or 0) do
local unit = random:table(#psykers > 0 and psykers or units)
Projectile{group = main.current.main, x = unit.x + 24*math.cos(unit.r), y = unit.y + 24*math.sin(unit.r), color = fg[0], v = 200, dmg = unit.dmg, character = 'psyker', parent = unit}
end
if self.psyker_orbs then
for i = 1, ((self.psyker_orbs == 1 and 1) or (self.psyker_orbs == 2 and 2) or (self.psyker_orbs == 3 and 4) or 0) do
local unit = random:table(#psykers > 0 and psykers or units)
Projectile{group = main.current.main, x = unit.x + 24*math.cos(unit.r), y = unit.y + 24*math.sin(unit.r), color = fg[0], v = 200, dmg = unit.dmg, character = 'psyker', parent = unit}
end
end
end)
end
if self.leader and self.psycholeak then
main.current.t:every(10, function()
local unit = main.current.player
Projectile{group = main.current.main, x = unit.x + 24*math.cos(unit.r), y = unit.y + 24*math.sin(unit.r), color = fg[0], v = 200, dmg = unit.dmg, character = 'psyker', parent = unit}
end)
end
if self.leader and self.divine_blessing then
main.current.t:every(8, function()
local x, y = random:float(main.current.x1 + 16, main.current.x2 - 16), random:float(main.current.y1 + 16, main.current.y2 - 16)
SpawnEffect{group = main.current.effects, x = x, y = y, color = green[0], action = function(x, y)
local check_circle = Circle(x, y, 2)
local objects = main.current.main:get_objects_in_shape(check_circle, {Seeker, EnemyCritter, Critter, Volcano, Saboteur, Bomb, Pet, Turret, Sentry, Automaton})
if #objects == 0 then HealingOrb{group = main.current.main, x = x, y = y} end
end}
end)
end
self.mouse_control_v_buffer = {}
if main.current:is(MainMenu) then
self.r = random:table{-math.pi/4, math.pi/4, 3*math.pi/4, -3*math.pi/4}
self:set_angle(self.r)
end
end
function Player:update(dt)
self:update_game_object(dt)
local sorcerer_level = main.current.sorcerer_level or 0
self.max_sorcerer_count = 5 - sorcerer_level
if sorcerer_level < 1 then self.max_sorcerer_count = -1 end
if self.character == 'squire' then
local all_units = self:get_all_units()
for _, unit in ipairs(all_units) do
unit.squire_dmg_m = 1.2
unit.squire_def_m = 1.2
if self.level == 3 then
unit.squire_dmg_m = 1.5
unit.squire_def_m = 1.5
unit.squire_aspd_m = 1.3
unit.squire_mvspd_m = 1.3
end
end
elseif self.character == 'chronomancer' then
local all_units = self:get_all_units()
for _, unit in ipairs(all_units) do
unit.chronomancer_aspd_m = 1.2
end
end
if self.character == 'vagrant' and self.level == 3 then
local class_levels = get_class_levels(self:get_all_units())
local number_of_active_sets = 0
if class_levels.ranger >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.warrior >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.mage >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.rogue >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.healer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.conjurer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.enchanter >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.psyker >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.nuker >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.curser >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.forcer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.swarmer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.voider >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.sorcerer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.mercenary >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.explorer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
self.vagrant_dmg_m = 1 + 0.1*number_of_active_sets
self.vagrant_aspd_m = 1 + 0.1*number_of_active_sets
end
if self.character == 'swordsman' and self.level == 3 then
self.swordsman_dmg_m = 2
end
if self.character == 'outlaw' and self.level == 3 then
self.outlaw_aspd_m = 1.5
end
if table.any(self.classes, function(v) return v == 'ranger' end) then
if main.current.ranger_level == 2 then self.chance_to_barrage = 16
elseif main.current.ranger_level == 1 then self.chance_to_barrage = 8
elseif main.current.ranger_level == 0 then self.chance_to_barrage = 0 end
end
if table.any(self.classes, function(v) return v == 'warrior' end) then
if main.current.warrior_level == 2 then self.warrior_def_a = 50
elseif main.current.warrior_level == 1 then self.warrior_def_a = 25
elseif main.current.warrior_level == 0 then self.warrior_def_a = 0 end
end
self.heal_effect_m = 1
if self.blessing then self.heal_effect_m = self.heal_effect_m*((self.blessing == 1 and 1.1) or (self.blessing == 2 and 1.2) or (self.blessing == 3 and 1.3)) end
if table.any(self.classes, function(v) return v == 'nuker' end) then
if main.current.nuker_level == 2 then self.nuker_area_size_m = 1.25; self.nuker_area_dmg_m = 1.25
elseif main.current.nuker_level == 1 then self.nuker_area_size_m = 1.15; self.nuker_area_dmg_m = 1.15
elseif main.current.nuker_level == 0 then self.nuker_area_size_m = 1; self.nuker_area_dmg_m = 1 end
end
if main.current.conjurer_level == 2 then self.conjurer_buff_m = 1.5
elseif main.current.conjurer_level == 1 then self.conjurer_buff_m = 1.25
else self.conjurer_buff_m = 1 end
if table.any(self.classes, function(v) return v == 'rogue' end) then
if main.current.rogue_level == 2 then self.chance_to_crit = 30
elseif main.current.rogue_level == 1 then self.chance_to_crit = 15
elseif main.current.rogue_level == 0 then self.chance_to_crit = 0 end
end
if main.current.enchanter_level == 2 then self.enchanter_dmg_m = 1.25
elseif main.current.enchanter_level == 1 then self.enchanter_dmg_m = 1.15
else self.enchanter_dmg_m = 1 end
if table.any(self.classes, function(v) return v == 'explorer' end) then
local class_levels = get_class_levels(self:get_all_units())
local number_of_active_sets = 0
if class_levels.ranger >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.warrior >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.mage >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.rogue >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.healer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.conjurer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.enchanter >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.psyker >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.nuker >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.curser >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.forcer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.swarmer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.voider >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.sorcerer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.mercenary >= 1 then number_of_active_sets = number_of_active_sets + 1 end
if class_levels.explorer >= 1 then number_of_active_sets = number_of_active_sets + 1 end
self.explorer_dmg_m = 1 + 0.15*number_of_active_sets
self.explorer_aspd_m = 1 + 0.15*number_of_active_sets
end
if main.current.forcer_level == 2 then self.knockback_m = 1.5
elseif main.current.forcer_level == 1 then self.knockback_m = 1.25
else self.knockback_m = 1 end
if self.force_push then self.knockback_m = self.knockback_m*1.25 end
self.dot_dmg_m = 1
if table.any(self.classes, function(v) return v == 'voider' end) then
if main.current.voider_level == 2 then self.dot_dmg_m = 1.4
elseif main.current.voider_level == 1 then self.dot_dmg_m = 1.2
else self.dot_dmg_m = 1 end
end
if self.call_of_the_void then self.dot_dmg_m = (self.dot_dmg_m or 1)*((self.call_of_the_void == 1 and 1.3) or (self.call_of_the_void == 2 and 1.6) or (self.call_of_the_void == 3 and 1.9) or 1) end
if self.ouroboros_technique_l and self.leader then
local units = self:get_all_units()
if (state.mouse_control and table.all(self.mouse_control_v_buffer, function(v) return v <= -0.5 end)) or (self.move_left_pressed and love.timer.getTime() - self.move_left_pressed > 1) then
for _, unit in ipairs(units) do
unit.ouroboros_def_m = (self.ouroboros_technique_l == 1 and 1.15) or (self.ouroboros_technique_l == 2 and 1.25) or (self.ouroboros_technique_l == 3 and 1.35)
end
else
for _, unit in ipairs(units) do
unit.ouroboros_def_m = 1
end
end
end
if self.berserking and table.any(self.classes, function(v) return v == 'warrior' end) then
self.berserking_aspd_m = math.remap(self.hp/self.max_hp, 0, 1, (self.berserking == 1 and 1.5) or (self.berserking == 2 and 1.75) or (self.berserking == 3 and 2), 1)
end
if self.speed_3 and self.follower_index == 2 then
self.speed_3_aspd_m = 1.5
end
if self.damage_4 and self.follower_index == 3 then
self.damage_4_dmg_m = 1.3
end
if self.defensive_stance and self.leader then
self.defensive_stance_def_m = (self.defensive_stance == 1 and 1.1) or (self.defensive_stance == 2 and 1.2) or (self.defensive_stance == 3 and 1.3)
end
if self.defensive_stance and not self.leader and self.follower_index == #self.parent.followers then
self.defensive_stance_def_m = (self.defensive_stance == 1 and 1.1) or (self.defensive_stance == 2 and 1.2) or (self.defensive_stance == 3 and 1.3)
end
if self.offensive_stance and self.leader then
self.offensive_stance_dmg_m = (self.offensive_stance == 1 and 1.1) or (self.offensive_stance == 2 and 1.2) or (self.offensive_stance == 3 and 1.3)
end
if self.offensive_stance and not self.leader and self.follower_index == #self.parent.followers then
self.offensive_stance_dmg_m = (self.offensive_stance == 1 and 1.1) or (self.offensive_stance == 2 and 1.2) or (self.offensive_stance == 3 and 1.3)
end
if self.leader and #self.followers == 0 and self.last_stand then
self.last_stand_dmg_m = 1.2
self.last_stand_def_m = 1.2
self.last_stand_aspd_m = 1.2
self.last_stand_area_size_m = 1.2
self.last_stand_area_dmg_m = 1.2
self.last_stand_mvspd_m = 1.2
end
if self.dividends and table.any(self.classes, function(v) return v == 'mercenary' end) then
self.dividends_dmg_m = (1 + gold/100)
end
if self.character == 'flagellant' and self.level == 3 then
self.flagellant_hp_m = 2
end
if self.haste then
if self.hasted then
self.haste_mvspd_m = math.clamp(math.remap(love.timer.getTime() - self.hasted, 0, 4, 1.5, 1), 1, 1.5)
else self.haste_mvspd_m = 1 end
end
self.buff_def_a = (self.warrior_def_a or 0)
self.buff_aspd_m = (self.chronomancer_aspd_m or 1)*(self.vagrant_aspd_m or 1)*(self.outlaw_aspd_m or 1)*(self.fairy_aspd_m or 1)*(self.psyker_aspd_m or 1)*(self.chronomancy_aspd_m or 1)*(self.awakening_aspd_m or 1)*(self.berserking_aspd_m or 1)*(self.reinforce_aspd_m or 1)*(self.squire_aspd_m or 1)*(self.speed_3_aspd_m or 1)*(self.last_stand_aspd_m or 1)*(self.enchanted_aspd_m or 1)*(self.explorer_aspd_m or 1)*(self.magician_aspd_m or 1)
self.buff_dmg_m = (self.squire_dmg_m or 1)*(self.vagrant_dmg_m or 1)*(self.enchanter_dmg_m or 1)*(self.swordsman_dmg_m or 1)*(self.flagellant_dmg_m or 1)*(self.psyker_dmg_m or 1)*(self.ballista_dmg_m or 1)*(self.awakening_dmg_m or 1)*(self.reinforce_dmg_m or 1)*(self.payback_dmg_m or 1)*(self.immolation_dmg_m or 1)*(self.damage_4_dmg_m or 1)*(self.offensive_stance_dmg_m or 1)*(self.last_stand_dmg_m or 1)*(self.dividends_dmg_m or 1)*(self.explorer_dmg_m or 1)
self.buff_def_m = (self.squire_def_m or 1)*(self.ouroboros_def_m or 1)*(self.unwavering_stance_def_m or 1)*(self.reinforce_def_m or 1)*(self.defensive_stance_def_m or 1)*(self.last_stand_def_m or 1)*(self.unrelenting_stance_def_m or 1)*(self.hardening_def_m or 1)
self.buff_area_size_m = (self.nuker_area_size_m or 1)*(self.magnify_area_size_m or 1)*(self.unleash_area_size_m or 1)*(self.last_stand_area_size_m or 1)
self.buff_area_dmg_m = (self.nuker_area_dmg_m or 1)*(self.amplify_area_dmg_m or 1)*(self.unleash_area_dmg_m or 1)*(self.last_stand_area_dmg_m or 1)
self.buff_mvspd_m = (self.wall_rider_mvspd_m or 1)*(self.centipede_mvspd_m or 1)*(self.squire_mvspd_m or 1)*(self.last_stand_mvspd_m or 1)*(self.haste_mvspd_m or 1)
self.buff_hp_m = (self.flagellant_hp_m or 1)
self:calculate_stats()
if self.attack_sensor then self.attack_sensor:move_to(self.x, self.y) end
if self.wide_attack_sensor then self.wide_attack_sensor:move_to(self.x, self.y) end
if self.gun_kata_sensor then self.gun_kata_sensor:move_to(self.x, self.y) end
self.t:set_every_multiplier('shoot', self.aspd_m)
self.t:set_every_multiplier('attack', self.aspd_m)
if self.hero and self.hero.update then self.hero:update() end
if self.leader then
if self.passives ~= nil then
for _,v in pairs(self.passives) do
if ModLoader.isXModded(v.passive) and v.passive.update ~= nil then v.passive:update(self) end
end
end
end
if self.leader then
if not main.current:is(MainMenu) then
if input.move_left.pressed and not self.move_right_pressed then self.move_left_pressed = love.timer.getTime() end
if input.move_right.pressed and not self.move_left_pressed then self.move_right_pressed = love.timer.getTime() end
if input.move_left.released then self.move_left_pressed = nil end
if input.move_right.released then self.move_right_pressed = nil end
if state.mouse_control then
self.mouse_control_v = Vector(math.cos(self.r), math.sin(self.r)):perpendicular():dot(Vector(math.cos(self:angle_to_mouse()), math.sin(self:angle_to_mouse())))
self.r = self.r + math.sign(self.mouse_control_v)*1.66*math.pi*dt
table.insert(self.mouse_control_v_buffer, 1, self.mouse_control_v)
if #self.mouse_control_v_buffer > 64 then self.mouse_control_v_buffer[65] = nil end
else
if input.move_left.down then self.r = self.r - 1.66*math.pi*dt end
if input.move_right.down then self.r = self.r + 1.66*math.pi*dt end
end
end
local total_v = 0
local units = self:get_all_units()
for _, unit in ipairs(units) do
total_v = total_v + unit.max_v
end
total_v = math.floor(total_v/#units)
self.total_v = total_v
self:set_velocity(total_v*math.cos(self.r), total_v*math.sin(self.r))
if not main.current.won and not main.current.choosing_passives then
if not state.no_screen_movement then
local vx, vy = self:get_velocity()
local hd = math.remap(math.abs(self.x - gw/2), 0, 192, 1, 0)
local vd = math.remap(math.abs(self.y - gh/2), 0, 108, 1, 0)
camera.x = camera.x + math.remap(vx, -100, 100, -24*hd, 24*hd)*dt
camera.y = camera.y + math.remap(vy, -100, 100, -8*vd, 8*vd)*dt
if input.move_right.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, math.pi/256)
elseif input.move_left.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, -math.pi/256)
--[[
elseif input.move_down.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, math.pi/256)
elseif input.move_up.down then camera.r = math.lerp_angle_dt(0.01, dt, camera.r, -math.pi/256)
]]--
else camera.r = math.lerp_angle_dt(0.005, dt, camera.r, 0) end
end
end
self:set_angle(self.r)
else
local target_distance = 10.4*(self.follower_index or 0)
local distance_sum = 0
local p
local previous = self.parent
for i, point in ipairs(self.parent.previous_positions) do
local distance_to_previous = math.distance(previous.x, previous.y, point.x, point.y)
distance_sum = distance_sum + distance_to_previous
if distance_sum >= target_distance then
p = self.parent.previous_positions[i-1]
break
end
previous = point
end
if p then
self:set_position(p.x, p.y)
self.r = p.r
if not self.following then
spawn1:play{pitch = random:float(0.8, 1.2), volume = 0.15}
for i = 1, random:int(3, 4) do HitParticle{group = main.current.effects, x = self.x, y = self.y, color = self.color} end
HitCircle{group = main.current.effects, x = self.x, y = self.y, rs = 10, color = fg[0]}:scale_down(0.3):change_color(0.5, self.color)
self.following = true
end
else
self.r = self:get_angle()
end
end
end
function Player:draw()
graphics.push(self.x, self.y, self.r, self.hfx.hit.x*self.hfx.shoot.x, self.hfx.hit.x*self.hfx.shoot.x)
if self.hero and self.hero.draw then self.hero:draw(self) else
if self.visual_shape == 'rectangle' then
if self.magician_invulnerable then
graphics.rectangle(self.x, self.y, self.shape.w, self.shape.h, 3, 3, blue_transparent)
elseif self.undead then
graphics.rectangle(self.x, self.y, self.shape.w, self.shape.h, 3, 3, self.color, 1)
else
graphics.rectangle(self.x, self.y, self.shape.w, self.shape.h, 3, 3, (self.hfx.hit.f or self.hfx.shoot.f) and fg[0] or self.color)
end
if self.leader and state.arrow_snake then
local x, y = self.x + 0.9*self.shape.w, self.y
graphics.line(x + 3, y, x, y - 3, self.color, 1)
graphics.line(x + 3, y, x, y + 3, self.color, 1)
end
if self.ouroboros_def_m and self.ouroboros_def_m > 1 then
graphics.rectangle(self.x, self.y, 1.25*self.shape.w, 1.25*self.shape.h, 3, 3, yellow_transparent)
end
if self.divined then
graphics.rectangle(self.x, self.y, 1.25*self.shape.w, 1.25*self.shape.h, 3, 3, green_transparent)
end
if self.fairyd then
graphics.rectangle(self.x, self.y, 1.25*self.shape.w, 1.25*self.shape.h, 3, 3, blue_transparent)
end
end
end
graphics.pop()
end
function Player:on_collision_enter(other, contact)
local x, y = contact:getPositions()
if shouldBounce(other) then
if self.leader then
if other.snkrx then
main.current.level_1000_text:pull(0.2, 200, 10)
end
self.hfx:use('hit', 0.5, 200, 10, 0.1)
camera:spring_shake(2, math.pi - self.r)
self:bounce(contact:getNormal())
local r = random:float(0.9, 1.1)
player_hit_wall1:play{pitch = r, volume = 0.1}
pop1:play{pitch = r, volume = 0.2}
for i, f in ipairs(self.followers) do
trigger:after(i*(10.6/self.v), function()
f.hfx:use('hit', 0.5, 200, 10, 0.1)
player_hit_wall1:play{pitch = r + 0.025*i, volume = 0.1}
pop1:play{pitch = r + 0.05*i, volume = 0.2}
end)
end
if self.wall_echo then
if random:bool(34) then
local target = self:get_closest_object_in_shape(Circle(self.x, self.y, 96), main.current.enemies)
if target then
self:barrage(self:angle_to_object(target), 2)
else
local r = Vector(contact:getNormal()):angle()
self:barrage(r, 2)
end
end
end
if self.wall_rider then
local units = self:get_all_units()
for _, unit in ipairs(units) do unit.wall_rider_mvspd_m = 1.25 end
trigger:after(1, function()
for _, unit in ipairs(units) do unit.wall_rider_mvspd_m = 1 end
end, 'wall_rider')
end
end
elseif table.any(main.current.enemies, function(v) return other:is(v) end) then
other:push(random:float(25, 35)*(self.knockback_m or 1), self:angle_to_object(other))
if self.character == 'vagrant' or self.character == 'psykeeper' then other:hit(2*self.dmg)
else other:hit(self.dmg) end
if other.headbutting then
self:hit((4 + math.floor(other.level/3))*other.dmg)
other.headbutting = false
else self:hit(other.dmg) end
HitCircle{group = main.current.effects, x = x, y = y, rs = 6, color = fg[0], duration = 0.1}
for i = 1, 2 do HitParticle{group = main.current.effects, x = x, y = y, color = self.color} end
for i = 1, 2 do HitParticle{group = main.current.effects, x = x, y = y, color = other.color} end
end
end
function Player:hit(damage, from_undead)
if self.dead then return end
if self.magician_invulnerable then return end
if self.undead and not from_undead then return end
local actual_damage = math.max(self:calculate_damage(damage), 0)
if ModLoader.pushEvent("player_hit", actual_damage, self).cancelled then return end
self.hfx:use('hit', 0.25, 200, 10)
self:show_hp()
self.hp = self.hp - actual_damage
_G[random:table{'player_hit1', 'player_hit2'}]:play{pitch = random:float(0.95, 1.05), volume = 0.5}
camera:shake(4, 0.5)
main.current.damage_taken = main.current.damage_taken + actual_damage
if self.hero and self.hero.hit then self.hero:hit(actual_damage, from_undead) end
if self.payback and table.any(self.classes, function(v) return v == 'enchanter' end) then
local units = self:get_all_units()
for _, unit in ipairs(units) do
if not unit.payback_dmg_m then unit.payback_dmg_m = 1 end
unit.payback_dmg_m = unit.payback_dmg_m + ((self.payback == 1 and 0.02) or (self.payback == 2 and 0.05) or (self.payback == 3 and 0.08) or 0)
end
end
if self.unrelenting_stance and table.any(self.classes, function(v) return v == 'warrior' end) then
local units = self:get_all_units()
for _, unit in ipairs(units) do
if not unit.unrelenting_stance_def_m then unit.unrelenting_stance_def_m = 1 end
unit.unrelenting_stance_def_m = unit.unrelenting_stance_def_m + ((self.unrelenting_stance == 1 and 0.02) or (self.unrelenting_stance == 2 and 0.05) or (self.unrelenting_stance == 3 and 0.08) or 0)
end
end
if self.character == 'beastmaster' and self.level == 3 then
critter1:play{pitch = random:float(0.95, 1.05), volume = 0.5}
trigger:after(0.01, function()
for i = 1, 4 do
Critter{group = main.current.main, x = self.x, y = self.y, color = orange[0], r = random:float(0, 2*math.pi), v = 20, dmg = self.dmg, parent = self}
end
end)
end
if self.crucio then
local enemies = main.current.main:get_objects_by_classes(main.current.enemies)
for _, enemy in ipairs(enemies) do
enemy:hit(((self.crucio == 1 and 0.2) or (self.crucio == 2 and 0.3) or (self.crucio == 3 and 0.4))*actual_damage)
HitCircle{group = main.current.effects, x = self.x, y = self.y, rs = 6, color = fg[0], duration = 0.1}
end
end
if self.character == 'psykeeper' then
self.stored_heal = self.stored_heal + actual_damage
if self.stored_heal > (0.25*self.max_hp) then
self.stored_heal = 0
local check_circle = Circle(random:float(main.current.x1 + 16, main.current.x2 - 16), random:float(main.current.y1 + 16, main.current.y2 - 16), 2)
local objects = main.current.main:get_objects_in_shape(check_circle, {Seeker, EnemyCritter, Critter, Volcano, Saboteur, Bomb, Pet, Turret, Sentry, Automaton})
while #objects > 0 do
check_circle:move_to(random:float(main.current.x1 + 16, main.current.x2 - 16), random:float(main.current.y1 + 16, main.current.y2 - 16))
objects = main.current.main:get_objects_in_shape(check_circle, {Seeker, EnemyCritter, Critter, Volcano, Saboteur, Bomb, Pet, Turret, Sentry, Automaton})
end
for i = 1, 3 do
SpawnEffect{group = main.current.effects, x = check_circle.x, y = check_circle.y, color = green[0], action = function(x, y)
local check_circle = Circle(x, y, 2)
local objects = main.current.main:get_objects_in_shape(check_circle, {Seeker, EnemyCritter, Critter, Sentry, Volcano, Saboteur, Bomb, Pet, Turret, Automaton})
if #objects == 0 then
HealingOrb{group = main.current.main, x = x, y = y}
end
end}
end
end
if self.level == 3 then
local enemies = main.current.main:get_objects_by_classes(main.current.enemies)
for _, enemy in ipairs(enemies) do
enemy:hit(2*actual_damage/#enemies)
end
end
end
self.character_hp:change_hp()
if self.hp <= 0 and not ModLoader.pushEvent("player_die", self).cancelled then
if self.divined then
self:heal(self.max_hp)
heal1:play{pitch = random:float(0.95, 1.05), volume = 0.5}
buff1:play{pitch = random:float(0.95, 1.05), volume = 0.5}
for i = 1, random:int(4, 6) do HitParticle{group = main.current.effects, x = self.x, y = self.y, color = self.color} end
HitCircle{group = main.current.effects, x = self.x, y = self.y, rs = 12}:scale_down(0.3):change_color(0.5, self.color)
self.divined = false
elseif self.lasting_7 and self.follower_index == 6 and not self.undead then
self.undead = true
self.t:after(10, function() self:hit(10000, true) end)
else
hit4:play{pitch = random:float(0.95, 1.05), volume = 0.5}
slow(0.25, 1)
for i = 1, random:int(4, 6) do HitParticle{group = main.current.effects, x = self.x, y = self.y, color = self.color} end
HitCircle{group = main.current.effects, x = self.x, y = self.y, rs = 12}:scale_down(0.3):change_color(0.5, self.color)
if self.leader and #self.followers == 0 then
if main.current:die() then
self.dead = true
else
self.hp = 1
end
else
self.dead = true
if self.leader then self:recalculate_followers()
else self.parent:recalculate_followers() end
if #main.current.player.followers == 0 and main.current.player.last_stand then
heal1:play{pitch = random:float(0.95, 1.05), volume = 0.5}
buff1:play{pitch == random:float(0.9, 1.1), volume = 0.5}
main.current.player:heal(10000)
end
end
if self.kinetic_bomb then
elementor1:play{pitch = random:float(0.9, 1.1), volume = 0.5}
local enemies = self:get_objects_in_shape(Circle(self.x, self.y, 96), main.current.enemies)
for _, enemy in ipairs(enemies) do
enemy:push(random:float(30, 50)*(self.knockback_m or 1), self:angle_to_object(enemy))
end
end
if self.porcupine_technique then
main.current.t:after(0.01, function()
local r = 0
for i = 1, 8 do
archer1:play{pitch = random:float(0.95, 1.05), volume = 0.35}
HitCircle{group = main.current.effects, x = self.x + 0.8*self.shape.w*math.cos(r), y = self.y + 0.8*self.shape.w*math.sin(r), rs = 6}
local t = {group = main.current.main, x = self.x + 1.6*self.shape.w*math.cos(r), y = self.y + 1.6*self.shape.w*math.sin(r), v = 250, r = r, color = self.color, dmg = self.dmg,
parent = self, character = 'barrage', level = self.level, pierce = 1000, ricochet = 2}
Projectile(table.merge(t, mods or {}))
r = r + math.pi/4
end
end)
end
if self.hardening then
local units = self:get_all_units()
for _, unit in ipairs(units) do
unit.hardening_def_m = 2.5
unit.t:after(3, function() unit.hardening_def_m = 1 end)
end
end
if self.annihilation and table.any(self.classes, function(v) return v == 'voider' end) then
local enemies = self.group:get_objects_by_classes({Seeker, EnemyCritter})
for _, enemy in ipairs(enemies) do
enemy:apply_dot(self.dmg*(self.dot_dmg_m or 1)*(main.current.chronomancer_dot or 1), 3)
end
end
if self.insurance then
if random:bool(4*((main.current.mercenary_level == 2 and 16) or (main.current.mercenary_level == 1 and 8) or 0)) then
main.current.t:after(0.01, function()
Gold{group = main.current.main, x = self.x, y = self.y}
Gold{group = main.current.main, x = self.x, y = self.y}
end)
end
end
if self.dot_area then self.dot_area.dead = true; self.dot_area = nil end
end
end
end
function Player:repeatIfNecessary(increase)
if self.sorcerer and self.max_sorcerer_count > -1 then
if increase then self.sorcerer_count = self.sorcerer_count + 1 end
if self.sorcerer_count >= self.max_sorcerer_count then
self:sorcerer_repeat()
self.sorcerer_count = 0
end
end
end
function Player:sorcerer_repeat()
if ModLoader.pushEvent("sorcerer_repeat", self).cancelled then return end
if self.hero.repeat_func ~= nil then
local delay = self.hero.sorcerer_repeat_delay or 0
self.t:after(delay, function()
self.hero.repeat_func(self)
end)
end
local enemies = self.group:get_objects_by_classes(main.current.enemies)
if not enemies then return end
local enemy = random:table(enemies)
if enemy then
if self.gravity_field then
ForceArea{group = main.current.effects, x = enemy.x, y = enemy.y, rs = self.area_size_m*24, color = fg[0], character = 'gravity_field', parent = self}
end
end
local enemy = random:table(enemies)
if enemy then
if self.burning_field then
fire1:play{pitch = random:float(0.9, 1.1), volume = 0.5}
DotArea{group = main.current.effects, x = enemy.x, y = enemy.y, rs = self.area_size_m*24, color = red[0], dmg = 30*self.area_dmg_m*(self.dot_dmg_m or 1), duration = 2, character = 'burning_field'}
end
end
local enemy = random:table(enemies)
if enemy then
if self.freezing_field then
frost1:play{pitch = random:float(0.8, 1.2), volume = 0.3}
elementor1:play{pitch = random:float(0.9, 1.1), volume = 0.3}
Area{group = main.current.effects, x = enemy.x, y = enemy.y, w = self.area_size_m*36, color = blue[0], character = 'freezing_field', parent = self}
end
end
end
function Player:heal(amount)
local hp = self.hp
if ModLoader.pushEvent("player_heal", amount, self).cancelled then return end
self.hfx:use('hit', 0.25, 200, 10)
self:show_hp(1.5)
self:show_heal(1.5)
self.hp = self.hp + amount
if self.hp > self.max_hp then self.hp = self.max_hp end
self.character_hp:change_hp()
end
function Player:chain_infuse(duration)
self.chain_infused = true
self.t:after(duration or 2, function() self.chain_infused = false end, 'chain_infuse')
end
function Player:get_all_units()
local followers
local leader = (self.leader and self) or self.parent
if self.leader then followers = self.followers else followers = self.parent.followers end
return {leader, unpack(followers)}
end
function Player:get_leader()
return (self.leader and self) or self.parent
end
function Player:get_unit(character)
local all_units = self:get_all_units()
for _, unit in ipairs(all_units) do
if unit.character == character then return unit end
end
end
function Player:recalculate_followers()
if self.dead then
local new_leader = table.remove(self.followers, 1)
new_leader.leader = true
new_leader.previous_positions = {}
new_leader.followers = self.followers
new_leader.t:every(0.01, function()
table.insert(new_leader.previous_positions, 1, {x = new_leader.x, y = new_leader.y, r = new_leader.r})
if #new_leader.previous_positions > 256 then new_leader.previous_positions[257] = nil end
end)
main.current.player = new_leader
for i, follower in ipairs(self.followers) do
follower.parent = new_leader
follower.follower_index = i
end
else
for i = #self.followers, 1, -1 do
if self.followers[i].dead then
table.remove(self.followers, i)
break
end
end
for i, follower in ipairs(self.followers) do
follower.follower_index = i
end
end
end
function Player:add_follower(unit)
table.insert(self.followers, unit)
unit.parent = self