-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGlobalScript.asc
2545 lines (2265 loc) · 65.9 KB
/
GlobalScript.asc
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
// main global script file
///////////////////////////////////////////////////////////////////////////
/////////// TEMPLATE FOR MAKING SCUMM TYPE GAMES BY PROSKRITO ////////////
/////////// MODIFIED FOR AGS VERSION 3 BY RULAMAN ////////////
///////////////////////////////////////////////////////////////////////////
/* legt den String der Datei fest, bze ermöglicht die "versteckte Debug-Option"
Ist die Datei im Spieleordner vorhanden und die HIDDEN_DEBUG_ENABLED Option gesetzt,
kann ein Spiel releast werden, ohne die Debug-Ebnabled-Option zurückzunehmen.
So kann man später bei einem Fehler, oder seinen BETA-Testern die Datei zuschicken.
Dann kann man auch in einem releasten Spiel noch etwaige Fehler suchen.*/
#define HIDDEN_DEBUG_STRING "MMM_GO"
//#define HIDDEN_DEBUG_ENABLED
#define DOORS_MAX 20
int i_Doors[DOORS_MAX];
#define TIMERS_MAX 40
int i_Timers[TIMERS_MAX];
File *debugfile;
String
GSlocname, // on_mouse_click -> unhandled_event
GSinvloc, // locationname>extension
SHOWNlocation; // location translated player.Say("Ist doch schon auf.");
Character *GSPlayerUp;
Character *GSPlayerDown;
Character *BGChar;
Overlay *ovChar;
bool isBgSpeech = false;
int
GStopsaveitem = 0,
ActionLabelColorNormal = 530, // Used in action bar
ActionLabelColorHighlighted = 1180, // Used in action bar
invUparrowONsprite = 202, // used in repeatedly execute
invUparrowOFFsprite = 213, // " " " "
invDownarrowONsprite = 204, // " " " "
invDownarrowOFFsprite = 214, // " " " "
defaultfontheight = 8, // used in save / load guis
GSlocid, // on_mouse_click ->
ItemGiven,
GScancelable, // MovePlayer
bgscounter=0;
eAction GSagsusedmode; // on_mouse_click -> unhandled_event
LocationType GSloctype; // on_mouse_click -> unhandled_event
int key_l_yes, key_u_yes, key_l_no, key_u_no;
// =======================================================================================
function DisplaySpeechBackgroundEx(this Character*, String message)
{
isBgSpeech = true;
ovChar = this.SayBackground(message);
BGChar = this;
}
#define BGS_DELAY 6 //! this is the animation delay for "background speech"
function repeatedly_execute_always()
{
if ( isBgSpeech )
{
if ( ovChar.Valid )
{
if ( bgscounter >= BGS_DELAY * 2 )
bgscounter=0;
BGChar.LockViewFrame(BGChar.SpeechView + 1, BGChar.Loop, bgscounter/BGS_DELAY);
bgscounter++;
}
else
{
BGChar.UnlockView();
}
isBgSpeech = false;
}
}
// ============================= math functions ===========================================
function Absolute (int value)
{
if (value < 0) value = - value;
return value;
}
function Offset (int point1, int point2)
{
return Absolute (point1 - point2);
}
// ============================= action functions ===========================================
eAction global_action;
eAction default_action;
eAction alternative_action;
eAction used_action;
int action_l_keycode [eActCount];
int action_u_keycode [eActCount];
eAction button_action [9];
int action_button_normal [eActCount];
int action_button_highlight [eActCount];
Button *action_Buttonb[10];
String TranslateAction (String result, eAction action, String objekt, String item)
{
// get translated action template
if (action == eActWalkTo) result = "Gehe zu %s";
else if (action == eActLookAt) result = "Schau an %s";
else if (action == eActTalkTo) result = "Rede mit %s";
else if (action == eActGiveTo)
{
if (item.Length > 0) result = "Gib !s an %s";
else result = "Gib %s";
}
else if (action == eActPickUp) result = "Nimm %s";
else if (action == eActUse)
{
if (item.Length > 0) result = "Benutze !s mit %s";
else result = "Benutze %s";
}
else if (action == eActOpen) result = "Öffne %s";
else if (action == eActClose) result = "Schließe %s";
else if (action == eActPush) result = "Drücke %s";
else if (action == eActPull) result = "Ziehe %s";
else if (action == eActSwitchTo) result = "Wechsle zu %s";
// fill object and item into action template
result = GetTranslation (result);
int ip = result.Contains("!s");
if (ip >= 0)
{
int op = result.Contains("%s");
result = result.ReplaceCharAt(ip, '%');
if (ip < op) result = result.Format(result, item, objekt);
else result = result.Format(result, objekt, item);
}
else result = result.Format(result, objekt);
return result;
}
function isAction (eAction test_action)
{
return global_action == test_action;
}
function UsedAction(eAction test_action)
{
return ((used_action == test_action) && (GSagsusedmode != eModeUseinv)) ||
((test_action == eActUseInventory) && (used_action == eActUse) && (GSagsusedmode == eModeUseinv)) ||
((test_action == eActGiveTo) && (used_action == eActGiveTo) && (GSagsusedmode == eModeUseinv));
}
function SetAction (eAction new_action)
{
// set default action
if (new_action == eActDefault) new_action = default_action;
// set corresponding cursormode
if (new_action == eActWalkTo) Mouse.Mode = eModeUsermode2;
else if (new_action == eActLookAt) Mouse.Mode = eModeLookat;
else if (new_action == eActTalkTo) Mouse.Mode = eModeTalkto;
else if (new_action == eActGiveTo) Mouse.Mode = eModeInteract;
else if (new_action == eActPickUp) Mouse.Mode = eModePickup;
else if (new_action == eActUse) Mouse.Mode = eModeInteract;
else if (new_action == eActOpen) Mouse.Mode = eModeUsermode1;
else if (new_action == eActClose) Mouse.Mode = eModeUsermode1;
else if (new_action == eActPush) Mouse.Mode = eModeUsermode1;
else if (new_action == eActPull) Mouse.Mode = eModeUsermode1;
// save action
global_action = new_action;
}
function SetDefaultAction (eAction def_action)
{
default_action = def_action;
SetAction (eActDefault);
}
// ============================= Load/Save game ===========================================
function GetLucasSavegameListBox(this GUI*, ListBox *box)
{
String strbuf, sgdesc;
int maxsavegames = 99;
int counter = 0;
strbuf = "";
box.Clear();
while ( counter < maxsavegames )
{
strbuf = String.Format("%d. ", counter + 1);
sgdesc = Game.GetSaveSlotDescription(counter + 100);
if ( null == sgdesc )
sgdesc = "";
strbuf = strbuf.Append(sgdesc);
box.AddItem(strbuf);
counter++;
}
box.TopItem = 0;
box.SelectedIndex = -1;
}
// ============================= Timer ===========================================
function SetOwnTimer(int timerid, int timeout)
{
if ( timerid >= TIMERS_MAX )
{
}
else
{
i_Timers[timerid] = timeout + 1;
}
}
function IsOwnTimerExpired(int timerid)
{
if ( timerid >= TIMERS_MAX )
{
}
else if ( i_Timers[timerid] == 1 )
{
i_Timers[timerid] = 0;
return 1;
}
else
{
return 0;
}
}
function CheckTimers()
{
int timers = 0;
while ( timers < TIMERS_MAX )
{
if ( i_Timers[timers] > 1 )
{
i_Timers[timers]--;
}
timers++;
}
}
// ============================= GlobalCondition ===========================================
function GlobalCondition (int parameter)
{
// here are some conditions that are used many times in the script
int cond;
InventoryItem* invItem;
GUI* guiItem;
GUIControl* guiControl;
invItem = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
guiItem = GUI.GetAtScreenXY(mouse.x, mouse.y);
guiControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (parameter == 1)
{
// if the mouse is in the inventory and modes Walk or pickup are selected
if ( null != invItem )
{
cond = ((isAction (eActWalkTo) || isAction (eActPickUp))); //( invItem.ID >= 0 ) &&
}
}
else if (parameter == 2)
{
// if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
cond = ( null != invItem && (Mouse.Mode == eModeUseinv) && (player.ActiveInventory.ID == invItem.ID ));
}
else if (parameter == 3)
{
// if the mode is talk, or "Give", and the mouse isnt over a character
cond = ((isAction (eActTalkTo) || (isAction (eActGiveTo) && (Mouse.Mode == eModeUseinv))) && (GetLocationType (mouse.x, mouse.y) != eLocationCharacter));
}
else if (parameter == 4)
{
// if its GIVE and the mouse isnt over a inv.item
cond = ( ( null == invItem ) && (Mouse.Mode == eModeInteract) && isAction (eActGiveTo));
}
if (parameter == 5)
{
// if its over the "other characters" buttons in the inventory.
if ( guiItem )
{
if ( guiControl )
{
cond = ((guiItem == gMaingui) && ((guiControl.ID == 12) || (guiControl.ID == 13)));
}
}
}
return cond;
}
// ============================= Extensions ===========================================
char Extension(this String*)
{
if ( this.Contains(">") >= 0)
{
return this.Chars[this.Length - 1];
}
else if ( this.Contains("$") >= 0)
{
return this.Chars[this.Length - 1];
}
return 0;
}
String RemoveExtension(this String*)
{
if ( this.Extension() ) // check Extension
{
return this.Truncate(this.Length - 2); // Remove Extension if any
}
return this; // no Extension
}
String AddExtension(this String*, char extension)
{
String temp;
if ( this.Extension() )
{
temp = this.RemoveExtension();
}
return String.Format("%s>%c", this, extension);
}
// ============================= Action ===========================================
function SetAlternativeAction (String location, char extension, eAction action)
{
if (action == eActDefault)
{
if (location.Extension() == extension)
{
alternative_action = action;
}
}
else
{
int normalbuttonpic = action_button_normal [action];
int overbuttonpic = action_button_highlight [action];
// used for setting the default action given the extension.
if (location.Extension() == extension)
{
if ( null != action_Buttonb[action] )
{
action_Buttonb[action].NormalGraphic = overbuttonpic;
}
// 1 = normal 2 = mouse-over 3 = button pushed
alternative_action = action;
}
else if ( null != action_Buttonb[action] )
{
action_Buttonb[action].NormalGraphic = normalbuttonpic;
}
if ( null != action_Buttonb[action] )
{
action_Buttonb[action].MouseOverGraphic = overbuttonpic;
}
}
}
String OpenCloseExtensionGraphic (Object *objekt, int openGraphic, int closeGraphic, String location)
{
if (objekt.Graphic == closeGraphic) return location.AddExtension('o');
else if (objekt.Graphic == openGraphic) return location.AddExtension('c');
}
String OpenCloseExtensionObject (String location, int objectid)
{
if ( object[objectid].Visible == false )
{
return location.AddExtension('o');
}
else if (object[objectid].Visible == true )
{
return location.AddExtension('c');
}
}
String OpenCloseExtension (int gi, String location)
{
if ((i_Doors[gi] == 0) || (i_Doors[gi] == 2)) return location.AddExtension('o');
else return location.AddExtension('c');
}
String VariableExtensions (String location)
{
int i = 0;
bool b_Ready = false;
Hotspot* hotAt = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
Object *objAt = Object.GetAtScreenXY(mouse.x, mouse.y);
while ( i < MAX_DOORS )
{
if ( ((Door[i].h_Hotspot == hotAt) && (Door[i].l_Room == player.Room)) ||
((Door[i].h_NewHotspot == hotAt) && (Door[i].l_NewRoom == player.Room)) )
{
if ( (Door[i].i_GlobalInt == eDoorClosed) || (Door[i].i_GlobalInt == eDoorLocked) )
{
location = location.AddExtension('o');
}
else
{
location = location.AddExtension('c');
}
i = MAX_DOORS; // simulates a break;
b_Ready = true;
}
i++;
}
// globig (Strg+F globig springt hierher)
if ( b_Ready )
{
}
else
{
// Muster
/*
if ((r == 31) && (h == 1)) location = OpenCloseExtension (10, location); // Haustür [main door]
else if ((r == 48) && (h == 1)) location = OpenCloseExtension (10, location); // Haustür [main door]
else if ((r == 32) && (h == 24)) location = OpenCloseExtensionObject(objAt, location, 24, 19); // Fenster in der Küche rechts
else if ((r == 32) && (o == 3)) location = OpenCloseExtensionGraphic(objAt, 639, 638, location); // Mikrowelle in der Küche
*/
if (player.Room == 8 && hotAt.ID == 7) location = OpenCloseExtensionObject(location, 2); // Toilette bowl in bathroom.
else if (player.Room == 18 && objAt.ID == 1) location = OpenCloseExtensionGraphic(object[objAt.ID], 465, 466, location); // Mailbox.
}
return location;
}
bool bTreppe = false;
export bTreppe;
bool bTreppe1 = true;
export bTreppe1;
function CheckDefaultAction()
{
// you could want to change which extension activates which default action, or which button sprite
// it changes. The extensions are characters, so remember to put them with single ', not ".
String location;
location = Game.GetLocationName(mouse.x, mouse.y);
InventoryItem *invItem = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (location.Extension() == 0)
{
// Setting default modes if the thing has no extension:
if ( GetLocationType(mouse.x, mouse.y) == eLocationCharacter )
{
// if it is a character
location = location.AddExtension ('t'); // set default action "talk to"
}
else if( (GetLocationType(mouse.x, mouse.y) != eLocationNothing) || null != invItem )
{
// if its an inv item, a hotspot or an object
location = location.AddExtension('l'); // set default action "look at"
}
else
{
location = location.AddExtension('n'); // set default action "none"
}
}
else if (location.Extension() == 'v')
{
// if the default action depends on some events
location = location.RemoveExtension();
location = VariableExtensions (location);
}
if (GlobalCondition (2) || GlobalCondition (3) || GlobalCondition (4))
{
location = ">n"; //Dont send the name of the hotspt/obj/char/inv to the action bar and set default action "none"
}
GSinvloc = String.Format("%s", location);
if ((location.Extension() == 'u') && ( null != invItem ) )
{
// it's an inv item
location = location.RemoveExtension();
location = location.AddExtension('l'); // set default action "look at"
}
SetAlternativeAction (location, 'n', eActDefault);
SetAlternativeAction (location, 'g', eActGiveTo);
SetAlternativeAction (location, 'p', eActPickUp);
SetAlternativeAction (location, 'u', eActUse);
SetAlternativeAction (location, 'o', eActOpen);
SetAlternativeAction (location, 'l', eActLookAt);
SetAlternativeAction (location, 's', eActPush);
SetAlternativeAction (location, 'c', eActClose);
SetAlternativeAction (location, 't', eActTalkTo);
SetAlternativeAction (location, 'y', eActPull);
location = location.RemoveExtension();
SHOWNlocation = location;
}
// ============================= ActionBar ===========================================
function UpdateActionBar()
{
// set the text in the action bar
String madetext;
int action = global_action;
String objekt;
String item;
GUIControl *guic;
madetext = "";
objekt = SHOWNlocation;
item = "";
if (GlobalCondition (5) == 1)
{
// write SWITCH TO CHAR
action = eActSwitchTo;
guic = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if ( null != guic )
{
if ( guic.ID == 12 )
{
if ( UpperButton() == -1 )
{
}
else
{
objekt = character[UpperButton()].Name;
}
}
else
{
if ( UpperButton() == -1 )
{
}
else
{
objekt = character[LowerButton()].Name;
}
}
}
}
else if (Mouse.Mode == 4)
{
// use or give inventory item
item = player.ActiveInventory.Name;
item = item.RemoveExtension();
}
else if (GlobalCondition (1) == 1)
{
// if the mouse is in the inventory and modes Walk or pickup are selected
action = eActUse;
}
madetext = TranslateAction (madetext, action, objekt, item);
// show action text
gAktionText.Text = madetext;
gAktionText.TextColor = ActionLabelColorNormal;
}
// ============================= Inventory ===========================================
function GiveInvEx (int invitem, Character *charidfrom, Character *charidto)
{
//for passing inv items between characters
int amount;
amount = charidfrom.InventoryQuantity[invitem];
charidfrom.InventoryQuantity[invitem] = 0;
charidto.InventoryQuantity[invitem] = amount;
UpdateInventory ();
}
bool GiveInv(this Character*, InventoryItem *invItem, Character *charac)
{
return GiveInvEx(invItem.ID, player, charac);
}
bool ReceiveInv(this Character*, InventoryItem *invItem, Character *charac)
{
return GiveInvEx(invItem.ID, charac, player);
}
function GiveInv (int invitem, Character *charid)
{
//for giving an inv item to other player
GiveInvEx (invitem, player, charid);
}
// ============================= translation ===========================================
String ClearToSpace(String text)
{
int p = 0;
// ignore white spaces at the beginning
while ( ( p < text.Length ) && ( text.Chars[p] == ' ' ) )
{
p++;
}
// write white spaces until next white space
while ( ( p < text.Length ) && ( text.Chars[p] != ' ' ) )
{
text = text.ReplaceCharAt(p, ' ');
p++;
}
return text;
}
function TranslateNumber (String number_name)
{
String tr;
tr = ClearToSpace(GetTranslation (number_name));
return tr.AsInt;
}
function SetActionButtons (eAction action, String button_definition)
{
// extract data from button_definition
String translat;
int i;
if (IsTranslationAvailable())
{
translat = GetTranslation(button_definition);
translat = ClearToSpace (translat);
}
else
{
translat = button_definition;
translat = ClearToSpace (translat);
}
i = translat.AsInt;
translat = ClearToSpace(translat);
if ( i == 4 ) { action_Buttonb[action] = gMainLookat; } //Schliesse 4
else if ( i == 2 ) { action_Buttonb[action] = gMainUse; } //Nimm 2
else if ( i == 1 ) { action_Buttonb[action] = gMainPickup; } //Benutze 1
else if ( i == 3 ) { action_Buttonb[action] = gMainOpen; } //Öffne 3
else if ( i == 6 ) { action_Buttonb[action] = gMainClose; } //Ziehe 6
else if ( i == 0 ) { action_Buttonb[action] = gMainGive; } //Schau 0
else if ( i == 8 ) { action_Buttonb[action] = gMainPull; } //Rede 8
else if ( i == 5 ) { action_Buttonb[action] = gMainPush; } //Gib 5
else if ( i == 7 ) { action_Buttonb[action] = gMainTalkto; } //Drücke 7
action_button_normal [action] = translat.AsInt;
translat = ClearToSpace(translat);
action_button_highlight [action] = translat.AsInt;
translat = ClearToSpace(translat);
int p = translat.Length - 1;
while (p > 0)
{
action_l_keycode [action] = translat.Chars[p];
p--;
action_u_keycode [action] = translat.Chars[p];
if (action_l_keycode [action] != ' ')
{
p = 0;
}
}
if ( null != action_Buttonb[action] )
button_action [action_Buttonb[action].ID] = action;
}
function AdjustLanguage ()
{
// --- translate yes/no-keys ---
String yes_no;
yes_no = GetTranslation ("JjNn");
key_u_yes = yes_no.Chars[0];
key_l_yes = yes_no.Chars[1];
key_u_no = yes_no.Chars[2];
key_l_no = yes_no.Chars[3];
// --- translate GUI action buttons ---
SetActionButtons (eActGiveTo, "a_button_give 5 802 803 Dd");
SetActionButtons (eActPickUp, "a_button_pick_up 2 800 801 Ee");
SetActionButtons (eActUse, "a_button_use 1 794 795 Ww");
SetActionButtons (eActOpen, "a_button_open 3 790 791 Aa");
SetActionButtons (eActLookAt, "a_button_look_at 0 788 789 Qq");
SetActionButtons (eActPush, "a_button_push 7 798 799 Xx");
SetActionButtons (eActClose, "a_button_close 4 796 797 Ss");
SetActionButtons (eActTalkTo, "a_button_talk_to 8 804 805 Cc");
SetActionButtons (eActPull, "a_button_pull 6 792 793 Yy");
// --- load font corresponding to language and screen width ---
String font_info;
font_info = GetTranslation ("font_320: 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0");
if (System.ViewportWidth >= 640) font_info = GetTranslation ("font_640: 13 14 14 14 14 14 14 14 14 14 14 14 14 14 14");
font_info = ClearToSpace(font_info);
// Labeles (Strg+F Labeles springt hierher)
Game.SpeechFont = font_info.AsInt; font_info = ClearToSpace(font_info); // Speech
gAktionText.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Status-Line
gOptionsTitel.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Save/Load-GUI Label
// Fehler im Speichern-Dialog korrigiert nichts auskommentieren
gOptionsSave.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Save-Button of Save/Load-GUI
gOptionsLoad.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Load-Button of Save/Load-GUI
gOptionsPlay.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Play-Button of Save/Load-GUI
gOptionsExit.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Quit-Button of Save/Load-GUI
gPausedText.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Pause-GUI Label
gRestoreTitel.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Restore-GUI Label
gRestoreCancel.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Cancel-Button of Load-GUI
gSaveTitel.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Save-GUI Label
gSaveOK.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // OK-Button of Save-GUI
gSaveCancel.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Cancel-Button of Save-GUI
gConfirmQuestion.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Quit-GUI Label
gRestartQuestion.Font = font_info.AsInt; font_info = ClearToSpace(font_info); // Restart-GUI Label
}
// ============================= MovePlayer ===========================================
function MovePlayerEx (int x, int y, int direct)
{
// Move the player character to x,y coords, waiting until he/she gets there,
// but allowing to cancel the action by pressing a mouse button.
GUI *guiAt = GUI.GetAtScreenXY(mouse.x, mouse.y);
InventoryItem *invAt = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if ( g_PlayerCanMove > 0 )
{
int cursorspritenumber = 16,
blankcursorspritenumber = 26;
GScancelable = 0;
Mouse.ChangeModeGraphic(eModeWait, cursorspritenumber);
if (direct == 0)
player.Walk(x, y);
else
player.Walk(x, y, eNoBlock, eAnywhere);
// wait for release of mouse button
while (player.Moving && (Mouse.IsButtonDown(eMouseLeft) || Mouse.IsButtonDown(eMouseRight) ))
{
Wait (1);
Mouse.Update();
CheckDefaultAction ();
}
// abort moving on new mouse down
while (player.Moving)
{
if ( Mouse.IsButtonDown (eMouseLeft) && ( null == guiAt || null != invAt ))
{
player.StopMoving();
GScancelable = 1;
}
else if ( Mouse.IsButtonDown(eMouseRight) && (null == guiAt || null != invAt ))
{
player.StopMoving();
GScancelable = 2;
}
else
{
Wait (1);
Mouse.Update();
CheckDefaultAction();
}
}
mouse.ChangeModeGraphic(eModeWait, blankcursorspritenumber);
if ( GScancelable == 0 && player.x == x && player.y == y )
{
return 2;
}
else if ( GScancelable == 0 )
{
return 1;
}
else
{
return 0;
}
}
else return 0;
}
//! veraltet (obsolete)
function MovePlayer (int x, int y)
{
//Move the player character to x,y coords, waiting until he/she gets there, but allowing to cancel the action
//by pressing a mouse button.
return MovePlayerEx (x, y, 0);
}
// ============================= Go ===========================================
// this section after MovePlayer
function GoToCharacterEx (Character *charidwhogoes, Character *charid, int direction, int xoffset, int yoffset, int NPCfacesplayer, int blocking)
{
//Goes to a character staying at the side defined by 'direction': 1 up, 2 right, 3 down, 4 left
//and it stays at xoffset or yofsset from the character. NPCfacesplayer self-explained. ;)
// blocking: 0=non-blocking; 1=blocking; 2=semi-blocking
int playerchar, charidx, charidy, playerx, playery;
charidx = charid.x;
charidy = charid.y;
playerx = player.x;
playery = player.y;
int arrived = 1;
if ((Offset (playerx, charidx) > xoffset) || (Offset (playery, charidy) > yoffset))
{
if (direction == 0)
{
// el camino mas cercano
if (Offset (charidx, playerx) >= Offset (charidy, playery))
{
// dcha o izda
if (playerx >= charidx) direction = 2; //right
else direction = 4; //left
}
else
{
if (playery >= charidy) direction = 3; //abajo
else direction = 1;
}
}
// calculate target position
if ( direction == eDirectionUp ) charidy -= yoffset;
else if ( direction == eDirectionLeft ) charidx += xoffset;
else if ( direction == eDirectionDown ) charidy += yoffset;
else if ( direction == eDirectionRight ) charidx -= xoffset;
// move character
if (blocking == 0)
{
player.Walk(charidx, charidy);
arrived = 0;
}
else if (blocking == 1)
{
charidwhogoes.Walk(charidx, charidy, eBlock);
arrived = 1;
}
else if (blocking == 2) arrived = MovePlayer (charidx, charidy);
}
if (arrived > 0)
{
// characters only face each other after the moving character arrived at the target point
if (NPCfacesplayer == 1) charid.FaceCharacter(charidwhogoes);
charidwhogoes.FaceCharacter(charid);
}
return arrived;
}
function NPCGoToCharacter (Character *charidwhogoes, Character *charidtogoto, int direction, int NPCfacesplayer, int blocking){
// same as above but with default x and y offset.
int defaultxoffset, defaultyoffset;
defaultxoffset = 35;
defaultyoffset = 20;
return GoToCharacterEx (charidwhogoes, charidtogoto, direction, defaultxoffset, defaultyoffset, NPCfacesplayer, blocking);
}
function GoToCharacter (Character *charid, int direction, int NPCfacesplayer, int blocking){
// same as above but with default x and y offset.
int defaultxoffset, defaultyoffset;
defaultxoffset = 35;
defaultyoffset = 20;
return GoToCharacterEx (player, charid, direction, defaultxoffset, defaultyoffset, NPCfacesplayer, blocking);
}
function GoTo (int blocking)
{
// Goes to whatever the player clicked on.
// blocking: 0=non-blocking; 1=blocking; 2=semi-blocking
Hotspot *hotAt = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
Character *charAt = Character.GetAtScreenXY(mouse.x, mouse.y);
Object *objAt = Object.GetAtScreenXY(mouse.x, mouse.y);
int xtogo, ytogo;
int locationtype = GetLocationType (mouse.x, mouse.y);
int arrived = 0;
if (locationtype == 2) arrived = GoToCharacter (charAt, 0, 0, blocking);
else
{
if ( hotAt )
if (locationtype == 1 && hotAt.ID > 0)
{
xtogo = hotAt.WalkToX;
ytogo = hotAt.WalkToY;
}
if (locationtype == 3)
{
int objekt = objAt.ID;
xtogo = objAt.X;
ytogo = objAt.Y;
}
if ( hotAt )
if (hotAt.ID == 0)
{
xtogo = mouse.x;
ytogo = mouse.y;
}
else
{
xtogo = mouse.x;
ytogo = mouse.y;
}
xtogo += GetViewportX ();
ytogo += GetViewportY ();
if (blocking == 0) player.Walk(xtogo, ytogo);
else if (blocking == 1)
{
player.Walk(xtogo, ytogo, eBlock);
arrived = 1;
}
else if (blocking == 2) arrived = MovePlayer (xtogo, ytogo);
}
return arrived;
}
function Go ()
{
// Go to whatever the player clicked on. You can cancel the action, and returns 1 if the player has gone to it.
return GoTo (2);
}
// ============================= interaction functions ===========================================
// this section after MovePlayer
function PlaceCharacter (this Character*, int x, int y, CharacterDirection dir)
{
this.x = x;
this.y = y;
this.FaceDirection(dir);
}
//! veraltet (obsolete)
function PlacePC (int x, int y, CharacterDirection dir)
{
player.PlaceCharacter(x, y, dir);
}
function any_click_move (int x, int y, CharacterDirection dir)
{
int result = MovePlayer (x, y);
if (result)
{
player.FaceDirection(dir);
Wait (5);
}
return result;
}
function any_click_walk (int x, int y, CharacterDirection dir){
int result = 1;
if (UsedAction (eActWalkTo)) any_click_move (x, y, dir);
else result = 0;
return result;
// 0 = unhandled
// 1 = handled
}
function any_click_walk_look (int x, int y, CharacterDirection dir, String lookat){
int result = any_click_walk (x, y, dir);
if ((result == 0) && (UsedAction (eActLookAt) && (lookat.Length > 0)))
{
result = 1;
if (any_click_move (x, y, dir)) player.Say(lookat);
}
return result;
// 0 = unhandled
// 1 = handled
}
function init_object(this Object*, int gi)
{
if ( null != this )
{
this.Clickable = false; // die Türenobjekte nicht Klickbar machen
if (i_Doors[gi] == 1) this.Visible = true;
else this.Visible = false;
}
}
String door_lookat;
String door_islocked;
String door_wrongitem;
function SetDoorStrings (String lookat, String islocked, String wrongitem)
{
door_lookat = lookat;