File size: 43,003 Bytes
b6a38d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
-- ========== GENERATED BY ClassDef Editor (Ctrl-Alt-F3) DO NOT EDIT MANUALLY! ==========

DefineClass.AL_Carry = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "civ_Walk_Carry_Start", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Walk_Carry", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "civ_Walk_Carry_End", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "MoveStyle", name = "Move Style", 
			editor = "combo", default = false, items = function (self) return GetAnimationStyleCombo() end, },
		{ category = "Ambient Life", id = "CarryDestination", name = "Destination", help = "Where the load needs to be carry to", 
			editor = "point", default = false, 
			buttons = {{name = "View", func = function(self) ViewPos(self.CarryDestination) end}}, helper = "absolute_pos", },
		{ category = "Ambient Life", id = "Teleport", name = "Teleport", 
			editor = "bool", default = false, },
		{ category = "Ambient Life", id = "GameStatesFilter", name = "States Required for Activation", 
			editor = "set", default = set( {Conflict = false} ), three_state = true, items = function (self) return GetGameStateFilter end, },
	},
	VisitPose = 1912,
	Appearance = "Legion_Jose",
	ToolEntity = "Shanty_CardboardBox_Carry",
}

function AL_Carry:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos
	
	return {self, pos, lookat}
end

function AL_Carry:GameInit()
	local valid = IsValidEntity(self.ToolEntity)
	if valid then
		if HasCollisions(self.ToolEntity) then
			StoreWarningSource(self, string.format("Spawn Tool '%s' has collision surfaces(or passability colliders) - they will bug the PF!", self.ToolEntity))
		end
		self:AttachCarryItem()
	else
		StoreErrorSource(self, string.format("Invalid ToolEntity '%s'!", self.ToolEntity))
	end
end

function AL_Carry:OnEditorSetProperty(prop_id, old_value, ged)
	if prop_id == "ToolEntity"  or prop_id == "ToolAttachOffset" or prop_id == "ToolColors" then
		self:AttachCarryItem()
	end
end

function AL_Carry:AttachCarryItem()
	if not IsValidEntity(self.ToolEntity) then return end
	
	if self.tool_attached then
		self:DestroyAttaches(self.tool_attached.class)
	end
	local marker_attach = PlaceObject(self.ToolEntity)
	if self.ToolColors then
		marker_attach:SetColorization(self.ToolColors)
	end
	self:Attach(marker_attach, self:GetSpotBeginIndex(self.ToolSpot))
	if self.ToolAttachOffset then
		marker_attach:SetAttachOffset(self.ToolAttachOffset)
	end
	
	DoneObject(self.tool_attached)
	self.tool_attached = PlaceObject(self.ToolEntity)
	if self.ToolColors then
		self.tool_attached:SetColorization(self.ToolColors)
	end
	if self.ToolAutoAttachMode then
		self.tool_attached:SetAutoAttachMode(self.ToolAutoAttachMode)
	end
	self.tool_attached:SetPos(self:GetPos())
end

function AL_Carry:CanVisit(unit, for_perpetual, dont_check_dist)
	if self:IsToolDestroyed() then
		return false
	end
	
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist)
end

function AL_Carry:EditorGetText()
	local texts = AmbientLifeMarker.EditorGetText(self)
	if  self:IsToolDestroyed() then
		texts = (texts and (texts .. "\n") or "") .. "Carry Item is destroyed!"
	end
	
	return texts
end

function AL_Carry:EditorGetTextColor()
	return self:IsToolDestroyed() and const.clrRed or AmbientLifeMarker.EditorGetTextColor(self)
end

DefineClass.AL_Cower = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Standing_Fear", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "GameStatesFilter", name = "States Required for Activation", help = "Map states requirements for the AL marker to be active.", 
			editor = "set", default = set( "Conflict" ), three_state = true, items = function (self) return GetGameStateFilter() end, },
	},
	VisitPose = 1424,
	VisitVariation = true,
	Appearance = "VillagerMale_01",
}

function AL_Cower:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

function AL_Cower:CanVisit(unit, for_perpetual, dont_check_dist)
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist)
end

