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
|
void
arenarespawn()
{
if (arenarespawnwait) {
if (arenarespawnwait < lastmillis) {
arenarespawnwait = 0;
conoutf("new round starting... fight!");
respawnself();
};
} else if (arenadetectwait == 0 || arenadetectwait < lastmillis) {
arenadetectwait = 0;
int alive = 0, dead = 0;
char *lastteam = NULL;
bool oneteam = true;
loopv(players) if (players[i])
arenacount(players[i], alive, dead, lastteam, oneteam);
arenacount(player1, alive, dead, lastteam, oneteam);
if (dead > 0 && (alive <= 1 || (m_teammode && oneteam))) {
conoutf(
"arena round is over! next round in 5 seconds...");
if (alive)
conoutf(
"team %s is last man standing", lastteam);
else
conoutf("everyone died!");
arenarespawnwait = lastmillis + 5000;
arenadetectwait = lastmillis + 10000;
player1->roll = 0;
};
};
};
|
|
|
|
|
|
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
|
void
arenarespawn()
{
if (arenarespawnwait) {
if (arenarespawnwait < lastmillis) {
arenarespawnwait = 0;
conoutf(@"new round starting... fight!");
respawnself();
};
} else if (arenadetectwait == 0 || arenadetectwait < lastmillis) {
arenadetectwait = 0;
int alive = 0, dead = 0;
char *lastteam = NULL;
bool oneteam = true;
loopv(players) if (players[i])
arenacount(players[i], alive, dead, lastteam, oneteam);
arenacount(player1, alive, dead, lastteam, oneteam);
if (dead > 0 && (alive <= 1 || (m_teammode && oneteam))) {
conoutf(
@"arena round is over! next round in 5 seconds...");
if (alive)
conoutf(
@"team %s is last man standing", lastteam);
else
conoutf(@"everyone died!");
arenarespawnwait = lastmillis + 5000;
arenadetectwait = lastmillis + 10000;
player1->roll = 0;
};
};
};
|
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
void
respawn()
{
if (player1->state == CS_DEAD) {
player1->attacking = false;
if (m_arena) {
conoutf("waiting for new round to start...");
return;
};
if (m_sp) {
nextmode = gamemode;
changemap(clientmap);
return;
}; // if we die in SP we try the same map again
|
|
|
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
void
respawn()
{
if (player1->state == CS_DEAD) {
player1->attacking = false;
if (m_arena) {
conoutf(@"waiting for new round to start...");
return;
};
if (m_sp) {
nextmode = gamemode;
changemap(clientmap);
return;
}; // if we die in SP we try the same map again
|
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
d->o.x += dx;
d->o.y += dy;
if (collide(d, true, 0, 0))
return;
d->o.x -= dx;
d->o.y -= dy;
};
conoutf(
"can't find entity spawn spot! (%d, %d)", (int)d->o.x, (int)d->o.y);
// leave ent at original pos, possibly stuck
};
int spawncycle = -1;
int fixspawn = 2;
void
|
<
|
>
|
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
d->o.x += dx;
d->o.y += dy;
if (collide(d, true, 0, 0))
return;
d->o.x -= dx;
d->o.y -= dy;
};
conoutf(@"can't find entity spawn spot! (%d, %d)", (int)d->o.x,
(int)d->o.y);
// leave ent at original pos, possibly stuck
};
int spawncycle = -1;
int fixspawn = 2;
void
|
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
|
: (player1->roll < 0
? -droll
: (rnd(2) ? droll
: -droll)); // give player a kick depending
// on amount of damage
if ((player1->health -= damage) <= 0) {
if (actor == -2) {
conoutf("you got killed by %s!", act->name);
} else if (actor == -1) {
actor = getclientnum();
conoutf("you suicided!");
addmsg(1, 2, SV_FRAGS, --player1->frags);
} else {
dynent *a = getclient(actor);
if (a) {
if (isteam(a->team, player1->team)) {
conoutf("you got fragged by a teammate "
"(%s)",
a->name);
} else {
conoutf(
"you got fragged by %s", a->name);
};
};
};
showscores(true);
addmsg(1, 2, SV_DIED, actor);
player1->lifesequence++;
player1->attacking = false;
player1->state = CS_DEAD;
player1->pitch = 0;
player1->roll = 60;
playsound(S_DIE1 + rnd(2));
spawnstate(player1);
player1->lastaction = lastmillis;
} else {
playsound(S_PAIN6);
};
};
void
timeupdate(int timeremain)
{
if (!timeremain) {
intermission = true;
player1->attacking = false;
conoutf("intermission:");
conoutf("game has ended!");
showscores(true);
} else {
conoutf("time remaining: %d minutes", timeremain);
};
};
dynent *
getclient(int cn) // ensure valid entity
{
if (cn < 0 || cn >= MAXCLIENTS) {
neterr("clientnum");
return NULL;
};
while (cn >= players.length())
players.add(NULL);
return players[cn] ? players[cn] : (players[cn] = newdynent());
};
void
initclient()
{
clientmap[0] = 0;
initclientnet();
};
void
startmap(char *name) // called just after a map load
{
if (netmapstart() && m_sp) {
gamemode = 0;
conoutf("coop sp not supported yet");
};
sleepwait = 0;
monsterclear();
projreset();
spawncycle = -1;
spawnplayer(player1);
player1->frags = 0;
loopv(players) if (players[i]) players[i]->frags = 0;
resetspawns();
strcpy_s(clientmap, name);
if (editmode)
toggleedit();
setvar("gamespeed", 100);
setvar("fog", 180);
setvar("fogcolour", 0x8099B3);
showscores(false);
intermission = false;
framesinmap = 0;
conoutf("game mode is %s", modestr(gamemode));
};
COMMANDN(map, changemap, ARG_1STR);
|
|
|
|
|
|
<
<
<
>
>
>
<
<
>
>
|
|
|
<
<
>
>
<
>
|
<
>
|
|
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
|
: (player1->roll < 0
? -droll
: (rnd(2) ? droll
: -droll)); // give player a kick depending
// on amount of damage
if ((player1->health -= damage) <= 0) {
if (actor == -2) {
conoutf(@"you got killed by %s!", act->name);
} else if (actor == -1) {
actor = getclientnum();
conoutf(@"you suicided!");
addmsg(1, 2, SV_FRAGS, --player1->frags);
} else {
dynent *a = getclient(actor);
if (a) {
if (isteam(a->team, player1->team)) {
conoutf(@"you got fragged by a "
@"teammate (%s)",
a->name);
} else {
conoutf(
@"you got fragged by %s", a->name);
}
}
}
showscores(true);
addmsg(1, 2, SV_DIED, actor);
player1->lifesequence++;
player1->attacking = false;
player1->state = CS_DEAD;
player1->pitch = 0;
player1->roll = 60;
playsound(S_DIE1 + rnd(2));
spawnstate(player1);
player1->lastaction = lastmillis;
} else {
playsound(S_PAIN6);
}
}
void
timeupdate(int timeremain)
{
if (!timeremain) {
intermission = true;
player1->attacking = false;
conoutf(@"intermission:");
conoutf(@"game has ended!");
showscores(true);
} else {
conoutf(@"time remaining: %d minutes", timeremain);
}
}
dynent *
getclient(int cn) // ensure valid entity
{
if (cn < 0 || cn >= MAXCLIENTS) {
neterr("clientnum");
return NULL;
};
while (cn >= players.length())
players.add(NULL);
return players[cn] ? players[cn] : (players[cn] = newdynent());
}
void
initclient()
{
clientmap[0] = 0;
initclientnet();
};
void
startmap(char *name) // called just after a map load
{
if (netmapstart() && m_sp) {
gamemode = 0;
conoutf(@"coop sp not supported yet");
}
sleepwait = 0;
monsterclear();
projreset();
spawncycle = -1;
spawnplayer(player1);
player1->frags = 0;
loopv(players) if (players[i]) players[i]->frags = 0;
resetspawns();
strcpy_s(clientmap, name);
if (editmode)
toggleedit();
setvar("gamespeed", 100);
setvar("fog", 180);
setvar("fogcolour", 0x8099B3);
showscores(false);
intermission = false;
framesinmap = 0;
conoutf(@"game mode is %s", modestr(gamemode));
};
COMMANDN(map, changemap, ARG_1STR);
|