-
Notifications
You must be signed in to change notification settings - Fork 5
/
GlobalScript.asc
258 lines (229 loc) · 6.06 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
// main global script file
// called when the game starts, before the first room is loaded
// =======================================================================================
function game_start()
{
SetRestartPoint();
}
// put anything you want to happen every game cycle in here
function repeatedly_execute()
{
}
// put here anything you want to happen every game cycle, even when the game is blocked
function repeatedly_execute_always()
{
}
void ShowOptions()
{
Verbs.UpdateActionBar();
OptionGui.ShowOptions();
}
// called when a key is pressed. keycode holds the key's ASCII code
function on_key_press(eKeyCode keycode, int mod)
{
if (keycode == eKeyF5) ShowOptions();
if (keycode == eKeyF12) SaveScreenShot("scrnshot.pcx"); // F12
if (mod & eKeyModCtrl)
{
if (keycode == eKeyC || keycode == eKeyQ) gQuit.Visible=true; // Ctrl-C or CTRL-Q QUIT
if (keycode == eKeyS) Debug(0,0); // Ctrl-S, give all inventory
if (keycode == eKeyV) Debug(1,0); // Ctrl-V, version
if (keycode == eKeyA) Debug(2,3); // Ctrl-A, show walkable areas
if (keycode == eKeyX) Debug(3,0); // Ctrl-X, teleport to ro
}
}
function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
{
}
function on_event(EventType event, int data) {
if (event==eEventRestoreGame) {
Verbs.Localize();
}
}
function dialog_request(int param) {
}
////////////////////////////////////////////////////////////////////////////////////
// Begin of GUI handling
////////////////////////////////////////////////////////////////////////////////////
function Action_Click(GUIControl *control, MouseButton button) {
Verbs.SetAction(Verbs.GetButtonAction(control.AsButton));
}
function ScrollInv_Click(GUIControl *control, MouseButton button) {
if (control == btnInvUp) invMain.ScrollUp();
else invMain.ScrollDown();
}
function btnShowOptions_OnClick(GUIControl *control, MouseButton button)
{
ShowOptions();
}
function btnOptions_OnClick(GUIControl *control, MouseButton button)
{
OptionGui.OnClick(control, button);
}
function btnOptions_OnSliderChange(GUIControl *control)
{
OptionGui.OnSliderChange(control);
}
////////////////////////////////////////////////////////////////////////////////////
// End of GUI handling
////////////////////////////////////////////////////////////////////////////////////
/* Character, Object, Hotspot full blown SAMPLE
function cChar_AnyClick(Character *thisCharacter, CursorMode mode)
{
// WALK TO
if (Verbs.UsedAction(eGA_WalkTo)) {
Verbs.GoTo();
}
// TALK TO
else if (Verbs.UsedAction(eGA_TalkTo)) {
Verbs.Unhandled();
}
// LOOK AT
else if(Verbs.UsedAction(eGA_LookAt)) {
Verbs.Unhandled();
}
// OPEN
else if(Verbs.UsedAction(eGA_Open)) {
Verbs.Unhandled();
}
// CLOSE
else if(Verbs.UsedAction(eGA_Close)) {
Verbs.Unhandled();
}
// USE
else if(Verbs.UsedAction(eGA_Use)) {
Verbs.Unhandled();
}
// Push
else if(Verbs.UsedAction(eGA_Push)) {
Verbs.Unhandled();
}
// Pull
else if(Verbs.UsedAction(eGA_Pull)) {
Verbs.Unhandled();
}
// PICKUP
else if(Verbs.UsedAction(eGA_PickUp)) {
Verbs.Unhandled();
}
// GIVE TO (characters only)
else if(Verbs.UsedAction(eGA_GiveTo)) {
Verbs.Unhandled();
}
//USE INV
else if(Verbs.UsedAction(eGA_UseInv)) {
Verbs.Unhandled();
}
else Verbs.Unhandled();
}
*/
/* Inventory SAMPLE
// LOOK AT
else if(Verbs.UsedAction(eGA_LookAt)) {
Unhandled();
}
// USE
else if(Verbs.UsedAction(eGA_Use)) {
Unhandled();
}
// Push
else if(Verbs.UsedAction(eGA_Push)) {
Unhandled();
}
// Pull
else if(Verbs.UsedAction(eGA_Pull)) {
Unhandled();
}
//USE INV
else if(Verbs.UsedAction(eGA_UseInv)) {
Unhandled();
}
else Unhandled();
*/
/***********************************************************************
* Inventory functions
*
***********************************************************************/
function iCup_OtherClick(InventoryItem *thisItem, CursorMode mode)
{
if (Verbs.UsedAction(eGA_Use)) {
player.Say("Let's spill the liquid and have a look.");
Wait(10);
player.LoseInventory(iCup);
player.AddInventory(iCupEmpty);
player.AddInventory(iKeyCard);
player.Say("Voilà, I found a keycard.");
}
else if (Verbs.UsedAction(eGA_LookAt)) {
player.Say("It is a blue cup, filled with liquid.");
player.Say("I could swear that there is tiny object shimmering on the ground.");
}
else Verbs.Unhandled();
}
function iCupEmpty_OtherClick(InventoryItem *thisItem, CursorMode mode)
{
if (Verbs.UsedAction(eGA_LookAt)) {
player.Say("It is an empty cup.");
}
else Verbs.Unhandled();
}
function iKeyCard_OtherClick(InventoryItem *thisItem, CursorMode mode)
{
if (Verbs.UsedAction(eGA_LookAt)) {
player.Say("It is a massive key card. I wonder how it fit in the cup.");
}
else Verbs.Unhandled();
}
/***********************************************************************
* Character functions
*
***********************************************************************/
function cHologram_AnyClick(Character *thisCharacter, CursorMode mode)
{
//Walk to
if (Verbs.UsedAction(eGA_WalkTo)) {
Verbs.GoTo();
}
// TALK TO
if (Verbs.UsedAction(eGA_TalkTo)) {
dDialog1.Start();
}
// LOOK AT
else if(Verbs.UsedAction(eGA_LookAt)) {
Verbs.Unhandled();
}
// OPEN
else if(Verbs.UsedAction(eGA_Open)) {
Verbs.Unhandled();
}
// CLOSE
else if(Verbs.UsedAction(eGA_Close)) {
Verbs.Unhandled();
}
// USE
else if(Verbs.UsedAction(eGA_Use)) {
Verbs.Unhandled();
}
// Push
else if(Verbs.UsedAction(eGA_Push)) {
Verbs.Unhandled();
}
// Pull
else if(Verbs.UsedAction(eGA_Pull)) {
Verbs.Unhandled();
}
// PICKUP
else if(Verbs.UsedAction(eGA_PickUp)) {
Verbs.Unhandled();
}
// GIVE TO
else if (Verbs.UsedAction(eGA_GiveTo)) {
player.Say("Do you want this?");
cHologram.Say("I have no pockets.");
}
//USE INV
else if(Verbs.UsedAction(eGA_UseInv)) {
player.Say("A hologram has no pockets.");
}
else Verbs.Unhandled();
}