DefineClass.AL_Defender_PlayAnimVariation = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "nw_Standing_Idle", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "Teleport", name = "Teleport", 
			editor = "bool", default = false, },
		{ category = "Ambient Life", id = "AllowAL", name = "Allow AL", 
			editor = "bool", default = false, },
		{ category = "Ambient Life", id = "GameStatesFilter", name = "States Required for Activation", 
			editor = "set", default = set(), three_state = true, items = function (self) return GetGameStateFilter end, },
		{ category = "Ambient Life", id = "Groups", name = "Groups", 
			editor = "string_list", default = {"AL_Defender"}, item_default = "AL_Defender", items = function (self)
local items = table.keys2(Groups or empty_table, "sorted")
table.insert(items, 1, "Closest AmbientZoneMarker")
return items
end, arbitrary_value = true, },
	},
	VisitPose = 1912,
	VisitVariation = true,
	Appearance = "Commando_Foreign_01",
}

function AL_Defender_PlayAnimVariation:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

DefineClass.AL_Football = {
	__parents = { "AmbientLifeMarker", "GameDynamicDataObject", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Ambient_PlayFootball", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "PartnerUnitDataDef", name = "Partner's Unit Data Def", 
			editor = "combo", default = false, items = function (self) return table.keys(UnitDataDefs, "sorted") end, },
		{ category = "Ambient Life", id = "PartnerLocation", name = "Partner Location", help = "The other player to pass to", 
			editor = "point", default = false, 
			buttons = {{name = "View", func = function(self) ViewPos(self.Partner) end}}, helper = "absolute_pos", helper_class = "PropertyHelper_AppearanceObjectAbsolutePos", use_object = true, },
		{ category = "Ambient Life", id = "BallSpeedMin", name = "Ball Speed Min", help = "Minimum speed of the ball", 
			editor = "number", default = 3000, scale = "m", },
		{ category = "Ambient Life", id = "BallSpeedMax", name = "Ball Speed Max", help = "Maximum speed of the ball", 
			editor = "number", default = 6000, scale = "m", },
		{ category = "Ambient Life", id = "BallRPMMin", name = "Ball RPM Min", help = "Minimum RPM of the ball", 
			editor = "number", default = 30, },
		{ category = "Ambient Life", id = "BallRPMMax", name = "Ball RPM Max", help = "Maximum RPM of the ball", 
			editor = "number", default = 80, },
		{ category = "Ambient Life", id = "unit", name = "Unit", help = "the visitor", 
			editor = "object", default = false, dont_save = true, 
			no_edit = true, base_class = "Object", format_func = function (gameobj)
	if gameobj and IsValid(gameobj) then
		local x, y = gameobj:GetPos():xy()
		local label = gameobj:GetProperty("EditorLabel") or gameobj.class
		return string.format("%s x:%d y:%d", label, x, y)
	else
		return ""
	end
end, 
},
		{ category = "Ambient Life", id = "partner", name = "Partner", help = "the actual unit - cloned from the visitor", 
			editor = "object", default = false, dont_save = true, 
			no_edit = true, base_class = "Object", format_func = function (gameobj)
	if gameobj and IsValid(gameobj) then
		local x, y = gameobj:GetPos():xy()
		local label = gameobj:GetProperty("EditorLabel") or gameobj.class
		return string.format("%s x:%d y:%d", label, x, y)
	else
		return ""
	end
end, 
},
		{ category = "Ambient Life", id = "ball", name = "Ball", help = "the ball - passed between the units", 
			editor = "object", default = false, dont_save = true, 
			no_edit = true, base_class = "Object", format_func = function (gameobj)
	if gameobj and IsValid(gameobj) then
		local x, y = gameobj:GetPos():xy()
		local label = gameobj:GetProperty("EditorLabel") or gameobj.class
		return string.format("%s x:%d y:%d", label, x, y)
	else
		return ""
	end
end, 
},
		{ category = "Ambient Life", id = "player_killed", name = "Player Killed", help = "the ball - passed between the units", 
			editor = "object", default = false, dont_save = true, 
			no_edit = true, base_class = "Object", format_func = function (gameobj)
	if gameobj and IsValid(gameobj) then
		local x, y = gameobj:GetPos():xy()
		local label = gameobj:GetProperty("EditorLabel") or gameobj.class
		return string.format("%s x:%d y:%d", label, x, y)
	else
		return ""
	end
end, 
},
	},
	Appearance = "Smiley",
	VisitPose = 2020,
}

