File: GameScripts.cpp

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (1751 lines) | stat: -rw-r--r-- 62,716 bytes parent folder | download | duplicates (2)
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
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/*
 * Copyright (C) 2006-2010 - Frictional Games
 *
 * This file is part of Penumbra Overture.
 */

#include "hpl1/penumbra-overture/GameScripts.h"
#include "hpl1/engine/engine.h"

#include "hpl1/penumbra-overture/AttackHandler.h"
#include "hpl1/penumbra-overture/Credits.h"
#include "hpl1/penumbra-overture/DemoEndText.h"
#include "hpl1/penumbra-overture/EffectHandler.h"
#include "hpl1/penumbra-overture/FadeHandler.h"
#include "hpl1/penumbra-overture/GameArea.h"
#include "hpl1/penumbra-overture/GameDamageArea.h"
#include "hpl1/penumbra-overture/GameEnemy.h"
#include "hpl1/penumbra-overture/GameEntity.h"
#include "hpl1/penumbra-overture/GameForceArea.h"
#include "hpl1/penumbra-overture/GameItem.h"
#include "hpl1/penumbra-overture/GameLadder.h"
#include "hpl1/penumbra-overture/GameLamp.h"
#include "hpl1/penumbra-overture/GameLink.h"
#include "hpl1/penumbra-overture/GameLiquidArea.h"
#include "hpl1/penumbra-overture/GameMessageHandler.h"
#include "hpl1/penumbra-overture/GameMusicHandler.h"
#include "hpl1/penumbra-overture/GameObject.h"
#include "hpl1/penumbra-overture/GameSaveArea.h"
#include "hpl1/penumbra-overture/GameStickArea.h"
#include "hpl1/penumbra-overture/GameSwingDoor.h"
#include "hpl1/penumbra-overture/GraphicsHelper.h"
#include "hpl1/penumbra-overture/Init.h"
#include "hpl1/penumbra-overture/Inventory.h"
#include "hpl1/penumbra-overture/MainMenu.h"
#include "hpl1/penumbra-overture/MapHandler.h"
#include "hpl1/penumbra-overture/Notebook.h"
#include "hpl1/penumbra-overture/NumericalPanel.h"
#include "hpl1/penumbra-overture/Player.h"
#include "hpl1/penumbra-overture/PlayerHelper.h"
#include "hpl1/penumbra-overture/RadioHandler.h"
#include "hpl1/penumbra-overture/SaveHandler.h"

#include "hpl1/penumbra-overture/GlobalInit.h"

//-----------------------------------------------------------------------

//////////////////////////////////////////////////////////////////////////
// SCRIPT FUNCTIONS
//////////////////////////////////////////////////////////////////////////

///////// HELPERS ////////////////////////////////////

//-----------------------------------------------------------------------

#define GAME_ENTITY_BEGIN(asName)                                       \
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName); \
	if (pEntity == NULL) {                                              \
		Warning("Couldn't find game entity '%s'\n", asName.c_str());    \
		return;                                                         \
	}

//-----------------------------------------------------------------------

tWString *gsTempString = nullptr;

//-----------------------------------------------------------------------

static void AddToTempString(tString asString) {
	*gsTempString += cString::To16Char(asString);
}
SCRIPT_DEFINE_FUNC_1(void, AddToTempString, string)

static void AddToTempStringTrans(tString asCat, tString asEntry) {
	cInit *mpInit = gpInit;
	*gsTempString += kTranslate(asCat, asEntry);
}
SCRIPT_DEFINE_FUNC_2(void, AddToTempStringTrans, string, string)

static void AddToTempStringAction(tString asAction) {
	cInit *mpInit = gpInit;
	iAction *pAction = gpInit->mpGame->GetInput()->GetAction(asAction);
	if (pAction) {
		tWString sString = kTranslate("ButtonNames", pAction->GetInputName());
		if (sString != _W(""))
			*gsTempString += sString;
		else
			*gsTempString += cString::To16Char(pAction->GetInputName());
	} else {
		*gsTempString += kTranslate("ButtonNames", "None");
	}
}
SCRIPT_DEFINE_FUNC_1(void, AddToTempStringAction, string)

//-----------------------------------------------------------------------

///////// GENERAL GAME ////////////////////////////////////

static void ResetGame() {
	gpInit->mpGame->ResetLogicTimer();

	gpInit->mpMapHandler->SetCurrentMapName("");
	gpInit->mpMainMenu->SetActive(true);
}
SCRIPT_DEFINE_FUNC(void, ResetGame)

//-----------------------------------------------------------------------

static void StartCredits() {
	gpInit->mpCredits->SetActive(true);
}
SCRIPT_DEFINE_FUNC(void, StartCredits)

static void StartDemoEndText() {
	gpInit->mpDemoEndText->SetActive(true);
}
SCRIPT_DEFINE_FUNC(void, StartDemoEndText)

//-----------------------------------------------------------------------

static void ClearSavedMaps() {
	gpInit->mpSaveHandler->ClearSavedMaps();
}
SCRIPT_DEFINE_FUNC(void, ClearSavedMaps)

//-----------------------------------------------------------------------

static tString GetActionKeyString(tString asAction) {
	iAction *pAction = gpInit->mpGame->GetInput()->GetAction(asAction);
	if (pAction) {
		return pAction->GetInputName();
	}

	return "ActionNotFound";
}
SCRIPT_DEFINE_FUNC_1(string, GetActionKeyString, string)

//-----------------------------------------------------------------------

static void AddMessageTrans(tString asTransCat,
							tString asTransName) {
	cInit *mpInit = gpInit;
	gpInit->mpGameMessageHandler->Add(kTranslate(asTransCat, asTransName));
}
SCRIPT_DEFINE_FUNC_2(void, AddMessageTrans, string, string)

//-----------------------------------------------------------------------

static void AddMessage(tString asMessage) {
	gpInit->mpGameMessageHandler->Add(cString::To16Char(asMessage));
}
SCRIPT_DEFINE_FUNC_1(void, AddMessage, string)

//-----------------------------------------------------------------------

static void AddMessageTempString() {
	gpInit->mpGameMessageHandler->Add(*gsTempString);
	*gsTempString = _W("");
}
SCRIPT_DEFINE_FUNC(void, AddMessageTempString)

//-----------------------------------------------------------------------

static void AddSubTitleTrans(tString asTransCat,
							 tString asTransName, float afTime) {
	cInit *mpInit = gpInit;
	gpInit->mpEffectHandler->GetSubTitle()->Add(kTranslate(asTransCat, asTransName), afTime, false);
}
SCRIPT_DEFINE_FUNC_3(void, AddSubTitleTrans, string, string, float)

//-----------------------------------------------------------------------

static void AddSubTitle(tString asMessage, float afTime) {
	gpInit->mpEffectHandler->GetSubTitle()->Add(cString::To16Char(asMessage), afTime, false);
}
SCRIPT_DEFINE_FUNC_2(void, AddSubTitle, string, float)

//-----------------------------------------------------------------------

static void AddSubTitleTempString(float afTime) {
	gpInit->mpEffectHandler->GetSubTitle()->Add(*gsTempString, afTime, false);
	*gsTempString = _W("");
}
SCRIPT_DEFINE_FUNC_1(void, AddSubTitleTempString, float)

//-----------------------------------------------------------------------

static void AddRadioMessage(tString asTransCat, tString asTransName,
							tString asSound) {
	cInit *mpInit = gpInit;
	gpInit->mpRadioHandler->Add(kTranslate(asTransCat, asTransName), asSound);
}
SCRIPT_DEFINE_FUNC_3(void, AddRadioMessage, string, string, string)

//-----------------------------------------------------------------------

