-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.lua
5465 lines (4778 loc) · 205 KB
/
actions.lua
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
require "class"
require "bufferedaction"
require "debugtools"
require 'util'
require 'vecutil'
require ("components/embarker")
local function DefaultRangeCheck(doer, target)
if target == nil then
return
end
local target_x, target_y, target_z = target.Transform:GetWorldPosition()
local doer_x, doer_y, doer_z = doer.Transform:GetWorldPosition()
local dst = distsq(target_x, target_z, doer_x, doer_z)
return dst <= 16
end
local function PhysicsPaddedRangeCheck(doer, target)
if target == nil then
return
end
local target_x, target_y, target_z = target.Transform:GetWorldPosition()
local doer_x, doer_y, doer_z = doer.Transform:GetWorldPosition()
local target_r = target:GetPhysicsRadius(0) + 4
local dst = distsq(target_x, target_z, doer_x, doer_z)
return dst <= target_r * target_r
end
local function CheckFishingOceanRange(doer, dest)
local doer_pos = doer:GetPosition()
local target_pos = Vector3(dest:GetPoint())
local dir = target_pos - doer_pos
local test_pt = doer_pos + dir:GetNormalized() * (doer:GetPhysicsRadius(0) + 0.25)
if TheWorld.Map:IsVisualGroundAtPoint(test_pt.x, 0, test_pt.z) or TheWorld.Map:GetPlatformAtPoint(test_pt.x, test_pt.z) ~= nil then
if FindVirtualOceanEntity(test_pt.x, 0, test_pt.z) ~= nil then
return true
end
return false
else
return true
end
end
local function CheckRowRange(doer, dest)
local doer_pos = doer:GetPosition()
local target_pos = Vector3(dest:GetPoint())
local dir = target_pos - doer_pos
local test_pt = doer_pos + dir:GetNormalized() * (doer:GetPhysicsRadius(0) + 0.25)
if TheWorld.Map:GetPlatformAtPoint(test_pt.x, test_pt.z) ~= nil then
return false
else
return true
end
end
local function CheckIsOnPlatform(doer, dest)
return doer:GetCurrentPlatform() ~= nil
end
local function CheckOceanFishingCastRange(doer, dest)
local doer_pos = doer:GetPosition()
local target_pos = Vector3(dest:GetPoint())
local dir = target_pos - doer_pos
local test_pt = doer_pos + dir:GetNormalized() * (doer:GetPhysicsRadius(0) + 1.5)
if TheWorld.Map:IsVisualGroundAtPoint(test_pt.x, 0, test_pt.z) or TheWorld.Map:GetPlatformAtPoint(test_pt.x, test_pt.z) ~= nil then
if FindVirtualOceanEntity(test_pt.x, 0, test_pt.z) ~= nil then
return true
end
return false
else
return true
end
end
local function CheckTileWithinRange(doer, dest)
local doer_pos = doer:GetPosition()
local target_pos = Vector3(dest:GetPoint())
local tile_x, tile_y, tile_z = TheWorld.Map:GetTileCenterPoint(target_pos.x, 0, target_pos.z)
local dist = TILE_SCALE * 0.5
if math.abs(tile_x - doer_pos.x) <= dist and math.abs(tile_z - doer_pos.z) <= dist then
return true
end
end
local function ShowPourWaterTilePlacer(right_mouse_action)
if right_mouse_action ~= nil then
if right_mouse_action.target ~= nil and right_mouse_action.target:HasTag("farm_plant") then
local x, y, z = right_mouse_action.target.Transform:GetWorldPosition()
return TheWorld.Map:IsFarmableSoilAtPoint(x, y, z)
else
-- If there is no target while hovering farm turf the POUR_WATER_GROUNDTILE point action will have taken priority anyway
return false
end
end
end
local function ExtraPickupRange(doer, dest)
if dest ~= nil then
local target_x, target_y, target_z = dest:GetPoint()
local is_on_water = TheWorld.Map:IsOceanTileAtPoint(target_x, 0, target_z) and not TheWorld.Map:IsPassableAtPoint(target_x, 0, target_z)
if is_on_water then
return 0.75
end
end
return 0
end
local function ExtraDeployDist(doer, dest, bufferedaction)
if dest ~= nil then
local invobject = bufferedaction and bufferedaction.invobject or nil
if invobject and invobject:HasTag("projectile") then
return 8 - ACTIONS.DEPLOY.distance
end
local doer_x, doer_y, doer_z = doer.Transform:GetWorldPosition()
local target_x, target_y, target_z = dest:GetPoint()
local use_extra_space = false
if TheWorld.Map:IsPassableAtPoint(doer_x, 0, doer_z) then
--doer on land or boat
if TheWorld.has_ocean then
if TheWorld.Map:IsOceanTileAtPoint(target_x, 0, target_z) and not TheWorld.Map:IsPassableAtPoint(target_x, 0, target_z) then
--target on ocean
use_extra_space = true
end
elseif TheWorld.Map:IsInvalidTileAtPoint(target_x, 0, target_z) then
--target on void
use_extra_space = true
end
else
--doer on ocean or void
if TheWorld.Map:IsPassableAtPoint(target_x, 0, target_z) then
--target on land or boat
use_extra_space = true
end
end
if use_extra_space then
if invobject and invobject:HasTag("usedeployspacingasoffset") then
local inventoryitem = invobject.replica.inventoryitem
return (inventoryitem and inventoryitem:DeploySpacingRadius() or 0) + 1
end
return 1
end
end
return 0
end
local function ExtraDropDist(doer, dest, bufferedaction)
if dest ~= nil then
local target_x, target_y, target_z = dest:GetPoint()
local is_on_water = TheWorld.Map:IsOceanTileAtPoint(target_x, 0, target_z) and not TheWorld.Map:IsPassableAtPoint(target_x, 0, target_z)
if is_on_water then
return 1.75
end
local invobject = bufferedaction and bufferedaction.invobject or nil
-- Extra drop dist to items that collide with doer.
if invobject ~= nil and doer ~= nil and invobject.Physics ~= nil and doer.Physics ~= nil then
if not checkbit(invobject.Physics:GetCollisionMask(), doer.Physics:GetCollisionGroup()) then
return 0
end
local physics_rad = invobject:GetPhysicsRadius(0)
if physics_rad > 0 then
return physics_rad + 0.5
end
end
end
return 0
end
local function ExtraPourWaterDist(doer, dest, bufferedaction)
return 1.5
end
local function ArriveAnywhere()
return true
end
global("CLIENT_REQUESTED_ACTION")
CLIENT_REQUESTED_ACTION = nil
-- NOTES(JBK): This is used to translate normal actions the player could do in the game but done on the map instead.
-- The amount of actions will be limited with how limiting the map itself is.
global("ACTIONS_MAP_REMAP")
ACTIONS_MAP_REMAP = {}
function SetClientRequestedAction(actioncode, mod_name)
if mod_name then
CLIENT_REQUESTED_ACTION = MOD_ACTIONS_BY_ACTION_CODE[mod_name] and MOD_ACTIONS_BY_ACTION_CODE[mod_name][actioncode] or nil
else
CLIENT_REQUESTED_ACTION = ACTIONS_BY_ACTION_CODE[actioncode]
end
end
function ClearClientRequestedAction()
CLIENT_REQUESTED_ACTION = nil
end
--Positional parameters have been deprecated, pass in a table instead.
Action = Class(function(self, data, instant, rmb, distance, ghost_valid, ghost_exclusive, canforce, rangecheckfn)
if data == nil then
data = {}
end
if type(data) ~= "table" then
--#TODO: get rid of the positional parameters all together, this warning here is for mods that may be using the old interface.
print("WARNING: Positional Action parameters are deprecated. Please pass action a table instead.")
print(string.format("Action defined at %s", debugstack_oneline(4)))
local priority = data
data = {priority=priority, instant=instant, rmb=rmb, ghost_valid=ghost_valid, ghost_exclusive=ghost_exclusive, canforce=canforce, rangecheckfn=rangecheckfn}
end
self.priority = data.priority or 0
self.fn = function() return false end
self.strfn = nil
self.instant = data.instant or false
self.rmb = data.rmb or nil -- note! This actually only does something for tools, everything tests 'right' in componentactions
self.distance = data.distance or nil
self.mindistance = data.mindistance or nil
self.arrivedist = data.arrivedist or nil
self.ghost_exclusive = data.ghost_exclusive or false
self.ghost_valid = self.ghost_exclusive or data.ghost_valid or false -- If it's ghost-exclusive, then it must be ghost-valid
self.mount_valid = data.mount_valid or false
self.encumbered_valid = data.encumbered_valid or false
self.canforce = data.canforce or nil
self.rangecheckfn = self.canforce ~= nil and data.rangecheckfn or nil
self.mod_name = nil
self.silent_fail = data.silent_fail or nil
--new params, only supported by passing via data field
self.paused_valid = data.paused_valid or false
self.actionmeter = data.actionmeter or nil
self.customarrivecheck = data.customarrivecheck
self.is_relative_to_platform = data.is_relative_to_platform
self.disable_platform_hopping = data.disable_platform_hopping
self.skip_locomotor_facing = data.skip_locomotor_facing
self.do_not_locomote = data.do_not_locomote
self.extra_arrive_dist = data.extra_arrive_dist
self.tile_placer = data.tile_placer
self.show_tile_placer_fn = data.show_tile_placer_fn
self.theme_music = data.theme_music
self.theme_music_fn = data.theme_music_fn -- client side function
self.pre_action_cb = data.pre_action_cb -- runs on client and server
self.invalid_hold_action = data.invalid_hold_action
self.show_primary_input_left = data.show_primary_input_left
self.show_secondary_input_right = data.show_secondary_input_right
self.map_action = data.map_action -- Should only be handled from the map and has action translations.
self.closes_map = data.closes_map -- Should immediately close the minimap on action start.
end)
-- NOTE: High priority is intended to be a shortcut flag for actions that we expect to always dominate if they are available.
-- We also expect that no two HIGH_ACTION_PRIORITY actions overlap with each other.
local HIGH_ACTION_PRIORITY = 10
ACTIONS =
{
REPAIR = Action({ mount_valid=true, encumbered_valid=true }),
READ = Action({ mount_valid=true }),
DROP = Action({ priority=-1, mount_valid=true, encumbered_valid=true, is_relative_to_platform=true, extra_arrive_dist=ExtraDropDist }),
TRAVEL = Action(),
CHOP = Action({ distance=1.75, invalid_hold_action=true }),
ATTACK = Action({priority=2, canforce=true, mount_valid=true, invalid_hold_action=true }), -- No custom range check, attack already handles that
EAT = Action({ mount_valid=true }),
PICK = Action({ canforce=true, rangecheckfn=PhysicsPaddedRangeCheck, extra_arrive_dist=ExtraPickupRange, mount_valid = true }),
PICKUP = Action({ priority=1, extra_arrive_dist=ExtraPickupRange, mount_valid=true }),
MINE = Action({ invalid_hold_action=true }),
DIG = Action({ rmb=true, invalid_hold_action=true }),
GIVE = Action({ mount_valid=true, canforce=true, rangecheckfn=DefaultRangeCheck }),
GIVETOPLAYER = Action({ priority=3, canforce=true, rangecheckfn=DefaultRangeCheck }),
GIVEALLTOPLAYER = Action({ priority=3, canforce=true, rangecheckfn=DefaultRangeCheck }),
FEEDPLAYER = Action({ priority=3, rmb=true, canforce=true, rangecheckfn=DefaultRangeCheck }),
DECORATEVASE = Action(),
COOK = Action({ priority=1, mount_valid=true }),
FILL = Action(),
FILL_OCEAN = Action({ is_relative_to_platform=true, extra_arrive_dist=ExtraDropDist }),
DRY = Action(),
ADDFUEL = Action({ mount_valid=true, paused_valid=true }),
ADDWETFUEL = Action({ mount_valid=true, paused_valid=true }),
LIGHT = Action({ priority=-4 }),
EXTINGUISH = Action({ priority=0 }),
STOKEFIRE = Action({ rmb=true, mount_valid=true, distance=8, invalid_hold_action=true }),
LOOKAT = Action({ priority=-3, instant=true, distance=3--[[for close inspection]], ghost_valid=true, mount_valid=true, encumbered_valid=true }),
TALKTO = Action({ priority=3, instant=true, mount_valid=true, encumbered_valid=true }),
WALKTO = Action({ priority=-4, ghost_valid=true, mount_valid=true, encumbered_valid=true, invalid_hold_action=true }),
INTERACT_WITH = Action({ distance=1.5, mount_valid=true }),
BAIT = Action(),
CHECKTRAP = Action({ priority=2, mount_valid=true }),
BUILD = Action({ mount_valid=true }),
PLANT = Action(),
HARVEST = Action(),
GOHOME = Action(),
SLEEPIN = Action(),
CHANGEIN = Action({ priority=-1 }),
HITCHUP = Action({ priority=-1 }),
MARK = Action({ distance=2, priority=-1 }),
UNHITCH = Action({ distance=2, priority=-1 }),
HITCH = Action({ priority=-1 }),
EQUIP = Action({ priority=0,instant=true, mount_valid=true, encumbered_valid=true, paused_valid=true }),
UNEQUIP = Action({ priority=-2,instant=true, mount_valid=true, encumbered_valid=true, paused_valid=true }),
--OPEN_SHOP = Action(),
SHAVE = Action({ mount_valid=true }),
STORE = Action(),
RUMMAGE = Action({ priority=-1, mount_valid=true }),
DEPLOY = Action({distance=1.1, mount_valid=true, extra_arrive_dist=ExtraDeployDist }),
DEPLOY_TILEARRIVE = Action({customarrivecheck=CheckTileWithinRange, theme_music = "farming"}), -- Note: If this is used for non-farming in the future, this would need to be swapped to theme_music_fn
PLAY = Action({ mount_valid=true }),
CREATE = Action(),
JOIN = Action(),
NET = Action({ priority=3, canforce=true, rangecheckfn=DefaultRangeCheck }),
CATCH = Action({ priority=3, distance=math.huge, mount_valid=true }),
FISH_OCEAN = Action({rmb=true, customarrivecheck=CheckFishingOceanRange, is_relative_to_platform = true, disable_platform_hopping=true}),
FISH = Action(),
REEL = Action({ instant=true }),
OCEAN_FISHING_POND = Action(),
OCEAN_FISHING_CAST = Action({priority=3, rmb=true, customarrivecheck=CheckOceanFishingCastRange, is_relative_to_platform=true, disable_platform_hopping=true, invalid_hold_action=true}),
OCEAN_FISHING_REEL = Action({priority=5, rmb=true, do_not_locomote=true, silent_fail = true }),
OCEAN_FISHING_STOP = Action({instant=true}),
OCEAN_FISHING_CATCH = Action({priority=6, instant=true}),
CHANGE_TACKLE = Action({priority=3, rmb=true, instant=true, mount_valid=true}), -- this is now a generic "put item into the container of the equipped hand item"
POLLINATE = Action(),
FERTILIZE = Action({priority=1, mount_valid=true }),
SMOTHER = Action({ priority=1, mount_valid=true }),
MANUALEXTINGUISH = Action({ priority=1 }),
LAYEGG = Action(),
HAMMER = Action({ priority=3, invalid_hold_action=true }),
TERRAFORM = Action({ tile_placer="gridplacer" }),
JUMPIN = Action({ ghost_valid=true, encumbered_valid=true }),
JUMPIN_MAP = Action({priority=HIGH_ACTION_PRIORITY, rmb=true, ghost_valid=true, encumbered_valid=true, map_action=true, closes_map=true,}),
TELEPORT = Action({ rmb=true, distance=2 }),
RESETMINE = Action({ priority=3 }),
ACTIVATE = Action({ priority=2, invalid_hold_action = true }),
OPEN_CRAFTING = Action({priority=2, distance = TUNING.RESEARCH_MACHINE_DIST - 1}),
MURDER = Action({ priority=1, mount_valid=true }),
HEAL = Action({ mount_valid=true }),
INVESTIGATE = Action(),
UNLOCK = Action(),
USEKLAUSSACKKEY = Action(),
TEACH = Action({ mount_valid=true }),
TURNON = Action({ priority=2, invalid_hold_action = true, }),
TURNOFF = Action({ priority=2, invalid_hold_action = true, }),
SEW = Action({ mount_valid=true }),
STEAL = Action(),
USEITEM = Action({ priority=1, instant=true }),
USEITEMON = Action({ distance=2, priority=1 }),
STOPUSINGITEM = Action({ priority=1 }),
TAKEITEM = Action(),
TAKESINGLEITEM = Action(),
MAKEBALLOON = Action({ mount_valid=true }),
CASTSPELL = Action({ priority=-1, rmb=true, distance=20, mount_valid=true }),
CAST_POCKETWATCH = Action({ priority=-1, rmb=true, mount_valid=true }), -- to actually use the mounted action, the pocket watch will need the pocketwatch_mountedcast tag
BLINK = Action({ priority=HIGH_ACTION_PRIORITY, rmb=true, distance=36, mount_valid=true }),
BLINK_MAP = Action({ priority=HIGH_ACTION_PRIORITY, customarrivecheck=ArriveAnywhere, rmb=true, mount_valid=true, map_action=true, }),
COMBINESTACK = Action({ mount_valid=true, extra_arrive_dist=ExtraPickupRange }),
TOGGLE_DEPLOY_MODE = Action({ priority=HIGH_ACTION_PRIORITY, instant=true, mount_valid=true }),
SUMMONGUARDIAN = Action({ rmb=false, distance=5 }),
HAUNT = Action({ rmb=false, mindistance=2, ghost_valid=true, ghost_exclusive=true, canforce=true, rangecheckfn=DefaultRangeCheck }),
UNPIN = Action(),
STEALMOLEBAIT = Action({ rmb=false, distance=.75 }),
MAKEMOLEHILL = Action({ priority=4, rmb=false, distance=0 }),
MOLEPEEK = Action({ rmb=false, distance=1 }),
FEED = Action({ rmb=true, mount_valid=true }),
UPGRADE = Action({ rmb=true, priority=1 }),
HAIRBALL = Action({ rmb=false, distance=3 }),
CATPLAYGROUND = Action({ rmb=false, distance=1 }),
CATPLAYAIR = Action({ rmb=false, distance=2 }),
FAN = Action({ rmb=true, mount_valid=true }),
ERASE_PAPER = Action({ rmb=true, mount_valid=true }),
DRAW = Action(),
BUNDLE = Action({ rmb=true, priority=2 }),
BUNDLESTORE = Action({ instant=true }),
WRAPBUNDLE = Action({ instant=true }),
UNWRAP = Action({ rmb=true, priority=2 }),
BREAK = Action({ rmb=true, priority=2 }),
CONSTRUCT = Action({ priority=1, distance=2.5 }),
STOPCONSTRUCTION = Action({ priority=1, instant=true, distance=2 }),
APPLYCONSTRUCTION = Action({ priority=1, instant=true, distance=2 }),
--channeling for scene entity
STARTCHANNELING = Action({ priority=2, distance=2.1 }), -- Keep higher priority over smother for waterpump but do something else if channelable is added to more things.
STOPCHANNELING = Action({ instant=true, distance=2.1 }),
--channeling for equipped item
START_CHANNELCAST = Action({ priority=-1, rmb=true, do_not_locomote=true }),
STOP_CHANNELCAST = Action({ priority=-1, rmb=true, do_not_locomote=true }),
--
APPLYPRESERVATIVE = Action(),
COMPARE_WEIGHABLE = Action({ encumbered_valid=true, priority=HIGH_ACTION_PRIORITY }),
WEIGH_ITEM = Action(),
START_CARRAT_RACE = Action({ rmb = true }),
CASTSUMMON = Action({ rmb=true, mount_valid=true }),
CASTUNSUMMON = Action({ mount_valid=true, distance=math.huge }),
COMMUNEWITHSUMMONED = Action({ rmb=true, mount_valid=true }),
TELLSTORY = Action({ rmb=true, distance=3 }),
PERFORM = Action({ rmb=true, distance=1.5, invalid_hold_action=true }),
TOSS = Action({priority=1, rmb=true, distance=8, mount_valid=true }),
TOSS_MAP = Action({ priority=HIGH_ACTION_PRIORITY, customarrivecheck=ArriveAnywhere, rmb=true, mount_valid=true, map_action=true, closes_map=true, }),
NUZZLE = Action(),
WRITE = Action(),
ATTUNE = Action(),
REMOTERESURRECT = Action({ rmb=false, ghost_valid=true, ghost_exclusive=true }),
REVIVE_CORPSE = Action({ rmb=false, actionmeter=true }),
MIGRATE = Action({ rmb=false, encumbered_valid=true, ghost_valid=true }),
MOUNT = Action({ priority=1, rmb=true, encumbered_valid=true }),
DISMOUNT = Action({ priority=1, instant=true, rmb=true, mount_valid=true, encumbered_valid=true }),
SADDLE = Action({ priority=1 }),
UNSADDLE = Action({ priority=3, rmb=false }),
BRUSH = Action({ priority=3, rmb=false }),
ABANDON = Action({ rmb=true }),
PET = Action(),
DISMANTLE = Action({ rmb=true }),
TACKLE = Action({ rmb=true, distance=math.huge, invalid_hold_action = true, }),
GIVE_TACKLESKETCH = Action(),
REMOVE_FROM_TROPHYSCALE = Action(),
CYCLE = Action({ rmb=true, priority=2 }),
CASTAOE = Action({ priority=HIGH_ACTION_PRIORITY, rmb=true, mount_valid=true, distance=8, invalid_hold_action=true }),
HALLOWEENMOONMUTATE = Action({ priority=-1 }),
WINTERSFEAST_FEAST = Action({ priority=1 }),
BEGIN_QUEST = Action(),
ABANDON_QUEST = Action(),
SING = Action({ rmb=true, mount_valid=true }),
SING_FAIL = Action({ rmb=true, mount_valid=true }),
--Quagmire
TILL = Action({ distance=0.5, theme_music = "farming" }),
PLANTSOIL = Action({ theme_music = "farming" }),
INSTALL = Action(),
TAPTREE = Action({priority=1, rmb=true}),
SLAUGHTER = Action({ canforce=true, rangecheckfn=DefaultRangeCheck }),
REPLATE = Action(),
SALT = Action(),
BATHBOMB = Action(),
COMMENT = Action({distance = 4}),
WATER_TOSS = Action({ priority=3, rmb=true, customarrivecheck=CheckOceanFishingCastRange, is_relative_to_platform=true, disable_platform_hopping=true}),
-- boats
RAISE_SAIL = Action({ distance=1.25, invalid_hold_action = true }),
LOWER_SAIL = Action({ distance=1.25, invalid_hold_action = true }),
LOWER_SAIL_BOOST = Action({ distance=1.25, invalid_hold_action = true }),
LOWER_SAIL_FAIL = Action({ distance=1.25, do_not_locomote=true, invalid_hold_action = true }),
RAISE_ANCHOR = Action({ distance=2.5, invalid_hold_action = true }),
LOWER_ANCHOR = Action({ distance=2.5, invalid_hold_action = true }),
EXTEND_PLANK = Action({ distance=2.5, invalid_hold_action = true }),
RETRACT_PLANK = Action({ distance=2.5, invalid_hold_action = true }),
ABANDON_SHIP = Action({ distance=2.5, priority=4, invalid_hold_action = true }),
MOUNT_PLANK = Action({ distance=0.5, invalid_hold_action = true }),
DISMOUNT_PLANK = Action({ distance=2.5 }),
REPAIR_LEAK = Action({ distance=2.5, invalid_hold_action = true }),
STEER_BOAT = Action({ arrivedist=0.1, invalid_hold_action = true }),
SET_HEADING = Action({distance=9999, do_not_locomote=true, invalid_hold_action = true }),
STOP_STEERING_BOAT = Action({ instant = true }),
CAST_NET = Action({ priority=HIGH_ACTION_PRIORITY, rmb=true, distance=12, mount_valid=true, disable_platform_hopping=true }),
ROW_FAIL = Action({customarrivecheck=ArriveAnywhere, disable_platform_hopping=true, skip_locomotor_facing=true, invalid_hold_action = true}),
ROW = Action({priority=3, customarrivecheck=CheckRowRange, is_relative_to_platform=true, disable_platform_hopping=true, invalid_hold_action = true}),
ROW_CONTROLLER = Action({priority=3, is_relative_to_platform=true, disable_platform_hopping=true, do_not_locomote=true, invalid_hold_action = true}),
BOARDPLATFORM = Action({ customarrivecheck=CheckIsOnPlatform }),
OCEAN_TOSS = Action({priority=3, rmb=true, customarrivecheck=CheckOceanFishingCastRange, is_relative_to_platform=true, disable_platform_hopping=true}),
UNPATCH = Action({ distance=0.5 }),
POUR_WATER = Action({rmb=true, tile_placer="gridplacer", show_tile_placer_fn=ShowPourWaterTilePlacer, extra_arrive_dist=ExtraPourWaterDist }),
POUR_WATER_GROUNDTILE = Action({rmb=true, customarrivecheck=CheckTileWithinRange, tile_placer="gridplacer", theme_music = "farming" }),
PLANTREGISTRY_RESEARCH_FAIL = Action({ priority = -1 }),
PLANTREGISTRY_RESEARCH = Action({ priority = HIGH_ACTION_PRIORITY }),
ASSESSPLANTHAPPINESS = Action({ priority = 1 }),
ATTACKPLANT = Action(),
PLANTWEED = Action(),
ADDCOMPOSTABLE = Action(),
WAX = Action({ encumbered_valid = true, mindistance=1.5 }),
APPRAISE = Action(),
UNLOAD_WINCH = Action({rmb=true, priority=3}),
USE_HEAVY_OBSTACLE = Action({encumbered_valid=true, rmb=true, priority=1}),
ADVANCE_TREE_GROWTH = Action(),
ROTATE_BOAT_CLOCKWISE = Action({ show_secondary_input_right = true, rmb = true, priority = 1 }),
ROTATE_BOAT_COUNTERCLOCKWISE = Action({ show_primary_input_left = true, priority = 1 }),
ROTATE_BOAT_STOP = Action(),
BOAT_MAGNET_ACTIVATE = Action(),
BOAT_MAGNET_DEACTIVATE = Action(),
BOAT_MAGNET_BEACON_TURN_ON = Action({ rmb = true, priority=3 }),
BOAT_MAGNET_BEACON_TURN_OFF = Action({ rmb = true, priority=3 }),
BOAT_CANNON_LOAD_AMMO = Action({ distance=1.4, mount_valid=true, paused_valid=true, rmb=true, priority=3 }),
BOAT_CANNON_START_AIMING = Action({ distance=1.4 }),
BOAT_CANNON_SHOOT = Action({distance=9999, do_not_locomote=true}),
BOAT_CANNON_STOP_AIMING = Action({instant=true}),
OCEAN_TRAWLER_LOWER = Action({ distance=2.8, rmb=true }),
OCEAN_TRAWLER_RAISE = Action({ distance=2.8, rmb=true }),
OCEAN_TRAWLER_FIX = Action({ distance=2.8 }),
EMPTY_CONTAINER = Action(),
CARNIVAL_HOST_SUMMON = Action(),
-- YOTB
YOTB_SEW = Action({ priority=1, mount_valid=true }),
YOTB_STARTCONTEST = Action(),
YOTB_UNLOCKSKIN = Action(),
CARNIVALGAME_FEED = Action({ mount_valid=true }),
-- YOT_Catcoon
RETURN_FOLLOWER = Action(),
HIDEANSEEK_FIND = Action({ rmb=true, priority=1, mount_valid=true }),
-- WEBBER
MUTATE_SPIDER = Action({priority = 2}),
HERD_FOLLOWERS = Action({ mount_valid=true }),
REPEL = Action({ mount_valid=true }),
BEDAZZLE = Action(),
-- WANDA
DISMANTLE_POCKETWATCH = Action({ mount_valid=true }),
-- WOLFGANG
LIFT_DUMBBELL = Action({ priority = 2, mount_valid=false }), -- Higher than TOSS
STOP_LIFT_DUMBBELL = Action({ priority = 2, mount_valid=false, instant = true }),
ENTER_GYM = Action({ mount_valid=false, invalid_hold_action = true }),
UNLOAD_GYM = Action({ mount_valid=false}),
-- Minigame actions:
LEAVE_GYM = Action({ mount_valid=false, instant = true }),
LIFT_GYM_SUCCEED_PERFECT = Action({ do_not_locomote=true, disable_platform_hopping=true, skip_locomotor_facing=true, invalid_hold_action = true }),
LIFT_GYM_SUCCEED = Action({ do_not_locomote=true, disable_platform_hopping=true, skip_locomotor_facing=true, invalid_hold_action = true }),
LIFT_GYM_FAIL = Action({ do_not_locomote=true, disable_platform_hopping=true, skip_locomotor_facing=true, invalid_hold_action = true }),
-- WX78
APPLYMODULE = Action({ mount_valid=true }),
APPLYMODULE_FAIL = Action({ mount_valid=true, instant = true }),
REMOVEMODULES = Action({ mount_valid=true }),
REMOVEMODULES_FAIL = Action({ mount_valid=true, instant = true }),
CHARGE_FROM = Action({ mount_valid=false }),
ROTATE_FENCE = Action({ rmb=true }),
-- MAXWELL
USEMAGICTOOL = Action({ mount_valid = true, priority = 1 }),
STOPUSINGMAGICTOOL = Action({ mount_valid = true, priority = 2, distance = math.huge, do_not_locomote = true }),
USESPELLBOOK = Action({ instant = true, mount_valid = true }),
CLOSESPELLBOOK = Action({ instant = true, mount_valid = true }),
CAST_SPELLBOOK = Action({ mount_valid = true }),
-- WOODIE
USE_WEREFORM_SKILL = Action({ rmb=true, distance=math.huge }),
-- WINONA
REMOTE_TELEPORT = Action({ rmb = true, invalid_hold_action = true, mount_valid = true }),
-- Rifts
SCYTHE = Action({ rmb=true, distance=1.8, rangecheckfn=DefaultRangeCheck, invalid_hold_action=true }),
SITON = Action({invalid_hold_action = true,}),
-- Rifts / Meta QoL
INCINERATE = Action({ priority=1, mount_valid=true }),
-- Rifts 4
BOTTLE = Action({ mount_valid=true }),
-- Hallowed Nights 2024
CARVEPUMPKIN = Action({ distance=1.5 }),
-- Winter's Feast 2024
DECORATESNOWMAN = Action({ distance=1.5, encumbered_valid=true, invalid_hold_action=true }),
START_PUSHING = Action({ distance=1.5, rmb=true, priority=1, invalid_hold_action=true }),
}
ACTIONS_BY_ACTION_CODE = {}
ACTION_IDS = {}
for k, v in orderedPairs(ACTIONS) do
v.str = STRINGS.ACTIONS[k] or "ACTION"
v.id = k
table.insert(ACTION_IDS, k)
v.code = #ACTION_IDS
ACTIONS_BY_ACTION_CODE[v.code] = v
end
MOD_ACTIONS_BY_ACTION_CODE = {}
ACTION_MOD_IDS = {} --This will be filled in when mods add actions via AddAction in modutil.lua
----set up the action functions!
ACTIONS.APPRAISE.fn = function(act)
local obj = act.invobject
local target = act.target
local canappraise, reason = obj.components.appraisable:CanAppraise(target)
if canappraise then
obj.components.appraisable:Appraise(target)
return true
elseif reason == "NOTNOW" then
return false, "NOTNOW"
end
end
ACTIONS.EAT.fn = function(act)
local obj = act.target or act.invobject
if obj ~= nil then
if obj.components.edible ~= nil and act.doer.components.eater ~= nil then
return act.doer.components.eater:Eat(obj, act.doer)
elseif obj.components.soul ~= nil and act.doer.components.souleater ~= nil then
return act.doer.components.souleater:EatSoul(obj)
elseif act.doer.components.oceanfishable ~= nil and obj.components.oceanfishable ~= nil then
return act.doer.components.oceanfishable:SetRod(obj.components.oceanfishable:GetRod())
end
end
end
ACTIONS.STEAL.fn = function(act)
local owner = act.target.components.inventory ~= nil and act.target or act.target.components.inventoryitem ~= nil and act.target.components.inventoryitem.owner or nil
local target = act.target.components.inventory == nil and act.target or nil
if owner ~= nil then
if act.doer.components.thief ~= nil then
return act.doer.components.thief:StealItem(owner, target, act.attack == true)
end
elseif act.target.components.dryer ~= nil then
return act.target.components.dryer:DropItem()
end
end
ACTIONS.MAKEBALLOON.fn = function(act)
if act.doer ~= nil and
act.invobject ~= nil and
act.invobject.components.balloonmaker ~= nil and
act.doer:HasTag("balloonomancer") then
if act.doer.components.sanity ~= nil then
if act.doer.components.sanity.current < TUNING.SANITY_TINY then
return false
end
act.doer.components.sanity:DoDelta(-TUNING.SANITY_TINY)
end
--Spawn it to either side of doer's current facing with some variance
local x, y, z = act.doer.Transform:GetWorldPosition()
local angle = act.doer.Transform:GetRotation()
local angle_offset = GetRandomMinMax(-10, 10)
angle_offset = angle_offset + (angle_offset < 0 and -65 or 65)
angle = (angle + angle_offset) * DEGREES
act.invobject.components.balloonmaker:MakeBalloon(
x + .5 * math.cos(angle),
0,
z - .5 * math.sin(angle)
)
return true
end
end
ACTIONS.EQUIP.fn = function(act)
if act.doer.components.inventory ~= nil then
return act.doer.components.inventory:Equip(act.invobject)
end
end
ACTIONS.UNEQUIP.strfn = function(act)
return (act.invobject ~= nil and
act.invobject:HasTag("heavy") or
GetGameModeProperty("non_item_equips") or
act.doer.replica.inventory:GetNumSlots() <= 0)
and "HEAVY"
or nil
end
ACTIONS.UNEQUIP.fn = function(act)
if act.invobject ~= nil and act.doer.components.inventory ~= nil then
if act.invobject.components.equippable ~= nil and act.invobject.components.equippable:ShouldPreventUnequipping() then
return nil
end
if act.invobject.components.inventoryitem.cangoincontainer and not GetGameModeProperty("non_item_equips") then
act.doer.components.inventory:GiveItem(act.invobject)
else
act.doer.components.inventory:DropItem(act.invobject, true, true)
end
return true
end
end
ACTIONS.PICKUP.strfn = function(act)
return act.target ~= nil
and act.target:HasTag("heavy")
and "HEAVY"
or nil
end
ACTIONS.PICKUP.fn = function(act)
if act.doer.components.inventory ~= nil and
act.target ~= nil and
act.target.components.inventoryitem ~= nil and
(
act.target.components.inventoryitem.canbepickedup or
(act.target.components.inventoryitem.canbepickedupalive and not act.doer:HasTag("player")) or
act.target.components.inventoryitem.grabbableoverridetag ~= nil and act.doer:HasTag(act.target.components.inventoryitem.grabbableoverridetag)
) and
not (act.target:IsInLimbo() or
(act.target.components.burnable ~= nil and act.target.components.burnable:IsBurning() and act.target.components.lighter == nil) or
(act.target.components.projectile ~= nil and act.target.components.projectile:IsThrown())) then
if act.doer.components.itemtyperestrictions ~= nil and not act.doer.components.itemtyperestrictions:IsAllowed(act.target) then
return false, "restriction"
elseif act.target.components.container ~= nil and act.target.components.container:IsOpenedByOthers(act.doer) then
return false, "INUSE"
elseif (act.target.components.yotc_racecompetitor ~= nil and act.target.components.entitytracker ~= nil) then
local trainer = act.target.components.entitytracker:GetEntity("yotc_trainer")
if trainer ~= nil and trainer ~= act.doer then
return false, "NOTMINE_YOTC"
end
elseif act.doer.components.inventory.noheavylifting and act.target:HasTag("heavy") then
return false, "NO_HEAVY_LIFTING"
end
if (act.target:HasTag("spider") and act.doer:HasTag("spiderwhisperer")) and
(act.target.components.follower.leader ~= nil and act.target.components.follower.leader ~= act.doer) then
return false, "NOTMINE_SPIDER"
end
if act.target.components.curseditem and not act.target.components.curseditem:checkplayersinventoryforspace(act.doer) then
return false, "FULL_OF_CURSES"
end
if act.target.components.inventory ~= nil and act.target:HasTag("drop_inventory_onpickup") then
act.target.components.inventory:TransferInventory(act.doer)
end
act.doer:PushEvent("onpickupitem", { item = act.target })
if act.target.components.equippable ~= nil and not act.target.components.equippable:IsRestricted(act.doer) then
local equip = act.doer.components.inventory:GetEquippedItem(act.target.components.equippable.equipslot)
if equip ~= nil and not act.target.components.inventoryitem.cangoincontainer then
--special case for trying to carry two backpacks
if equip.components.inventoryitem ~= nil and equip.components.inventoryitem.cangoincontainer then
--act.doer.components.inventory:SelectActiveItemFromEquipSlot(act.target.components.equippable.equipslot)
act.doer.components.inventory:GiveItem(act.doer.components.inventory:Unequip(act.target.components.equippable.equipslot))
else
act.doer.components.inventory:DropItem(equip)
end
act.doer.components.inventory:Equip(act.target)
return true
elseif act.doer:HasTag("player") then
if equip == nil or act.doer.components.inventory:GetNumSlots() <= 0 then
act.doer.components.inventory:Equip(act.target)
return true
elseif GetGameModeProperty("non_item_equips") then
act.doer.components.inventory:DropItem(equip)
act.doer.components.inventory:Equip(act.target)
return true
end
end
end
act.doer.components.inventory:GiveItem(act.target, nil, act.target:GetPosition())
return true
end
end
ACTIONS.EMPTY_CONTAINER.fn = function(act)
if act.target.components.container ~= nil and act.target.components.workable ~= nil then
if act.target.components.workable.onwork then
act.target.components.workable.onwork(act.target, act.doer)
end
--act.target.components.container:DropEverything()
return true
end
end
ACTIONS.REPAIR.strfn = function(act)
return act.target ~= nil
and (
(act.target:HasTag("repairable_moon_altar") and "SOCKET")
or (act.target:HasTag("repairable_vitae") and "REFRESH")
)
or nil
end
ACTIONS.REPAIR.fn = function(act)
if act.target ~= nil then
if act.target.components.repairable ~= nil then
local material
if act.doer ~= nil and
act.doer.components.inventory ~= nil and
act.doer.components.inventory:IsHeavyLifting() and
not (act.doer.components.rider ~= nil and
act.doer.components.rider:IsRiding()) then
material = act.doer.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY)
else
material = act.invobject
end
if material ~= nil and material.components.repairer ~= nil then
return act.target.components.repairable:Repair(act.doer, material)
end
elseif act.target.components.forgerepairable ~= nil then
local material = act.invobject
if material ~= nil and material.components.forgerepair ~= nil then
return act.target.components.forgerepairable:Repair(act.doer, material)
end
end
end
end
ACTIONS.SEW.strfn = function(act)
return act.invobject ~= nil
and (act.invobject:HasTag("tape") and "PATCH")
or nil
end
ACTIONS.SEW.fn = function(act)
if act.target ~= nil and
act.invobject ~= nil and
act.target.components.fueled ~= nil and
act.invobject.components.sewing ~= nil then
return act.invobject.components.sewing:DoSewing(act.target, act.doer)
end
end
ACTIONS.RUMMAGE.fn = function(act)
local targ = act.target or act.invobject
if targ == nil then
return
end
local proxy
if targ.components.container_proxy ~= nil then
local master = targ.components.container_proxy:GetMaster()
if master ~= nil then
proxy = targ
targ = master
end
end
if targ ~= nil and targ.components.container ~= nil then
if proxy ~= nil and proxy.components.container_proxy:IsOpenedBy(act.doer) then
proxy.components.container_proxy:Close(act.doer)
act.doer:PushEvent("closecontainer", { container = targ })
return true
elseif proxy == nil and targ.components.container:IsOpenedBy(act.doer) then
targ.components.container:Close(act.doer)
act.doer:PushEvent("closecontainer", { container = targ })
return true
elseif targ:HasTag("mermonly") and not act.doer:HasTag("merm") then
return false, "NOTAMERM"
elseif targ:HasTag("mastercookware") and not act.doer:HasTag("masterchef") then
return false, "NOTMASTERCHEF"
--elseif targ:HasTag("professionalcookware") and not act.doer:HasTag("professionalchef") then
--return false, "NOTPROCHEF"
elseif not targ.components.container:IsOpenedBy(act.doer) and not targ.components.container:CanOpen() then
return false, "INUSE"
elseif targ.components.container.canbeopened and (proxy == nil or proxy.components.container_proxy:CanBeOpened()) then
local owner = targ.components.inventoryitem ~= nil and targ.components.inventoryitem:GetGrandOwner() or nil
if owner and
(targ.components.container.droponopen or targ.components.quagmire_stewer) and
not (owner:HasTag("player") and targ:HasTag("portablestorage"))
then
if owner == act.doer then
owner.components.inventory:DropItem(targ, true, true)
elseif owner:HasTag("pocketdimension_container") then
--V2C: skipped IsOpenedBy(act.doer) check because magician's top hat
-- closes when performing actions, but it's pretty safe to assume
-- this action is valid.
local x, y, z = (act.doer.components.inventory ~= nil and act.doer.components.inventory:GetOpenContainerProxyFor(owner) or act.doer).Transform:GetWorldPosition()
owner.components.container:DropItemAt(targ, x, y, z)
elseif owner.components.container ~= nil and owner.components.container:IsOpenedBy(act.doer) then
owner.components.container:DropItem(targ)
else
--Silent fail, should not reach here
return true
end
end
--Silent fail for opening containers in the dark
if owner == act.doer or CanEntitySeeTarget(act.doer, proxy or targ) then
act.doer:PushEvent("opencontainer", { container = targ })
if proxy ~= nil then
proxy.components.container_proxy:Open(act.doer)
else
targ.components.container:Open(act.doer)
end
end
return true
end
end
end
ACTIONS.RUMMAGE.strfn = function(act)
local targ = act.target or act.invobject
if targ == nil then
return
elseif targ.components.container_proxy ~= nil then --exists on clients too
if targ.components.container_proxy:IsOpenedBy(act.doer) then
return "CLOSE"
end
elseif targ.replica.container ~= nil then
if targ.replica.container:IsOpenedBy(act.doer) then
return "CLOSE"
end
end
return act.target ~= nil and act.target:HasTag("decoratable") and "DECORATE" or nil
end
ACTIONS.DROP.fn = function(act)
if act.invobject ~= nil and act.invobject.components.equippable ~= nil and
act.invobject.components.equippable:IsEquipped() and
act.invobject.components.equippable:ShouldPreventUnequipping() then
return nil
end
return act.doer.components.inventory ~= nil
and act.doer.components.inventory:DropItem(
act.invobject,
act.options.wholestack and
not (act.invobject ~= nil and
act.invobject.components.stackable ~= nil and
act.invobject.components.stackable.forcedropsingle),
(act.invobject.components.inventoryitem ~= nil
and act.invobject.components.inventoryitem.droprandomdir)
or false,
act:GetActionPoint(),
true -- <--keepoverstacked
)
or nil
end
ACTIONS.DROP.strfn = function(act)
if act.invobject ~= nil and not act.invobject:HasActionComponent("deployable") then
return (act.invobject:HasTag("trap") and "SETTRAP")
or (act.invobject:HasTag("mine") and "SETMINE")
or (act.invobject:HasTag("soul") and "FREESOUL")
or (act.invobject.prefab == "pumpkin_lantern" and "PLACELANTERN")
or (act.invobject.GetDropActionString ~= nil and act.invobject:GetDropActionString(act:GetActionPoint()))
or nil
end
end
local function ShouldLOOKATStopLocomotor(act)
return not (
(act.doer.components.playercontroller ~= nil and act.doer.components.playercontroller.directwalking) or
(act.doer.sg ~= nil and act.doer.sg:HasStateTag("overridelocomote"))
)
end
ACTIONS.LOOKAT.strfn = function(act)
return act.invobject == nil
and CLOSEINSPECTORUTIL.CanCloseInspect(act.doer, act.target or act:GetActionPoint())
and "CLOSEINSPECT"
or nil
end
ACTIONS.LOOKAT.fn = function(act)
--Try close inspection first
if act.invobject == nil and act.doer.components.inventory then
if act.target then
if CLOSEINSPECTORUTIL.CanCloseInspect(act.doer, act.target) then
for k, v in pairs(EQUIPSLOTS) do
local equip = act.doer.components.inventory:GetEquippedItem(v)
if equip and equip.components.closeinspector then
if ShouldLOOKATStopLocomotor(act) then
act.doer.components.locomotor:Stop()
end
local success, reason = equip.components.closeinspector:CloseInspectTarget(act.doer, act.target)
if not success then
local sgparam = { closeinspect = true }
act.doer.components.talker:Say(GetActionFailString(act.doer, "LOOKAT", reason), nil, nil, nil, nil, nil, nil, nil, nil, sgparam)
end
return success, reason
end
end
end
else
local pt = act:GetActionPoint()
if pt and CLOSEINSPECTORUTIL.CanCloseInspect(act.doer, pt) then
for k, v in pairs(EQUIPSLOTS) do
local equip = act.doer.components.inventory:GetEquippedItem(v)
if equip and equip.components.closeinspector then
if ShouldLOOKATStopLocomotor(act) then
act.doer.components.locomotor:Stop()
end
local success, reason = equip.components.closeinspector:CloseInspectPoint(act.doer, pt)