function AL_Football:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

function AL_Football:Despawn()
	if IsValid(self.unit) then
		self.unit:SetBehavior()
		self.unit:SetCommand("Idle")
	end
	if IsValid(self.partner) then
		DoneObject(self.partner)
		self.partner = false
	end
	if IsValid(self.ball) then
		DoneObject(self.ball)
		self.ball = false
	end
	AmbientLifeMarker.Despawn(self)
end

function AL_Football:StartVisit(unit)
	self:SpawnTool(unit)
	self.ball = PlaceObject("Shanty_Ball_01")
	unit:Attach(self.ball, unit:GetSpotBeginIndex("Ball1"))
	
	self.unit = unit
	self:SpawnPartner()
	self.partner:Face(unit)
	unit:Face(self.partner)
	self:SetVisitAnimation(unit)
	if unit.perpetual_marker then
		local phase = self:Random(unit:TimeToMoment(1, "hit"))
		unit:SetPhaseHighLevel(phase)
	end
end

function AL_Football:SpawnPartner(unit)
	if IsValid(self.partner) then return end
	
	local unit_def = UnitDataDefs[self.PartnerUnitDataDef]
	
	local pers_session_id = (unit_def and (unit_def.PersistentSessionId or "") ~= "") and  unit_def.PersistentSessionId
	local session_id = pers_session_id or GenerateUniqueUnitDataId("AmbientSpawnDef", gv_CurrentSectorId or "A1", "ClonedFootballPartner")
	local unitdatadef_id = unit_def and unit_def.id or self.unit.unitdatadef_id
	
	self.partner = SpawnUnit(unitdatadef_id, session_id)
	CheckUniqueSessionId(self.partner)
	self.partner.zone = self
	self.partner:SetSide("neutral")
	self.partner.routine_spawner = self.unit.routine_spawner
	
	local appearance = ChooseUnitAppearance(unitdatadef_id, self.partner.handle)
	self.partner:ApplyAppearance(appearance)
	self.partner:SetState("civ_Standing_Idle")
	self.partner:SetPos(self.PartnerLocation)
	self.partner:SetCommand(false)
	self.partner.SetCommand = empty_func
end

function AL_Football:SetDynamicData(data)
	self.partner = data.partner and HandleToObject[data.partner] or false
	if not IsKindOf(self.partner, "Unit") then
		self.partner = false
	end
	if self.partner then
		if not self:IsPartnerDead() then
			self.partner:SetCommand(false)
			self.partner.SetCommand = empty_func
		end
	end
	self.player_killed = data.player_killed or false
end

function AL_Football:GetDynamicData(data)
	data.partner = self.partner and self.partner.handle or nil
	data.player_killed = self.player_killed or nil
end

function AL_Football:Visit(unit, dest, lookat)
	dest = dest or self:GetPos()
	
	-- going to the marker spot
	if not self:GotoEnterSpot(unit, dest) then return end
	
	-- prepare the unbreakable exit from the marker
	local tool
	unit:PushDestructor(function()
		if self.perpetual_unit then
			self.perpetual_unit = false
		end
		unit:FreeVisitable()
		if not IsValid(unit) then return end
		self:ExitVisit(unit)
		if not self:IsPartnerDead() then
			DoneObject(self.partner)
			self.partner = false
		end
		DoneObject(self.ball)
		self.ball = false
	end)
	
	local start_time = GameTime()
	self:Enter(unit, dest, lookat)
	local visit_duration = GameTime() - start_time
	if self.VisitMinDuration and visit_duration >= self.VisitMinDuration then return end
	
	-- actual visit
	self:StartVisit(unit)
	repeat
		local start_time = GameTime()
		if IsValid(unit) and not self:IsPartnerDead() then
			local _, ball_spot_index = unit:GetRandomAnim(self.VisitIdle)
			self:PlayBall(unit, self.partner, ball_spot_index)
		end
		if IsValid(unit) and not self:IsPartnerDead() then
			local _, ball_spot_index = self.partner:GetRandomAnim(self.VisitIdle)
			self:PlayBall(self.partner, unit, ball_spot_index)
		end
		Sleep(50 + self:Random(50))
		visit_duration = visit_duration + (GameTime() - start_time)
	until self:IsPartnerDead() or (self.perpetual_unit and self.perpetual_unit ~= unit) or (self.VisitMinDuration and visit_duration >= self.VisitMinDuration)
	
	-- unbreakable exit from the marker
	unit:PopAndCallDestructor()