static void SetRadioOnEndCallback(tString asFunc) {
	gpInit->mpRadioHandler->SetOnEndCallback(asFunc);
}
SCRIPT_DEFINE_FUNC_1(void, SetRadioOnEndCallback, string)

//-----------------------------------------------------------------------

static void SetInventoryMessage(tString asMessage) {
	gpInit->mpInventory->SetMessage(cString::To16Char(asMessage));
}
SCRIPT_DEFINE_FUNC_1(void, SetInventoryMessage, string)

static void SetInventoryMessageTrans(tString asTransCat,
									 tString asTransName) {
	cInit *mpInit = gpInit;
	gpInit->mpInventory->SetMessage(kTranslate(asTransCat, asTransName));
}
SCRIPT_DEFINE_FUNC_2(void, SetInventoryMessageTrans, string, string)

//-----------------------------------------------------------------------

static void SetMessagesOverCallback(tString asFunction) {
	gpInit->mpGameMessageHandler->SetOnMessagesOverCallback(asFunction);
}
SCRIPT_DEFINE_FUNC_1(void, SetMessagesOverCallback, string)

//-----------------------------------------------------------------------

static void ChangeMap(tString asMapFile, tString asMapPos,
					  tString asStartSound, tString asStopSound,
					  float afFadeOutTime, float afFadeInTime,
					  tString asLoadTextCat, tString asLoadTextEntry) {
	// if(gpInit->mpRadioHandler->IsActive()) return;

	gpInit->mpMapHandler->ChangeMap(asMapFile, asMapPos, asStartSound, asStopSound,
									afFadeOutTime, afFadeInTime,
									asLoadTextCat, asLoadTextEntry);
}
SCRIPT_DEFINE_FUNC_8(void, ChangeMap, string, string, string, string, float, float, string, string)

//-----------------------------------------------------------------------

static void SetMapGameName(tString asName) {
	gpInit->mpMapHandler->SetMapGameName(cString::To16Char(asName));
}
SCRIPT_DEFINE_FUNC_1(void, SetMapGameName, string)

static void SetMapGameNameTrans(tString asTransCat, tString asTransEntry) {
	cInit *mpInit = gpInit;
	gpInit->mpMapHandler->SetMapGameName(kTranslate(asTransCat, asTransEntry));
}
SCRIPT_DEFINE_FUNC_2(void, SetMapGameNameTrans, string, string)

//-----------------------------------------------------------------------

static void AddNotebookTaskText(tString asName, tString asText) {
	gpInit->mpNotebook->AddTask(asName, cString::To16Char(asText));
}
SCRIPT_DEFINE_FUNC_2(void, AddNotebookTaskText, string, string)

//-----------------------------------------------------------------------

static void AddNotebookTask(tString asName, tString asTransCat,
							tString asTransEntry) {
	cInit *mpInit = gpInit;
	gpInit->mpNotebook->AddTask(asName, kTranslate(asTransCat, asTransEntry));
}
SCRIPT_DEFINE_FUNC_3(void, AddNotebookTask, string, string, string)

//-----------------------------------------------------------------------

static void RemoveNotebookTask(tString asName) {
	gpInit->mpNotebook->RemoveTask(asName);
}
SCRIPT_DEFINE_FUNC_1(void, RemoveNotebookTask, string)

//-----------------------------------------------------------------------

static void AddNotebookNote(tString asNameCat, tString asNameEntry,
							tString asTextCat, tString asTextEntry) {
	cInit *mpInit = gpInit;
	gpInit->mpNotebook->AddNote(kTranslate(asNameCat, asNameEntry), asTextCat, asTextEntry);
}
SCRIPT_DEFINE_FUNC_4(void, AddNotebookNote, string, string, string, string)

//-----------------------------------------------------------------------

static void StartNumericalPanel(tString asName, int alCode1, int alCode2, int alCode3, int alCode4,
								float afDifficulty, tString asCallback) {
	gpInit->mpNumericalPanel->SetActive(true);
	tIntVec vCode;
	vCode.resize(4);
	vCode[0] = alCode1;
	vCode[1] = alCode2;
	vCode[2] = alCode3;
	vCode[3] = alCode4;

	gpInit->mpNumericalPanel->SetUp(asName, asCallback);
	gpInit->mpNumericalPanel->SetCode(vCode);
}
SCRIPT_DEFINE_FUNC_7(void, StartNumericalPanel, string, int, int, int, int, float, string)

//-----------------------------------------------------------------------

static void SetInventoryActive(bool abX) {
	gpInit->mpInventory->SetActive(abX);
}
SCRIPT_DEFINE_FUNC_1(void, SetInventoryActive, bool)

//-----------------------------------------------------------------------

static void FadeIn(float afTime) {
	gpInit->mpFadeHandler->FadeIn(afTime);
}
SCRIPT_DEFINE_FUNC_1(void, FadeIn, float)

static void FadeOut(float afTime) {
	gpInit->mpFadeHandler->FadeOut(afTime);
}
SCRIPT_DEFINE_FUNC_1(void, FadeOut, float)

static bool IsFading() {
	return gpInit->mpFadeHandler->IsActive();
}
SCRIPT_DEFINE_FUNC(bool, IsFading)

//-----------------------------------------------------------------------

static void SetWideScreenActive(bool abActive) {
	gpInit->mpFadeHandler->SetWideScreenActive(abActive);
}
SCRIPT_DEFINE_FUNC_1(void, SetWideScreenActive, bool)

//-----------------------------------------------------------------------

static void AutoSave() {
	if (gpInit->mpPlayer->GetHealth() <= 0)
		return;

	// TODO: Some other effect here.
	// gpInit->mpGraphicsHelper->DrawLoadingScreen("other_saving.jpg");
	// gpInit->mpSaveHandler->SaveGameToFile("save/auto.sav");
	// gpInit->mpSaveHandler->AutoSave("Auto",5);
	gpInit->mpEffectHandler->GetSaveEffect()->AutoSave();
}
SCRIPT_DEFINE_FUNC(void, AutoSave)

//-----------------------------------------------------------------------

static void StartFlash(float afFadeIn, float afWhite, float afFadeOut) {
	gpInit->mpEffectHandler->GetFlash()->Start(afFadeIn, afWhite, afFadeOut);
}
SCRIPT_DEFINE_FUNC_3(void, StartFlash, float, float, float)

//-----------------------------------------------------------------------

static void SetWaveGravityActive(bool abX) {
	gpInit->mpEffectHandler->GetWaveGravity()->SetActive(abX);
}
SCRIPT_DEFINE_FUNC_1(void, SetWaveGravityActive, bool)

static void SetupWaveGravity(float afMaxAngle, float afSwingLength,
							 float afGravitySize, tString asAxis) {
	int lDir = cString::ToLowerCase(asAxis) == "x" ? 0 : 1;

	gpInit->mpEffectHandler->GetWaveGravity()->Setup(cMath::ToRad(afMaxAngle), afSwingLength, afGravitySize, lDir);
}
SCRIPT_DEFINE_FUNC_4(void, SetupWaveGravity, float, float, float, string)

//-----------------------------------------------------------------------

static void SetDepthOfFieldActive(bool abX, float afFadeTime) {
	gpInit->mpEffectHandler->GetDepthOfField()->SetActive(abX, afFadeTime);
}
SCRIPT_DEFINE_FUNC_2(void, SetDepthOfFieldActive, bool, float)

//-----------------------------------------------------------------------

static void SetupDepthOfField(float afNearPlane, float afFocalPlane, float afFarPlane) {
	gpInit->mpEffectHandler->GetDepthOfField()->SetUp(afNearPlane, afFocalPlane, afFarPlane);
	gpInit->mpEffectHandler->GetDepthOfField()->SetFocusBody(NULL);
}
SCRIPT_DEFINE_FUNC_3(void, SetupDepthOfField, float, float, float)

