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 
 
 
 
 
 
 
 
 
 
 
 
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
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
# CObject Overview

CObjects are objects, accessible to Lua, which have a counterpart in the C++ side of the engine.

They do not have allocated memory in the Lua side, and therefore cannot store any information.

Reference: [CObject](LuaCObject.md.html)

# Parent classes

* ColorizableObject
* FXObject
* MapObject
* [PropertyObject](LuaClasses.md.html#propertyobject)

# CObject reference


## CObject:Attach

Attaches one object to another at a specified spot.


void **CObject:Attach**(object child, int spot)
object child
: object to be attached

int spot
: spot numeric index


## CObject:ChangeEntity

Changes the object's entity.


void **CObject:ChangeEntity**(string entity)
string entity
: the entity name


## CObject:ClearEnumFlags

Clear the object's enumeration flags.


void **CObject:ClearEnumFlags**(int mask)
int mask
: mask containing the flags to be cleared.

Example:

~~~~ Lua
obj:ClearEnumFlags(const.efVisible)
-- the object is now invisible
~~~~

## CObject:ClearGameFlags

Clear the object's game flags.


void **CObject:ClearGameFlags**(int mask)
int mask
: mask containing the flags to be cleared.

Example:

~~~~ Lua
obj:ClearGameFlags(const.gofAlwaysRenderable)
-- the object wont be drawn when outside the camera view
~~~~

## CObject:CountAttaches

Counts object attaches based on certain criteria


int **CObject:CountAttaches**([string classes], [function filter], ...)
string classes
: an optional comma separated list of classes, to filter the attached objects. If not provided, all attaches shall be processed.

function filter
: an optional function to test if an attach is to be counted. Any parameter provided after the callback, would be passed to it when called.

_returns_ int
: the count of matched attaches.

Example:

~~~~ Lua
local count = obj:CountAttaches("foo, bar", function(obj) return not obj:GetVisible() end)
-- 'count' equals the number of the invisible attaches form the classes "foo" and "bar"
~~~~

## CObject:DestroyAttaches

Destroys object attaches based on certain criteria


int **CObject:DestroyAttaches**([string classes], [function filter], ...)
string classes
: an optional comma separated list of classes, to filter the attached objects. If not provided, all attaches shall be processed.

function filter
: an optional function to test if an attach is to be deleted. Any parameter provided after the callback, would be passed to it when called.

_returns_ int
: the count of matched attaches.

Example:

~~~~ Lua
obj:DestroyAttaches("foo, bar", function(obj) return not obj:GetVisible() end)
-- all invisible attaches form the classes "foo" and "bar" are now destroyed
~~~~

## CObject:Detach

Detach an attached object from its parent.


void **CObject:Detach**()

## CObject:DetachFromMap

Removes the object from the map. The object's position wont be valid any more.


void **CObject:DetachFromMap**()

## CObject:ForEachAttach

Calls a function callback for each attached object from a list of classes


int **CObject:ForEachAttach**([string classes], function callback, ...)
string classes
: an optional comma separated list of classes, to filter the attached objects. If not provided, all attaches shall be processed.

function callback
: a function to call for each attach. Any parameter provided after the callback, would be passed to it when called.

_returns_ int
: the count of matched attaches.

Example:

~~~~ Lua
obj:ForEachAttach("foo, bar", function(obj, visible) obj:SetVisible(visible) end, false)
-- all attaches form the classes "foo" and "bar" are now invisible
~~~~

## CObject:GetAccelerationAndTime

Computes the linear acceleration and the time needed to reach a target position with a given final speed.


int, int **CObject:GetAccelerationAndTime**(point pos, int speed, [int speed0])

int, int **CObject:GetAccelerationAndTime**(int x, int y, int z, int speed, [int speed0])
point pos
: the target position as a point

int x, y, z
: the target position as coordinates

int speed
: the desired final speed

int speed0
: the initial speed (optional, the current speed by default)

_returns_ int, int
: the acceleration and the time

Example:

~~~~ Lua
local accel, time = obj:GetAccelerationAndTime(pos, 0)
obj:SetAcceleration(accel)
obj:SetPos(pos, time)
-- the object will slowly stop at the target position
~~~~

## CObject:GetAngle

Returns the final rotation angle of an object.

The visual angle is different from the final angle, only when the object is still rotating.


int **CObject:GetAngle**()
_returns_ int
: final rotation angle.


## CObject:GetAttaches

Collects the attaches from given class(es). If no class is specified, then all attached objects shall be collected.


table **CObject:GetAttaches**([string class])

table **CObject:GetAttaches**([table classes])
string class
: an optional class name, to filter the attached objects.

table classes
: an optional class list, to filter the attached objects.

_returns_ table
: a list containing the matched attaches, or nil if none has been found.

Example:

~~~~ Lua
local attaches = obj:GetAttaches("foo")
-- 'attaches' containts all attached objects form the class "foo"
~~~~

## CObject:GetAxis

Returns the rotation axis of an object.


point **CObject:GetAxis**()
_returns_ point
: rotation axis vector as point


## CObject:GetClassFlags

Returns the object's class flags. All object flags are represented as a single bit (0 or 1).


int **CObject:GetClassFlags**([int mask])
int mask
: optional flag mask, used to check if the object contains specific flags.

_returns_ int
: the object's enumeration flags, masked with the mask if provided.

Example:

~~~~ Lua
if obj:GetClassFlags(const.cfDecal) ~= 0 then
-- the object is a decal
end
~~~~

## CObject:GetDist

Computes the distance from the object's final position to another position.


int **CObject:GetDist**(object obj)

int **CObject:GetDist**(box bx)

int **CObject:GetDist**(point pos)
object obj
: check distance to an object

box bx
: check distance to a box

point pos
: check distance to a position

_returns_ int
: the computed distance


## CObject:GetEntityBBox

Returns the bounding box of the current state of the object with mirroring applied, but without applying object's position, scale and orientation.


box **CObject:GetEntityBBox**()
_returns_ box
: the bounding box of the entity.


## CObject:GetEnumFlags

Returns the object's enumeration flags. All object flags are represented as a single bit (0 or 1).


int **CObject:GetEnumFlags**([int mask])
int mask
: optional flag mask, used to check if the object contains specific flags.

_returns_ int
: the object's enumeration flags, masked with the mask if provided.

Example:

~~~~ Lua
if obj:GetEnumFlags(const.efVisible) ~= 0 then
-- the object is visible
end
~~~~

## CObject:GetFreeSpot

Returns an index of a spot from a given type with no attaches


int **CObject:GetFreeSpot**(string spot)
string spot
: spot type name

_returns_ int
: the spot index, -1 if not found.


## CObject:GetGameFlags

Returns the object's game flags. All object flags are represented as a single bit (0 or 1).


int **CObject:GetGameFlags**([int mask])
int mask
: optional flag mask, used to check if the object contains specific flags.

_returns_ int
: the object's game flags, masked with the mask if provided.

Example:

~~~~ Lua
if obj:GetGameFlags(const.gofAlwaysRenderable) ~= 0 then
-- the object is drawn even when outside the camera view
end
~~~~

## CObject:GetMaxRadius

Returns the maximim object's entity radius in any of its states (animations).


int **CObject:GetMaxRadius**()
_returns_ int
: object's max radius.


## CObject:GetNearestSpot

Returns the index of the nearest spot to a specified location


int **CObject:GetNearestSpot**(string spot, point pos)

int **CObject:GetNearestSpot**(string spot, object obj)
string spot
: spot type name

point pos
: location as point

object obj
: location as object

_returns_ int
: the spot index, -1 if not found.


## CObject:GetNumStates

Returns the number of valid states (animations) for current object.


int **CObject:GetNumStates**()
_returns_ int
: number of states


## CObject:GetObjectBBox

Returns the object's bounding box in its current state (animation).


box **CObject:GetObjectBBox**()
_returns_ box
: the object's bounding box.


## CObject:GetParent

Returns the parent object (if the current object is attached).


object **CObject:GetParent**()
_returns_ object
: the parent object if any, nil otherwise


## CObject:GetPos

Returns the final map position of an object .

The visual position is different from the final position, only when the object is still moving.


point **CObject:GetPos**()
_returns_ point
: final map position.


## CObject:GetPosXYZ

Same as GetPos, but returns the coordinates of the position.


int, int, int **CObject:GetPosXYZ**()
_returns_ int, int, int
: coordinates of the final map position.


## CObject:GetRadius

Returns the object's entity radius in its current state (animation). For objects without entity, the radius can be specified as a member 'radius' in the class definition.


int **CObject:GetRadius**()
_returns_ int
: object's radius.


## CObject:GetRandomSpot

Returns the index of a random spot from a given type


int **CObject:GetRandomSpot**(string spot)
string spot
: spot type name

_returns_ int
: the spot index, -1 if not found.


## CObject:GetRelativePoint

Computes the world position of a point relative to an object.


point **CObject:GetRelativePoint**(point pos)

point **CObject:GetRelativePoint**(int x, int y, int z)
point pos
: position relative to the object as a point.

int x, y, z
: position relative to the object as coordinates.

Example:

~~~~ Lua
local pos = obj:GetRelativePoint(0, 0, 10*guim)
-- 'pos' is located 10 meters above the object
~~~~

## CObject:GetRollPitchYaw

Returns the object's orientation as roll, pitch and yaw angles.


int **CObject:GetRollPitchYaw**([int time_delta])
int time_delta
: optional time interval in the future, thus enabling to get a future orientation.

_returns_ int, int, int
: the object's roll, pitch and yaw angle.


## CObject:GetScale

Returns the object's scale (disregarding parent hierarchy).


int **CObject:GetScale**()
_returns_ int
: the object's scale in percent (100% is the default).


## CObject:GetSpotAxisAngle

Returns the rotation of the specified spot around it's rotation axis.


angle axis **CObject:GetSpotAxisAngle**(int spot)
int spot
: spot index.

_returns_ point axis
: the spot rotation axis vector as point.

_returns_ int angle
: the spot rotation.


## CObject:GetSpotBeginIndex

Returns the first spot index from a given spot type for an object


int, int **CObject:GetSpotBeginIndex**(string spot)
string spot
: spot name

_returns_ int
: the spot index, -1 if not found.


## CObject:GetSpotEndIndex

Returns the last spot index from a given spot type for an object


int, int **CObject:GetSpotEndIndex**(string spot)
string spot
: spot name

_returns_ int
: the spot index, -1 if not found.


## CObject:GetSpotPos

Returns the final world position of the specified spot.


point **CObject:GetSpotPos**(int spot)
int spot
: spot index.

_returns_ point
: the spot position.


## CObject:GetSpotPosXYZ

Same as GetSpotPos but the returned values are the position's coordinates.


int, int, int **CObject:GetSpotPosXYZ**(int spot)
int spot
: spot index.

_returns_ int, int, int
: the coordinates of the spot position.


## CObject:GetSpotRange

Returns the first and the last spot indexes from a given spot type for an object


int, int **CObject:GetSpotRange**(string spot)
string spot
: spot name

_returns_ int, int
: the spot indexes, -1 if not found.


## CObject:GetState

Gets the object's current state index (animation index).


int **CObject:GetState**()
_returns_ int
: the state index


## CObject:GetVisualAngle

Returns the visual rotation angle of an object.

The visual angle is different from the final angle, only when the object is still rotating.


int **CObject:GetVisualAngle**()
_returns_ int
: visual rotation angle.


## CObject:GetVisualDist

Computes the distance from the object's visual position to another position.


int **CObject:GetVisualDist**(object obj)

int **CObject:GetVisualDist**(box bx)

int **CObject:GetVisualDist**(point pos)
object obj
: check distance to an object

box bx
: check distance to a box

point pos
: check distance to a position

_returns_ int
: the computed distance


## CObject:GetVisualPos

Returns the visual position of an object.

The visual position is different from the final position, only when the objects is still moving.


point **CObject:GetVisualPos**([int time_delta = 0], [bool extrapolate = false])
int time_delta
: optional parameter to specify a different moment than now.

bool extrapolate
: if true and if the provided time exceeds the movement time, avoids the clamping.

_returns_ point
: visual position.


## CObject:GetVisualPos2D

Same as GetVisualPos, but the returned position is only two dimensional.


point **CObject:GetVisualPos2D**([int time], [bool extrapolate = false])
_returns_ point
: visual 2D position.


## CObject:GetVisualPosXYZ

Same as GetVisualPos, but the returned values are the object coordinates.


int, int, int **CObject:GetVisualPosXYZ**([int time_delta = 0], [bool extrapolate = false])
_returns_ int, int, int
: visual coordinates X, Y and Z.


## CObject:GetVisualScale

Returns the object's current visual scale (disregarding parent hierarchy).


int **CObject:GetVisualScale**(int delta = 0)
_returns_ int
: the object's scale in percent (100% is the default).


## CObject:GetVisualWorldScale

Returns the object's world current visual scale (considering parent hierarchy).


int **CObject:GetVisualWorldScale**(int delta = 0)
_returns_ int
: the object's world scale in percent (100% is the default).


## CObject:GetVisualZ

Same as GetVisualPos, but returns only the Z coordinate of the visual map position.


int **CObject:GetVisualZ**([int time_delta = 0], [bool extrapolate = false])
_returns_ int
: Z coordinate of the visual map position.


## CObject:GetWorldScale

Returns the object's world scale (considering parent hierarchy).


int **CObject:GetWorldScale**()
_returns_ int
: the object's world scale in percent (100% is the default).


## CObject:GetZ

Same as GetPos, but returns only the Z coordinate of the final map position, or nil if on the terrain.


int **CObject:GetZ**()
_returns_ int
: Z coordinate of the final map position.


## CObject:HasAllSurfaces

Checks if the object's entity has specific surfaces.


bool **CObject:HasAllSurfaces**(int mask, [bool hierarchical])
int mask
: A mask of the surfaces in question. See the 'EntitySurfaces' global for a list of surfaces and their masks.

bool hierarchical
: Checks the attached objects too.

_returns_ bool
: Returns true if the entity has all of those surfaces.


## CObject:HasAnySurfaces

Checks if the object's entity has specific surfaces.


bool **CObject:HasAnySurfaces**(int mask, [bool hierarchical])
int mask
: A mask of the surfaces in question. See the 'EntitySurfaces' global for a list of surfaces and their masks.

bool hierarchical
: Checks the attached objects too.

_returns_ bool
: Returns true if the entity has any of those surfaces.


## CObject:HasEntity

Checks if an object has an entity.


bool **CObject:HasEntity**()
_returns_ bool
: true if entity is present.


## CObject:HasSpot

Checks if an object has a given spot type.


bool **CObject:HasSpot**(string spot)
string spot
: the spot name to be checked

_returns_ bool
: true if the spot is present.


## CObject:HasState

Checks if the object's entity has a given state (animation).


bool **CObject:HasState**(string name)

bool **CObject:HasState**(int index)
string name
: the state name to check for

int index
: the state index to check for

_returns_ bool
: Returns true if the state is present


## CObject:IntersectBBox

Intersects object's bounding box in its current state/animation with a given box or point.


int **CObject:IntersectBBox**(box/point, b2D = false)
_returns_ int/bool
: intersection result.


## CObject:IsAnimEnd

Returns if the current phase is the last anim phase


int **CObject:IsAnimEnd**([int channel = 1])
int channel
: optional animation channel

_returns_ bool
: true if the current phase is the last anim phase


## CObject:IsReachableFrom

Checks if any of the source points can reach any of the approach points.

The function makes a single path finding call. In order to work correctly, all pass tunnels have to be symetrical (no one way tunnels).


bool **CObject:IsReachableFrom**(table sources, int pfclass = 0, int restrict_dist = 150*guim)
table sources
: Table with points or objects or a single object

int pfclass
: Optional pfclass

int restrict_dist
: Optional restrict distance


## CObject:IsSoundMuted

Returns  the value of the sound mute flag for an object.


void **CObject:IsSoundMuted**()

## CObject:IsValidPos

Checks if an object is present on the map


bool **CObject:IsValidPos**()
_returns_ bool
: returns true, if the object has a position on the map.


## CObject:IsValidZ

Checks if the object position has a valid Z coordinate. Objects with invalid Z are always drawn on the terrain surface.


bool **CObject:IsValidZ**()
_returns_ bool
: returns true, if the object has a valid Z coordinate.


## CObject:PlayState

Similar to SetState, but waits until the state animation is played before returning.


void **CObject:PlayState**(string name, [int count = 1, int flags = 0, int crossfade = -1])

void **CObject:PlayState**(int index, [int count = 1, int flags = 0, int crossfade = -1])
string name
: the state name to check for

string index
: the state index to check for

int count
: optional count of animation replays (for looped animations only)

int flags
: optional animation control flags (see object documentation for details)

int crossfade
: optional animation crossfade time (see object documentation for details)


## CObject:RemoveLuaReference

Called when a cobject having a Lua reference is being destroyed. The method isn't overriden by child classes, but instead all implementations are called starting from the topmost parent.


void **CObject:RemoveLuaReference**()

## CObject:SetAcceleration

Sets linear acceleration as easing function when moving the object.


void **CObject:SetAcceleration**(int accel)
int accel
: the linear acceleration value


## CObject:SetAngle

Smoothly changes the object's rotation angle over the specified time.


void **CObject:SetAngle**(int angle, [int time = 0])
int angle
: the new angle (in minutes, 1 degree equals 60 minutes)

int time
: the time (ms) to change the axis (optional)


## CObject:SetAnimPhase

Advance the object's animation to a specific moment (phase). For nonlooping animations, the phase is clamped between 0 and the normal duration of the animation (without considering any speed modifications).


void **CObject:SetAnimPhase**(int channel, int phase)
int channel
: animation channel index (first channel is 1)

int phase
: the animation time to set.

Example:

~~~~ Lua
local duration = obj:SetState("step")
obj:SetAnimPhase(1, duration - 1)
-- the object animation is forced to advance to its last frame
~~~~

## CObject:SetAnimSpeed

Sets the new object's animation channel speed.

The channel speed is a property of the animation channel alone and doesn't affect the animations played on other channels.


void **CObject:SetAnimSpeed**(int channel, int speed, [int time = 0])
int channel
: animation channel (the first channel is 1)

int speed
: the new speed to set in promilles

int time
: the time we want the animation to reach smoothly the given speed (optional)


## CObject:SetAnimSpeedModifier

Sets the new object's animation speed modifier.

The speed modifier is a property of the object and affects all animation channels.


void **CObject:SetAnimSpeedModifier**(int speed)
int speed
: the new speed modifier to set in promilles


## CObject:SetAttachAngle

Specifies the angle for the rotation offset when the object is attached.


void **CObject:SetAttachAngle**(int angle)
int angle
: attach rotation angle


## CObject:SetAttachAxis

Specifies the axis for the rotation offset when the object is attached.


void **CObject:SetAttachAxis**(point axis)

void **CObject:SetAttachAxis**(int dx, int dy, int dz)
point axis
: attach rotation axis vector as point

int dx, dy, dz
: the axis vector as coordinates


## CObject:SetAttachOffset

Specifies a linear offset when the object is attached.


void **CObject:SetAttachOffset**(point offset)

void **CObject:SetAttachOffset**(int dx, int dy, int dz)
point offset
: offset vector from the spot position as point

int dx, dy, dz
: the offset vector as coordinates


## CObject:SetAxis

Smoothly changes the object's rotation axis over the specified time.


void **CObject:SetAxis**(point axis, [int time = 0])

void **CObject:SetAxis**(int dx, int dy, int dz, [int time = 0])
point axis
: the new rotation axis vector as point

int dx, dy, dz
: the new rotation axis vector as coordinates

int time
: the time (ms) to change the axis (optional).


## CObject:SetAxisAngle

Smoothly turns the object to the given axis and angle for the specified time. This method ensures proper interpolation avoiding discontinuities.


void **CObject:SetAxisAngle**(point axis, int angle, [int time = 0])

void **CObject:SetAxisAngle**(int axis_x, int axis_y, int axis_z, int angle, [int time = 0])

void **CObject:SetAxisAngle**(object other, [int time = 0])

## CObject:SetColorModifier

Modifies the colorization of the entire object.


void **CObject:SetColorModifier**(int color, [int time = 0, bool recursive = false])
int color
: the modification color in integer format. Each color component ranges between 0 and 255. For values above 100 the color component's value is being increased, while for values below, it's being reduced. To disable any modification, use RGB(100, 100, 100).

int time
: optional parameter allowing to make the modification smoothly over an interval of time.

bool recursive
: optional parameter indicating to set the color to all the attaches too.

Example:

~~~~ Lua
obj:SetColorModifier(RGB(200, 100, 50))
-- the object is now with increased red color, reduced blue color and unchanged green
obj:SetColorModifier(RGB(100, 100, 100))
-- the object's true colors are now restored
~~~~

## CObject:SetColorizationMaterial

Specifies object's material properties.


void **CObject:SetColorizationMaterial**(int idx, int color, int roughness, int metallic)

void **CObject:SetColorizationMaterial**(object other)
int idx
: colorization index, depends on the number of colorization masks available in the object's entity

int color
: the material color to be used, in RGB format represented as an unsigned integer (one byte per color component).

int roughness
: the material roughness, represented as an integer between -128 and 127

int metallic
: the metallic degree, represented as an integer between -128 and 127

object other
: copy the colorization from another object


## CObject:SetDust

Changes the object's dust visuals. Has an effect only if the entity has a dust mask.


void **CObject:SetDust**(int value, int material, int color)
int value
: the degree of dust, ranging from 0 to 255

int material
: material index, can be 0 (exterior) or 1 (interior)


## CObject:SetEnumFlags

Sets the object's enumeration flags.


void **CObject:SetEnumFlags**(int mask)
int mask
: mask containing the flags to be set.

Example:

~~~~ Lua
obj:SetEnumFlags(const.efVisible)
-- the object is now visible
~~~~

## CObject:SetGameFlags

Sets the object's game flags.



Example:

~~~~ Lua
obj:SetGameFlags(const.gofAlwaysRenderable)
-- the object is now drawn even when outside the camera view
~~~~

void **CObject:SetGameFlags**(int mask)
int mask
: mask containing the flags to be set.


## CObject:SetGravity

Sets gravity acceleration as easing function when moving the object.


void **CObject:SetGravity**([int gravity = 980])
int gravity
: the gravity acceleration value (optional)


## CObject:SetMirrored

Specifies the the object entity should be mirrored.


void **CObject:SetMirrored**(bool mirrored)
bool mirrored
: true if mirrored


## CObject:SetOpacity

Sets the current object opacity.


void **CObject:SetOpacity**(int opacity, [int time = 0, bool recursive = false])
int opacity
: 0 for full transparency; 100 for full opacity

int time
: time for smooth transition (optional)

int recursive
: if true, apply to attached objects too (optional)


## CObject:SetPos

Smoothly changes the object's position over the specified time.

The map position of the object is changed immediately, but its visual position will change over the given interval of time.


void **CObject:SetPos**(point pos, [int time = 0])

void **CObject:SetPos**(int x, int y, int z, [int time = 0])
point pos
: the new position as a point

int x, y, z
: the new position as three coordinates.

int time
: the time (ms) to change the position (optional).


## CObject:SetPosAxisAngle

Smoothly moves and turns the object to the given pos, axis and angle for the specified time. It is better to use this method instead of invoking the interpolations separately.


void **CObject:SetPosAxisAngle**(point pos, point axis, int angle, [int time = 0])

void **CObject:SetPosAxisAngle**(int pos_x, int pos_y, int pos_z, int axis_x, int axis_y, int axis_z, int angle, [int time = 0])

void **CObject:SetPosAxisAngle**(object other, [int time = 0])

## CObject:SetRollPitchYaw

Sets the object's orientation via roll, pitch and yaw angles.


void **CObject:SetRollPitchYaw**(int roll, int pitch, int yaw, [int time_delta])
int roll
: roll angle (Rotation around the object's front-to-back axis)

int pitch
: pitch angle (Rotation around the object's side-to-side axis)

int yaw
: yaw angle (Rotation around the object's vertical axis)

int time_delta
: optional time interval in the future, thus enabling smooth interpolation from the current orientation.


## CObject:SetSIModulation

Sets the current self illumination modulation.


void **CObject:SetSIModulation**(int modulation)
int modulation
: 0 for no self illumination; 100 for max self illumination


## CObject:SetScale

Changes the object's scale.


void **CObject:SetScale**(int scale)
int scale
: the object's scale in percent (100% is the default).

int time
: interpolation delta (0 by default).


## CObject:SetSound

Associates a sound to be played from this object.


void **CObject:SetSound**(string sound, [string type, int volume, int crossfade, bool looping])
string sound
: a sound name (sound bank) or a sound filename.

string type
: a sound type name, indicating that a sound file is provided, instead of a sound name.

int volume
: forces the volume of the sound between 0 and 1000 (the sound bank volume is used by default).

int crossfade
: optional cross-fade time if changing the sound state.

bool looping
: specifies if the sound should be looping (uses the sound bank flag by default).


## CObject:SetSoundMute

Sets or resets the sound mute flag for an object.


void **CObject:SetSoundMute**(int volume, bool bMute)
bool bMute
: mutes the sounds from the object if set


## CObject:SetSoundVolume

Changes the sound volume for an object.


void **CObject:SetSoundVolume**(int volume, [int time = 0])
int volume
: specifies the volume of the sound between 0 and 1000.

int time
: optional time for smooth change.


## CObject:SetState

Changes the object's state (animation).


int **CObject:SetState**(string name, [int flags = 0, int crossfade = -1, int speed = 1000, bool change_only])

int **CObject:SetState**(int index, [int flags = 0, int crossfade = -1, int speed = 1000, bool change_only])
string name
: the state name to check for

string index
: the state index to check for

int flags
: optional animation control flags (see object documentation for details) 

int crossfade
: optional animation crossfade time (see object documentation for details)

int speed
: optional animation speed in promilles

bool change_only
: will early-out if the state is already the requested one


## CObject:StopSound

Stops the sound of an object.


void **CObject:StopSound**([int time = 0])
int time
: optional time for smoothly muting the sound.


## CObject:TimeToAnimEnd

Returns remaining time to the end of currently played animation of the object (the result is depending on the current animation speed).


int **CObject:TimeToAnimEnd**([int channel = 1])
int channel
: optional animation channel

_returns_ int
: the time remaining


## GetEntityBBox

Returns the bounding box of an entity in a given state.


box **GetEntityBBox**(string entity, string state)

box **GetEntityBBox**(string entity, int state)
string entity
: entity name

string state
: state name

int state
: state idx

_returns_ box
: the bounding box of the entity.


## GetNumStates

Returns the number of valid states (animations) for a given entity.


int **GetNumStates**(string entity)
string entity
: the entity name

_returns_ int
: number of states


## GetSpotBeginIndex

Returns the first spot index from a given spot type for an entity in a given state


int, int **GetSpotBeginIndex**(string entity, string state, string spot)

int, int **GetSpotBeginIndex**(string entity, int state, string spot)
string entity
: entity name

string state
: state name

int state
: state index

string spot
: spot name

_returns_ int
: the spot index, -1 if not found.


## GetSpotEndIndex

Returns the last spot index from a given spot type for an entity in a given state


int, int **GetSpotEndIndex**(string entity, string state, string spot)

int, int **GetSpotEndIndex**(string entity, int state, string spot)
string entity
: entity name

string state
: state name

int state
: state index

string spot
: spot name

_returns_ int
: the spot index, -1 if not found.


## GetSpotRange

Returns the first and the last spot indexes from a given spot type for an entity in a given state


int, int **GetSpotRange**(string entity, string state, string spot)

int, int **GetSpotRange**(string entity, int state, string spot)
string entity
: entity name

string state
: state name

int state
: state index

string spot
: spot name

_returns_ int, int
: the spot indexes, -1 if not found.


## GetTopmostParent

Returns the topmost parent, if attached, or the object itself otherwise.


object **GetTopmostParent**(object obj [, string class = false])
object obj
: the object

string class
: optional class name as filter

_returns_ object
: the topmost parent


## HasAllSurfaces

Checks if an entity has specific surfaces.


bool **HasAllSurfaces**(string entity, int mask)
string entity
: The entity name.

int mask
: A mask of the surfaces in question. See the 'EntitySurfaces' global for a list of surfaces and their masks.

_returns_ bool
: Returns true if the entity has all of those surfaces.


## HasAnySurfaces

Checks if an entity has specific surfaces.


bool **HasAnySurfaces**(string entity, int mask)
string entity
: The entity name.

int mask
: A mask of the surfaces in question. See the 'EntitySurfaces' global for a list of surfaces and their masks.

_returns_ bool
: Returns true if the entity has any of those surfaces.


## HasSpot

Checks if an entity has a given spot type in a specified state.


bool **HasSpot**(string entity, string state, string spot)
string entity
: the entity name

#param string state - the state to check

string spot
: the spot name to be checked

_returns_ bool
: true if the spot is present.


## HasState

Checks if an entity has a given state (animation).


bool **HasState**(string entity, string name)

bool **HasState**(string entity, int index)
string entity
: the entity name

string name
: the state name to check for

int index
: the state index to check for

_returns_ bool
: Returns true if the state is present


## IsBeingDestructed

Returns if the given param is an object in the process of being destroyed.


bool **IsBeingDestructed**(object obj)
object obj
: the object to be tested

_returns_ bool
: true if the object is being destroyed


## IsValid

Returns if the given param is a valid, non yet destroyed object.


bool **IsValid**(object obj)
object obj
: the object to be tested

_returns_ bool
: true if the object is valid





(insert footer.md.html here)
<link rel="stylesheet" type="text/css" href="Style.css" />
<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js" charset="utf-8"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>