end

function AL_Football:PlayBall(unit, partner, ball_spot_index)
	Sleep(unit:TimeToMoment(1, "hit") or 0)
	self.ball:Detach()
	if not self:IsPartnerDead() then
		self:ShootBall(partner, ball_spot_index, unit, unit:TimeToAnimEnd())
	end
end

function AL_Football:IsPartnerDead()
	return IsValid(self.partner) and self.partner:IsDead()
end

function AL_Football:EditorGetText()
	if self.player_killed then
		return "AL CAN'T Visit(Inactive do the dead player)"
	end
	
	return AmbientLifeMarker.EditorGetText(self)
end

function AL_Football:EditorGetTextColor()
	if self.player_killed then
		return const.clrRed
	end
	
	return AmbientLifeMarker.EditorGetTextColor(self)
end

function AL_Football:CanVisit(unit, for_perpetual, dont_check_dist)
	if self.player_killed or not IsValid(self.partner) then
		return false
	end
	
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist)
end

function AL_Football:ShootBall(target, ball_spot_index, ball_dest, kicker, kicker_time_end)
	if target:GetEnumFlags(const.efVisible) ~= 0 then
		self.ball:SetEnumFlags(const.efVisible)
	else
		self.ball:ClearEnumFlags(const.efVisible)
	end
	
	local target_spot = "Ball" .. ball_spot_index
	local ball_spot = target:GetSpotBeginIndex(target_spot)
	local ball_dest = target:GetSpotPos(ball_spot)
	local ball_start = self.ball:GetPos()
	local ball_dir = ball_dest - ball_start
	local ball_speed = self.BallSpeedMin + self:Random(self.BallSpeedMax - self.BallSpeedMin)
	local ball_travel_time = MulDivTrunc(ball_dir:Len(), 1000, ball_speed)
	local rpm = self.BallRPMMin * 360+ self:Random((self.BallRPMMax - self.BallRPMMin) * 360)
	local angle = MulDivTrunc(rpm, ball_travel_time, 1000)
	local axis = Rotate(ball_dir, 90 * 60)
	self.ball:SetAxis(axis)
	self.ball:SetPos(ball_dest, ball_travel_time)
	
	local suffix = (ball_spot_index == 1) and "" or tostring(ball_spot_index)
	local target_football_anim = self.VisitIdle .. suffix
	local recieve_moment = target:GetAnimMoment(target_football_anim, "start")
	ball_travel_time = (ball_travel_time < recieve_moment) and recieve_moment or ball_travel_time
	local target_time_recieve = ball_travel_time - recieve_moment
	local time, dt_sleep = 0, 10
	while not self:IsPartnerDead() and time < ball_travel_time do
		local dt = Min(dt_sleep, ball_travel_time - time)
		dt = kicker_time_end and Min(dt, kicker_time_end - time) or dt
		dt = target_time_recieve and Min(dt, target_time_recieve - time) or dt
		self.ball:SetAngle(self.ball:GetAngle() + MulDivTrunc(dt, angle, ball_travel_time))
		Sleep(dt)
		time = time + dt
		if kicker_time_end and time >= kicker_time_end then
			local idle_base = (self:Random(100) < 50) and "civ_Standing_Idle" or "civ_Standing_IdlePassive"
			local idle_anim = kicker:GetNearbyUniqueRandomAnim(idle_base)
			kicker:SetState(idle_anim)
			kicker_time_end = false
		end
		if target_time_recieve and time >= target_time_recieve then
			target:SetState(target_football_anim)
			target_time_recieve = false
		end
	end
	self.ball:SetAxis(axis_z)
	self.ball:SetPos(ball_dest)