//-----------------------------------------------------------------------

static void FocusOnEntity(tString asEntity) {
	GAME_ENTITY_BEGIN(asEntity);

	if (pEntity->GetBodyNum() == 0) {
		Error("Entity %s had no bodies and can not be focus on.\n", pEntity->GetName().c_str());
		return;
	}

	gpInit->mpEffectHandler->GetDepthOfField()->FocusOnBody(pEntity->GetBody(0));
	gpInit->mpEffectHandler->GetDepthOfField()->SetFocusBody(NULL);
}
SCRIPT_DEFINE_FUNC_1(void, FocusOnEntity, string)

//-----------------------------------------------------------------------

static void SetConstantFocusOnEntity(tString asEntity) {
	if (asEntity == "") {
		gpInit->mpEffectHandler->GetDepthOfField()->SetFocusBody(NULL);
		return;
	}

	GAME_ENTITY_BEGIN(asEntity);

	if (pEntity->GetBodyNum() == 0) {
		Error("Entity %s had no bodies and can not be focus on.\n", pEntity->GetName().c_str());
		return;
	}

	gpInit->mpEffectHandler->GetDepthOfField()->SetFocusBody(pEntity->GetBody(0));
}
SCRIPT_DEFINE_FUNC_1(void, SetConstantFocusOnEntity, string)

//-----------------------------------------------------------------------

static void PlayGameMusic(tString asFile, float afVolume, float afFadeStep,
						  bool abLoop, int alPrio) {
	gpInit->mpMusicHandler->Play(asFile, abLoop, afVolume, afFadeStep, alPrio);
}
SCRIPT_DEFINE_FUNC_5(void, PlayGameMusic, string, float, float, bool, int)

//-----------------------------------------------------------------------

static void StopGameMusic(float afFadeStep, int alPrio) {
	gpInit->mpMusicHandler->Stop(afFadeStep, alPrio);
}
SCRIPT_DEFINE_FUNC_2(void, StopGameMusic, float, int)

//-----------------------------------------------------------------------

static void StartScreenShake(float afAmount, float afTime, float afFadeInTime, float afFadeOutTime) {
	gpInit->mpEffectHandler->GetShakeScreen()->Start(afAmount, afTime, afFadeInTime, afFadeOutTime);
}
SCRIPT_DEFINE_FUNC_4(void, StartScreenShake, float, float, float, float)

//-----------------------------------------------------------------------

static void CreateLightFlashAtArea(tString asArea, float afRadius,
								   float afR, float afG, float afB, float afA,
								   float afAddTime, float afNegTime) {
	cAreaEntity *pArea = gpInit->mpGame->GetScene()->GetWorld3D()->GetAreaEntity(asArea);
	if (pArea == NULL) {
		Error("Could not find area '%s'\n", asArea.c_str());
		return;
	}

	gpInit->mpMapHandler->AddLightFlash(pArea->m_mtxTransform.GetTranslation(), afRadius,
										cColor(afR, afG, afB, afA), afAddTime, afNegTime);
}
SCRIPT_DEFINE_FUNC_8(void, CreateLightFlashAtArea, string, float, float, float, float, float, float, float)

//-----------------------------------------------------------------------

///////// ATTACK ////////////////////////////////////

//-----------------------------------------------------------------------

static void CreateSplashDamage(tString asAreaName, float afRadius,
							   float afMinDamage, float afMaxDamge,
							   float afMinForce, float afMaxForce,
							   float afMaxImpulse, int alStrength) {
	///////////////////
	// Get area
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asAreaName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Area) {
		Warning("Couldn't find area entity '%s'\n", asAreaName.c_str());
		return;
	}
	cGameArea *pArea = static_cast<cGameArea *>(pEntity);

	gpInit->mpAttackHandler->CreateSplashDamage(pArea->GetBody(0)->GetWorldPosition(),
												afRadius, afMinDamage, afMaxDamge,
												afMinForce, afMaxForce, afMaxImpulse,
												eAttackTargetFlag_Bodies |
													eAttackTargetFlag_Player |
													eAttackTargetFlag_Enemy,
												1, alStrength);
}
SCRIPT_DEFINE_FUNC_8(void, CreateSplashDamage, string, float, float, float, float, float, float, int)
//-----------------------------------------------------------------------

///////// GAME TIMER ////////////////////////////////////

//-----------------------------------------------------------------------

static void CreateTimer(tString asName, float afTime, tString asCallback, bool abGlobal) {
	gpInit->mpMapHandler->CreateTimer(asName, afTime, asCallback, abGlobal);
}
SCRIPT_DEFINE_FUNC_4(void, CreateTimer, string, float, string, bool)

static void DestroyTimer(tString asName) {
	cGameTimer *pTimer = gpInit->mpMapHandler->GetTimer(asName);
	if (pTimer == NULL) {
		Warning("Couldn't find timer '%s'\n", asName.c_str());
		return;
	}

	pTimer->mbDeleteMe = true;
}
SCRIPT_DEFINE_FUNC_1(void, DestroyTimer, string)

static void SetTimerPaused(tString asName, bool abPaused) {
	cGameTimer *pTimer = gpInit->mpMapHandler->GetTimer(asName);
	if (pTimer == NULL) {
		Warning("Couldn't find timer '%s'\n", asName.c_str());
		return;
	}

	pTimer->mbPaused = abPaused;
}
SCRIPT_DEFINE_FUNC_2(void, SetTimerPaused, string, bool)

static void SetTimerTime(tString asName, float afTime) {
	cGameTimer *pTimer = gpInit->mpMapHandler->GetTimer(asName);
	if (pTimer == NULL) {
		Warning("Couldn't find timer '%s'\n", asName.c_str());
		return;
	}

	pTimer->mfTime = afTime;
}
SCRIPT_DEFINE_FUNC_2(void, SetTimerTime, string, float)

static void AddTimerTime(tString asName, float afTime) {
	cGameTimer *pTimer = gpInit->mpMapHandler->GetTimer(asName);
	if (pTimer == NULL) {
		Warning("Couldn't find timer '%s'\n", asName.c_str());
		return;
	}

	pTimer->mfTime += afTime;
}
SCRIPT_DEFINE_FUNC_2(void, AddTimerTime, string, float)

static float GetTimerTime(tString asName) {
	cGameTimer *pTimer = gpInit->mpMapHandler->GetTimer(asName);
	if (pTimer == NULL) {
		Warning("Couldn't find timer '%s'\n", asName.c_str());
		return 0.0f;
	}

	return pTimer->mfTime;
}
SCRIPT_DEFINE_FUNC_1(float, GetTimerTime, string)

//-----------------------------------------------------------------------

///////// PLAYER ////////////////////////////////////

//-----------------------------------------------------------------------

static void GivePlayerDamage(float afAmount, tString asType) {
	ePlayerDamageType type = ePlayerDamageType_BloodSplash;
	tString sLowType = cString::ToLowerCase(asType);

	if (sLowType == "bloodsplash")
		type = ePlayerDamageType_BloodSplash;
	else if (sLowType == "ice")
		type = ePlayerDamageType_Ice;
	else
		Warning("Damage type %s does not exist!\n", asType.c_str());

	gpInit->mpPlayer->Damage(afAmount, type);
}
SCRIPT_DEFINE_FUNC_2(void, GivePlayerDamage, float, string)

//-----------------------------------------------------------------------

static void SetPlayerHealth(float afHealth) {
	gpInit->mpPlayer->SetHealth(afHealth);
}
SCRIPT_DEFINE_FUNC_1(void, SetPlayerHealth, float)

