This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathscripting.cpp
2126 lines (1979 loc) · 86.6 KB
/
scripting.cpp
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
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <math.h>
#include <string.h>
#include "gameobjects.h"
#include "gamestrings.h"
#include "tilemap.h"
#include "main.h"
#include "scripting.h"
FILE *fGLOBALS;
FILE *fMAIN;
FILE *fBODY;
int lookupString(int BlockNo, int StringNo, char StringOut[255] );
void scriptShockButtons(tile LevelInfo[64][64], ObjectItem objList[1600], ObjectItem currObj);
void scriptShockTriggerAction(tile LevelInfo[64][64], ObjectItem objList[1600], ObjectItem currObj);
void shockScriptActivate(ObjectItem objList[1600], ObjectItem targetObj);
void MovingPlatformSCRIPT(int triggerX, int triggerY, int targetFloor, int targetCeiling, tile LevelInfo[64][64]);
void toggleSCRIPT(ObjectItem objList[1600], ObjectItem currObj);
void scriptShockButtonsActions(tile LevelInfo[64][64], ObjectItem objList[1600], ObjectItem currObj);
extern long SHOCK_CEILING_HEIGHT;
extern long UW_CEILING_HEIGHT;
short globals[255];
void BullFrogScript()
{
fprintf(fGLOBALS, "\tfloat bullfrog_targetX=48;\n");
fprintf(fGLOBALS, "\tfloat bullfrog_targetY=48;\n");
for (int x = 48; x< 56; x++)
{
for (int y = 48; y< 56; y++)
{
fprintf(fGLOBALS, "\tfloat bullfrog_%d_%d_state=0;\n",x,y);
//Lift and drop functions for each tile
fprintf(fBODY, "\nvoid Raise_bullfrog_%d_%d(float distance)", x, y);
fprintf(fBODY, "\n\t{\n");
fprintf(fBODY, "\tsys.println(\"raise %d %d\");\n", x,y);
fprintf(fBODY, "\tif ( bullfrog_%d_%d_state <=360)\n\t\t{\n",x, y);
fprintf(fBODY, "\tsys.println(\"raise %d %d execute\");\n", x, y);
fprintf(fBODY, "\t\t$bullfrog_%d_%d.move( UP, distance );\n", x, y);
fprintf(fBODY, "\t\tbullfrog_%d_%d_state=bullfrog_%d_%d_state+distance;\n", x, y, x, y);
fprintf(fBODY, "\tsys.println(\"raise %d %d Completed\");\n", x, y);
fprintf(fBODY, "\t\t}");
fprintf(fBODY, "\n\t}");
fprintf(fBODY, "\nvoid Lower_bullfrog_%d_%d(float distance)", x, y);
fprintf(fBODY, "\n\t{\n");
fprintf(fBODY, "\tsys.println(\"lower %d %d\");\n", x, y);
fprintf(fBODY, "\tif ( bullfrog_%d_%d_state >=0)\n\t\t{\n", x, y);
fprintf(fBODY, "\tsys.println(\"lower %d %d execute\");\n", x, y);
fprintf(fBODY, "\t\t$bullfrog_%d_%d.move( DOWN, distance );\n", x, y);
fprintf(fBODY, "\t\tbullfrog_%d_%d_state=bullfrog_%d_%d_state-distance;\n", x, y,x,y);
fprintf(fBODY, "\tsys.println(\"lower %d %d Completed\");\n", x, y);
fprintf(fBODY, "\t\t}");
fprintf(fBODY, "\n\t}");
}
}
fprintf(fBODY, "\nvoid ExecuteBullFrogUp(float targetX, float targetY)\n\t{\n");
fprintf(fBODY, "\tsys.println(targetX);\n");
fprintf(fBODY, "\tsys.println(targetY);\n");
for (int x = 48; x< 56; x++)
{
for (int y = 48; y< 56; y++)
{
//fprintf(fBODY, "\tsys.println(\"Testing up %d %d\");\n", x, y);
fprintf(fBODY, "\n\tif ( (targetX==%d) && (targetY == %d) )",x,y);
fprintf(fBODY, "\n\t\t{");
fprintf(fBODY, "\tsys.println(\"Passed %d %d\");\n", x, y);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(60);", x, y);
//fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d();", x, y);
switch (x)
{
case 48://West edge
switch (y)
{
case 48://sw corner
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x+1, y);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x , y+1);
break;
case 55://nw corner
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x+1, y);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x, y-1);
break;
default://west edge
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x+1, y+1 );
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x, y+1);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x,y-1 );
break;
}
break;
case 55://east edge
switch (y)
{
case 48://se corner
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x -1, y);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x , y+1);
break;
case 55://ne corner
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x , y-1);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x-1 , y);
break;
default://east edge
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x, y-1);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x-1, y);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x, y+1);
break;
}
break;
default:
switch (y)
{
case 48://south edge
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x+1, y);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x-1, y);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x, y+1);
break;
case 55://north edge
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x+1, y);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x-1, y);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x, y-1);
break;
default://middle
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x+1, y);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x-1, y);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x, y+1);
fprintf(fBODY, "\n\t\tRaise_bullfrog_%d_%d(45);", x, y-1);
break;
}
break;
}
fprintf(fBODY, "\n\t\t}");
}
}
fprintf(fBODY, "\n\t}");
fprintf(fBODY, "\nvoid ExecuteBullFrogDown(float targetX, float targetY)\n\t{\n");
fprintf(fBODY, "\tsys.println(targetX);\n");
fprintf(fBODY, "\tsys.println(targetY);\n");
for (int x = 48; x< 56; x++)
{
for (int y = 48; y< 56; y++)
{
//fprintf(fBODY, "\tsys.println(\"testing down %d %d\");\n", x, y);
fprintf(fBODY, "\n\tif ( (targetX == %d) && (targetY == %d) )", x, y);
fprintf(fBODY, "\n\t\t{");
fprintf(fBODY, "\tsys.println(\"passed down %d %d\");\n", x, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(60);", x, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(60);", x, y);
switch (x)
{
case 48://West edge
switch (y)
{
case 48://sw corner
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x + 1, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y + 1);
break;
case 55://nw corner
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x + 1, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y - 1);
break;
default://west edge
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x + 1, y + 1);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y + 1);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y - 1);
break;
}
break;
case 55://east edge
switch (y)
{
case 48://se corner
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x - 1, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y + 1);
break;
case 55://ne corner
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y - 1);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x - 1, y);
break;
default://east edge
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y - 1);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x - 1, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y + 1);
break;
}
break;
default:
switch (y)
{
case 48://south edge
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x + 1, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x - 1, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y + 1);
break;
case 55://north edge
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x + 1, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x - 1, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y - 1);
break;
default://middle
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x + 1, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x - 1, y);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y + 1);
fprintf(fBODY, "\n\t\tLower_bullfrog_%d_%d(45);", x, y - 1);
break;
}
break;
}
fprintf(fBODY, "\n\t\t}");
}
}
fprintf(fBODY, "\n\t}");
}
void EMAILScript(char objName[80], ObjectItem currObj, int logChunk)
{
//printf("void start_%s()\n{",UniqueObjectName(currObj));
fprintf(fBODY,"\n\t$data_reader_trigger.setKey(\"snd_say\",\"shock_audio_log_%04d\");",logChunk);
fprintf(fBODY,"\n\t$data_reader_trigger.activate($player1);\n");
//printf("\n}\n\n");
}
void LightingScript(tile LevelInfo[64][64], ObjectItem objList[1600], ObjectItem currObj)
{
//000C int16 Control point 1
//000E int16 Control point 2
// ... ?
//printf("\tACTION_LIGHTING\n");
//printf("\t\tControl point 1:%d\n",getValAtAddress(sub_ark,add_ptr+12,16));
//printf("\t\tControl point 2%d\n",getValAtAddress(sub_ark,add_ptr+14,16));
//printf("\t\tOther values 1:%d\n",getValAtAddress(sub_ark,add_ptr+16,16));
//printf("\t\tOther values 2:%d\n",getValAtAddress(sub_ark,add_ptr+18,16));
//printf("\t\tOther values 3:%d\n",getValAtAddress(sub_ark,add_ptr+20,16));
//printf("\t\tOther values 4:%d\n",getValAtAddress(sub_ark,add_ptr+22,16));
//printf("\t\tOther values 5:%d\n",getValAtAddress(sub_ark,add_ptr+24,16));
//printf("\t\tOther values 6:%d\n",getValAtAddress(sub_ark,add_ptr+26,16));
//objList[objIndex].shockProperties[TRIG_PROPERTY_CONTROL_1]
//objList[objIndex].shockProperties[TRIG_PROPERTY_CONTROL_2]
//shade = (0.50) * (1 - ((float)LevelInfo[x][y].shockShadeUpper / 15));
if (ENABLE_LIGHTING == 1)
{
int shadeUpper1 = currObj.shockProperties[TRIG_PROPERTY_UPPERSHADE_1]; //TRIG_PROPERTY_UPPERSHADE
int shadeLower1 = currObj.shockProperties[TRIG_PROPERTY_LOWERSHADE_1];
int shadeUpper2 = currObj.shockProperties[TRIG_PROPERTY_UPPERSHADE_2]; //TRIG_PROPERTY_UPPERSHADE
int shadeLower2 = currObj.shockProperties[TRIG_PROPERTY_LOWERSHADE_2];
int x1 = objList[currObj.shockProperties[TRIG_PROPERTY_CONTROL_1]].tileX;
int y1 = objList[currObj.shockProperties[TRIG_PROPERTY_CONTROL_1]].tileY;
int x2 = objList[currObj.shockProperties[TRIG_PROPERTY_CONTROL_2]].tileX;
int y2 = objList[currObj.shockProperties[TRIG_PROPERTY_CONTROL_2]].tileY;
int xMin=0; int xMax=0;
int yMin=0; int yMax=0;
if (x1 >= x2)
{
xMin = x2; xMax = x1;
}
else
{
xMin = x1; xMax = x2;
}
if (y1 >= y2)
{
yMin = y2; yMax = y1;
}
else
{
yMin = y1; yMax = y2;
}
if (yMin < 0){ yMin = 0; }
if (xMin < 0){ xMin = 0; }
//fprintf(fBODY, "\tfloat dir = 1;\n");
fprintf(fBODY, "\tfloat shade = 0;\n");
fprintf(fBODY, "\tfloat shadeUpperAdj =0;");
fprintf(fBODY, "\tfloat shadeLowerAdj =0;\n");
fprintf(fBODY, "\tif (%s_light_state == 0)\n\t{\n", UniqueObjectName(currObj));
fprintf(fBODY, "\tshadeUpperAdj =%d; shadeLowerAdj =%d;\n\t}\n\telse\n\t{\n", shadeUpper1, shadeLower1);
fprintf(fBODY, "\tshadeUpperAdj =%d; shadeLowerAdj =%d;\n\t}\n", shadeUpper2, shadeLower2);
//fprintf(fBODY, "\tshade = (0.50) * (1 - ((%d - shadeUpperAdj) / 15));\n",15);
//fprintf(fBODY, "\tshade = (0.50) * (1 - ((%d - shadeLowerAdj) / 15));\n",15);
//fprintf(fBODY, "\tif (%s_light_state == 0)\n\t{\n", UniqueObjectName(currObj));
//fprintf(fBODY, "\t\tdir = -1 ;\n\t\t%s_light_state = 1;\n\t}\n\telse\n\t{\n", UniqueObjectName(currObj));
//fprintf(fBODY, "\t\tdir = 1 ;\n\t\t%s_light_state = 0;\n\t}\n", UniqueObjectName(currObj));
//if ((yMin >= 0) || (xMin >= 0))
//{
for (int x = xMin; x <= xMax; x++)
{
for (int y = yMin; y <= yMax; y++)
{
if (LevelInfo[x][y].tileType != 0)
{
//if ((LevelInfo[x][y].shadeUpperGlobal == 0) && ((shadeUpper1 >= 1) || (shadeUpper2 >=1)))
//{//add a global for this light
// //fprintf(fGLOBALS, "\n\tfloat light_%02d_%02d_upper_state = %d;\n",x,y, LevelInfo[x][y].shockShadeUpper);
// LevelInfo[x][y].shadeUpperGlobal = 1;
//}
//if ((LevelInfo[x][y].shadeLowerGlobal == 0) && ((shadeLower1 >= 1) || (shadeLower2 >= 1)))
// {//add a global for this light
// //fprintf(fGLOBALS, "\n\tfloat light_%02d_%02d_lower_state = %d;\n",x,y, LevelInfo[x][y].shockShadeLower);
// LevelInfo[x][y].shadeLowerGlobal = 1;
// }
if ((shadeUpper1 >= 1) || (shadeUpper2 >= 1))
{
//fprintf(fBODY, "\tshade = (0.50) * (1 - ((%d + (dir * %d)) / 15)) ;\n", x, y, LevelInfo[x][y].shockShadeUpper);
fprintf(fBODY, "\tshade = (0.50) * (1 - ((%d - shadeUpperAdj) / 15));\n", LevelInfo[x][y].shockShadeUpper);
//fprintf(fBODY, "\tlight_%02d_%02d_upper_state = light_%02d_%02d_upper_state + (dir * %d);\n", x, y,x,y,shadeUpper);
//fprintf(fBODY, "\tsys.println(\"Setting upper shade %02d %02d\"); \n",x,y);
//fprintf(fBODY, "\tsys.println(shade); \n");
fprintf(fBODY, "\t$light_%02d_%02d_upper.setColor( shade,shade,shade );\n", x, y);
}
if ((shadeLower1 >= 1) || (shadeLower2 >= 1))
{
//fprintf(fBODY, "\tshade = (0.50) * (1 - ((light_%02d_%02d_lower_state + (dir * %d)) / 15)) ;\n", x, y, shadeLower);
//fprintf(fBODY, "\tlight_%02d_%02d_lower_state = light_%02d_%02d_lower_state + (dir * %d);\n", x, y, x, y, shadeLower);
//fprintf(fBODY, "\tsys.println(\"Setting lower shade %02d %02d\"); \n", x, y);
//fprintf(fBODY, "\tsys.println(shade); \n");
fprintf(fBODY, "\tshade = (0.50) * (1 - ((%d - shadeLowerAdj) / 15));\n", LevelInfo[x][y].shockShadeLower);
fprintf(fBODY, "\t$light_%02d_%02d_lower.setColor( shade,shade,shade );\n", x, y);
}
}
// }
}
}
fprintf(fGLOBALS, "\tfloat %s_light_state = 1;\n", UniqueObjectName(currObj)); //Global for the master trigger state for on / off behaviour.
//fprintf(fBODY, "\tif (%s_light_state == 0)\n\t{\n", UniqueObjectName(currObj));
//fprintf(fBODY, "\t\t%s_light_state = 1;\n\t}\n\telse\n\t{\n", UniqueObjectName(currObj));
//fprintf(fBODY, "\t\t%s_light_state = 0;\n\t}\n", UniqueObjectName(currObj));
fprintf(fBODY, "\tif (%s_light_state == 0)\n\t{\n", UniqueObjectName(currObj));
fprintf(fBODY, "\t\t%s_light_state = 1;\n\t}\n\telse\n\t{\n", UniqueObjectName(currObj));
fprintf(fBODY, "\t\t%s_light_state = 0;\n\t}\n", UniqueObjectName(currObj));
}
else
{
fprintf(fBODY, "\tsys.println(\"Lighting control cp1=%d cp2=%d\");\n", currObj.shockProperties[TRIG_PROPERTY_CONTROL_1], currObj.shockProperties[TRIG_PROPERTY_CONTROL_2]);
}
}
void a_change_terrain_trapSCRIPT(ObjectItem currObj, int targetX, int targetY, int dimX, int dimY, ObjectItem objList[1600])
{//This needs to be updated to support multiple traps working on a single tile.
int i;
int j;
if (currObj.index == 996)
{
printf("");
}
//int k;
//k = 0;
//if ((dimX == 0) && (dimY == 0))
// {//A single tile trap.
// fprintf(fBODY, "\t$initial_%s_%03d.remove();\n"
// , UniqueObjectName(currObj), 0);
// }
for (i=0;i<=dimX;i++)
{
for (j=0;j<=dimY;j++)
{//\"initial_%s_%03d\"\n", UniqueObjectName(currobj), tileCount);
fprintf(fBODY, "\n\t//Change terrain script %s\n", UniqueObjectName(currObj));
fprintf(fBODY, "\tif (tile_%02d_%02d_removed == 0)\n", currObj.tileX + i, currObj.tileY + j);
fprintf(fBODY,"\t{\n\t\t$tile_%02d_%02d.remove();\n"
,currObj.tileX+i,currObj.tileY+j);
fprintf(fBODY, "\t\ttile_%02d_%02d_removed = 1;\n", currObj.tileX + i, currObj.tileY + j);
fprintf(fBODY, "\t}\n");
//Hide the other terrain changes on the affected tiles
for (int k = 0; k < LevelInfo[currObj.tileX + i][currObj.tileY + j].TerrainChangeCount; k++)
{
if (LevelInfo[currObj.tileX + i][currObj.tileY + j].TerrainChangeIndices[k] != currObj.index)
{
fprintf(fBODY, "\t$%s_%02d_%02d.hide();\n"
, UniqueObjectName(objList[LevelInfo[currObj.tileX + i][currObj.tileY + j].TerrainChangeIndices[k]]), currObj.tileX + i, currObj.tileY + j);
}
}
fprintf(fBODY, "\t$%s_%02d_%02d.show();\n"
, UniqueObjectName(currObj), currObj.tileX + i, currObj.tileY+j);
}
}
// fprintf(fBODY,"\t$final_%s.show();\n"
// ,UniqueObjectName(currObj));
}
void a_delete_object_trapSCRIPT(ObjectItem objList[1600], int objectToDelete)
{
fprintf(fBODY,"\t$%s.hide();"
, UniqueObjectName(objList[objectToDelete]));
}
void a_text_string_trapSCRIPT(int game, int stringId, int targetLevelNo)
{
char pStr[255];
if (game == UW1)
{
if (lookupString(9, 64 * (targetLevelNo) + stringId ,pStr))
{
fprintf(fBODY,"\tsys.println(\"%s\");\n",pStr );
}
else
{
fprintf(fBODY,"\tsys.println(\"Text trap String not found %3\n\");\n", stringId );
}
}
else
{
fprintf(fBODY, "\tsys.println(\"UW2 Text trap String not found\");\n");
}
}
void enchantmentSCRIPT(int stringId)
{
char pStr[255];
if (lookupString(9, 6 ,pStr))
{
fprintf(fBODY,"\tsys.println(\"Enchantment:%s\");",pStr );
}
else
{
fprintf(fBODY,"\tsys.println(\"Enchantment String not found %3\");", stringId );
}
}
void a_teleport_trapSCRIPT(ObjectItem currObj, int x, int y, int TargetLevelNo, int triggerX, int triggerY)
{
if (TargetLevelNo !=0 ) //Move to another level
{
fprintf(fBODY,"\tsys.setcvar(\"targetX\",\"%d\");\n",x);
fprintf(fBODY,"\tsys.setcvar(\"targetY\",\"%d\");\n",y);
fprintf(fBODY,"\tsys.trigger($trigger_endlevel_%03d_%03d);\n",triggerX,triggerY);
}
else
{
fprintf(fBODY, "\tif (JustTeleported == 0)\n\t{");
fprintf(fBODY, "\n\tJustTeleported = 1;");
fprintf(fBODY, "\n\t$%s.activate($player1);", UniqueObjectName(currObj));
fprintf(fBODY, "\n\tsys.wait(5);"); //wait a few seconds before we try and teleport again
fprintf(fBODY, "\n\tJustTeleported = 0;");
fprintf(fBODY, "\n\t}");
}
}
void a_do_trap_cameraSCRIPT(char objDesc[80], int triggerX, int triggerY, int objId)
{
//chainArray(objDescription) & "_" & Format(TriggerTargetX, "00#") & "_" & Format(TriggerTargetY, "00#")
fprintf(fBODY,"\tsys.wait(1);\n");
fprintf(fBODY,"\t$%s_%03d_%03d.activate($player1);\n",objDesc,triggerX,triggerY);
fprintf(fBODY,"\tsys.wait(10);\n");
fprintf(fBODY,"\t$%s_%03d_%03d.activate($player1);\n",objDesc,triggerX,triggerY);
}
void a_do_trap_platformSCRIPT(char objDesc[80], int triggerX, int triggerY, int objId,int state,int up, int down)
{
fprintf(fBODY,"\tif ( %s_%03d_%03d_state ==8)\n\t\t{\n",objDesc, triggerX,triggerY);
fprintf(fBODY,"\t\t$floor_%03d_%03d.move( DOWN, %d );\n", triggerX,triggerY,down);
fprintf(fBODY,"\t\t%s_%03d_%03d_state = 0;\n}\n",objDesc, triggerX,triggerY);
fprintf(fBODY,"\telse\n\t\t{\n");
fprintf(fBODY,"\t\t$floor_%03d_%03d.move ( UP, %d );\n" , triggerX,triggerY,up);
fprintf(fBODY,"\t\t%s_%03d_%03d_state++ ;\n\t}\n",objDesc,triggerX,triggerY);
}
void a_lock(int doorX, int doorY, int targetState)
{
switch (targetState)
{
case 1: //Try open
fprintf(fBODY, "\tsys.println(\"Try Open -> a_door_%03d_%03d\");", doorX, doorY);
fprintf(fBODY,"\t$a_door_%03d_%03d.Open();\n",doorX,doorY);
break;
case 2: //Try close
fprintf(fBODY, "\tsys.println(\"Try Close -> a_door_%03d_%03d\");", doorX, doorY);
fprintf(fBODY,"\t$a_door_%03d_%03d.Close();\n",doorX,doorY);
fprintf(fBODY,"\tsys.wait(2);\n");
fprintf(fBODY, "\t//sys.println(\"Try Lock -> a_door_%03d_%03d\");", doorX, doorY);
fprintf(fBODY,"\t$a_door_%03d_%03d.Lock();",doorX,doorY);
break;
default: //toggle
fprintf(fBODY, "\tsys.println(\"toggle -> a_door_%03d_%03d\");", doorX, doorY);
fprintf(fBODY,"\t$a_lock_%03d_%03d.activate($player1);\n",doorX,doorY);
break;
}
}
void entranceteleporters()
{
//todo
}
void tobedone(char desc[80])
{
fprintf(fBODY,"\tsys.println(\"TODO:%s\");\n",desc);
}
void a_set_variable_trapSCRIPT(int variable, int value, int operation)
{
// heading operation bit-field operation
// 0 add set bit
// 1 sub clear bit
// 2 set set bit
// 3 and set bit
// 4 or set bit
// 5 xor flip bit
// 6 shl set bit
if (variable != 0)
{
switch(operation)
{
case 0 : //add
fprintf(fBODY,"\tglobal_var_%d += %d ;\n",variable,value);
break;
case 1: //sub
fprintf(fBODY,"\tglobal_var_%d -= %d ;\n",variable,value);
break;
case 2 : //set
fprintf(fBODY,"\tglobal_var_%d = %d ;\n",variable,value);
break;
case 3 : //and
fprintf(fBODY,"\tglobal_var_%d &= %d ;\n",variable,value); //Does this work??
break;
case 4: //or
fprintf(fBODY,"\tglobal_var_%d |= %d ;\n",variable,value);
break;
case 5 : //xor ! ((a&b) & (a|b))
fprintf(fBODY,"\tglobal_var_%d = (~( global_var_%d & %d) ) & ( global_var_%d | %d) ;\n",variable,variable,value,variable,value);
break;
case 6: //shiftleft double by value times
fprintf(fBODY,"\tglobal_var_%d = (global_var_%d * %d ) & 63 ;\n",variable,variable,2*value);
break;
}
}
else
{
//bitwise 'todo
// switch operation
// Case 0 'set
// Case 1 'clear
// Case 2 'set
// Case 3 'set
// Case 4 'set
// Case 5 'flip
// Case 6 'set
//pOut = pOut & vbNewLine & "sys.println(var_" & variable & ");" & vbNewLine
}
}
void a_check_variable_trapSCRIPT(int variable, int value)
{
//Will need to expand on this for more complex checks
fprintf(fBODY,"\tif (global_var_%d == %d) \n\t{\n",variable,value);
}
void addConditionals(int noofCond)
{
int i = 1;
for(i=1;i<=noofCond;i++)
{
fprintf(fBODY,"\n\t}");
}
}
//0 1 2 3 4 5 6 7 8 9 10 11 12
//Index Type Description TileX TileY x y z heading qual owner link flags
void buildScriptsUW(int game,tile LevelInfo[64][64],ObjectItem objList[1600],int LevelNo, char Script_Final_File[255])
{
int conditionalCount =0;
int TriggerTargetX=-1;
int TriggerTargetY=-1;
int TriggerQuality=-1;
int TriggerFlags=-1;
int TriggerHomeX=-1;
int TriggerHomeY=-1;
if (fopen_s(&fBODY,SCRIPT_BODY_FILE, "w")!=0)
{
printf("Unable to create output file for body");
return;
}
if (fopen_s(&fGLOBALS, SCRIPT_GlOBAL_FILE, "w")!=0)
{
printf("Unable to create output file for globals");
return;
}
if (fopen_s(&fMAIN, SCRIPT_MAIN_FILE, "w")!=0)
{
printf("Unable to create output file for main");
return;
}
fprintf(fGLOBALS,"\tfloat JustTeleported = 0;\n");
for (int x = 0; x <63; x++)
{
for (int y = 0; y <63; y++)
{
if (LevelInfo[x][y].TerrainChange == 1)
{
fprintf(fGLOBALS, "\tfloat tile_%02d_%02d_removed = 0;\n",x,y);
}
}
}
if ((game == UW1) && (LevelNo == 3))
{
BullFrogScript();
}
fprintf(fMAIN,"\nvoid main()\n{\n");
fprintf(fMAIN, "\t$light_1.bind($player1);\n");
for (int i = 0; i < 1600; i++)
{
if (objList[i].item_id >0)
{
if (objectMasters[objList[i].item_id].type == A_USE_TRIGGER)
{
fprintf(fGLOBALS, "\tfloat %s_state = 0;\n", UniqueObjectName(objList[i]));
}
}
if (objList[i].InUseFlag >0)
{
if ((objectMasters[objList[i].item_id].isMoveable == 1) && (objectMasters[objList[i].item_id].isInventory == 1))
{//For hiding the particle attached to this objec"gt when it's picked up.
fprintf(fBODY, "\nvoid %s_frob()", UniqueObjectName(objList[i]));
fprintf(fBODY, "\n\t{\n\t$%s_particle.activate($player1);\n\t}\n", UniqueObjectName(objList[i]));
}
if (objectMasters[objList[i].item_id].type == A_CHANGE_TERRAIN_TRAP)
{
for (int x = 0; x <= objList[i].x; x++)
{
for (int y = 0; y <= objList[i].y; y++)
{
fprintf(fMAIN, "\t$%s_%02d_%02d.hide();\n", UniqueObjectName(objList[i]), objList[i].tileX + x, objList[i].tileY+y);
}
}
}
}
}
for (int y=63; y>=0;y--)
{
for (int x=0; x<64;x++)
{
if(LevelInfo[x][y].indexObjectList !=0) //there is an object in this tile
{
long nextObj = LevelInfo[x][y].indexObjectList;
while (nextObj !=0)
{
if ((isTrigger(objList[nextObj]) || (isButton(objList[nextObj])) || (isTrigger(objList[objList[nextObj].link]))))
{
//printObject(objList[nextObj],1); //Prints the first object the inital trigger.
fprintf(fBODY,"\n\nvoid start_%s()\n\t{\n",
UniqueObjectName(objList[nextObj]));
conditionalCount = 0;
//UW triggers get some of their parameters from the triggers that called them.
TriggerTargetX=objList[nextObj].quality ;
TriggerTargetY=objList[nextObj].owner ;
TriggerQuality=objList[nextObj].quality ;
TriggerFlags=objList[nextObj].flags ;
TriggerHomeX=objList[nextObj].tileX ;
TriggerHomeY=objList[nextObj].tileY ;
long nextInChain = objList[nextObj].link; //for uw.
while (nextInChain !=0)
{
if (isTrigger(objList[nextInChain]) || (isButton(objList[nextInChain])) || (isTrap(objList[nextInChain])) || (isLock(objList[nextInChain])))
{
switch (objectMasters[objList[nextInChain].item_id].type)
{
case A_DELETE_OBJECT_TRAP: //Need to stop on this due to infinite loops if the trigger object is being deleted.
case LOCK://A lock uses it's link to set the key needed. stop here.
{
//printObject(objList[nextInChain],1);fprintf(fBODY,"\n");
//scriptChainFunctions(objList[nextInChain]);
scriptChainFunctionsUW(game, objList,objList[nextInChain],&conditionalCount,&TriggerTargetX,&TriggerTargetY,&TriggerQuality,&TriggerFlags,&TriggerHomeX,&TriggerHomeY,LevelNo);
nextInChain=0;
break;
}
case A_USE_TRIGGER:
if (objList[nextInChain].next != 0)
{
fprintf(fBODY, "\n//A use trigger (%s) with a next (%s)\n", UniqueObjectName(objList[nextInChain]), UniqueObjectName(objList[objList[nextInChain].next]));
fprintf(fBODY, "\n\tif (%s_state==1)\n\t{", UniqueObjectName(objList[nextInChain]));
fprintf(fBODY, "\n\t\t %s_state=0;\n", UniqueObjectName(objList[nextInChain]));
int originalNext = nextInChain;
nextInChain = objList[objList[nextInChain].next].link;
while (nextInChain!=0)
{
scriptChainFunctionsUW(game, objList, objList[nextInChain], &conditionalCount, &TriggerTargetX, &TriggerTargetY, &TriggerQuality, &TriggerFlags, &TriggerHomeX, &TriggerHomeY, LevelNo);
nextInChain = objList[nextInChain].link;
}
fprintf(fBODY, "\n\t}");
fprintf(fBODY, "\n\telse\n\t{");
fprintf(fBODY, "\n\t\t %s_state=1;\n", UniqueObjectName(objList[originalNext]));
conditionalCount++;
nextInChain = originalNext;
}
default:
{
//printObject(objList[nextInChain],1); fprintf(fBODY,"\n");
scriptChainFunctionsUW(game, objList,objList[nextInChain],&conditionalCount,&TriggerTargetX,&TriggerTargetY,&TriggerQuality,&TriggerFlags,&TriggerHomeX,&TriggerHomeY,LevelNo);
nextInChain = objList[nextInChain].link;
if (nextInChain !=0)
{fprintf(fBODY, "\n\t//NextInChain is %d - %s\n", nextInChain,UniqueObjectName(objList[nextInChain]));}
break;
}
}
}
else
{
if (nextInChain !=0)
{
fprintf(fBODY, "\n\t//NextInChain is %d - %s (breaks chain)\n", nextInChain, UniqueObjectName(objList[nextInChain]));
}
//fprintf(fBODY,"break on no trigger,trap or button\n");
//printObject(objList[nextInChain],1); fprintf(fBODY,"\n");
nextInChain=0;
// }
}
}
//Now end the function call here
addConditionals(conditionalCount+1); //+1 to close it out.
}
nextObj=nextObject(objList[nextObj]);
}
}
}
}
fclose ( fBODY );
fprintf(fMAIN,"\n}\n");
fclose ( fMAIN );
fclose ( fGLOBALS );
//now merge these three together
FILE *fFINALSCRIPT;
char line[255];
if (fopen_s(&fFINALSCRIPT,Script_Final_File, "w")==0)
{
//fprintf(fFINALSCRIPT,"#ifndef __game%d_%d_script__\n#__game%d_%d_script__\n",game,LevelNo,game,LevelNo);
if (fopen_s(&fBODY, SCRIPT_GlOBAL_FILE, "r")!=0)
{
printf("Unable to read output file for globals");
}
else
{
while (fgets(line,255,fBODY))
{
fprintf(fFINALSCRIPT,"%s",line);
}
fclose(fBODY);
}
if (fopen_s(&fBODY, SCRIPT_MAIN_FILE, "r")!=0)
{
printf("Unable to read output file for main");
}
else
{
while (fgets(line,255,fBODY))
{
fprintf(fFINALSCRIPT,"%s",line);
}
fclose(fBODY);
}
if (fopen_s(&fBODY,SCRIPT_BODY_FILE, "r")!=0)
{
printf("Unable to read output file for body");
}
else
{
while (fgets(line,255,fBODY))
{
fprintf (fFINALSCRIPT,"%s",line);
}
fclose(fBODY);
}
//fprintf(fFINALSCRIPT,"#endif //__game%d_%d_script__",game,LevelNo);
fclose (fFINALSCRIPT);
}
else
{
printf("Unable to open output file");
}
}
void a_do_trapBullfrogSCRIPT(int game, ObjectItem objList[1600], ObjectItem currObj, int Operation )
{
switch (Operation)
{
case 0: //up
fprintf(fBODY, "\n\t//Move up\n");
fprintf(fBODY, "\n\tExecuteBullFrogUp(bullfrog_targetX, bullfrog_targetY);\n");
break;
case 1: //down
fprintf(fBODY, "\n\t//Move down\n");
fprintf(fBODY, "\n\tExecuteBullFrogDown(bullfrog_targetX, bullfrog_targetY);\n");
break;
case 2://increase x
fprintf(fBODY, "\n\tbullfrog_targetX = bullfrog_targetX + 1 ;");
fprintf(fBODY, "\n\tif (bullfrog_targetX >= 56){bullfrog_targetX=48;}\n");
break;
case 3://increase x
fprintf(fBODY, "\n\tbullfrog_targetY = bullfrog_targetY + 1 ;");
fprintf(fBODY, "\n\tif (bullfrog_targetY >= 56){bullfrog_targetY=48;}\n");
break;
case 4: //reset
fprintf(fBODY, "\tsys.println(\"Resetting Bullfrog\");\n");
for (int x = 48; x< 56; x++)
{
for (int y = 48; y< 56; y++)
{
fprintf(fBODY, "\n\tbullfrog_%d_%d.move( DOWN, - (bullfrog_%d_%d_state*60) );",x,y,x,y);
fprintf(fBODY, "\n\tbullfrog_%d_%d_state = 0;", x, y, x, y);
}
}
break;
}
}
void scriptChainFunctionsUW(int game, ObjectItem objList[1600], ObjectItem currObj,int *conditionalCount, int *TriggerTargetX,int *TriggerTargetY,int *TriggerQuality,int *TriggerFlags,int *TriggerHomeX,int *TriggerHomeY,int scriptLevelNo)
{
//picks which script to generate.
switch (objectMasters[currObj.item_id].type)
{
case A_DAMAGE_TRAP:
tobedone("A_DAMAGE_TRAP");
break;
case A_TELEPORT_TRAP:
a_teleport_trapSCRIPT(currObj, currObj.tileX , currObj.tileY, currObj.zpos, *TriggerHomeX, *TriggerHomeY);
break;
case A_ARROW_TRAP:
tobedone("A_ARROW_TRAP");
break;
case A_DO_TRAP:
switch(currObj.quality)
{
case 2: //Camera
{
a_do_trap_cameraSCRIPT(objectMasters[currObj.item_id].desc,*TriggerTargetX,*TriggerTargetY, currObj.index );
break;
}
case 3:
{
fprintf(fGLOBALS,"\nfloat %s_%03d_%03d_state = %d; \n",objectMasters[currObj.item_id].desc, *TriggerTargetX, *TriggerTargetY,*TriggerFlags);
a_do_trap_platformSCRIPT(objectMasters[currObj.item_id].desc, *TriggerTargetX, *TriggerTargetY,currObj.index,*TriggerFlags,BrushSizeZ,8*BrushSizeZ);
break;
case 24://Bullfrog
{
a_do_trapBullfrogSCRIPT(game,objList,currObj,currObj.owner);
}
}
break;
}
case A_PIT_TRAP:
tobedone("A_PIT_TRAP");
break;
case A_CHANGE_TERRAIN_TRAP:
a_change_terrain_trapSCRIPT(currObj,*TriggerTargetX,*TriggerTargetY,currObj.x,currObj.y,objList);
//fprintf(fMAIN, "$final_%s.hide();\n",objectMasters[currObj.item_id].desc, *TriggerTargetX, *TriggerTargetY,currObj.index );
//fprintf(fMAIN, "$final_%s.hide();\n",UniqueObjectName(currObj));
break;
case A_SPELLTRAP:
tobedone("A_SPELLTRAP");
break;
case A_CREATE_OBJECT_TRAP:
tobedone("A_CREATE_OBJECT_TRAP");
break;
case A_DOOR_TRAP:
*TriggerQuality = currObj.quality;
a_lock(*TriggerTargetX, *TriggerTargetY, *TriggerQuality);
break;
// case A_LOCK:
//skip this not needed implemented above
// break;
case A_WARD_TRAP:
tobedone("A_WARD_TRAP");
break;
case A_TELL_TRAP:
tobedone("A_TELL_TRAP");
break;
case A_DELETE_OBJECT_TRAP:
a_delete_object_trapSCRIPT(objList , currObj.link);
break;
case AN_INVENTORY_TRAP:
tobedone("AN_INVENTORY_TRAP");
break;
case A_SET_VARIABLE_TRAP:
//fprintf(fGLOBALS,"\nfloat $var_%d = 0; \n",currObj.zpos);
addGlobal(currObj.zpos);
a_set_variable_trapSCRIPT(currObj.zpos, (((currObj.owner & 0x7) <<3) | (currObj.y )), currObj.heading / 45);
break;
case A_CHECK_VARIABLE_TRAP:
a_check_variable_trapSCRIPT(currObj.zpos, (((currObj.owner & 0x7) <<3) | (currObj.y )));
*conditionalCount = *conditionalCount+1;
break;
case A_COMBINATION_TRAP:
tobedone("A_COMBINATION_TRAP");
break;
case A_TEXT_STRING_TRAP:
a_text_string_trapSCRIPT(game, currObj.owner,scriptLevelNo);
break;
case A_MOVE_TRIGGER:
case A_PICK_UP_TRIGGER:
case A_USE_TRIGGER:
case A_LOOK_TRIGGER:
case A_STEP_ON_TRIGGER:
case AN_UNLOCK_TRIGGER:
*TriggerTargetX =currObj.quality ;
*TriggerTargetY = currObj.owner;
fprintf(fBODY,"\n\t//Trigger set to %d %d",currObj.quality,currObj.owner);
break;
// case ENCHANTMENT: //Cast a spell
// enchantment(currObj.link);
// break;
}
}
void BuildScriptsShock(int game, tile LevelInfo[64][64], ObjectItem objList[1600], int LevelNo, char Script_Final_File[255])
{
if (fopen_s(&fBODY,SCRIPT_BODY_FILE, "w")!=0)
{
printf("Unable to create output file for body");
return;
}
if (fopen_s(&fGLOBALS, SCRIPT_GlOBAL_FILE, "w")!=0)
{
printf("Unable to create output file for globals");
return;
}
if (fopen_s(&fMAIN, SCRIPT_MAIN_FILE, "w") != 0)
{
printf("Unable to create output file for globals");
return;
}
//fprintf(fBODY,"#ifndef __game%d_%d_script__\n#define __game%d_%d_script__\n",game,LevelNo,game,LevelNo);
for (int y=63; y>=0;y--)
{
for (int x=0; x<64;x++)
{
if(LevelInfo[x][y].indexObjectList !=0) //there is an object in this tile
{//traverse the list
int nextObj = LevelInfo[x][y].indexObjectList;
while (nextObj!=0)
{
//is it something that starts a script
//This does not include screens just yet.
if ((isButtonSHOCK(objList[nextObj]))
|| (isLog(objList[nextObj]))
|| (isTriggerSHOCK(objList[nextObj]))
|| (objectMasters[objList[nextObj].item_id].DeathWatch >=1)
|| ((isContainer(objList[nextObj])) && (hasContents(objList[nextObj])))
)
//|| (isSHOCKDoor(objList[nextObj])
{
if (isTriggerSHOCK(objList[nextObj]) && (objList[nextObj].item_id != 378))
{//Create global variables for testing conditions.
if ((objList[nextObj].conditions[0] >0) && (objList[nextObj].conditions[0])<255)
{
if (globals[objList[nextObj].conditions[0]]!=1) //A new global
{//add the new global here.
fprintf(fGLOBALS, "\tfloat global_var_%d = 0;\n", objList[nextObj].conditions[0]);
globals[objList[nextObj].conditions[0]] = 1;
}
}
//create a global for testing conditions
}
//Create the function call.
fprintf(fBODY,"\n\n\nvoid start_%s()\n{\n",
UniqueObjectName(objList[nextObj]));