end

function AL_Football:OnHelperCreated(helper)
	helper:ApplyAppearance(self.Appearance)
end

DefineClass.AL_Maraud = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Ambient_FindSomething", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ id = "corspe", name = "Corspe", 
			editor = "object", default = false, dont_save = true, read_only = true, base_class = "Object", format_func = function (gameobj)
	if gameobj and IsValid(gameobj) then
		local x, y = gameobj:GetPos():xy()
		local label = gameobj:GetProperty("EditorLabel") or gameobj.class
		return string.format("%s x:%d y:%d", label, x, y)
	else
		return ""
	end
end, 
},
	},
	VisitPose = 912,
	VisitVariation = true,
	IgnoreGroupsMatch = true,
}

function AL_Maraud:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

function AL_Maraud:CanVisit(unit, for_perpetual, dont_check_dist)
	if unit.ImportantNPC then
		return false
	end
	
	if self.corpse and unit:GetSide() == "neutral" then
		if not IsKindOf(self.corpse, "Unit") then
			-- Somehow Units becomes an ItemDropContainer
			return false
		end
		local side = self.corpse:GetSide()
		if not (side == "enemy1" or side == "enemy2" or side == "player1" or side == "player2") then
			return false
		end
	end
	
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist)
end

function AL_Maraud:EditorGetText()
	if not IsValid(self.corpse) then
		return "AL CAN'T Visit(Corpse is missing)"
	end
	if not IsKindOf(self.corpse, "Unit") then
		return "AL CAN'T Visit(Corpse is not Unit?!?)"
	end
	
	return AmbientLifeMarker.EditorGetText(self)
end

function AL_Maraud:EditorGetTextColor()
	if not IsValid(self.corpse) or not IsKindOf(self.corpse, "Unit") then
		return const.clrRed
	end
	
	return AmbientLifeMarker.EditorGetTextColor(self)
end

function AL_Maraud:GetDynamicData(data)
	data.corpse = self.corpse and self.corpse.handle or false
end

function AL_Maraud:SetDynamicData(data)
	self.corpse = data.corpse and HandleToObject[data.corpse] or false
end

function AL_Maraud:OnVisitAnimEnded(unit)
	local item = self.corpse:FindItemInSlot("InventoryDead", function(item, self)
		if IsKindOf(item, "Valuables") then
			if self:Random(100) < item.drop_chance then
				return item
			end
		end
	end, self)
	if not item then
		item = self.corpse:FindItemInSlot("InventoryDead", function(item, self)
			if not IsKindOf(item, "Valuables") then
				if self:Random(100) < item.drop_chance then
					return item
				end
			end
		end, self)
	end
	if item then
		self.corpse:RemoveItem("InventoryDead", item)
		unit:AddItem("Inventory", item)
		CreateFloatingText(unit:GetVisualPos(),  T(911186423849, "Picked up something"))
	end
end

DefineClass.AL_MineWorkPick = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Work_Pick", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
	},
	ToolEntity = "Mine_PickAxe",
	VisitPose = 1912,
}

function AL_MineWorkPick:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

DefineClass.AL_MineWorkShovel = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Work_Shovel", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
	},
	ToolEntity = "Mine_Shovel",
	VisitPose = 8154,
}

function AL_MineWorkShovel:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

DefineClass.AL_MineWorkSift = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Work_Sift", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
	},
	ToolEntity = "Mine_WoodenTray",
	VisitPose = 8154,
}

function AL_MineWorkSift:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

DefineClass.AL_Mourn = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Ambient_SadCrying", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ id = "corspe", name = "Corspse", 
			editor = "object", default = false, dont_save = true, read_only = true, base_class = "Object", format_func = function (gameobj)
	if gameobj and IsValid(gameobj) then
		local x, y = gameobj:GetPos():xy()
		local label = gameobj:GetProperty("EditorLabel") or gameobj.class
		return string.format("%s x:%d y:%d", label, x, y)
	else
		return ""
	end