static float GetPlayerHealth() {
	return gpInit->mpPlayer->GetHealth();
}
SCRIPT_DEFINE_FUNC(float, GetPlayerHealth)

//-----------------------------------------------------------------------

static void SetPlayerPose(tString asPose, bool abChangeDirectly) {
	tString sPose = cString::ToLowerCase(asPose);

	if (sPose == "stand") {
		gpInit->mpPlayer->ChangeMoveState(ePlayerMoveState_Walk, abChangeDirectly);
	} else if (sPose == "crouch") {
		gpInit->mpPlayer->ChangeMoveState(ePlayerMoveState_Crouch, abChangeDirectly);
	} else {
		Warning("Player pose mode '%s' does not exist\n", asPose.c_str());
	}
}
SCRIPT_DEFINE_FUNC_2(void, SetPlayerPose, string, bool)

static void SetPlayerActive(bool abActive) {
	gpInit->mpPlayer->SetActive(abActive);
}
SCRIPT_DEFINE_FUNC_1(void, SetPlayerActive, bool)

//-----------------------------------------------------------------------

static void StartPlayerLookAt(tString asEntityName, float afSpeedMul, float afMaxSpeed) {
	///////////////////
	// Get entity
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asEntityName);
	if (pEntity == NULL) {
		Warning("Couldn't find entity '%s'\n", asEntityName.c_str());
		return;
	}
	if (pEntity->GetBody(0) == NULL) {
		Warning("Couldn't find a body in entity '%s'\n", asEntityName.c_str());
		return;
	}

	gpInit->mpPlayer->GetLookAt()->SetTarget(pEntity->GetBody(0)->GetWorldPosition(), afSpeedMul, afMaxSpeed);
	gpInit->mpPlayer->GetLookAt()->SetActive(true);
}
SCRIPT_DEFINE_FUNC_3(void, StartPlayerLookAt, string, float, float)

static void StopPlayerLookAt() {
	gpInit->mpPlayer->GetLookAt()->SetActive(false);
}
SCRIPT_DEFINE_FUNC(void, StopPlayerLookAt)

//-----------------------------------------------------------------------

static void StartPlayerFearFilter(float afStrength) {
	gpInit->mpPlayer->GetFearFilter()->SetActive(true);
}
SCRIPT_DEFINE_FUNC_1(void, StartPlayerFearFilter, float)

static void StopPlayerFearFilter() {
	gpInit->mpPlayer->GetFearFilter()->SetActive(false);
}
SCRIPT_DEFINE_FUNC(void, StopPlayerFearFilter)

//-----------------------------------------------------------------------

static void SetFlashlightDisabled(bool abDisabled) {
	gpInit->mpPlayer->GetFlashLight()->SetDisabled(abDisabled);
}
SCRIPT_DEFINE_FUNC_1(void, SetFlashlightDisabled, bool)

//-----------------------------------------------------------------------

///////// INVENTORY ////////////////////////////////////

//-----------------------------------------------------------------------

static void AddPickupCallback(tString asItem, tString asFunction) {
	gpInit->mpInventory->AddPickupCallback(asItem, asFunction);
}
SCRIPT_DEFINE_FUNC_2(void, AddPickupCallback, string, string)

static void AddUseCallback(tString asItem, tString asEntity, tString asFunction) {
	gpInit->mpInventory->AddUseCallback(asItem, asEntity, asFunction);
}
SCRIPT_DEFINE_FUNC_3(void, AddUseCallback, string, string, string)

static void AddCombineCallback(tString asItem1, tString asItem2, tString asFunction) {
	gpInit->mpInventory->AddCombineCallback(asItem1, asItem2, asFunction);
}
SCRIPT_DEFINE_FUNC_3(void, AddCombineCallback, string, string, string)

//-----------------------------------------------------------------------

static void RemovePickupCallback(tString asFunction) {
	gpInit->mpInventory->RemovePickupCallback(asFunction);
}
SCRIPT_DEFINE_FUNC_1(void, RemovePickupCallback, string)

static void RemoveUseCallback(tString asFunction) {
	gpInit->mpInventory->RemoveUseCallback(asFunction);
}
SCRIPT_DEFINE_FUNC_1(void, RemoveUseCallback, string)

static void RemoveCombineCallback(tString asFunction) {
	gpInit->mpInventory->RemoveCombineCallback(asFunction);
}
SCRIPT_DEFINE_FUNC_1(void, RemoveCombineCallback, string)

//-----------------------------------------------------------------------

static bool HasItem(tString asName) {
	// if(cString::ToLowerCase(asName)=="notebook") return gpInit->mpInventory->GetNoteBookActive();

	return gpInit->mpInventory->GetItem(asName) != NULL;
}
SCRIPT_DEFINE_FUNC_1(bool, HasItem, string)

static void RemoveItem(tString asName) {
	cInventoryItem *pItem = gpInit->mpInventory->GetItem(asName);
	if (pItem) {
		gpInit->mpInventory->RemoveItem(pItem);
	} else {
		Warning("Cannot find item '%s' in inventory\n", asName.c_str());
	}
}
SCRIPT_DEFINE_FUNC_1(void, RemoveItem, string)

static void GiveItem(tString asName, tString asEntityFile, int alSlotIndex) {
	gpInit->mpInventory->AddItemFromFile(asName, asEntityFile, alSlotIndex);
}
SCRIPT_DEFINE_FUNC_3(void, GiveItem, string, string, int)

//-----------------------------------------------------------------------

///////// GAME ENTITY PROPERTIES //////////////////////////////////

//-----------------------------------------------------------------------

static void ReplaceEntity(tString asName, tString asBodyName,
						  tString asNewName, tString asNewFile) {
	GAME_ENTITY_BEGIN(asName)

	if (pEntity->GetBodyNum() == 0) {
		Error("Entity '%s' contains no bodies!\n", pEntity->GetName().c_str());
		return;
	}

	iPhysicsBody *pBody = NULL;

	if (asBodyName != "" && pEntity->GetBodyNum() > 1) {
		for (int i = 0; i < pEntity->GetBodyNum(); ++i) {
			tString sBodyName = cString::Sub(pEntity->GetBody(i)->GetName(), (int)asName.size() + 1);
			if (sBodyName == asBodyName) {
				pBody = pEntity->GetBody(i);
				break;
			}
		}

		if (pBody == NULL) {
			Error("Body '%s' could not be found in entity '%s'!\n", asBodyName.c_str(), asName.c_str());
			return;
		}
	} else {
		pBody = pEntity->GetBody(0);
	}

	cMatrixf mtxTransform = pBody->GetWorldMatrix();

	gpInit->mpMapHandler->RemoveGameEntity(pEntity);

	cWorld3D *pWorld = gpInit->mpGame->GetScene()->GetWorld3D();
	pWorld->CreateEntity(asNewName, mtxTransform, asNewFile, true);
}
SCRIPT_DEFINE_FUNC_4(void, ReplaceEntity, string, string, string, string)

//-----------------------------------------------------------------------

static void SetGameEntityActive(tString asName, bool abX) {
	GAME_ENTITY_BEGIN(asName)

	pEntity->SetActive(abX);
}
SCRIPT_DEFINE_FUNC_2(void, SetGameEntityActive, string, bool)

static bool GetGameEntityActive(tString asName) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL) {
		Warning("Couldn't find game entity '%s'\n", asName.c_str());
		return false;
	}

	return pEntity->IsActive();
}
SCRIPT_DEFINE_FUNC_1(bool, GetGameEntityActive, string)

//-----------------------------------------------------------------------

static void CreateGameEntityVar(tString asEntName, tString asVarName, int alVal) {
	GAME_ENTITY_BEGIN(asEntName);

	pEntity->CreateVar(asVarName, alVal);
}
SCRIPT_DEFINE_FUNC_3(void, CreateGameEntityVar, string, string, int)

