-
Notifications
You must be signed in to change notification settings - Fork 1
/
qobjectives.acs
250 lines (223 loc) · 5.85 KB
/
qobjectives.acs
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
//==========================================================
// Nikki Shore
// QObjectives - Objectives system.
//
// Code by CRxTRDude.
//==========================================================
#library "qobjectives"
#include "zcommon.acs"
#import "qcommon.acs"
#define NOTE_BOUNDX 57
#define NOTE_BOUNDY 45
#define NOTE_BOUNDW 194
#define NOTE_BOUNDH 339
#define OBJ_BOUNDX 339
#define OBJ_BOUNDY 52
#define OBJ_BOUNDW 248
#define OBJ_BOUNDH 81
#define CLUE_BOUNDX 384
#define CLUE_BOUNDY 157
#define CLUE_BOUNDW 202
#define CLUE_BOUNDH 233
#define CLUENUMX 363.0
#define CLUENUMY 165.0
global str 1:objectives;
global str 2:notes;
global str 3:clue[];
global int 4:cluetotal;
int isObjectiveDisplayed = False;
int disabledObjectives = False;
int clueindex;
Function void OBJ_Initialize (void){
Log(s:"OBJ_Initialize");
//Called at a start of a 'game' map.
//Just initialize the icon
OBJ_Disable (TRUE);
cluetotal = 0; //the total number of evidences you have.
clue[0] = "NULLDOC";
objectives = "NULLOBJ";
notes = "NULLNTS";
Log(s:"Objective system initialized.");
}
Function void OBJ_Disable (int a){
disabledObjectives = a;
if (!a){
ACS_NamedExecute("OBJ_HudShow",0,1);
Log(s:"Objective system enabled.");
}else{
ACS_NamedExecute("OBJ_HudShow",0,0);
Log(s:"Objective system disabled.");
}
}
Script "OBJ_Toggle" (void){
player = ActivatorTID();
//This toggles off the screen.
//controlled by a CCMD using pukename
if (!DisabledObjectives){
if (!isObjectiveDisplayed){
clueindex = 0; //the current index of evidences
Q_Pause(player, True, True);
GiveInventory("NoWeapon",1);
SetWeapon("NoWeapon");
Delay(GetTicUnit()/2);
isObjectiveDisplayed = TRUE;
log(s:"Toggled");
ACS_NamedExecute("OBJ_Update",0);
}else{
ACS_NamedExecute("OBJ_Stop",0);
}
}
}
Script "OBJ_Update" (void){
Log(s:"OBJ_Update");
Delay(1);
if (isObjectiveDisplayed){
pressed = FALSE;
ACS_NamedExecute("OBJ_Draw",0);
if (cluetotal != 0){
Log(s:"Waiting for key input ...");
ACS_NamedExecute("OBJ_KeyInput",0);
While(!pressed){
delay(1);
}
ACS_NamedTerminate("OBJ_KeyInput",0);
ACS_NamedExecute("OBJ_KeyCatcher",0);
}
}
}
Script "OBJ_Draw" (void){
Log(s:"OBJ_Draw");
Delay(1);
int notecenterx = 154.0;
int notecentery = 215.2;
int objcenterx = 463.0;
int objcentery = 88.0;
int cluecenterx = 485.0;
int cluecentery = 274.0;
str currentclue = clue[clueindex];
int currentindex = clueindex + 1;
if (isObjectiveDisplayed){
SetHudSize(640, 480, 1);
SetFont("SCR_OBJ");
HudMessage(s:"A"; HUDMSG_PLAIN, 6, 0, 320.0, 240.0, 0.0);
//Notes
SetFont("HAND3FNT");
SetHudClipRect(NOTE_BOUNDX, NOTE_BOUNDY, NOTE_BOUNDW, NOTE_BOUNDH, NOTE_BOUNDW);
HudMessage(l:notes; HUDMSG_PLAIN, 2, CR_BLACK, notecenterx, notecentery, 0.0);
//Objective
SetHudClipRect(OBJ_BOUNDX, OBJ_BOUNDY, OBJ_BOUNDW, OBJ_BOUNDH, OBJ_BOUNDW);
HudMessage(l:objectives; HUDMSG_PLAIN, 3, CR_BLACK, objcenterx, objcentery, 0.0);
//Clues
SetHudClipRect(CLUE_BOUNDX, CLUE_BOUNDY, CLUE_BOUNDW, CLUE_BOUNDH, CLUE_BOUNDW);
HudMessage(l:currentclue; HUDMSG_PLAIN, 4, CR_BLACK, cluecenterx, cluecentery, 0.0);
SetHudClipRect(0,0,0,0,0);
//Clue count
HudMessage(i:currentindex; HUDMSG_PLAIN,5,CR_BLACK,CLUENUMX,CLUENUMY,0);
}
}
Script "OBJ_KeyInput" (void){
Log(s:"OBJ_KeyInput");
Delay(1);
int buttons;
int indexcontext = cluetotal - 1;
pressed = FALSE;
log(s:"clueindex previous ",i:clueindex);
While(TRUE)
{
buttons = GetPlayerInput(-1, MODINPUT_BUTTONS);
If (buttons == BT_FORWARD){
log(s:"Pressed Forward");
pressed = TRUE;
keyc = FALSE;
if(clueindex == 0){
clueindex = indexcontext;
}else{
clueindex = clueindex - 1;
}
break;
}
Else If (buttons == BT_BACK){
log(s:"Pressed Back");
pressed = TRUE;
keyc = TRUE;
if (clueindex == indexcontext){
clueindex = 0;
}else{
clueindex = clueindex + 1;
}
break;
}
Else{
pressed = FALSE;
}
Delay(1);
}
log(s:"clueindex current ",i:clueindex);
}
Script "OBJ_KeyCatcher" (void){
//This is what's called after input is passed.
//Might not be called a 'catcher', but I
//don't know what to call it.
if (isObjectiveDisplayed){
Delay(10);
ACS_NamedExecute("OBJ_Update",0);
}
}
Script "OBJ_Stop" (void){
Log(s:"OBJ_Stop");
Delay(1);
player = ActivatorTID();
if (isObjectiveDisplayed){
pressed = TRUE;
ACS_NamedTerminate("OBJ_KeyInput",0);
HudMessage(s:""; HUDMSG_PLAIN,2,0,0,0,0);
HudMessage(s:""; HUDMSG_PLAIN,3,0,0,0,0);
HudMessage(s:""; HUDMSG_PLAIN,4,0,0,0,0);
HudMessage(s:""; HUDMSG_PLAIN,5,0,0,0,0);
HudMessage(s:""; HUDMSG_PLAIN,6,0,0,0,0);
TakeInventory("NoWeapon",0x7fffffff);
Q_Pause(player, False, True);
isObjectiveDisplayed = FALSE;
}
}
Script "OBJ_HudShow" (int stats){
//Stats:
// 0 - Inactive or init
// 1 - Active
// 2 - Flash
int ObjIcoHudX = 60.0;
int ObjIcoHudY = 60.0;
SetHudSize(640,480,1);
if (stats == 1){
SetFont("I_OBJ");
}else if (stats == 2){
SetFont("I_OBJN");
}else{
SetFont("I_OBJ0");
}
HudMessage(s:"A"; HUDMSG_PLAIN,8,0,ObjIcoHudX,ObjIcoHudY,0);
}
Script "OBJ_HudFlash" (void){
ACS_NamedExecute("OBJ_HudShow",0,2);
PlaySound(0,"objective/new");
delay(GetTicUnit()*2);
ACS_NamedExecute("OBJ_HudShow",0,1);
}
Script "OBJ_ClueFlash" (void){
// Just flashes temporarily.
}
Function void OBJ_Add (int s, int f){
Log(s:"OBJ_Add");
objectives = StrParam(s:s);
notes = StrParam(s:f);
if (disabledObjectives) OBJ_Disable(FALSE);
ACS_NamedExecute("OBJ_HudFlash",0);
}
Function void OBJ_AddClue (int c){
Log(s:"OBJ_AddClue");
str cluestring = c;
clue[cluetotal] = cluestring;
str cluelog = clue[cluetotal];
log(s:"Clue ", i:cluetotal, s:"\: ", l:cluelog, s:" - Okay!");
cluetotal++;
}