end, 
},
	},
	VisitPose = 1312,
	VisitVariation = true,
	IgnoreGroupsMatch = true,
}

function AL_Mourn:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

function AL_Mourn:CanVisit(unit, for_perpetual, dont_check_dist)
	if unit.ImportantNPC then
		return false
	end
	
	if self.corpse and unit:GetSide() == "neutral" then
		if not IsKindOf(self.corpse, "Unit") then
			-- Somehow Units becomes an ItemDropContainer
			return false
		end
		local side = self.corpse:GetSide()
		if side == "enemy1" or side == "enemy2" or side == "neutral" then
			return false
		end
	end
	
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist)
end

function AL_Mourn:EditorGetText()
	if not IsValid(self.corpse) then
		return "AL CAN'T Visit(Corpse is missing)"
	end
	if not IsKindOf(self.corpse, "Unit") then
		return "AL CAN'T Visit(Corpse is not Unit?!?)"
	end
	
	return AmbientLifeMarker.EditorGetText(self)
end

function AL_Mourn:EditorGetTextColor()
	if not IsValid(self.corpse) or not IsKindOf(self.corpse, "Unit") then
		return const.clrRed
	end
	
	return AmbientLifeMarker.EditorGetTextColor(self)
end

function AL_Mourn:GetDynamicData(data)
	data.corpse = self.corpse and self.corpse.handle or false
end

function AL_Mourn:SetDynamicData(data)
	self.corpse = data.corpse and HandleToObject[data.corpse] or false
end

DefineClass.AL_PlayAnimVariation = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "nw_Standing_Idle", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "Teleport", name = "Teleport", 
			editor = "bool", default = false, },
		{ category = "Ambient Life", id = "GameStatesFilter", name = "States Required for Activation", 
			editor = "set", default = set( {Conflict = false} ), three_state = true, items = function (self) return GetGameStateFilter end, },
	},
	VisitPose = 1912,
	VisitVariation = true,
	Appearance = "Legion_Jose",
}

function AL_PlayAnimVariation:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

DefineClass.AL_Prostitute_Idle = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Seduce_Idle", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
	},
	VisitPose = 1912,
	VisitVariation = true,
	Appearance = "VillagerFemale_01",
}

function AL_Prostitute_Idle:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

function AL_Prostitute_Idle:CanVisit(unit, for_perpetual, dont_check_dist)
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist) and unit:IsProstitute()
end

DefineClass.AL_Prostitute_Parade = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Seduce_Parade", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
	},
	VisitPose = 11477,
	VisitVariation = true,
	Appearance = "VillagerFemale_01",
}

function AL_Prostitute_Parade:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

function AL_Prostitute_Parade:CanVisit(unit, for_perpetual, dont_check_dist)
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist) and unit:IsProstitute()
end

DefineClass.AL_Roam = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Standing_Idle", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "Teleport", name = "Teleport", 
			editor = "bool", default = false, },
		{ category = "Ambient Life", id = "DontReorient", name = "Don't Reorient", help = "Does not reorient the unit to marker position", 
			editor = "bool", default = false, },
		{ category = "Ambient Life", id = "GameStatesFilter", name = "States Required for Activation", 
			editor = "set", default = set( {Conflict = false} ), three_state = true, items = function (self) return GetGameStateFilter end, },
	},
	VisitPose = 1912,
	VisitVariation = true,
	Appearance = "VillagerFemale_01",
}

function AL_Roam:ApplyAppearance(appearance, force)
	AppearanceObject.ApplyAppearance(self, appearance, force)
	
	local clr = const.clrGreen
	self:SetColorModifier(clr)
	for _, part in ipairs(self.parts) do
		part:SetColorModifier(clr)
	end
end

DefineClass.AL_SitChair = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "civ_Sit_Start", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Sit_Idle", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "civ_Sit_End", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "Teleport", name = "Teleport", 
			editor = "bool", default = false, },
		{ category = "Ambient Life", id = "GameStatesFilter", name = "States Required for Activation", 
			editor = "set", default = set( {Conflict = false} ), three_state = true, items = function (self) return GetGameStateFilter end, },
		{ category = "Ambient Life", id = "EditorMarkerVisitAnim", name = "Editor Marker Visit Anim", 
			editor = "combo", default = "editorMarkerAnim_Sit", items = function (self) return GetStates("Male") end, },
	},
	VisitPose = 16,
	Appearance = "Legion_Jose",
	VisitSupportCollectionVME = true,
}