static void SetGameEntityVar(tString asEntName, tString asVarName, int alVal) {
	GAME_ENTITY_BEGIN(asEntName);

	pEntity->SetVar(asVarName, alVal);
}
SCRIPT_DEFINE_FUNC_3(void, SetGameEntityVar, string, string, int)

static void AddGameEntityVar(tString asEntName, tString asVarName, int alVal) {
	GAME_ENTITY_BEGIN(asEntName);

	pEntity->AddVar(asVarName, alVal);
}
SCRIPT_DEFINE_FUNC_3(void, AddGameEntityVar, string, string, int)

static int GetGameEntityVar(tString asEntName, tString asVarName) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asEntName);
	if (pEntity == NULL) {
		Warning("Couldn't find game entity '%s'\n", asEntName.c_str());
		return 0;
	}

	return pEntity->GetVar(asVarName);
}
SCRIPT_DEFINE_FUNC_2(int, GetGameEntityVar, string, string)

//-----------------------------------------------------------------------

static void SetGameEntityMaxExamineDist(tString asName, float afDist) {
	GAME_ENTITY_BEGIN(asName)

	pEntity->SetMaxExamineDist(afDist);
}
SCRIPT_DEFINE_FUNC_2(void, SetGameEntityMaxExamineDist, string, float)

static void SetGameEntityMaxInteractDist(tString asName, float afDist) {
	GAME_ENTITY_BEGIN(asName)

	pEntity->SetMaxInteractDist(afDist);
}
SCRIPT_DEFINE_FUNC_2(void, SetGameEntityMaxInteractDist, string, float)

//-----------------------------------------------------------------------

static void SetGameEntityDescriptionTrans(tString asName,
										  tString asTransCat,
										  tString asTransName) {
	cInit *mpInit = gpInit;
	GAME_ENTITY_BEGIN(asName)

	pEntity->SetDescription(kTranslate(asTransCat, asTransName));
	pEntity->SetShowDescritionOnce(false);
}
SCRIPT_DEFINE_FUNC_3(void, SetGameEntityDescriptionTrans, string, string, string)

//-----------------------------------------------------------------------

static void SetGameEntityDescriptionOnceTrans(tString asName,
											  tString asTransCat,
											  tString asTransName) {
	cInit *mpInit = gpInit;
	GAME_ENTITY_BEGIN(asName)

	pEntity->SetDescription(kTranslate(asTransCat, asTransName));
	pEntity->SetShowDescritionOnce(true);
}
SCRIPT_DEFINE_FUNC_3(void, SetGameEntityDescriptionOnceTrans, string, string, string)

//-----------------------------------------------------------------------

static void SetGameEntityDescription(tString asName, tString asMessage) {
	GAME_ENTITY_BEGIN(asName)

	pEntity->SetDescription(cString::To16Char(asMessage));
	pEntity->SetShowDescritionOnce(false);
}
SCRIPT_DEFINE_FUNC_2(void, SetGameEntityDescription, string, string)

static void SetGameEntityGameNameTrans(tString asName,
									   tString asTransCat,
									   tString asTransName) {
	cInit *mpInit = gpInit;
	GAME_ENTITY_BEGIN(asName)

	pEntity->SetGameName(kTranslate(asTransCat, asTransName));
}
SCRIPT_DEFINE_FUNC_3(void, SetGameEntityGameNameTrans, string, string, string)

//-----------------------------------------------------------------------

static void ChangeEntityAnimation(tString asName,
								  tString asAnimation,
								  bool abLoop) {
	GAME_ENTITY_BEGIN(asName)

	pEntity->GetMeshEntity()->PlayName(asAnimation, abLoop, true);
}
SCRIPT_DEFINE_FUNC_3(void, ChangeEntityAnimation, string, string, bool)

//-----------------------------------------------------------------------

static void SetEntityHealth(tString asName, float afHealth) {
	GAME_ENTITY_BEGIN(asName)

	pEntity->SetHealth(afHealth);
}
SCRIPT_DEFINE_FUNC_2(void, SetEntityHealth, string, float)

static void DamageEntity(tString asName, float afDamage, int alStrength) {
	GAME_ENTITY_BEGIN(asName)

	pEntity->Damage(afDamage, alStrength);
}
SCRIPT_DEFINE_FUNC_3(void, DamageEntity, string, float, int)

//-----------------------------------------------------------------------

static void SetDoorState(tString asName,
						 tString asState) {
	/*iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if(pEntity==NULL || pEntity->GetType() != eGameEntityType_Door)
	{
		Warning("Couldn't find door entity '%s'\n",asName.c_str());
		return;
	}

	cGameDoor *pDoor = static_cast<cGameDoor*>(pEntity);

	asState = cString::ToLowerCase(asState);
	eGameDoorState DoorState;

	if(asState == "open") DoorState = eGameDoorState_Open;
	else if(asState == "closed") DoorState = eGameDoorState_Closed;
	else if(asState == "opening") DoorState = eGameDoorState_Opening;
	else if(asState == "closing") DoorState = eGameDoorState_Closing;
	else{
		Warning("Invalid door state '%s'\n",asState.c_str());
		return;
	}

	pDoor->ChangeDoorState(DoorState);*/
}
SCRIPT_DEFINE_FUNC_2(void, SetDoorState, string, string)

//-----------------------------------------------------------------------

static void SetObjectInteractMode(tString asName, tString asMode) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Object) {
		Warning("Couldn't find object entity '%s'\n", asName.c_str());
		return;
	}

	cGameObject *pObject = static_cast<cGameObject *>(pEntity);

	pObject->SetInteractMode(cEntityLoader_GameObject::ToInteractMode(asMode.c_str()));
}
SCRIPT_DEFINE_FUNC_2(void, SetObjectInteractMode, string, string)

//-----------------------------------------------------------------------

static void SetupLink(tString asName,
					  tString asMapFile, tString asMapPos,
					  tString asStartSound, tString asStopSound,
					  float afFadeOutTime, float afFadeInTime) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Link) {
		Warning("Couldn't find object entity '%s'\n", asName.c_str());
		return;
	}

	cGameLink *pLink = static_cast<cGameLink *>(pEntity);

	pLink->msMapFile = asMapFile;
	pLink->msMapPos = asMapPos;
	pLink->msStartSound = asStartSound;
	pLink->msStopSound = asStopSound;
	pLink->mfFadeInTime = afFadeInTime;
	pLink->mfFadeOutTime = afFadeOutTime;
	pLink->msLoadTextCat = "";
	pLink->msLoadTextEntry = "";
}
SCRIPT_DEFINE_FUNC_7(void, SetupLink, string, string, string, string, string, float, float)

//-----------------------------------------------------------------------

static void SetupLinkLoadText(tString asName,
							  tString asMapFile, tString asMapPos,
							  tString asStartSound, tString asStopSound,
							  float afFadeOutTime, float afFadeInTime,
							  tString asTextCat, tString asTextEntry) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Link) {
		Warning("Couldn't find object entity '%s'\n", asName.c_str());
		return;
	}

	cGameLink *pLink = static_cast<cGameLink *>(pEntity);

	pLink->msMapFile = asMapFile;
	pLink->msMapPos = asMapPos;
	pLink->msStartSound = asStartSound;
	pLink->msStopSound = asStopSound;
	pLink->mfFadeInTime = afFadeInTime;
	pLink->mfFadeOutTime = afFadeOutTime;
	pLink->msLoadTextCat = asTextCat;
	pLink->msLoadTextEntry = asTextEntry;
}
SCRIPT_DEFINE_FUNC_9(void, SetupLinkLoadText, string, string, string, string, string, float, float, string, string)

//-----------------------------------------------------------------------

