-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcomponentactions.lua
2726 lines (2411 loc) · 113 KB
/
componentactions.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 'util'
require 'vecutil'
local function CanCastFishingNetAtPoint(thrower, target_x, target_z)
local min_throw_distance = 2
local thrower_x, thrower_y, thrower_z = thrower.Transform:GetWorldPosition()
local isoceanactionable = TheWorld.Map:IsOceanAtPoint(target_x, 0, target_z) or FindVirtualOceanEntity(target_x, 0, target_z) ~= nil
if isoceanactionable and VecUtil_LengthSq(target_x - thrower_x, target_z - thrower_z) > min_throw_distance * min_throw_distance then
return true
end
return false
end
local function Row(inst, doer, pos, actions)
local map = TheWorld.Map
local platform_under_cursor = map:GetPlatformAtPoint(pos.x, pos.z)
local doer_x, doer_y, doer_z = doer.Transform:GetWorldPosition()
local my_platform = doer:GetCurrentPlatform()
local is_controller_attached = doer.components.playercontroller.isclientcontrollerattached
local is_hovering_cursor_over_my_platform = false
if not is_controller_attached then
is_hovering_cursor_over_my_platform = my_platform ~= nil and (my_platform == platform_under_cursor)
end
if is_hovering_cursor_over_my_platform or my_platform == nil then
return
end
if CLIENT_REQUESTED_ACTION == ACTIONS.ROW_FAIL then
table.insert(actions, ACTIONS.ROW_FAIL)
elseif doer ~= nil and not doer:HasTag("is_row_failing") then
local animation_fail_frame = doer.AnimState:IsCurrentAnimation("row_pre") and 30 or 4
if doer:HasTag("is_rowing") and doer.AnimState:GetCurrentAnimationFrame() < animation_fail_frame then
table.insert(actions, ACTIONS.ROW_FAIL)
elseif not is_controller_attached then
table.insert(actions, ACTIONS.ROW)
else
local my_platform_x, my_platform_y, my_platform_z = my_platform.Transform:GetWorldPosition()
local dir_x, dir_z = VecUtil_Normalize(doer_x - my_platform_x, doer_z - my_platform_z)
local test_length = 0.5
-- So the position on the client/server don't quite match and the server position doesn't stick as tight to the
-- area surrounding the boat so give a little leeway when checking to see if there's water around you when the client
-- is requesting to row
if ThePlayer ~= doer then
test_length = 0.75
end
local test_x, test_z = doer_x + dir_x * test_length, doer_z + dir_z * test_length
local found_water = not map:IsVisualGroundAtPoint(test_x, 0, test_z) and map:GetPlatformAtPoint(test_x, test_z) == nil
if found_water then
table.insert(actions, ACTIONS.ROW_CONTROLLER)
end
end
end
end
local function PlantRegistryResearch(inst, doer, actions)
if inst ~= doer and (doer.CanExamine == nil or doer:CanExamine()) then
local plantinspector = doer.replica.inventory and doer.replica.inventory:EquipHasTag("plantinspector") or false
local plantkin = doer:HasTag("plantkin")
if plantinspector and ((inst.GetPlantRegistryKey and inst.GetResearchStage) or inst.GetFertilizerKey) then
local act = CLIENT_REQUESTED_ACTION
if (not TheNet:IsDedicated() and doer == ThePlayer) then
if (inst:HasTag("plantresearchable") and not ThePlantRegistry:KnowsPlantStage(inst:GetPlantRegistryKey(), inst:GetResearchStage())) or
(inst:HasTag("fertilizerresearchable") and not ThePlantRegistry:KnowsFertilizer(inst:GetFertilizerKey())) then
act = ACTIONS.PLANTREGISTRY_RESEARCH
else
act = ACTIONS.PLANTREGISTRY_RESEARCH_FAIL
end
end
if act == ACTIONS.PLANTREGISTRY_RESEARCH or act == ACTIONS.PLANTREGISTRY_RESEARCH_FAIL then
table.insert(actions, act)
end
end
if (plantinspector or plantkin) and (inst:HasTag("farmplantstress") or inst:HasTag("weedplantstress")) then
table.insert(actions, ACTIONS.ASSESSPLANTHAPPINESS)
end
end
end
local function GetFishingAction(doer, fishing_target)
if doer:HasTag("fishing_idle") then
if fishing_target ~= nil and not fishing_target:HasTag("projectile") then
if fishing_target:HasTag("oceanfishing_catchable") then -- not fishing_target:HasTag("partiallyhooked") then
if fishing_target:HasTag("fishinghook") then
return ACTIONS.OCEAN_FISHING_STOP
else
return ACTIONS.OCEAN_FISHING_CATCH
end
end
return ACTIONS.OCEAN_FISHING_REEL
end
end
return nil
end
local function CheckRowOverride(doer, target)
-- If near an object with the 'overriderowaction' tag (e.g. ocean trawler), the object's actions supersede this.
if target ~= nil then
local doer_pos = doer:GetPosition()
local boat = TheWorld.Map:GetPlatformAtPoint(doer_pos.x, doer_pos.z)
if boat == nil then
return false
end
local target_pos = target:GetPosition()
local dist_to_target = VecUtil_Dist(target_pos.x, target_pos.z, doer_pos.x, doer_pos.z)
local boat_pos = boat:GetPosition()
local dist_to_boat = VecUtil_Dist(target_pos.x, target_pos.z, boat_pos.x, boat_pos.z)
local boatradius = boat.components.boatringdata and boat.components.boatringdata:GetRadius() or 0
local boat_dist_to_target = dist_to_boat - boatradius
if target:HasTag("overriderowaction") and math.min(dist_to_target, boat_dist_to_target) < TUNING.OVERRIDE_ROW_ACTION_DISTANCE then
return true
end
end
return false
end
local SCYTHE_ONEOFTAGS = {"plant", "lichen", "oceanvine", "kelp"}
local KITCOON_MUST_TAGS = {"kitcoonden"}
local function IsValidScytheTarget(target)
return target:HasOneOfTags(SCYTHE_ONEOFTAGS)
end
-- SCENE using an object in the world
-- USEITEM using an inventory item on an object in the world
-- POINT using an inventory item on a point in the world
-- EQUIPPED using an equiped item on yourself or a target object in the world
-- INVENTORY using an inventory item
local COMPONENT_ACTIONS =
{
SCENE = --args: inst, doer, actions, right
{
activatable = function(inst, doer, actions, right)
if inst:HasTag("inactive") then
--keep playercontroller.lua::GetPickupAction updated as well
if right and inst:HasTag("engineering") and doer:HasTag("portableengineer") then
--portableengineer needs r.click for dismantle
return
elseif not right and (inst.replica.inventoryitem or inst:HasTag("activatable_forceright")) then
--no l.click for inventoryitem or forceright
return
end
if not (inst:HasTag("smolder") or inst:HasTag("fire")) then
table.insert(actions, ACTIONS.ACTIVATE)
end
end
end,
anchor = function(inst, doer, actions, right)
if not inst:HasTag("burnt") then
if not inst:HasTag("anchor_raised") or inst:HasTag("anchor_transitioning") then
table.insert(actions, ACTIONS.RAISE_ANCHOR)
elseif inst:HasTag("anchor_raised") then
table.insert(actions, ACTIONS.LOWER_ANCHOR)
end
end
end,
attunable = function(inst, doer, actions)
if doer.components.attuner ~= nil and --V2C: this is on clients too
not doer.components.attuner:IsAttunedTo(inst) then
table.insert(actions, ACTIONS.ATTUNE)
end
end,
battery = function(inst, doer, actions)
if inst:HasTag("battery") and doer:HasTag("batteryuser") then
table.insert(actions, ACTIONS.CHARGE_FROM)
end
end,
boatmagnet = function(inst, doer, actions, right)
if not inst:HasTag("fire") and not inst:HasTag("burnt") then
if not inst:HasTag("paired") then
table.insert(actions, ACTIONS.BOAT_MAGNET_ACTIVATE)
else
table.insert(actions, ACTIONS.BOAT_MAGNET_DEACTIVATE)
end
end
end,
boatmagnetbeacon = function(inst, doer, actions, right)
if right and inst:HasTag("paired") and not inst:HasTag("burnt") then
if inst:HasTag("turnedoff") then
table.insert(actions, ACTIONS.BOAT_MAGNET_BEACON_TURN_ON)
else
table.insert(actions, ACTIONS.BOAT_MAGNET_BEACON_TURN_OFF)
end
end
end,
boatcannon = function(inst, doer, actions, right)
if not inst:HasTag("occupied") and not inst:HasTag("fire") and not inst:HasTag("burnt") then
if inst:HasTag("ammoloaded") then
table.insert(actions, ACTIONS.BOAT_CANNON_START_AIMING)
elseif right then
table.insert(actions, ACTIONS.BOAT_CANNON_LOAD_AMMO)
end
end
end,
boatrotator = function(inst, doer, actions, right)
local boat = inst:GetCurrentPlatform()
if boat and boat:HasTag("boat") and boat.components.boatringdata and not inst:HasTag("fire") and not inst:HasTag("burnt") then
if boat.components.boatringdata:IsRotating() then
table.insert(actions, ACTIONS.ROTATE_BOAT_STOP)
elseif right then
table.insert(actions, ACTIONS.ROTATE_BOAT_CLOCKWISE)
else
table.insert(actions, ACTIONS.ROTATE_BOAT_COUNTERCLOCKWISE)
end
end
end,
book = function(inst, doer, actions)
if doer:HasTag("reader") and not inst:HasTag("fire") and not inst:HasTag("smolder") then
table.insert(actions, ACTIONS.READ)
end
end,
burnable = function(inst, doer, actions)
if inst:HasTag("smolder") then
table.insert(actions, ACTIONS.SMOTHER)
end
end,
bundlemaker = function(inst, doer, actions, right)
if right then
table.insert(actions, ACTIONS.BUNDLE)
end
end,
catcher = function(inst, doer, actions)
if inst:HasTag("cancatch") then
table.insert(actions, ACTIONS.CATCH)
end
end,
channelable = function(inst, doer, actions, right)
if right and inst:HasTag("channelable") then
if not inst:HasTag("channeled") then
table.insert(actions, ACTIONS.STARTCHANNELING)
elseif doer:HasTag("channeling") then
table.insert(actions, ACTIONS.STOPCHANNELING)
end
end
end,
combat = function(inst, doer, actions, right)
if not right and
doer:CanDoAction(ACTIONS.ATTACK) and
not IsEntityDead(inst, true) and
inst.replica.combat ~= nil and inst.replica.combat:CanBeAttacked(doer) then
table.insert(actions, ACTIONS.ATTACK)
end
end,
constructionsite = function(inst, doer, actions, right)
if not right and inst:HasTag("pickable") then
--V2C: -pickable and constructionsite actions conflict
-- -not normal for constructionsites to have other actions, but collapsedchest does now
return
elseif not inst:HasTag("burnt") and not inst:HasTag("smolder") and (not inst:HasTag("fire") or inst:HasTag("campfire")) then
local constructionsite = inst.replica.constructionsite
if constructionsite:IsEnabled() then
table.insert(actions,
not (doer.components.playercontroller ~= nil and
doer.components.playercontroller.isclientcontrollerattached) and
inst.replica.constructionsite:IsBuilder(doer) and
ACTIONS.STOPCONSTRUCTION or
ACTIONS.CONSTRUCT)
end
end
end,
container = function(inst, doer, actions, right)
if inst:HasTag("bundle") then
if right and inst.replica.container:IsOpenedBy(doer) then
table.insert(actions, doer.components.constructionbuilderuidata ~= nil and doer.components.constructionbuilderuidata:GetContainer() == inst and ACTIONS.APPLYCONSTRUCTION or ACTIONS.WRAPBUNDLE)
end
elseif not inst:HasTag("burnt")
and inst.replica.container:CanBeOpened()
and doer.replica.inventory ~= nil
and (not inst:HasTag("oceantrawler") or not inst:HasTag("trawler_lowered"))
and not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding()) then
table.insert(actions, ACTIONS.RUMMAGE)
end
end,
container_proxy = function(inst, doer, actions)
if inst.components.container_proxy:CanBeOpened() and
not inst:HasTag("burnt") and
doer.replica.inventory ~= nil
and not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding()) then
table.insert(actions, ACTIONS.RUMMAGE)
end
end,
crittertraits = function(inst, doer, actions, right)
if inst.replica.follower ~= nil and inst.replica.follower:GetLeader() == doer then
if right then
if inst.replica.container then -- Added for wobysmall
table.insert(actions, ACTIONS.PET)
elseif doer.replica.builder ~= nil
and doer.replica.builder:GetTechTrees().ORPHANAGE > 0
and not inst:HasTag("noabandon") then
table.insert(actions, ACTIONS.ABANDON)
end
elseif inst.replica.container == nil then
table.insert(actions, ACTIONS.PET)
end
end
end,
crop = function(inst, doer, actions)
if (inst:HasTag("readyforharvest") or inst:HasTag("withered")) and doer.replica.inventory ~= nil then
table.insert(actions, ACTIONS.HARVEST)
end
end,
cyclable = function(inst, doer, actions, right)
if right and inst:HasTag("cancycle") then
table.insert(actions, ACTIONS.CYCLE)
end
end,
dryer = function(inst, doer, actions)
if inst:HasTag("dried") and not inst:HasTag("burnt") then
table.insert(actions, ACTIONS.HARVEST)
end
end,
farmplanttendable = function(inst, doer, actions, right)
if inst:HasTag("fire") or inst:HasTag("smolder") then
return
end
if inst:HasTag("tendable_farmplant") and not doer:HasTag("mime") then
table.insert(actions, ACTIONS.INTERACT_WITH)
end
end,
fertilizerresearchable = function(inst, doer, actions, right)
if right then
PlantRegistryResearch(inst, doer, actions)
end
end,
grabbable = function(inst, doer, actions, right)
if not right then
return
end
-- NOTES(DiogoW): Please refactor this if more cases are added, spellcaster types is a good example.
if inst:HasTag("mosquito") and
doer.components.skilltreeupdater ~= nil and
doer.components.skilltreeupdater:IsActivated("wurt_mosquito_craft_3") and
doer.replica.inventory ~= nil and
doer.replica.inventory:HasItemWithTag("mosquitomusk", 1)
then
table.insert(actions, ACTIONS.NET)
end
end,
groomer = function(inst, doer, actions, right)
if inst:HasTag("groomer") and not inst:HasTag("fire") and not inst:HasTag("burnt") and not inst:HasTag("hitcher") and right then
table.insert(actions, ACTIONS.CHANGEIN)
end
end,
harvestable = function(inst, doer, actions)
if inst:HasTag("harvestable") then
table.insert(actions, ACTIONS.HARVEST)
end
end,
hauntable = function(inst, doer, actions)
if not (inst:HasTag("haunted") or inst:HasTag("catchable")) then
table.insert(actions, ACTIONS.HAUNT)
end
end,
heavyobstacleusetarget = function(inst, doer, actions, right)
local item = doer.replica.inventory:GetEquippedItem(EQUIPSLOTS.BODY)
if right and item ~= nil and item:HasTag("heavy") and inst:HasTag("can_use_heavy")
and (inst.use_heavy_obstacle_action_filter == nil or inst.use_heavy_obstacle_action_filter(inst, doer, item)) then
table.insert(actions, ACTIONS.USE_HEAVY_OBSTACLE)
end
end,
hideandseekhidingspot = function(inst, doer, actions, right)
if right then
table.insert(actions, ACTIONS.HIDEANSEEK_FIND)
end
end,
hitcher = function(inst, doer, actions, right)
if inst:HasTag("hitcher") and not inst:HasTag("fire") and not inst:HasTag("burnt") and not inst:HasTag("hitcher_locked") then
table.insert(actions, ACTIONS.HITCHUP)
end
-- [TODO] this needs to confirm that beefalo is the owners beef.
if not inst:HasTag("hitcher") and not inst:HasTag("fire") and not inst:HasTag("burnt") and not inst:HasTag("hitcher_locked") and not right then
table.insert(actions, ACTIONS.UNHITCH)
end
end,
inspectable = function(inst, doer, actions, right)
if inst ~= doer and
(doer.CanExamine == nil or doer:CanExamine()) and
(doer.sg == nil or (doer.sg:HasStateTag("idle") and not doer.sg:HasStateTag("moving") or doer.sg:HasStateTag("channeling"))) and
(doer:HasTag("idle") and not doer:HasTag("moving") or doer:HasTag("channeling")) then
--Check state graph as well in case there is movement prediction
--@V2C: #FORGE_AOE_RCLICK *searchable*
-- -Forge used to strip ALL r.click actions, so now we manually strip LOOKAT action.
if right and doer.components.playercontroller and doer.components.playercontroller:HasAOETargeting() then
return
end
table.insert(actions, ACTIONS.LOOKAT)
end
end,
inventoryitem = function(inst, doer, actions, right)
if inst.replica.inventoryitem:CanBePickedUp() and
doer.replica.inventory ~= nil and
(doer.replica.inventory:GetNumSlots() > 0 or inst.replica.equippable ~= nil) and
not (inst:HasTag("catchable") or (inst:HasTag("fire") and not inst:HasTag("lighter")) or inst:HasTag("smolder")) and
(not inst:HasTag("spider") or (doer:HasTag("spiderwhisperer") and right)) and
(right or not inst:HasTag("heavy")) and
not (right and inst.replica.container ~= nil and inst.replica.equippable == nil) then
table.insert(actions, ACTIONS.PICKUP)
end
end,
kitcoon = function(inst, doer, actions, right)
if right then
if inst.replica.follower ~= nil and inst.replica.follower:GetLeader() == doer then
if doer:HasTag("near_kitcoonden") and FindEntity(inst, TUNING.KITCOON_NEAR_DEN_DIST, nil, KITCOON_MUST_TAGS) ~= nil then
table.insert(actions, ACTIONS.RETURN_FOLLOWER)
else
table.insert(actions, ACTIONS.ABANDON)
end
end
else
table.insert(actions, ACTIONS.PET)
end
end,
lock = function(inst, doer, actions)
if inst:HasTag("unlockable") then
table.insert(actions, ACTIONS.UNLOCK)
end
end,
machine = function(inst, doer, actions, right)
if right and not inst:HasTag("cooldown") and
not inst:HasTag("fueldepleted") and
not inst:HasTag("alwayson") and
not inst:HasTag("emergency") and
inst:HasTag("enabled") then
local inventoryitem = inst.replica.inventoryitem
local held = inventoryitem ~= nil and inventoryitem:IsHeld()
if inst:HasTag("groundonlymachine") and (held or (inst.components.floater ~= nil and inst.components.floater:IsFloating())) then
return
elseif held then
local equippable = inst.replica.equippable
if equippable ~= nil and not equippable:IsEquipped() then
return
end
end
table.insert(actions, inst:HasTag("turnedon") and ACTIONS.TURNOFF or ACTIONS.TURNON)
end
end,
madsciencelab = function(inst, doer, actions, right)
if right and
(inst:HasTag("readytocook")
or (inst.replica.container ~= nil and
inst.replica.container:IsFull() and
inst.replica.container:IsOpenedBy(doer))) then
table.insert(actions, ACTIONS.COOK)
end
end,
magician = function(inst, doer, actions, right)
if inst == doer and inst:HasTag("usingmagiciantool") then
table.insert(actions, ACTIONS.STOPUSINGMAGICTOOL)
end
end,
markable = function(inst, doer, actions, right)
if inst:HasTag("markable") then
table.insert(actions, ACTIONS.MARK)
end
end,
markable_proxy = function(inst, doer, actions, right)
if inst:HasTag("markable_proxy") then
table.insert(actions, ACTIONS.MARK)
end
end,
mast = function(inst, doer, actions, right)
if inst:HasTag("sailraised") then
if not doer:HasTag("is_furling") then
return table.insert(actions, ACTIONS.LOWER_SAIL_BOOST)
else
if doer.AnimState:IsCurrentAnimation("pull_big_pre") or doer.AnimState:IsCurrentAnimation("pull_big_lag") or doer.AnimState:IsCurrentAnimation("pull_big_loop") then
return table.insert(actions, ACTIONS.LOWER_SAIL_FAIL)
elseif doer.AnimState:IsCurrentAnimation("pull_small_loop") or doer.AnimState:IsCurrentAnimation("pull_small_pre") then
return table.insert(actions, ACTIONS.LOWER_SAIL_BOOST)
end
end
elseif inst:HasTag("saillowered") and not inst:HasTag("sail_transitioning") then
table.insert(actions, ACTIONS.RAISE_SAIL)
end
end,
mightygym = function(inst, doer, actions, right)
if doer:HasTag("player") and doer:HasTag("strongman") and
not inst:HasTag("hasstrongman") then
if right and inst:HasTag("loaded") then
table.insert(actions, ACTIONS.UNLOAD_GYM)
else
table.insert(actions, ACTIONS.ENTER_GYM)
end
end
end,
mine = function(inst, doer, actions, right)
if right and inst:HasTag("minesprung") and not inst:HasTag("mine_not_reusable") then
table.insert(actions, ACTIONS.RESETMINE)
end
end,
occupiable = function(inst, doer, actions)
if inst:HasTag("occupied") then
table.insert(actions, ACTIONS.HARVEST)
end
end,
oceantrawler = function(inst, doer, actions, right)
if not inst:HasTag("fire") and not inst:HasTag("burnt") then
if right then
if inst:HasTag("trawler_lowered") then
table.insert(actions, ACTIONS.OCEAN_TRAWLER_RAISE)
else
table.insert(actions, ACTIONS.OCEAN_TRAWLER_LOWER)
end
elseif inst:HasTag("trawler_fish_escaped") and not inst:HasTag("trawler_lowered") then
table.insert(actions, ACTIONS.OCEAN_TRAWLER_FIX)
end
end
end,
pinnable = function(inst, doer, actions)
if not doer:HasTag("pinned") and inst:HasTag("pinned") and inst ~= doer then
table.insert(actions, ACTIONS.UNPIN)
end
end,
pickable = function(inst, doer, actions)
if inst:HasTag("pickable") and not (inst:HasTag("fire") or inst:HasTag("intense")) then
table.insert(actions, ACTIONS.PICK)
end
end,
plantresearchable = function(inst, doer, actions, right)
if not right then
PlantRegistryResearch(inst, doer, actions)
end
end,
portablestructure = function(inst, doer, actions, right)
if right and not inst:HasTag("fire") and
(not inst:HasTag("mastercookware") or doer:HasTag("masterchef")) and
(not inst:HasTag("engineering") or doer:HasTag("portableengineer"))
then
if not inst.candismantle or inst.candismantle(inst) then
local container = inst.replica.container
if (container == nil or (container:CanBeOpened() and not container:IsOpenedBy(doer))) then
table.insert(actions, ACTIONS.DISMANTLE)
end
end
end
end,
projectile = function(inst, doer, actions)
if inst:HasTag("catchable") and doer:HasTag("cancatch") then
table.insert(actions, ACTIONS.CATCH)
end
end,
prototyper = function(inst, doer, actions, right)
if not right then
table.insert(actions, ACTIONS.OPEN_CRAFTING)
end
end,
quagmire_tappable = function(inst, doer, actions, right)
if not inst:HasTag("tappable") and not inst:HasTag("fire") then
if right then
--TAPTREE action also untaps the tree
table.insert(actions, inst:HasTag("tapped_harvestable") and doer.replica.inventory:EquipHasTag("CHOP_tool") and ACTIONS.HARVEST or ACTIONS.TAPTREE)
elseif inst:HasTag("tapped_harvestable") then
table.insert(actions, ACTIONS.HARVEST)
end
end
end,
questowner = function(inst, doer, actions, right)
if right and (inst.CanBeActivatedBy_Client == nil or inst:CanBeActivatedBy_Client(doer)) then
if inst:HasTag("questing") then
table.insert(actions, ACTIONS.ABANDON_QUEST)
else
table.insert(actions, ACTIONS.BEGIN_QUEST)
end
end
end,
repairable = function(inst, doer, actions, right)
if right and
(doer.replica.inventory ~= nil and doer.replica.inventory:IsHeavyLifting()) and
not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding()) then
local item = doer.replica.inventory:GetEquippedItem(EQUIPSLOTS.BODY)
if item ~= nil then
if (inst:HasTag("repairable_sculpture") and item:HasTag("work_sculpture"))
or (inst:HasTag("repairable_moon_altar") and item:HasTag("work_moon_altar")) then
table.insert(actions, ACTIONS.REPAIR)
end
end
end
end,
revivablecorpse = function(inst, doer, actions, right)
if inst.components.revivablecorpse:CanBeRevivedBy(doer) then
table.insert(actions, ACTIONS.REVIVE_CORPSE)
end
end,
rideable = function(inst, doer, actions, right)
if right and inst:HasTag("rideable") and
not inst:HasTag("hitched") and
(not inst:HasTag("dogrider_only") or
(inst:HasTag("dogrider_only") and doer:HasTag("dogrider"))) then
local rider = doer.replica.rider
if rider ~= nil and not rider:IsRiding() then
table.insert(actions, ACTIONS.MOUNT)
end
end
end,
rider = function(inst, doer, actions)
if inst == doer and inst.replica.rider:IsRiding() then
table.insert(actions, ACTIONS.DISMOUNT)
end
end,
searchable = function(inst, doer, actions)
if inst:HasTag("searchable") and not (inst:HasTag("fire") or inst:HasTag("intense")) then
table.insert(actions, ACTIONS.PICK)
end
end,
shelf = function(inst, doer, actions)
if inst:HasTag("takeshelfitem") then
table.insert(actions, ACTIONS.TAKEITEM)
end
end,
sittable = function(inst, doer, actions, right)
if inst:HasTag("cansit") and not inst:HasTag("fire") then
table.insert(actions, ACTIONS.SITON)
end
end,
sleepingbag = function(inst, doer, actions)
if (doer:HasTag("player") and not doer:HasTag("insomniac") and not inst:HasTag("hassleeper")) and
(not inst:HasTag("spiderden") or doer:HasTag("spiderwhisperer")) then
table.insert(actions, ACTIONS.SLEEPIN)
end
end,
steeringwheel = function(inst, doer, actions, right)
if not inst:HasTag("occupied") and not inst:HasTag("fire") then
table.insert(actions, ACTIONS.STEER_BOAT)
end
end,
stewer = function(inst, doer, actions, right)
if not inst:HasTag("burnt") and
not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding()) then
if inst:HasTag("donecooking") then
table.insert(actions, ACTIONS.HARVEST)
elseif right and (
( inst:HasTag("readytocook") and
--(not inst:HasTag("professionalcookware") or doer:HasTag("professionalchef")) and
(not inst:HasTag("mastercookware") or doer:HasTag("masterchef"))
) or
( inst.replica.container ~= nil and
inst.replica.container:IsFull() and
inst.replica.container:IsOpenedBy(doer)
)
) then
table.insert(actions, ACTIONS.COOK)
end
end
end,
stageactingprop = function(inst, doer, actions, right)
if right and inst:HasTag("stageactingprop") and doer:HasTag("stageactor") and not inst:HasTag("play_in_progress") then
table.insert(actions, ACTIONS.PERFORM)
end
end,
storytellingprop = function(inst, doer, actions, right)
if right and inst:HasTag("storytellingprop") and doer:HasTag("storyteller") then
table.insert(actions, ACTIONS.TELLSTORY)
end
end,
talkable = function(inst, doer, actions)
if inst:HasTag("maxwellnottalking") then
table.insert(actions, ACTIONS.TALKTO)
end
end,
teleporter = function(inst, doer, actions, right)
if inst:HasTag("teleporter") then
if not inst:HasTag("townportal") then
table.insert(actions, ACTIONS.JUMPIN)
elseif right and not doer:HasTag("channeling") then
table.insert(actions, ACTIONS.TELEPORT)
end
end
end,
trap = function(inst, doer, actions)
if inst:HasTag("trapsprung") then
table.insert(actions, ACTIONS.CHECKTRAP)
end
end,
trophyscale = function(inst, doer, actions, right)
if right then
if (doer.replica.inventory ~= nil and doer.replica.inventory:IsHeavyLifting()) and
not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding()) then
local item = doer.replica.inventory:GetEquippedItem(EQUIPSLOTS.BODY)
if item ~= nil then
for _,v in pairs(TROPHYSCALE_TYPES) do
if inst:HasTag("trophyscale_"..v) and item:HasTag("weighable_"..v) and item.replica.inventoryitem ~= nil and item.replica.inventoryitem:IsGrandOwner(doer) then
table.insert(actions, ACTIONS.COMPARE_WEIGHABLE)
return
end
end
end
elseif inst:HasTag("trophycanbetaken") and
not inst:HasTag("burnt") and
not inst:HasTag("fire") then
table.insert(actions, ACTIONS.REMOVE_FROM_TROPHYSCALE)
end
end
end,
unwrappable = function(inst, doer, actions, right)
if right and inst:HasTag("unwrappable") then
table.insert(actions, ACTIONS.UNWRAP)
end
end,
walkingplank = function(inst, doer, actions, right)
if right then
if doer:HasTag("on_walkable_plank") then
table.insert(actions, ACTIONS.ABANDON_SHIP)
else
if inst:HasTag("interactable") then
if inst:HasTag("plank_extended") then
table.insert(actions, ACTIONS.RETRACT_PLANK)
else
table.insert(actions, ACTIONS.EXTEND_PLANK)
end
end
end
else
if inst:HasTag("interactable") then
if inst:HasTag("plank_extended") then
table.insert(actions, ACTIONS.MOUNT_PLANK)
end
end
end
end,
wardrobe = function(inst, doer, actions, right)
if inst:HasTag("wardrobe") and not inst:HasTag("fire") and (right or not inst:HasTag("dressable")) then
table.insert(actions, ACTIONS.CHANGEIN)
end
end,
writeable = function(inst, doer, actions)
if inst:HasTag("writeable") then
table.insert(actions, ACTIONS.WRITE)
end
end,
winch = function(inst, doer, actions, right)
if right and inst:HasTag("takeshelfitem") then
table.insert(actions, ACTIONS.UNLOAD_WINCH)
end
end,
wintersfeasttable = function(inst, doer, actions, right)
if right and inst:HasTag("readyforfeast") and not inst:HasTag("fire") and not inst:HasTag("burnt") then
table.insert(actions, ACTIONS.WINTERSFEAST_FEAST)
end
end,
worldmigrator = function(inst, doer, actions)
if inst:HasTag("migrator") then
table.insert(actions, ACTIONS.MIGRATE)
end
end,
yotb_sewer = function(inst, doer, actions, right)
if not inst:HasTag("burnt") and
not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding()) then
if right and (inst:HasTag("readytosew") or
( inst.replica.container ~= nil and
inst.replica.container:IsFull() and
inst.replica.container:IsOpenedBy(doer)
)) then
table.insert(actions, ACTIONS.YOTB_SEW)
end
end
end,
yotb_stager = function(inst, doer, actions, right)
if inst:HasTag("yotb_conteststartable") and IsSpecialEventActive(SPECIAL_EVENTS.YOTB) then
table.insert(actions, ACTIONS.YOTB_STARTCONTEST)
end
if inst:HasTag("has_prize") then
table.insert(actions, ACTIONS.INTERACT_WITH)
end
end,
yotc_racecompetitor = function(inst, doer, actions, right)
if (inst:HasTag("has_prize") or inst:HasTag("has_no_prize"))
and not IsEntityDead(inst) then
table.insert(actions, ACTIONS.PICKUP)
end
end,
yotc_racestart = function(inst, doer, actions, right)
if right and not (inst:HasTag("burnt") or inst:HasTag("fire") or inst:HasTag("race_on")) then
table.insert(actions, ACTIONS.START_CARRAT_RACE)
end
end,
inventoryitemholder = function(inst, doer, actions, right)
if inst:HasTag("inventoryitemholder_take") and not inst:HasTag("fire") then
table.insert(actions, ACTIONS.TAKEITEM)
end
end,
incinerator = function(inst, doer, actions, right)
if not inst:HasTag("burnt") and not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding()) then
if right and
inst.replica.container ~= nil and
not inst.replica.container:IsEmpty() and
inst.replica.container:IsOpenedBy(doer)
then
table.insert(actions, ACTIONS.INCINERATE)
end
end
end,
},
USEITEM = --args: inst, doer, target, actions, right
{
appraisable = function(inst, doer, target, actions)
if target:HasTag("appraiser") then
table.insert(actions, ACTIONS.APPRAISE)
end
end,
bait = function(inst, doer, target, actions)
if target:HasTag("canbait") then
table.insert(actions, ACTIONS.BAIT)
end
end,
bathbomb = function(inst, doer, target, actions)
if inst:HasTag("bathbomb") and target:HasTag("bathbombable") then
table.insert(actions, ACTIONS.BATHBOMB)
end
end,
bedazzler = function(inst, doer, target, actions)
if doer:HasTag("spiderwhisperer") and target:HasTag("spiderden") and target:HasTag("bedazzleable") and not target:HasTag("bedazzled") then
table.insert(actions, ACTIONS.BEDAZZLE)
end
end,
boatpatch = function(inst, doer, target, actions)
if inst:HasTag("boat_patch") and target:HasTag("boat_leak") then
table.insert(actions, ACTIONS.REPAIR_LEAK)
end
end,
brush = function(inst, doer, target, actions, right)
if not right and target:HasTag("brushable") then
table.insert(actions, ACTIONS.BRUSH)
end
end,
carnivalgameitem = function(inst, doer, target, actions, right)
if target:HasTag("carnivalgame_canfeed") then
if target.prefab == "carnivalgame_feedchicks_nest" then
table.insert(actions, ACTIONS.CARNIVALGAME_FEED)
end
end
end,
cookable = function(inst, doer, target, actions)
if target:HasTag("cooker") and
not target:HasTag("fueldepleted") and
(not target:HasTag("dangerouscooker") or doer:HasTag("expertchef")) and
not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding() and
not (target.replica.inventoryitem ~= nil and target.replica.inventoryitem:IsGrandOwner(doer)))
then
table.insert(actions, ACTIONS.COOK)
end
end,
constructionplans = function(inst, doer, target, actions)
if target.prefab ~= nil and inst:HasTag(target.prefab.."_plans") then
table.insert(actions, ACTIONS.CONSTRUCT)
end
end,
cooker = function(inst, doer, target, actions)
if (not inst:HasTag("dangerouscooker") or doer:HasTag("expertchef")) and
target:HasTag("cookable") and
not (inst:HasTag("fueldepleted") or
target:HasTag("fire") or
target:HasTag("catchable")) then
local inventoryitem = target.replica.inventoryitem
if not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding() and
not (inventoryitem ~= nil and inventoryitem:IsGrandOwner(doer))) and
(inventoryitem == nil or inventoryitem:IsHeld() or inventoryitem:CanBePickedUp()) then
table.insert(actions, ACTIONS.COOK)
end
end
end,
drawingtool = function(inst, doer, target, actions)
if target:HasTag("drawable") then
table.insert(actions, ACTIONS.DRAW)
end
end,
dryable = function(inst, doer, target, actions)
if target:HasTag("candry") and inst:HasTag("dryable") and not target:HasTag("burnt") then
table.insert(actions, ACTIONS.DRY)
end
end,
edible = function(inst, doer, target, actions, right)
local iscritter = target:HasTag("critter")
local ishandfed = target:HasTag("handfed")
if not (target.replica.rider ~= nil and target.replica.rider:IsRiding()) and
not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding() and
not (target.replica.inventoryitem ~= nil and target.replica.inventoryitem:IsGrandOwner(doer))) and
not target:HasTag("wereplayer") then
if right or iscritter then
for k, v in pairs(FOODGROUP) do
if target:HasTag(v.name.."_eater") then
for i, v2 in ipairs(v.types) do
if inst:HasTag("edible_"..v2) then
if iscritter or ishandfed then