function AL_SitChair:CanVisit(unit, for_perpetual, dont_check_dist)
	local enemy, dist = GetNearestEnemy(unit, "ignore awareness")
	if enemy and dist <= const.AmbientLife.ForbidSitChairEnemyDist then
		return false
	end
	
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist)
end

DefineClass.AL_SitChair_SleepingAtTable = {
	__parents = { "AL_SitChair", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "civ_Ambient_SleepingAtTable_Start", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Ambient_SleepingAtTable", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "civ_Ambient_SleepingAtTable_End", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "Teleport", name = "Teleport", 
			editor = "bool", default = false, },
		{ category = "Ambient Life", id = "GameStatesFilter", name = "States Required for Activation", 
			editor = "set", default = set( {Conflict = false} ), three_state = true, items = function (self) return GetGameStateFilter end, },
		{ category = "Ambient Life", id = "EditorMarkerVisitAnim", name = "Editor Marker Visit Anim", 
			editor = "combo", default = "editorMarkerAnim_Sit", items = function (self) return GetStates("Male") end, },
	},
	VisitPose = 16,
	Appearance = "Legion_Jose",
	VisitSupportCollectionVME = true,
}

function AL_SitChair_SleepingAtTable:CanVisit(unit, for_perpetual, dont_check_dist)
	local enemy, dist = GetNearestEnemy(unit, "ignore awareness", dont_check_dist)
	if enemy and dist <= const.AmbientLife.ForbidSitChairEnemyDist then
		return false
	end
	
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist)
end

DefineClass.AL_Talk = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "nw_Standing_IdlePassive", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitAlternate", name = "During Visit Alternate", help = 'There is some chance to play this animation instead of the original "During Visit" one', 
			editor = "combo", default = "civ_Talking", 
			no_edit = function(self) return self.VisitAlternateChance == 0 end, items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
	},
	VisitPose = 8866,
	VisitVariation = true,
	VisitAlternateVariation = true,
	VisitAlternateChance = 50,
	EmotionChance = 10,
	Appearance = "VillagerMale_02",
}

function AL_Talk:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

DefineClass.AL_WallLean = {
	__parents = { "AmbientLifeMarker", "GroundAlignedObj", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "civ_Wall_Start", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Wall_Idle", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "civ_Wall_End", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "Teleport", name = "Teleport", 
			editor = "bool", default = false, },
		{ category = "Ambient Life", id = "GameStatesFilter", name = "States Required for Activation", 
			editor = "set", default = set( {Conflict = false} ), three_state = true, items = function (self) return GetGameStateFilter end, },
		{ category = "Ambient Life", id = "EditorMarkerVisitAnim", name = "Editor Marker Visit Anim", 
			editor = "combo", default = "editorMarkerAnim_Wall", items = function (self) return GetStates("Male") end, },
	},
	VisitPose = 16,
	Appearance = "Legion_Jose",
	VisitSupportCollectionVME = true,
}

function AL_WallLean:CanVisit(unit, for_perpetual, dont_check_dist)
	local enemy, dist = GetNearestEnemy(unit, "ignore awareness")
	if enemy and dist <= const.AmbientLife.ForbidWallLeanEnemyDist then
		return false
	end
	
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist)
end

function AL_WallLean:EditorCallbackPlace(...)
	AlignedObj.EditorCallbackPlace(self, ...)
	AmbientLifeMarker.EditorCallbackPlace(self, ...)
end

function AL_WallLean:EditorCallbackRotate(...)
	AlignedObj.EditorCallbackRotate(self, ...)
	AmbientLifeMarker.EditorCallbackRotate(self, ...)
end

function AL_WallLean:EditorCallbackScale(...)
	AlignedObj.EditorCallbackScale(self, ...)
	AmbientLifeMarker.EditorCallbackScale(self, ...)
end