static void SetAreaCustomIcon(tString asName, tString asIcon) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Area) {
		Warning("Couldn't find area entity '%s'\n", asName.c_str());
		return;
	}
	cGameArea *pArea = static_cast<cGameArea *>(pEntity);

	eCrossHairState aCrosshair = eCrossHairState_None;

	tString sIconName = cString::ToLowerCase(asIcon);

	if (sIconName == "active")
		aCrosshair = eCrossHairState_Active;
	else if (sIconName == "inactive")
		aCrosshair = eCrossHairState_Inactive;
	else if (sIconName == "invalid")
		aCrosshair = eCrossHairState_Invalid;
	else if (sIconName == "grab")
		aCrosshair = eCrossHairState_Grab;
	else if (sIconName == "examine")
		aCrosshair = eCrossHairState_Examine;
	else if (sIconName == "pointer")
		aCrosshair = eCrossHairState_Pointer;
	else if (sIconName == "item")
		aCrosshair = eCrossHairState_Item;
	else if (sIconName == "doorlink")
		aCrosshair = eCrossHairState_DoorLink;
	else if (sIconName == "pickup")
		aCrosshair = eCrossHairState_PickUp;
	else if (sIconName == "none")
		aCrosshair = eCrossHairState_None;
	else
		Warning("Icon type %s not found!\n", asIcon.c_str());

	pArea->SetCustomIcon(aCrosshair);
}
SCRIPT_DEFINE_FUNC_2(void, SetAreaCustomIcon, string, string)

//-----------------------------------------------------------------------

static void AddEnemyPatrolNode(tString asEnemy, tString asNode, float afTime,
							   tString asAnimation) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asEnemy);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Enemy) {
		Warning("Couldn't find enemy entity '%s'\n", asEnemy.c_str());
		return;
	}
	iGameEnemy *pEnemy = static_cast<iGameEnemy *>(pEntity);

	pEnemy->AddPatrolNode(asNode, afTime, asAnimation);
}
SCRIPT_DEFINE_FUNC_4(void, AddEnemyPatrolNode, string, string, float, string)

/**
 * Clears all the patrol nodes for the enemy
 * \param asEnemy The Name of the enemy.
 */
static void ClearEnemyPatrolNodes(tString asEnemy) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asEnemy);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Enemy) {
		Warning("Couldn't find enemy entity '%s'\n", asEnemy.c_str());
		return;
	}
	iGameEnemy *pEnemy = static_cast<iGameEnemy *>(pEntity);

	pEnemy->ClearPatrolNodes();
}
SCRIPT_DEFINE_FUNC_1(void, ClearEnemyPatrolNodes, string)

//-----------------------------------------------------------------------

static void SetEnemyDeathCallback(tString asEnemy, tString asFunction) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asEnemy);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Enemy) {
		Warning("Couldn't find enemy entity '%s'\n", asEnemy.c_str());
		return;
	}
	iGameEnemy *pEnemy = static_cast<iGameEnemy *>(pEntity);

	pEnemy->SetOnDeathCallback(asFunction);
}
SCRIPT_DEFINE_FUNC_2(void, SetEnemyDeathCallback, string, string)

//-----------------------------------------------------------------------

static void SetEnemyAttackCallback(tString asEnemy, tString asFunction) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asEnemy);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Enemy) {
		Warning("Couldn't find enemy entity '%s'\n", asEnemy.c_str());
		return;
	}
	iGameEnemy *pEnemy = static_cast<iGameEnemy *>(pEntity);

	pEnemy->SetOnAttackCallback(asFunction);
}
SCRIPT_DEFINE_FUNC_2(void, SetEnemyAttackCallback, string, string)

//-----------------------------------------------------------------------

static float GetEnemyHealth(tString asEnemy) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asEnemy);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Enemy) {
		Warning("Couldn't find enemy entity '%s'\n", asEnemy.c_str());
		return 0;
	}
	iGameEnemy *pEnemy = static_cast<iGameEnemy *>(pEntity);

	return pEnemy->GetHealth();
}
SCRIPT_DEFINE_FUNC_1(float, GetEnemyHealth, string)

//-----------------------------------------------------------------------

static void SetEnemyUseTriggers(tString asEnemy, bool abUseTriggers) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asEnemy);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Enemy) {
		Warning("Couldn't find enemy entity '%s'\n", asEnemy.c_str());
		return;
	}
	iGameEnemy *pEnemy = static_cast<iGameEnemy *>(pEntity);

	pEnemy->SetUsesTriggers(abUseTriggers);
}
SCRIPT_DEFINE_FUNC_2(void, SetEnemyUseTriggers, string, bool)

//-----------------------------------------------------------------------

static void ShowEnemyPlayer(tString asEnemy) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asEnemy);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Enemy) {
		Warning("Couldn't find enemy entity '%s'\n", asEnemy.c_str());
		return;
	}
	iGameEnemy *pEnemy = static_cast<iGameEnemy *>(pEntity);

	pEnemy->SetLastPlayerPos(gpInit->mpPlayer->GetCharacterBody()->GetFeetPosition() +
							 cVector3f(0, 0.1f, 0));
	pEnemy->ChangeState(STATE_HUNT);
}
SCRIPT_DEFINE_FUNC_1(void, ShowEnemyPlayer, string)

//-----------------------------------------------------------------------

static void SetDoorLocked(tString asDoor, bool abLocked) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asDoor);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_SwingDoor) {
		Warning("Couldn't find swing door entity '%s'\n", asDoor.c_str());
		return;
	}
	cGameSwingDoor *pDoor = static_cast<cGameSwingDoor *>(pEntity);

	pDoor->SetLocked(abLocked);
}
SCRIPT_DEFINE_FUNC_2(void, SetDoorLocked, string, bool)

//-----------------------------------------------------------------------

static void SetupStickArea(tString asArea, bool abCanDeatch,
						   bool abMoveBody, bool abRotateBody,
						   bool abCheckCenterInArea, float afPoseTime,
						   tString asAttachSound, tString asDetachSound,
						   tString asAttachPS, tString asDetachPS,
						   tString asAttachFunc, tString asDetachFunc) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asArea);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_StickArea) {
		Warning("Couldn't find stick area '%s'\n", asArea.c_str());
		return;
	}
	cGameStickArea *pArea = static_cast<cGameStickArea *>(pEntity);

	pArea->SetCanDeatch(abCanDeatch);

	pArea->SetRotateBody(abRotateBody);
	pArea->SetMoveBody(abMoveBody);

	pArea->SetCheckCenterInArea(abCheckCenterInArea);

	pArea->SetPoseTime(afPoseTime);

	pArea->SetAttachSound(asAttachSound);
	pArea->SetDetachSound(asDetachSound);

	pArea->SetAttachPS(asAttachPS);
	pArea->SetDetachPS(asDetachPS);

	pArea->SetAttachFunction(asAttachFunc);
	pArea->SetDetachFunction(asDetachFunc);
}
SCRIPT_DEFINE_FUNC_12(void, SetupStickArea, string, bool, bool, bool, bool, float,
					  string, string, string, string, string, string)

//-----------------------------------------------------------------------

static void AllowAttachment() {
	cGameStickArea::mbAllowAttachment = true;
}
SCRIPT_DEFINE_FUNC(void, AllowAttachment)

//-----------------------------------------------------------------------

static void SetLampLit(tString asName, bool abLit, bool abFade) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Lamp) {
		Warning("Couldn't find lamp '%s'\n", asName.c_str());
		return;
	}
	cGameLamp *pLamp = static_cast<cGameLamp *>(pEntity);

	pLamp->SetLit(abLit, abFade);
}
SCRIPT_DEFINE_FUNC_3(void, SetLampLit, string, bool, bool)

