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
|
// entities.cpp: map entity related functions (pickup etc.)
#include "cube.h"
#import "DynamicEntity.h"
#import "MapModelInfo.h"
vector<entity> ents;
static OFString *entmdlnames[] = {
@"shells",
@"bullets",
@"rockets",
@"rrounds",
@"health",
@"boost",
@"g_armour",
@"y_armour",
@"quad",
@"teleporter",
};
int triggertime = 0;
void
renderent(entity &e, OFString *mdlname, float z, float yaw, int frame = 0,
int numf = 1, int basetime = 0, float speed = 10.0f)
{
rendermodel(mdlname, frame, numf, 0, 1.1f,
OFMakeVector3D(e.x, z + S(e.x, e.y)->floor, e.y), yaw, 0, false,
1.0f, speed, 0, basetime);
}
void
renderentities()
{
if (lastmillis > triggertime + 1000)
triggertime = 0;
loopv(ents)
{
entity &e = ents[i];
if (e.type == MAPMODEL) {
MapModelInfo *mmi = getmminfo(e.attr2);
if (mmi == nil)
continue;
rendermodel(mmi.name, 0, 1, e.attr4, (float)mmi.rad,
OFMakeVector3D(e.x,
(float)S(e.x, e.y)->floor + mmi.zoff + e.attr3,
|
>
|
>
>
>
>
>
>
|
<
|
|
|
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
|
// entities.cpp: map entity related functions (pickup etc.)
#include "cube.h"
#import "DynamicEntity.h"
#import "Entity.h"
#import "MapModelInfo.h"
OFMutableArray<Entity *> *ents;
static OFString *entmdlnames[] = {
@"shells",
@"bullets",
@"rockets",
@"rrounds",
@"health",
@"boost",
@"g_armour",
@"y_armour",
@"quad",
@"teleporter",
};
int triggertime = 0;
void
initEntities()
{
ents = [[OFMutableArray alloc] init];
}
void
renderent(Entity *e, OFString *mdlname, float z, float yaw, int frame = 0,
int numf = 1, int basetime = 0, float speed = 10.0f)
{
rendermodel(mdlname, frame, numf, 0, 1.1f,
OFMakeVector3D(e.x, z + S(e.x, e.y)->floor, e.y), yaw, 0, false,
1.0f, speed, 0, basetime);
}
void
renderentities()
{
if (lastmillis > triggertime + 1000)
triggertime = 0;
for (Entity *e in ents) {
if (e.type == MAPMODEL) {
MapModelInfo *mmi = getmminfo(e.attr2);
if (mmi == nil)
continue;
rendermodel(mmi.name, 0, 1, e.attr4, (float)mmi.rad,
OFMakeVector3D(e.x,
(float)S(e.x, e.y)->floor + mmi.zoff + e.attr3,
|
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
|
}
void
checkitems()
{
if (editmode)
return;
loopv(ents)
{
entity &e = ents[i];
if (e.type == NOTUSED)
continue;
if (!ents[i].spawned && e.type != TELEPORT && e.type != JUMPPAD)
continue;
if (OUTBORD(e.x, e.y))
continue;
OFVector3D v = OFMakeVector3D(
e.x, e.y, (float)S(e.x, e.y)->floor + player1.eyeheight);
vdist(dist, t, player1.o, v);
if (dist < (e.type == TELEPORT ? 4 : 2.5))
pickup(i, player1);
}
}
void
checkquad(int time)
{
if (player1.quadmillis && (player1.quadmillis -= time) < 0) {
player1.quadmillis = 0;
playsoundc(S_PUPOUT);
conoutf(@"quad damage is over");
}
}
void
putitems(uchar *&p) // puts items in network stream and also spawns them locally
{
loopv(ents) if ((ents[i].type >= I_SHELLS && ents[i].type <= I_QUAD) ||
ents[i].type == CARROT)
{
putint(p, i);
ents[i].spawned = true;
}
}
void
resetspawns()
{
loopv(ents) ents[i].spawned = false;
}
void
setspawn(uint i, bool on)
{
if (i < (uint)ents.length())
ents[i].spawned = on;
}
|
<
|
<
>
>
|
|
>
|
>
|
>
|
>
|
|
<
|
|
|
>
>
|
|
|
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
|
}
void
checkitems()
{
if (editmode)
return;
[ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) {
if (e.type == NOTUSED)
return;
if (!e.spawned && e.type != TELEPORT && e.type != JUMPPAD)
return;
if (OUTBORD(e.x, e.y))
return;
OFVector3D v = OFMakeVector3D(
e.x, e.y, (float)S(e.x, e.y)->floor + player1.eyeheight);
vdist(dist, t, player1.o, v);
if (dist < (e.type == TELEPORT ? 4 : 2.5))
pickup(i, player1);
}];
}
void
checkquad(int time)
{
if (player1.quadmillis && (player1.quadmillis -= time) < 0) {
player1.quadmillis = 0;
playsoundc(S_PUPOUT);
conoutf(@"quad damage is over");
}
}
void
putitems(uchar *&p) // puts items in network stream and also spawns them locally
{
[ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) {
if ((e.type >= I_SHELLS && e.type <= I_QUAD) ||
e.type == CARROT) {
putint(p, i);
e.spawned = true;
}
}];
}
void
resetspawns()
{
for (Entity *e in ents)
e.spawned = false;
}
void
setspawn(uint i, bool on)
{
if (i < (uint)ents.count)
ents[i].spawned = on;
}
|