function AL_WallLean:EditorCallbackMove(...)
	AlignedObj.EditorCallbackMove(self, ...)
	AmbientLifeMarker.EditorCallbackMove(self, ...)
end

DefineClass.AL_WallLean_NoSnap = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "civ_Wall_Start", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Wall_Idle", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "civ_Wall_End", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "Teleport", name = "Teleport", 
			editor = "bool", default = false, },
		{ category = "Ambient Life", id = "GameStatesFilter", name = "States Required for Activation", 
			editor = "set", default = set( {Conflict = false} ), three_state = true, items = function (self) return GetGameStateFilter end, },
		{ category = "Ambient Life", id = "EditorMarkerVisitAnim", name = "Editor Marker Visit Anim", 
			editor = "combo", default = "editorMarkerAnim_Wall", items = function (self) return GetStates("Male") end, },
	},
	VisitPose = 16,
	Appearance = "Legion_Jose",
	VisitSupportCollectionVME = true,
}

function AL_WallLean_NoSnap:CanVisit(unit, for_perpetual, dont_check_dist)
	local enemy, dist = GetNearestEnemy(unit, "ignore awareness")
	if enemy and dist <= const.AmbientLife.ForbidWallLeanEnemyDist then
		return false
	end
	
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist)
end

DefineClass.AL_WallLean_Prostitute = {
	__parents = { "AmbientLifeMarker", "GroundAlignedObj", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "civ_Seduce_Wall", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
	},
	VisitPose = 3267,
	VisitVariation = true,
	Appearance = "VillagerFemale_01",
	VisitSupportCollectionVME = true,
}

function AL_WallLean_Prostitute:CanVisit(unit, for_perpetual, dont_check_dist)
	if not  unit:IsProstitute() then
		return false
	end
	
	local enemy, dist = GetNearestEnemy(unit, "ignore awareness")
	if enemy and dist <= const.AmbientLife.ForbidWallLeanEnemyDist then
		return false
	end
	
	return AmbientLifeMarker.CanVisit(self, unit, for_perpetual, dont_check_dist)
end

function AL_WallLean_Prostitute:EditorCallbackPlace(...)
	AlignedObj.EditorCallbackPlace(self, ...)
	AmbientLifeMarker.EditorCallbackPlace(self, ...)
end

function AL_WallLean_Prostitute:EditorCallbackRotate(...)
	AlignedObj.EditorCallbackRotate(self, ...)
	AmbientLifeMarker.EditorCallbackRotate(self, ...)
end

function AL_WallLean_Prostitute:EditorCallbackScale(...)
	AlignedObj.EditorCallbackScale(self, ...)
	AmbientLifeMarker.EditorCallbackScale(self, ...)
end

function AL_WallLean_Prostitute:EditorCallbackMove(...)
	AlignedObj.EditorCallbackMove(self, ...)
	AmbientLifeMarker.EditorCallbackMove(self, ...)
end

DefineClass.AL_WeaponAim = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "ar_Standing_Aim", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "Weapon", name = "Weapon", 
			editor = "combo", default = "DoubleBarrelShotgun", items = function (self) return InventoryItemWeaponsCombo end, },
	},
	VisitPose = 1912,
	VisitVariation = true,
}

function AL_WeaponAim:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end

DefineClass.AL_WeaponIdle = {
	__parents = { "AmbientLifeMarker", },
	__generated_by_class = "ClassDef",

	properties = {
		{ category = "Ambient Life", id = "VisitEnter", name = "Entering Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitIdle", name = "During Visit", 
			editor = "combo", default = "ar_Standing_Idle", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "VisitExit", name = "Exit Visit", 
			editor = "combo", default = "", items = function (self) return GetStates("Male") end, },
		{ category = "Ambient Life", id = "Weapon", name = "Weapon", 
			editor = "combo", default = "DoubleBarrelShotgun", items = function (self) return InventoryItemWeaponsCombo end, },
	},
	VisitPose = 1912,
	VisitVariation = true,
}

function AL_WeaponIdle:GenerateVisitable()
	local pos = self:GetPos()
	local lookat = pos + Rotate(point(const.SlabSizeX, 0), self:GetAngle())
	
	return {self, pos, lookat}
end