//-----------------------------------------------------------------------

static void SetLampFlicker(tString asName, bool abFlicker) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Lamp) {
		Warning("Couldn't find lamp '%s'\n", asName.c_str());
		return;
	}
	cGameLamp *pLamp = static_cast<cGameLamp *>(pEntity);

	pLamp->SetFlicker(abFlicker);
}
SCRIPT_DEFINE_FUNC_2(void, SetLampFlicker, string, bool)

//-----------------------------------------------------------------------

static void SetLampLitChangeCallback(tString asName, tString asCallback) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Lamp) {
		Warning("Couldn't find lamp '%s'\n", asName.c_str());
		return;
	}
	cGameLamp *pLamp = static_cast<cGameLamp *>(pEntity);

	pLamp->SetLitChangeCallback(asCallback);
}
SCRIPT_DEFINE_FUNC_2(void, SetLampLitChangeCallback, string, string)

//-----------------------------------------------------------------------

static void SetupLadder(tString asName,
						tString asAttachSound,
						tString asClimbUpSound,
						tString asClimbDownSound) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_Ladder) {
		Warning("Couldn't find ladder '%s'\n", asName.c_str());
		return;
	}
	cGameLadder *pLadder = static_cast<cGameLadder *>(pEntity);

	pLadder->SetAttachSound(asAttachSound);
	pLadder->SetClimbUpSound(asClimbUpSound);
	pLadder->SetClimbDownSound(asClimbDownSound);
}
SCRIPT_DEFINE_FUNC_4(void, SetupLadder, string, string, string, string)

//-----------------------------------------------------------------------

static void SetupDamageArea(tString asName, float afDamage,
							float afUpdatesPerSec, int alStrength,
							bool abDisableObjects, bool abDisableEnemies) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_DamageArea) {
		Warning("Couldn't find damage area '%s'\n", asName.c_str());
		return;
	}
	cGameDamageArea *pDamage = static_cast<cGameDamageArea *>(pEntity);

	pDamage->SetDamage(afDamage);
	pDamage->SetUpdatesPerSec(afUpdatesPerSec);
	pDamage->SetStrength(alStrength);
	pDamage->SetDisableObjects(abDisableObjects);
	pDamage->SetDisableEnemies(abDisableEnemies);
}
SCRIPT_DEFINE_FUNC_6(void, SetupDamageArea, string, float, float, int, bool, bool)

//-----------------------------------------------------------------------

static void SetupForceArea(tString asName,
						   float afMaxForce, float afConstant,
						   float afDestSpeed, float afMaxMass,
						   bool abMulWithMass, bool abForceAtPoint,
						   bool abAffectBodies, bool abAffectCharacters) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_ForceArea) {
		Warning("Couldn't find force area '%s'\n", asName.c_str());
		return;
	}
	cGameForceArea *pForce = static_cast<cGameForceArea *>(pEntity);

	pForce->SetMaxForce(afMaxForce);
	pForce->SetConstant(afConstant);
	pForce->SetDestSpeed(afDestSpeed);
	pForce->SetMaxMass(afMaxMass);
	pForce->SetMulWithMass(abMulWithMass);
	pForce->SetForceAtPoint(abForceAtPoint);
	pForce->SetAffectBodies(abAffectBodies);
	pForce->SetAffectCharacters(abAffectCharacters);
}
SCRIPT_DEFINE_FUNC_9(void, SetupForceArea, string, float, float, float, float, bool, bool, bool, bool)

//-----------------------------------------------------------------------

static void SetupLiquidArea(tString asName,
							float afDensity, float afLinearViscosity,
							float afAngularViscosity,
							tString asPhysicsMaterial,
							float fR, float fG, float fB,
							bool abHasWaves) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_LiquidArea) {
		Warning("Couldn't find liquid area '%s'\n", asName.c_str());
		return;
	}
	cGameLiquidArea *pLiquid = static_cast<cGameLiquidArea *>(pEntity);

	pLiquid->SetDensity(afDensity);
	pLiquid->SetLinearViscosity(afLinearViscosity);
	pLiquid->SetAngularViscosity(afAngularViscosity);

	pLiquid->SetPhysicsMaterial(asPhysicsMaterial);

	pLiquid->SetColor(cColor(fR, fG, fB, 1));

	pLiquid->SetHasWaves(abHasWaves);
}
SCRIPT_DEFINE_FUNC_9(void, SetupLiquidArea, string, float, float, float, string, float, float, float, bool)

//-----------------------------------------------------------------------

static void SetupSaveArea(tString asName,
						  tString asMessageCat, tString asMessageEntry,
						  tString asSound) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asName);
	if (pEntity == NULL || pEntity->GetType() != eGameEntityType_SaveArea) {
		Warning("Couldn't find save area '%s'\n", asName.c_str());
		return;
	}
	cGameSaveArea *pSave = static_cast<cGameSaveArea *>(pEntity);

	pSave->SetMessageCat(asMessageCat);
	pSave->SetMessageEntry(asMessageEntry);
	pSave->SetSound(asSound);
}
SCRIPT_DEFINE_FUNC_4(void, SetupSaveArea, string, string, string, string)

//-----------------------------------------------------------------------

///////// GAME ENTITY CALLBACKS //////////////////////////////////

//-----------------------------------------------------------------------

static eGameCollideScriptType GetGameCollideScriptType(const tString &asType) {
	tString sName = cString::ToLowerCase(asType);

	if (sName == "enter")
		return eGameCollideScriptType_Enter;
	if (sName == "leave")
		return eGameCollideScriptType_Leave;
	if (sName == "during")
		return eGameCollideScriptType_During;

	Warning("Collide Type %s doesn't exist!\n", asType.c_str());

	return eGameCollideScriptType_LastEnum;
}

//////////////////////////////

static void AddEntityCollideCallback(tString asType,
									 tString asDestName,
									 tString asEntityName,
									 tString asFuncName) {
	if (cString::ToLowerCase(asDestName) == "player") {
		eGameCollideScriptType type = GetGameCollideScriptType(asType);

		if (type != eGameCollideScriptType_LastEnum)
			gpInit->mpPlayer->AddCollideScript(type, asFuncName, asEntityName);
	} else {
		iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asDestName);
		if (pEntity == NULL) {
			Warning("Couldn't find entity '%s'\n", asDestName.c_str());
			return;
		}

		eGameCollideScriptType type = GetGameCollideScriptType(asType);

		if (type != eGameCollideScriptType_LastEnum)
			pEntity->AddCollideScript(type, asFuncName, asEntityName);
	}
}
SCRIPT_DEFINE_FUNC_4(void, AddEntityCollideCallback, string, string, string, string)

//////////////////////////////

static void RemoveEntityCollideCallback(tString asType,
										tString asDestName,
										tString asEntityName) {
	if (cString::ToLowerCase(asDestName) == "player") {
		eGameCollideScriptType type = GetGameCollideScriptType(asType);

		if (type != eGameCollideScriptType_LastEnum)
			gpInit->mpPlayer->RemoveCollideScript(type, asEntityName);
	} else {
		iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asDestName);
		if (pEntity == NULL) {
			Warning("Couldn't find entity '%s'\n", asDestName.c_str());
			return;
		}

		eGameCollideScriptType type = GetGameCollideScriptType(asType);

		if (type != eGameCollideScriptType_LastEnum) {
			pEntity->RemoveCollideScript(type, asEntityName);
		}
	}
}
SCRIPT_DEFINE_FUNC_3(void, RemoveEntityCollideCallback, string, string, string)

//-----------------------------------------------------------------------

