-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathc9997.hks
12784 lines (11715 loc) · 406 KB
/
c9997.hks
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
------------------------------------------
-- Fixed decompiled c9997.hks for ELDEN RING
-- HKS file shared across all enemies
-- Refined from decompiles by Vawser
-- Curated at: https://github.com/ividyon/EldenRingHKS
------------------------------------------
-- Version 4 for ER version 1.15.1
------------------------------------------
-- Changelog:
-- 2023-02-14 - Vawser: Cleaned up and added.
-- 2024-06-28 - Exelot: Recreated to update to ER v1.12.1 [DLC Initial Release]
-- 2024-07-30 - Exelot: Updated to ER v1.13
-- 2024-10-03 - Exelot: Named almost all remaining acts and envs thanks to a list provided by ElaDiDu. Some of the existing ones have been renamed.
------------------------------------------
-- Core: Functions
------------------------------------------
function IncNum(num)
local str = nil
if num < 10 then
str = "Debug0"
else
str = "Debug"
end
local vec = GetVariable(str .. num)
vec[0] = vec[0] + 1
vec[1] = g_FrameCount
SetVariable(str .. num, vec)
end
function DebugPrint(pos, val)
local str = nil
if pos < 10 then
str = "Debug0"
else
str = "Debug"
end
vector = GetVariable(str .. pos)
vector[0] = val
vector[1] = g_FrameCount
SetVariable(str .. pos, vector)
end
function Fire(event)
hkbFireEvent(event)
end
function IsExistAnime(id)
return env(DoesAnimExist, id)
end
function Replanning()
act(DoAIReplanningAtCancelTiming)
end
function SetVariable(name, val)
act(SetHavokVariable, name, val)
end
function GetVariable(name)
return hkbGetVariable(name)
end
function SetIdleType(idle_type)
if idle_type == AI_STATE_DEFAULT then
if IsExistAnime(ANIME_ID_IDLE_DEFAULT) == TRUE then
SetVariable("IndexAiState", AI_STATE_DEFAULT)
else
SetVariable("IndexAiState", AI_STATE_BATTLE)
end
else
SetVariable("IndexAiState", AI_STATE_BATTLE)
end
end
function CallActionState(action_type)
act(SetAIAttackState, action_type)
end
function IsNodeActive(...)
local buff = {...}
for i = 1, #buff, 1 do
if hkbIsNodeActive(buff[i]) then
return TRUE
end
end
return FALSE
end
function SoulDropUp()
if IS_INITIALIZED_SOUL_DROP_UP == TRUE then
return
end
if env(GetSpEffectID, 5250) == TRUE or env(GetSpEffectID, 5255) == TRUE then
IS_INITIALIZED_SOUL_DROP_UP = TRUE
return
end
local feversoul = math.random(1000)
local feverchance = 0
if env(GetSpEffectID, 5269) == TRUE then
feverchance = 1000
elseif env(GetSpEffectID, 5268) == TRUE then
feverchance = 500
elseif env(GetSpEffectID, 5267) == TRUE then
feverchance = 300
elseif env(GetSpEffectID, 5266) == TRUE then
feverchance = 100
elseif env(GetSpEffectID, 5265) == TRUE then
feverchance = 50
elseif env(GetSpEffectID, 5264) == TRUE then
feverchance = 30
elseif env(GetSpEffectID, 5263) == TRUE then
feverchance = 20
elseif env(GetSpEffectID, 5262) == TRUE then
feverchance = 10
elseif env(GetSpEffectID, 5261) == TRUE then
feverchance = 5
end
if feverchance > 0 and feversoul <= feverchance then
if env(GetSpEffectID, 5271) == TRUE then
act(AddSpEffect, 5251)
elseif env(GetSpEffectID, 5272) == TRUE then
act(AddSpEffect, 5252)
elseif env(GetSpEffectID, 5273) == TRUE then
act(AddSpEffect, 5253)
else
act(AddSpEffect, 5250)
end
else
act(AddSpEffect, 5255)
end
IS_INITIALIZED_SOUL_DROP_UP = TRUE
end
function GolemConfusion()
if IS_INITIALIZED_CONFUSION == FALSE then
if env(GetSpEffectID, SP_EFFECT_CONFUSION_BORDER_A) == TRUE then
BORDER_CONFUSION = 10
CAN_CONFUSION = TRUE
elseif env(GetSpEffectID, SP_EFFECT_CONFUSION_BORDER_B) == TRUE then
BORDER_CONFUSION = 20
CAN_CONFUSION = TRUE
elseif env(GetSpEffectID, SP_EFFECT_CONFUSION_BORDER_C) == TRUE then
BORDER_CONFUSION = 30
CAN_CONFUSION = TRUE
end
IS_INITIALIZED_CONFUSION = TRUE
end
if CAN_CONFUSION == TRUE then
local dT = GetDeltaTime()
local IsConfused = env(GetSpEffectType, SP_EFFECT_TYPE_GOLEM_CONFUSION)
if POINT_CONFUSION > 0 and IsConfused == FALSE then
POINT_CONFUSION = POINT_CONFUSION - dT
elseif POINT_CONFUSION >= BORDER_CONFUSION and IsConfused == TRUE then
POINT_CONFUSION = 0
end
if env(GetBehaviorID, BEH_IDENTIFIER_GOLEM_CONFUSION) == TRUE and IsConfused == FALSE then
act(AddSpEffect, SP_EFFECT_CONFUSION_SIGN)
if env(GetSpEffectID, SP_EFFECT_CONFUSION_POINT_A) == TRUE then
POINT_CONFUSION = POINT_CONFUSION + 6
elseif env(GetSpEffectID, SP_EFFECT_CONFUSION_POINT_B) == TRUE then
POINT_CONFUSION = POINT_CONFUSION + 13
elseif env(GetSpEffectID, SP_EFFECT_CONFUSION_POINT_C) == TRUE then
POINT_CONFUSION = POINT_CONFUSION + 26
end
end
end
end
function ParryResist()
if IS_INITIALIZED_PARRY_RESIST == FALSE then
if env(GetSpEffectID, 6030) == TRUE then
BORDER_PARRY_RESIST = 1
CAN_PARRY_RESIST = TRUE
elseif env(GetSpEffectID, 6031) == TRUE then
BORDER_PARRY_RESIST = 2
CAN_PARRY_RESIST = TRUE
elseif env(GetSpEffectID, 6032) == TRUE then
BORDER_PARRY_RESIST = 3
CAN_PARRY_RESIST = TRUE
end
IS_INITIALIZED_PARRY_RESIST = TRUE
end
if CAN_PARRY_RESIST == TRUE then
local damage_type = env(GetReceivedDamageType)
if damage_type == DAMAGE_TYPE_PARRY or damage_type >= DAMAGE_TYPE_PARRY_ENEMY1 and damage_type <= DAMAGE_TYPE_PARRY_ENEMY3 then
if env(GetSpEffectID, 6043) == TRUE then
POINT_PARRY_RESIST = 4
elseif env(GetSpEffectID, 6042) == TRUE then
POINT_PARRY_RESIST = 3
act(AddSpEffect, 6043)
elseif env(GetSpEffectID, 6041) == TRUE then
POINT_PARRY_RESIST = 2
act(AddSpEffect, 6042)
elseif env(GetSpEffectID, 6040) == TRUE then
POINT_PARRY_RESIST = 1
act(AddSpEffect, 6041)
else
POINT_PARRY_RESIST = 1
act(AddSpEffect, 6041)
end
end
end
end
function ExecTurn(is_on_cancel)
if is_on_cancel == TRUE and env(IsMoveCancelPossible) == FALSE then
return FALSE
end
local turn_angle = GetVariable("TurnAngle")
if math.abs(turn_angle) <= 0 then
return FALSE
end
local is_emergency_turn = env(IsEmergencyQuickTurnActivated)
if math.abs(turn_angle) < 45 and is_emergency_turn == FALSE then
return FALSE
end
if env(GetSpEffectID, 5841) == TRUE or env(GetSpEffectID, 5843) == TRUE then
return FALSE
end
if env(GetSpEffectID, 5840) == TRUE and math.abs(turn_angle) < 135 then
return FALSE
end
local dir = INVALID
local correction_factor = 0
local fly_route_state = env(GetFlyRouteState)
if fly_route_state ~= AI_FLY_ROUTE_STATE_NOT_USE_FLY_ROUTE and fly_route_state ~= AI_FLY_ROUTE_STATE_ON_GROUND and fly_route_state ~= AI_FLY_ROUTE_STATE_ON_GROUND_TAKEOFF_REQUESTED then
if math.abs(turn_angle) < 45 then
return FALSE
else
if turn_angle < 0 then
dir = INDEX_TURN_DIRECTION_LEFT180
else
dir = INDEX_TURN_DIRECTION_RIGHT180
end
correction_factor = 180
end
elseif math.abs(turn_angle) < 67.5 then
IncNum(1)
if turn_angle < 0 then
if env(GetSpEffectID, SP_EFFECT_IGNORE_TURN45) == TRUE then
dir = INDEX_TURN_DIRECTION_LEFT90
correction_factor = 90
else
dir = INDEX_TURN_DIRECTION_LEFT45
correction_factor = 45
end
elseif env(GetSpEffectID, SP_EFFECT_IGNORE_TURN45) == TRUE then
dir = INDEX_TURN_DIRECTION_RIGHT90
correction_factor = 90
else
dir = INDEX_TURN_DIRECTION_RIGHT45
correction_factor = 45
end
elseif math.abs(turn_angle) < 135 then
if turn_angle < 0 then
dir = INDEX_TURN_DIRECTION_LEFT90
else
dir = INDEX_TURN_DIRECTION_RIGHT90
end
correction_factor = 90
else
if turn_angle < 0 then
dir = INDEX_TURN_DIRECTION_LEFT180
else
dir = INDEX_TURN_DIRECTION_RIGHT180
end
correction_factor = 180
end
local buff = {}
local ai_rec = env(GetAITargetAwareState)
local action_type = env(GetAIActionType)
if action_type == ACTION_TYPE_GUARD then
buff[1] = INDEX_TURN_GUARD
buff[2] = INDEX_TURN_BATTLE
buff[3] = INDEX_TURN_DEFAULT
elseif action_type == ACTION_TYPE_PARRY then
buff[1] = INDEX_TURN_PARRY
buff[2] = INDEX_TURN_BATTLE
buff[3] = INDEX_TURN_DEFAULT
elseif ai_rec > AI_RECOGNITION_NONE then
buff[1] = INDEX_TURN_BATTLE
buff[2] = INDEX_TURN_DEFAULT
buff[3] = INDEX_TURN_GUARD
else
buff[1] = INDEX_TURN_DEFAULT
buff[2] = INDEX_TURN_BATTLE
buff[3] = INDEX_TURN_GUARD
end
local turn_index = INVALID
for i = 1, #buff, 1 do
local anim = ANIME_ID_TURN + buff[i] * 10 + dir
if IsExistAnime(anim) == TRUE then
turn_index = buff[i]
break
elseif dir == INDEX_TURN_DIRECTION_LEFT45 then
anim = ANIME_ID_TURN + buff[i] * 10 + INDEX_TURN_DIRECTION_LEFT90
if IsExistAnime(anim) == TRUE then
turn_index = buff[i]
dir = INDEX_TURN_DIRECTION_LEFT90
correction_factor = 90
break
end
elseif dir == INDEX_TURN_DIRECTION_RIGHT45 then
anim = ANIME_ID_TURN + buff[i] * 10 + INDEX_TURN_DIRECTION_RIGHT90
if IsExistAnime(anim) == TRUE then
turn_index = buff[i]
dir = INDEX_TURN_DIRECTION_RIGHT90
correction_factor = 90
break
end
end
end
if turn_index >= 0 then
act(SetTurnAnimCorrectionRate, correction_factor)
act(SetIsTurnAnimInProgress)
local event = "W_Turn"
local ai_state = AI_STATE_BATTLE
if turn_index == INDEX_TURN_BATTLE then
event = event .. "Battle"
elseif turn_index == INDEX_TURN_GUARD then
event = event .. "Guard"
elseif turn_index == INDEX_TURN_PARRY then
event = event .. "Parry"
else
event = event .. "Default"
ai_state = AI_STATE_DEFAULT
end
SetIdleType(ai_state)
if dir == INDEX_TURN_DIRECTION_LEFT90 then
event = event .. "_Left90"
elseif dir == INDEX_TURN_DIRECTION_RIGHT90 then
event = event .. "_Right90"
elseif dir == INDEX_TURN_DIRECTION_LEFT180 then
event = event .. "_Left180"
elseif dir == INDEX_TURN_DIRECTION_RIGHT180 then
event = event .. "_Right180"
elseif dir == INDEX_TURN_DIRECTION_LEFT45 then
event = event .. "_Left45"
elseif dir == INDEX_TURN_DIRECTION_RIGHT45 then
event = event .. "_Right45"
end
Fire(event)
return TRUE
end
return FALSE
end
function ExecAIAction(style)
local action_type = env(GetAIActionType)
if action_type <= 0 then
if style == STYLE_DEFAULT then
return FALSE
else
if style == STYLE_GUARD then
Fire("W_GuardEnd")
elseif style == STYLE_PARRY then
Fire("W_ParryEnd")
end
return TRUE
end
end
if ExecArtEnd(action_type, style) == TRUE then
return TRUE
end
if ExecGuardEnd(action_type, style) == TRUE then
return TRUE
end
if ExecAIStep(action_type) == TRUE then
return TRUE
end
if ExecAIAttack(action_type, style) == TRUE then
return TRUE
end
if ExecRide() == TRUE then
return TRUE
end
if ExecAIGuard(action_type, style) == TRUE then
return TRUE
end
if ExecAIParry(action_type, style) == TRUE then
return TRUE
end
return FALSE
end
function ExecAICancelAction(style)
local action_type_atk = INVALID
local action_type = INVALID
local action_type_combo = env(GetAIChainActionType)
local action_type_cancel = env(GetAIAtkCancelType)
local action_type_step = env(GetAIChainStepType)
if action_type_combo > 0 then
action_type_atk = action_type_combo
action_type = action_type_combo
elseif action_type_cancel > 0 then
action_type_atk = action_type_cancel
action_type = action_type_cancel
elseif action_type_step > 0 then
action_type = action_type_step
else
return FALSE
end
if ExecArtEnd(action_type, style) == TRUE then
return TRUE
end
if ExecGuardEnd(action_type, style) == TRUE then
return TRUE
end
if ExecAIStep(action_type_step) == TRUE then
return TRUE
end
if ExecAIAttack(action_type_atk, style) == TRUE then
return TRUE
end
if ExecRide() == TRUE then
return TRUE
end
if ExecAIGuard(action_type_atk, style) == TRUE then
return TRUE
end
if ExecAIParry(action_type_atk, style) == TRUE then
return TRUE
end
return FALSE
end
function ExecArtEnd(action_type, style)
if env(GetSpEffectID, SP_EFFECT_ART_STANCE) == FALSE then
return FALSE
end
if action_type == ACTION_TYPE_PARRY then
return FALSE
end
if action_type >= ANIME_ID_ART_STANCE_BEGIN and action_type <= ANIME_ID_ART_STANCE_END then
return FALSE
end
if style == STYLE_GUARD then
if action_type ~= ACTION_TYPE_GUARD then
Fire("W_GuardEnd")
return TRUE
end
elseif style == STYLE_PARRY and action_type ~= ACTION_TYPE_PARRY then
Fire("W_ParryEnd")
return TRUE
end
return FALSE
end
function ExecGuardEnd(action_type, style)
if env(GetSpEffectID, 5825) == FALSE then
return FALSE
end
if action_type == ACTION_TYPE_GUARD then
return FALSE
end
if action_type >= ANIME_ID_GUARD_ATTACK_BEGIN and action_type <= ANIME_ID_GUARD_ATTACK_END then
return FALSE
end
if style == STYLE_GUARD then
Fire("W_GuardEnd")
return TRUE
end
return FALSE
end
function ExecAIGuard(action_type, style)
if action_type ~= ACTION_TYPE_GUARD then
return FALSE
end
if style == STYLE_GUARD then
return FALSE
elseif style == STYLE_PARRY then
Fire("W_ParryEnd")
return TRUE
end
if env(GetSpEffectID, 5822) == TRUE then
return FALSE
end
local move_speed_level = GetVariable("MoveSpeedLevel")
if move_speed_level > 0 then
local i = GetMoveDir(move_speed_level)
local anim_id = move_table_guard[i][1]
if IsExistAnime(anim_id) == FALSE then
return FALSE
end
end
Fire("W_GuardStart")
return TRUE
end
function ExecAIParry(action_type, style)
if action_type ~= ACTION_TYPE_PARRY then
return FALSE
end
if style == STYLE_PARRY then
return FALSE
elseif style == STYLE_GUARD then
Fire("W_GuardEnd")
return TRUE
end
if env(GetSpEffectID, 5821) == TRUE then
return FALSE
end
local move_speed_level = GetVariable("MoveSpeedLevel")
if move_speed_level > 0 then
local i = GetMoveDir(move_speed_level)
local anim_id = move_table_parry[i][1]
if IsExistAnime(anim_id) == FALSE then
return FALSE
end
end
Fire("W_ParryStart")
return TRUE
end
function ExecAIAttack(action_type, style)
if action_type == ANIME_ID_SLEEP_START and IsExistAnime(ANIME_ID_SLEEP_START) == TRUE and IsExistAnime(ANIME_ID_SLEEP_LOOP) == TRUE and IsExistAnime(ANIME_ID_SLEEP_END) == TRUE then
Fire("W_Sleep_Start")
return TRUE
end
if action_type == ANIME_ID_SLEEP_END and IsExistAnime(ANIME_ID_SLEEP_END) == TRUE then
Fire("W_Sleep_End")
return TRUE
end
if action_type == ANIME_ID_SLEEP_COLLECT_END and IsExistAnime(ANIME_ID_SLEEP_COLLECT_END) == TRUE then
Fire("W_SleepCollect_End")
return TRUE
end
if action_type == ANIME_ID_HEATUP then
ExecAttack(action_type)
return TRUE
end
if action_type == ANIME_ID_MODE_CHANGE then
ExecAttack(action_type)
return TRUE
end
if action_type == ANIME_ID_LOSE_TARGET then
ExecAttack(action_type)
return TRUE
end
if action_type >= ANIME_ID_ATTACK_BEGIN and action_type <= ANIME_ID_ATTACK_END then
ExecAttack(action_type)
return TRUE
end
if action_type >= ANIME_ID_GUARD_ATTACK_BEGIN and action_type <= ANIME_ID_GUARD_ATTACK_END then
if style ~= STYLE_GUARD and env(GetSpEffectID, 5822) == FALSE then
Fire("W_GuardStart")
return TRUE
else
ExecAttack(action_type)
return TRUE
end
end
if action_type == ANIME_ID_THROW_ERROR_ATTACK then
ExecAttack(action_type)
return TRUE
end
if action_type >= ANIME_ID_ART_STANCE_BEGIN and action_type <= ANIME_ID_ART_STANCE_END then
if env(GetSpEffectID, SP_EFFECT_ART_STANCE) == FALSE and env(GetSpEffectID, 5821) == FALSE then
Fire("W_ParryStart")
return TRUE
else
ExecAttack(action_type)
return TRUE
end
end
if action_type >= ANIME_ID_GOAL_ACTION_BEGIN and action_type <= ANIME_ID_GOAL_ACTION_END then
ExecGoalAction(action_type)
return TRUE
end
if action_type == ANIME_ID_PARRY_ATTACK then
ExecAttack(action_type)
return TRUE
end
if action_type == ANIME_ID_BRING_EST then
ExecAttack(action_type)
return TRUE
end
if action_type >= ANIME_ID_EVENT_BEGIN and action_type <= ANIME_ID_EVENT_END then
ExecEventAction(action_type)
return TRUE
end
if action_type == ANIME_ID_BUDDY_DISAPPEAR then
Fire("W_BuddyDisappear")
return TRUE
end
if action_type >= ANIME_ID_IDLE_TO_IDLE_UNIQUE_BEGIN and action_type <= ANIME_ID_IDLE_TO_IDLE_UNIQUE_END and IsExistAnime(action_type) == TRUE then
ExecTransToIdleUnique(action_type)
return TRUE
end
return FALSE
end
function ExecAIStep(action_type)
if ANIME_ID_STEP_BEGIN <= action_type and action_type <= ANIME_ID_STEP_END or action_type >= ANIME_ID_STEP2_BEGIN and action_type <= ANIME_ID_STEP2_END or action_type >= ANIME_ID_STEP3_BEGIN and action_type <= ANIME_ID_STEP3_END then
ExecStep(action_type)
return TRUE
end
return FALSE
end
function ExecAttack(action_number)
Fire("W_Attack" .. action_number)
end
function ExecEventAction(action_number)
Fire("W_Event" .. action_number)
CallActionState(action_number)
end
function ExecGoalAction(action_number)
Fire("W_GoalAction" .. action_number)
end
function ExecStep(action_number)
Fire("W_Step" .. action_number)
end
function ExecLand(fall_type)
if env(IsLanding) == FALSE then
if env(GetReceivedDamageType) == DAMAGE_TYPE_DEATH and env(HasReceivedAnyDamage) == FALSE then
Fire("W_DeathStartDefault")
return TRUE
end
if env(IsHamariFallDeath, 12) == TRUE then
if env(GetSpEffectType, 143) == TRUE then
act(AddSpEffect, 5155)
end
Fire("W_DeathStartDefault")
return TRUE
end
if env(IsVersusDivineDamage) == TRUE then
FLAG_HOLY_DAMAGE = TRUE
else
FLAG_HOLY_DAMAGE = FALSE
end
if fall_type ~= FALL_LADDER_DEATH and ExecDeath() == TRUE then
return TRUE
end
if env(HasReceivedAnyDamage) == TRUE and ExecNoSyncAddDamage(DAMAGE_LEVEL_NONE, TRUE) == TRUE then
return TRUE
end
return FALSE
end
if IsDead() == TRUE then
if fall_type == FALL_UPWARD then
anim_id = ANIME_ID_DEATH_LAND_UPWARD
event = "W_DeathStartLandUpward"
elseif fall_type == FALL_DOWNWARD then
anim_id = ANIME_ID_DEATH_LAND_DOWNWARD
event = "W_DeathStartLandDownward"
if IsExistAnime(anim_id) == FALSE then
anim_id = ANIME_ID_DEATH_LAND_DEFAULT
event = "W_DeathStartLandDefault"
end
elseif fall_type == FALL_LADDER_DEATH then
anim_id = ANIME_ID_DEATH_START_LADDER
event = "W_DeathStartLadder"
elseif fall_type == FALL_LADDER then
anim_id = ANIME_ID_DEATH_START_LADDER
event = "W_DeathStartLadder"
else
anim_id = ANIME_ID_DEATH_LAND_DEFAULT
event = "W_DeathStartLandDefault"
if IsExistAnime(anim_id) == FALSE then
anim_id = ANIME_ID_DEATH_LAND_DOWNWARD
event = "W_DeathStartLandDownward"
end
end
if env(GetSpEffectID, 12605) == TRUE then
anim_id = 20030
event = "W_Event20030"
elseif env(GetSpEffectID, 12640) == TRUE then
anim_id = 20020
event = "W_Event20020"
end
if IsExistAnime(anim_id) == FALSE then
local num = GetExistAnimeNum(ANIME_ID_DEATH_VARIATION, 2, 10) + 1
local index = math.random(0, num - 1)
SetVariable("IndexDeathVariation", index)
event = "W_DeathStartDefault"
end
Fire(event)
return TRUE
end
if env(CheckForEventAnimPlaybackRequest) == TRUE then
return TRUE
end
if fall_type == FALL_LADDER then
Replanning()
Fire("W_LadderFallLand")
return TRUE
elseif fall_type == FALL_DEFAULT then
local height = env(GetFallHeight) / 100
if height > HEIGHT_TRANS_TO_HEAVY_LAND then
if IsExistAnime(ANIME_ID_LAND_HEAVY) == TRUE then
Fire("W_LandHeavy")
else
Fire("W_LandDefault")
end
Replanning()
return TRUE
else
Replanning()
Fire("W_LandDefault")
return TRUE
end
elseif fall_type == FALL_UPWARD then
Replanning()
Fire("W_LandUpward")
return TRUE
elseif fall_type == FALL_DOWNWARD then
Replanning()
Fire("W_LandDownward")
return TRUE
else
Fire("W_LandDefault")
return TRUE
end
return FALSE
end
function ExecIdleUnique()
local anim_id = env(GetSpecialStayAnimID)
if anim_id > 0 then
Fire("W_IdleUnique" .. anim_id)
return TRUE
end
return FALSE
end
function ExecTransToBattleFromIdleUnique(id)
local ai_state = env(GetAITargetAwareState)
local action_type = env(GetAIActionType)
local move_speed_level = GetVariable("MoveSpeedLevel")
if ai_state ~= AI_RECOGNITION_NONE or action_type ~= -1 or move_speed_level > 0 or env(GetSpEffectType, SP_EFFECT_TYPE_SLEEP) == TRUE then
local param_idle_unique = id
local offset = param_idle_unique % 100
local anim_id = ANIME_ID_IDLE_UNIQUE_TO_IDLE + offset
if ai_state == AI_RECOGNITION_NONE then
SetIdleType(AI_STATE_DEFAULT)
else
SetIdleType(AI_STATE_BATTLE)
end
if IsExistAnime(anim_id) == TRUE then
Fire("W_IdleUniqueToIdle" .. anim_id)
else
Fire("W_Idle")
end
return TRUE
end
return FALSE
end
function ExecTransToIdleUnique(action_number)
Fire("W_IdleToIdleUnique" .. action_number)
end
function ExecFallStart(judge_fall_type)
if env(IsFalling) == FALSE then
return FALSE
end
if judge_fall_type == JUDGE_FALL_TYPE_UPWARD then
if IsExistAnime(ANIME_ID_FALLING_UPWARD) == TRUE then
Fire("W_FallingUpward")
return TRUE
end
elseif judge_fall_type == JUDGE_FALL_TYPE_DOWNWARD then
if IsExistAnime(ANIME_ID_FALLING_DOWNWARD) == TRUE then
Fire("W_FallingDownward")
return TRUE
end
elseif judge_fall_type == JUDGE_FALL_TYPE_DIRECTION then
local damage_direction = env(GetReceivedDamageDirection)
if damage_direction >= DIRECTION_LEFT and damage_direction <= DIRECTION_FORWARD then
if IsExistAnime(ANIME_ID_FALLING_UPWARD) == TRUE then
Fire("W_FallingUpward")
return TRUE
end
elseif damage_direction == DIRECTION_BACK and IsExistAnime(ANIME_ID_FALLING_DOWNWARD) == TRUE then
Fire("W_FallingDownward")
return TRUE
end
end
Fire("W_FallingDefault")
return TRUE
end
function ExecAIStateChange(is_on_cancel)
local cur_ai_state = env(GetAITargetAwareState)
local pre_ai_state = env(GetAITargetAwareStatePreviousFrame)
if cur_ai_state > AI_RECOGNITION_NONE then
cur_ai_state = AI_STATE_BATTLE
elseif IsExistAnime(ANIME_ID_IDLE_DEFAULT) == TRUE then
cur_ai_state = AI_STATE_DEFAULT
else
cur_ai_state = AI_STATE_BATTLE
end
if is_on_cancel == TRUE and env(IsMoveCancelPossible) == FALSE then
return FALSE
end
if cur_ai_state == GetVariable("IndexAiState") then
return FALSE
end
SetIdleType(cur_ai_state)
if cur_ai_state == AI_STATE_DEFAULT then
if env(GetSpEffectID, 5815) == TRUE then
return FALSE
end
if IsExistAnime(ANIME_ID_TRANS_BATTLE_DEFAULT) == TRUE then
Fire("W_TransToDefaultFromBattle")
return TRUE
end
else
if env(GetSpEffectID, 5815) == TRUE then
return FALSE
end
if IsExistAnime(ANIME_ID_TRANS_DEFAULT_BATTLE) == TRUE then
Fire("W_TransToBattleFromDefault")
return TRUE
end
end
return FALSE
end
function ExecTransToDefaultFromBattle(is_on_cancel, is_check_AIStateChange)
local cur_ai_state = env(GetAITargetAwareState)
if cur_ai_state > AI_RECOGNITION_NONE then
cur_ai_state = AI_STATE_BATTLE
elseif IsExistAnime(ANIME_ID_IDLE_DEFAULT) == TRUE then
cur_ai_state = AI_STATE_DEFAULT
else
cur_ai_state = AI_STATE_BATTLE
end
if is_on_cancel == TRUE and env(IsMoveCancelPossible) == FALSE then
return FALSE
end
if is_check_AIStateChange == TRUE and cur_ai_state == GetVariable("IndexAiState") then
return FALSE
end
SetIdleType(cur_ai_state)
if cur_ai_state == AI_STATE_DEFAULT then
if env(GetSpEffectID, 5815) == TRUE then
return FALSE
end
if env(GetSpEffectID, 5816) == TRUE then
return FALSE
end
if IsExistAnime(ANIME_ID_TRANS_BATTLE_DEFAULT) == TRUE then
Fire("W_TransToDefaultFromBattle")
return TRUE
end
end
return FALSE
end
function ExecTransToBattleFromDefault(is_on_cancel, is_check_AIStateChange)
local cur_ai_state = env(GetAITargetAwareState)
if cur_ai_state > AI_RECOGNITION_NONE then
cur_ai_state = AI_STATE_BATTLE
elseif IsExistAnime(ANIME_ID_IDLE_DEFAULT) == TRUE then
cur_ai_state = AI_STATE_DEFAULT
else
cur_ai_state = AI_STATE_BATTLE
end
if is_on_cancel == TRUE and env(IsMoveCancelPossible) == FALSE then
return FALSE
end
if is_check_AIStateChange == TRUE and cur_ai_state == GetVariable("IndexAiState") then
return FALSE
end
SetIdleType(cur_ai_state)
if cur_ai_state == AI_STATE_BATTLE then
if env(GetSpEffectID, 5815) == TRUE then
return FALSE
end
if IsExistAnime(ANIME_ID_TRANS_DEFAULT_BATTLE) == TRUE then
Fire("W_TransToBattleFromDefault")
return TRUE
end
end
return FALSE
end
function IsDead()
local hp = env(GetHP)
local height = env(GetFallHeight) / 100
if env(GetReceivedDamageType) == DAMAGE_TYPE_DEATH or hp <= 0 then
return TRUE
end
if env(IsLanding) == TRUE and height > HEIGHT_FORCE_DEATH and env(GetStateChangeType, SP_EFFECT_TYPE_CAT_LANDING) == FALSE then
return TRUE
end
if env(GetSpEffectID, 5723) == TRUE and env(GetSpEffectID, 5835) == TRUE then
return TRUE
end
if env(GetSpEffectID, 12510) == TRUE and env(HasReceivedAnyDamage) == TRUE and env(GetSpEffectID, 14717) == FALSE then
return TRUE
end
if hp <= 1 and env(GetSpEffectID, 12510) == FALSE and env(GetSpEffectID, SP_EFFECT_DOSOU_SKELETON_NO_DEAD) == TRUE then
return TRUE
end
if env(GetSpEffectID, 5730) == TRUE and env(GetSpEffectID, 5863) == TRUE then
return TRUE
end
if env(GetSpEffectID, 10592) == TRUE and env(HasReceivedAnyDamage) == TRUE and env(GetSpEffectID, 14717) == FALSE then
return TRUE
end
if hp <= 1 and env(GetSpEffectID, 10592) == FALSE and env(GetSpEffectID, SP_EFFECT_NEW_SKELETON_NO_DEAD) == TRUE then
return TRUE
end
if hp <= 1 and env(GetSpEffectID, SP_EFFECT_SKELETON_NO_DEAD) == TRUE then
return TRUE
end
if hp <= 1 and env(GetSpEffectID, 14057) == FALSE and env(GetSpEffectID, SP_EFFECT_BALLOON_DOLL_NO_DEAD) == TRUE then
return TRUE
end
if env(GetSpEffectID, 16566) == TRUE and env(GetSpecialAttribute) == DAMAGE_ELEMENT_FIRE then
return TRUE
end
if env(GetSpEffectID, 15111) == TRUE and (env(GetSpEffectType, SP_EFFECT_TYPE_POISON) == TRUE or env(GetSpEffectType, SP_EFFECT_TYPE_PLAGUE) == TRUE) then
return TRUE
end
if env(GetSpEffectID, 15153) == TRUE and (env(GetSpEffectType, SP_EFFECT_TYPE_POISON) == TRUE or env(GetSpEffectType, SP_EFFECT_TYPE_PLAGUE) == TRUE) then
return TRUE
end
if env(GetSpEffectID, 15160) == TRUE and (env(GetSpEffectType, SP_EFFECT_TYPE_PLAGUE) == TRUE or env(GetSpEffectType, SP_EFFECT_TYPE_POISON) == TRUE) then
return TRUE
end
if env(GetSpEffectID, 12660) == TRUE and env(GetSpecialAttribute) == DAMAGE_ELEMENT_FIRE then
return TRUE
end
if env(GetSpEffectID, 14962) == TRUE and env(GetSpecialAttribute) == DAMAGE_ELEMENT_FIRE then
return TRUE
end
if env(GetSpEffectID, 16159) == TRUE then
return TRUE
end
if env(GetSpEffectID, 16153) == TRUE then
return TRUE
end
return FALSE
end
function ExecDeath()
if env(GetReceivedDamageType) == DAMAGE_TYPE_DEATHIDLE then
SetVariable("IndexDeathIdleVariation", 0)
Fire("W_DeathIdleDefault")
return TRUE
end
if IsDead() == FALSE then
return FALSE
end
local death_type = GetDeathType()
local anim_id = -1
local event = "W_DeathStartDefault"
if death_type == DEATH_TYPE_WEAK then
anim_id = ANIME_ID_DEATH_WEAK
event = "W_DeathStartWeak"
elseif death_type == DEATH_TYPE_BLAST then
anim_id = ANIME_ID_DEATH_BLAST
event = "W_DeathStartBlast"
elseif death_type == DEATH_TYPE_FIRE then
anim_id = ANIME_ID_DEATH_FIRE
event = "W_DeathStartFire"
elseif death_type == DEATH_TYPE_UPPER then
anim_id = ANIME_ID_DEATH_UPPER
event = "W_DeathStartUpper"
elseif death_type == DEATH_TYPE_FLING then
anim_id = ANIME_ID_DEATH_FLING
event = "W_DeathStartFling"
elseif death_type == DEATH_TYPE_SLEEP then
anim_id = ANIME_ID_DEATH_START_SLEEP
event = "W_DeathStartSleep"
elseif death_type == DEATH_TYPE_SLEEP_COLLECT then
anim_id = ANIME_ID_DEATH_START_SLEEP_COLLECT
event = "W_DeathStartSleepCollect"
end
if anim_id >= 0 and IsExistAnime(anim_id) == FALSE then
event = "W_DeathStartDefault"