-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8BDMLIB.acs
415 lines (365 loc) · 10.4 KB
/
8BDMLIB.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
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
// [Lego] In your source code, always include "zcommon.acs" before this file.
// This was done for clarity and organizational purposes.
// This file contains a number of variables added to make expanding 8BDM easier.
// If using SLADE 3.1.0.5 or later, include this file in the same directory
// as your source ACS before compiling.
// Otherwise, extract it to the same folder as your acc.exe.
// Note that this file SHOULD NOT be compiled on its own.
//#library "8BDMLIB"
#DEFINE TEAM_LIGHT 0
#DEFINE TEAM_WILY 1
#DEFINE TEAM_COSSACK 2
#DEFINE TEAM_KING 3
// These are used in WEPACS
#DEFINE COLOR_LIGHT 230
#DEFINE COLOR_WILY 231
#DEFINE COLOR_COSSACK 232
#DEFINE COLOR_KING 233
BOOL IsTeamGame = 0; // Is mode a team game?
int timestop=-1; // Is time stopper active?
int MaxFrags; // Frag limit for match
int BossMusic = 0; // Boss Music State
int ServerMAX = 32; // Max number of players (Default: 32)
// [Lego] Stores player's default gravity for situational uses in customized classes.
int PlayerGravity[64];
// [Lego] These are global ints to allow values to be rolled at the beginning of rounds only.
global int 5: RangedWepRandom;
global int 6: RapidWepRandom;
global int 7: CloseWepRandom;
global int 8: PowerWepRandom;
global int 9: ShieldWepRandom;
//Functions
// [Lego] Gets the absolute maximum number of players in the server.
function int GetMaxPlayers(void)
{
int ret = GetCVAR("sv_MaxClients");
if(PlayerCount()>ret) // admins can join above the max player limit.
{
ret = PlayerCount();
}
return ret;
}
// [Mess] The following function returns:
// 0 if they haven't pressed jump (in a given tic)
// 1 if the player pressed jump
// 2 if the player released jump
// 3 if the player is holding jump
Function int JumpStatus (int Buttons, int OldButtons)
{
int JumpNow = Buttons & BT_JUMP;
int JumpOld = OldButtons & BT_JUMP;
If(JumpNow > JumpOld){Return 1;}
If(JumpNow < JumpOld){Return 2;}
If(JumpNow > 0 && JumpOld > 0){Return 3;}
Return 0;
}
// [Mess] Remaining Lives for LMS boss music
Function int LivesLeft (int p)
{
//If(ACS_ExecuteWithResult(975) != 2){Return 1;}
Return((GetPlayerLivesLeft(p)) + (GetActorProperty(p+1000, APROP_HEALTH) > 0));
}
// [Mess] Boss Music Selection Function
Function void BossMusicSelect(int ThePar, int Type)
{
Switch(Type)
{
Case 0:
if(StrCmp(GetCvarString("mm8bdm_map_bossmusic"), "") == false){
if(ThePar==1){SetMusic("MM1BOSS");}
else if(ThePar==2){SetMusic("MM2BOSS");}
else if(ThePar==3){SetMusic("MM3BOSS");}
else if(ThePar==4){SetMusic("MM4BOSS");}
else if(ThePar==5){SetMusic("MM5BOSS");}
else if(ThePar==6){SetMusic("MM6BOSS");}
else if(ThePar==7){SetMusic("MM7BOSS");}
else if(ThePar==8){SetMusic("MM7OBOS");}
else if(ThePar==9){SetMusic("MM8BOSS");}
else if(ThePar==10){SetMusic("MM1PBOSS");}
else if(ThePar==11){SetMusic("DUOMUS");}
else if(ThePar==12){SetMusic("MMBBOSS");}
else if(ThePar==13){SetMusic("MMBOBOS");}
else if(ThePar==14){SetMusic("MMWTBOSS");}
else if(ThePar==15){SetMusic("MM9BOSS");}
break;
}
else
{
SetMusic(GetCvarString("mm8bdm_map_bossmusic"));
break;
}
Case 1:
if(StrCmp(GetCvarString("mm8bdm_map_victorymusic"), "") == false){
if(ThePar==1){SetMusic("MM1VIC");}
else if(ThePar==2){SetMusic("MM2VIC");}
else if(ThePar==3){SetMusic("MM3VIC");}
else if(ThePar==4){SetMusic("MM4VIC");}
else if(ThePar==5){SetMusic("MM4VIC");}
else if(ThePar==6){SetMusic("MM4VIC");}
else if(ThePar==7){SetMusic("MM7VIC");}
else if(ThePar==8){SetMusic("MM7VIC");}
else if(ThePar==9){SetMusic("MM4VIC");}
else if(ThePar==10){SetMusic("MM1VIC");}
else if(ThePar==11){SetMusic("MM4VIC");}
else if(ThePar==12){SetMusic("MM4VIC");}
else if(ThePar==13){SetMusic("MM4VIC");}
else if(ThePar==14){SetMusic("MMWTVIC");}
else if(ThePar==15){SetMusic("MM2VIC");}
break;
}
else
{
SetMusic(GetCvarString("mm8bdm_map_victorymusic"));
break;
}
Case 2:
if(StrCmp(GetCvarString("mm8bdm_map_intensemusic"), "") == false){
if(ThePar==1){SetMusic("MM1PWBOS");}
else if(ThePar==2){SetMusic("GUTSBOSS");}
else if(ThePar==3){SetMusic("PROMBOSS");}
else if(ThePar==4){SetMusic("MM4BOSS2");}
else if(ThePar==5){SetMusic("MM5BOSS2");}
else if(ThePar==6){SetMusic("MM6BOSS2");}
else if(ThePar==7){SetMusic("MM7BASS2");}
else if(ThePar==8){SetMusic("MM7BASS2");}
else if(ThePar==9){SetMusic("ERBATTLE");}
else if(ThePar==10){SetMusic("MM1PWBOS");}
else if(ThePar==11){SetMusic("ERBATTLE");}
else if(ThePar==12){SetMusic("MMWTFBOS");}
else if(ThePar==13){SetMusic("MMWTFBOS");}
else if(ThePar==14){SetMusic("MMWTFBOS");}
else if(ThePar==15){SetMusic("MM9FBOS");}
break;
}
else
{
SetMusic(GetCvarString("mm8bdm_map_intensemusic"));
break;
}
}
}
//[Mess] Used by ridable items (Item2, Ice wall etc)
Function int SpeedCheck (int x1, int x2, int y1, int y2)
{
int x, y;
x = x1 - x2 >> 16;
y = y1 - y2 >> 16;
return(sqrt8( x*x + y*y ));
}
function int onPlatformZ (int tid1z, int tid2z, int height)
{
return tid2z==(tid1z+(height<<16));
}
function int onPlatformXY (int tid1x, int tid1y, int tid2x, int tid2y, int radius)
{
int x, y, d;
x = tid1x - tid2x >> 16;
y = tid1y - tid2y >> 16;
d = sqrt8(x*x + y*y);
return d<=radius;
}
// Finds the pitch between two Z points
Function int VectorPitch (Int TID1, Int TID2, int ZAdjust)
{
If(ZAdjust != 0){ZAdjust = ZAdjust << 16;}
Return(VectorAngle(xydistance(TID1, TID2)<<16,GetActorZ(TID1)-(GetActorZ(TID2)-ZAdjust)));
}
// Returns absolute value
function int abs (int x)
{
if (x < 0)
{
return -x;
}
return x;
}
// Returns the closest integer, rounded up
function int ceil(int fixedIn)
{
if(fixedIn % 65536 != 0)
{
return (fixedIn >> 16) + 1;
}
return fixedIn >> 16;
}
function int max(int x, int y)
{
if(x > y)
{
return x;
}
return y;
}
function int min (int x, int y)
{
if(x<y)return x;
return y;
}
// sqrt and distance functions from ZDoom wiki
function int sqrt8(int number)
{
if(number <= 3)
{
if(number > 0)
{
return 1;
}
return 0;
}
int oldAns = number >> 1, // initial guess
newAns = (oldAns + number / oldAns) >> 1; // first iteration
// main iterative method
while(newAns < oldAns)
{
oldAns = newAns;
newAns = (oldAns + number / oldAns) >> 1;
}
return oldAns;
}
// Distance measuring functions
function int xyzDistance (int tid1, int tid2)
{
int x, y, z, d;
x = GetActorX(tid1) - GetActorX(tid2) >> 16; // Convert fixed point to integer
y = GetActorY(tid1) - GetActorY(tid2) >> 16;
z = GetActorZ(tid1) - GetActorZ(tid2) >> 16;
d = sqrt8( x*x + y*y + z*z );
return d;
}
function int xyDistance (int tid1, int tid2)
{
int x, y, d;
x = GetActorX(tid1) - GetActorX(tid2) >> 16;
y = GetActorY(tid1) - GetActorY(tid2) >> 16;
d = sqrt8( x*x + y*y );
return d;
}
function int zdistance (int tid1, int tid2)
{
int z;
z = GetActorZ(tid1) - GetActorZ(tid2) >> 16;
return z;
}
// [Mess] Function to determine the closest player
function int ClosestPlayer (int max_distance)
{
int LowestDistance=max_distance;
int ClosestPlayerTID;
int CurrentDistance;
int FiringPlayer=ACS_ExecuteWithResult(257,0);
for(int h=0;h<=ServerMAX-1;h++)
{
if(PlayerInGame(h) && h+1000 != FiringPlayer && h+1000 != ActivatorTID())
{
CurrentDistance = xyzdistance(ActivatorTID(), h+1000);
If(LowestDistance==0){LowestDistance=CurrentDistance;ClosestPlayerTID=h+1000;}
If(CurrentDistance < LowestDistance)
{
LowestDistance=CurrentDistance;
ClosestPlayerTID=h+1000;
}
}
}
Return ClosestPlayerTID;
}
// [Mess] Checks to see if there's a team with 1 player left and one team with 1 or greater.
Function int LMSBossCheck (int blue, int red, int orange, int purple)
{
int Check1;
int Check2;
If(blue == 1 || red == 1 || orange == 1 || purple == 1){Check1 = 1;}
If(Blue == 0){Check2++;}
If(Red == 0){Check2++;}
If(Orange == 0){Check2++;}
If(Purple == 0){Check2++;}
Return(Check1 == 1 && Check2 >= 2);
}
// Returns frags from Orange Team
Function int OrangeFrags(void)
{
int O = ActivatorTID();
int CossackFrags=0;
For(int i = 0; i < ServerMAX; i++)
{
If(!PlayerInGame(i)){continue;}
SetActivator(i+1000);
If(GetPlayerInfo(i, PLAYERINFO_TEAM) == 2)
{
CossackFrags+=PlayerFrags();
}
}
SetActivator(O);
return(CossackFrags);
}
// Returns frags from Purple Team
Function int PurpleFrags(void)
{
int O = ActivatorTID();
int KingFrags=0;
For(int i = 0; i < ServerMAX; i++)
{
If(!PlayerInGame(i)){continue;}
SetActivator(i+1000);
If(GetPlayerInfo(i, PLAYERINFO_TEAM) == 3)
{
KingFrags+=PlayerFrags();
}
}
SetActivator(O);
return(KingFrags);
}
// Makes facer face target
// takes in two TIDs
function int ActorFace (int facer, int target)
{
int x = (GetActorX(target) - GetActorX(facer));
int y = (GetActorY(target) - GetActorY(facer));
SetActorAngle(facer, VectorAngle(x, y));
return 0;
}
// (Lego) Thrust an actor towards another with offsets
function void actorPull(int puller, int pullee, int force, int xOff, int yOff, int zOff)
{
int angle = VectorAngle((GetActorX(puller)+xOff)-GetActorX(pullee), (GetActorY(puller)+yOff)-GetActorY(pullee));
int pitch = pitchBetween(puller, pullee, xOff, yOff, zOff);
angle = angle >> 8; // Convert fixed point angle to byte angle.
int horizForce = fixedMul(cos(pitch), force<<16)>>16;
int vertiForce = fixedMul(sin(pitch), force<<16)>>16;
//PrintBold(s:"pitch: ", f:pitch, s:"\n",
// s:"horizontal force: ", i:horizForce, s:"\n",
// s:"vertical force: ", i:vertiForce, s:"\n");
//
ThrustThing(angle, horizForce, horizForce>30, pullee);
ThrustThingZ(pullee, vertiForce*4, 0, 0);
}
// (Lego) Stolen from Evil Escort, which in turn was stolen from the ZDoom forum
function int pitchBetween(int looker, int target, int xOff, int yOff, int zOff)
{
int x, y, z, ang, pitch, len;
x = (getactorx(target) + xOff) - getactorx(looker);
y = (getactory(target) + yOff)- getactory(looker);
ang = vectorangle(x,y);
if(((ang+0.125)%0.5) > 0.25) len = fixeddiv(y, sin(ang));
else len = fixeddiv(x, cos(ang));
z = (getactorz(target) - zOff) - getactorz(looker);
pitch = -vectorangle(len, z);
return pitch;
}
// (Lego)
function int normalize(int x)
{
while(x < 0)
{
x += 1.0;
}
while(x > 1.0)
{
x -= 1.0;
}
return x;
}
// Hookshot
function int magnitudeThree(int x, int y, int z)
{
return sqrt8(x*x + y*y + z*z);
}