static eGameEntityScriptType GetGameScriptType(const tString &asType) {
	tString sName = cString::ToLowerCase(asType);

	if (sName == "playerinteract")
		return eGameEntityScriptType_PlayerInteract;
	if (sName == "playerexamine")
		return eGameEntityScriptType_PlayerExamine;
	if (sName == "playerlook")
		return eGameEntityScriptType_PlayerPick;
	if (sName == "onupdate")
		return eGameEntityScriptType_OnUpdate;
	if (sName == "onbreak")
		return eGameEntityScriptType_OnBreak;

	Warning("Script type '%s' doesn't exist!\n", asType.c_str());

	return eGameEntityScriptType_LastEnum;
}

/////////////////////

static void AddEntityCallback(tString asType,
							  tString asDestName,
							  tString asFuncName) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asDestName);
	if (pEntity == NULL) {
		Warning("Couldn't find entity '%s'\n", asDestName.c_str());
		return;
	}

	eGameEntityScriptType type = GetGameScriptType(asType);

	if (type != eGameEntityScriptType_LastEnum) {
		pEntity->AddScript(type, asFuncName);
	}
}
SCRIPT_DEFINE_FUNC_3(void, AddEntityCallback, string, string, string)

/////////////////////

static void RemoveEntityCallback(tString asType,
								 tString asDestName) {
	iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asDestName);
	if (pEntity == NULL) {
		Warning("Couldn't find entity '%s'\n", asDestName.c_str());
		return;
	}

	eGameEntityScriptType type = GetGameScriptType(asType);

	if (type != eGameEntityScriptType_LastEnum) {
		pEntity->RemoveScript(type);
	}
}
SCRIPT_DEFINE_FUNC_2(void, RemoveEntityCallback, string, string)

//-----------------------------------------------------------------------

///////// GAME SOUND //////////////////////////////////

//-----------------------------------------------------------------------

static void CreateSoundEntityAt(tString asType, tString asDestName,
								tString asSoundName, tString asSoundFile) {
	cWorld3D *pWorld = gpInit->mpGame->GetScene()->GetWorld3D();
	iPhysicsWorld *pPhysicsWorld = gpInit->mpGame->GetScene()->GetWorld3D()->GetPhysicsWorld();

	int lType = 0;
	tString sTypeLow = cString::ToLowerCase(asType);

	if (sTypeLow == "body")
		lType = 1;
	else if (sTypeLow == "joint")
		lType = 2;
	else if (sTypeLow == "entity")
		lType = 3;

	if (lType == 0) {
		Warning("Cannot find type '%s' for sound entity position.\n", asType.c_str());
		return;
	}

	cVector3f vPos;

	////////////////////////
	// Body
	if (lType == 1) {
		iPhysicsBody *pBody = pPhysicsWorld->GetBody(asDestName);
		if (pBody == NULL) {
			Warning("Body '%s' coudln't be found!\n", asDestName.c_str());
			return;
		}

		vPos = pBody->GetLocalPosition();
	}
	////////////////////////
	// Joint
	else if (lType == 2) {
		iPhysicsJoint *pJoint = pPhysicsWorld->GetJoint(asDestName);
		if (pJoint == NULL) {
			Warning("Body '%s' coudln't be found!\n", asDestName.c_str());
			return;
		}

		vPos = pJoint->GetPivotPoint();
	}
	////////////////////////
	// Entity
	{
		iGameEntity *pEntity = gpInit->mpMapHandler->GetGameEntity(asDestName);
		if (pEntity == NULL) {
			Warning("Couldn't find entity '%s'\n", asDestName.c_str());
			return;
		}

		if (pEntity->GetMeshEntity())
			vPos = pEntity->GetMeshEntity()->GetWorldPosition();
		else
			vPos = pEntity->GetBody(0)->GetLocalPosition();
	}

	////////////////////////
	// Create sound.
	cSoundEntity *pSound = pWorld->CreateSoundEntity(asSoundName, asSoundFile, true);
	if (pSound) {
		pSound->SetPosition(vPos);
	}
}
SCRIPT_DEFINE_FUNC_4(void, CreateSoundEntityAt, string, string, string, string)

//-----------------------------------------------------------------------

//////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS
//////////////////////////////////////////////////////////////////////////

//-----------------------------------------------------------------------

void cGameScripts::Init() {
	LowLevelSystem *pLowLevelSystem = gpInit->mpGame->GetSystem()->GetLowLevel();
	gsTempString = new tWString;

	// Game helper
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddToTempString));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddToTempStringTrans));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddToTempStringAction));

	// Game general
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(ResetGame));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(StartCredits));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(StartDemoEndText));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(ClearSavedMaps));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(GetActionKeyString));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddMessageTrans));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddMessage));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddMessageTempString));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddSubTitleTrans));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddSubTitle));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddSubTitleTempString));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddRadioMessage));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetRadioOnEndCallback));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetMessagesOverCallback));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(ChangeMap));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetMapGameName));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetMapGameNameTrans));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddNotebookTaskText));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddNotebookTask));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(RemoveNotebookTask));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddNotebookNote));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(StartNumericalPanel));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetInventoryActive));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(FadeIn));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(FadeOut));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(IsFading));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetWideScreenActive));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AutoSave));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(StartFlash));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetWaveGravityActive));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetupWaveGravity));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetDepthOfFieldActive));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetupDepthOfField));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(FocusOnEntity));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetConstantFocusOnEntity));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(PlayGameMusic));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(StopGameMusic));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(StartScreenShake));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(CreateLightFlashAtArea));

	// Attack
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(CreateSplashDamage));

	// Game timer
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(CreateTimer));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(DestroyTimer));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetTimerPaused));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetTimerTime));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddTimerTime));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(GetTimerTime));

	// Player
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(GivePlayerDamage));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetPlayerHealth));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(GetPlayerHealth));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetPlayerPose));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetPlayerActive));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(StartPlayerLookAt));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(StopPlayerLookAt));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(StartPlayerFearFilter));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(StopPlayerFearFilter));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetFlashlightDisabled));

	// Inventory
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddPickupCallback));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddUseCallback));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddCombineCallback));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(RemovePickupCallback));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(RemoveUseCallback));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(RemoveCombineCallback));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(HasItem));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(RemoveItem));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(GiveItem));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetInventoryMessage));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetInventoryMessageTrans));

	// Game entity properties
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(ReplaceEntity));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetGameEntityActive));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(GetGameEntityActive));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetGameEntityMaxExamineDist));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetGameEntityMaxInteractDist));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(CreateGameEntityVar));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetGameEntityVar));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddGameEntityVar));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(GetGameEntityVar));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetGameEntityDescriptionTrans));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetGameEntityDescriptionOnceTrans));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetGameEntityDescription));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetGameEntityGameNameTrans));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(ChangeEntityAnimation));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetEntityHealth));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(DamageEntity));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetDoorState));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetObjectInteractMode));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetupLink));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetupLinkLoadText));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetAreaCustomIcon));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddEnemyPatrolNode));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(ClearEnemyPatrolNodes));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetEnemyDeathCallback));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetEnemyAttackCallback));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(GetEnemyHealth));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetEnemyUseTriggers));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(ShowEnemyPlayer));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetDoorLocked));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetupStickArea));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AllowAttachment));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetLampLit));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetLampLitChangeCallback));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetLampFlicker));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetupLadder));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetupDamageArea));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetupForceArea));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetupLiquidArea));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(SetupSaveArea));

	// Game entity callbacks
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddEntityCollideCallback));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(RemoveEntityCollideCallback));

	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(AddEntityCallback));
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(RemoveEntityCallback));

	// Game sound
	pLowLevelSystem->addScriptFunc(SCRIPT_REGISTER_FUNC(CreateSoundEntityAt));
}

void cGameScripts::finalize() {
	delete gsTempString;
}

//-----------------------------------------------------------------------