1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
// 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",
|
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
// entities.cpp: map entity related functions (pickup etc.)
#include "cube.h"
#import "DynamicEntity.h"
#import "Entity.h"
#import "MapModelInfo.h"
#import "Player.h"
OFMutableArray<Entity *> *ents;
static OFString *entmdlnames[] = {
@"shells",
@"bullets",
@"rockets",
|
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
|
{ 150, 150, S_ITEMARMOUR },
{ 20000, 30000, S_ITEMPUP },
};
void
baseammo(int gun)
{
player1.ammo[gun] = itemstats[gun - 1].add * 2;
}
// these two functions are called when the server acknowledges that you really
// picked up the item (in multiplayer someone may grab it before you).
static int
radditem(int i, int v)
{
struct itemstat *is = &itemstats[ents[i].type - I_SHELLS];
ents[i].spawned = false;
v += is->add;
if (v > is->max)
v = is->max;
playsoundc(is->sound);
return v;
}
void
realpickup(int n, DynamicEntity *d)
{
switch (ents[n].type) {
case I_SHELLS:
d.ammo[1] = radditem(n, d.ammo[1]);
break;
case I_BULLETS:
d.ammo[2] = radditem(n, d.ammo[2]);
|
|
|
|
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
|
{ 150, 150, S_ITEMARMOUR },
{ 20000, 30000, S_ITEMPUP },
};
void
baseammo(int gun)
{
Player.player1.ammo[gun] = itemstats[gun - 1].add * 2;
}
// these two functions are called when the server acknowledges that you really
// picked up the item (in multiplayer someone may grab it before you).
static int
radditem(int i, int v)
{
struct itemstat *is = &itemstats[ents[i].type - I_SHELLS];
ents[i].spawned = false;
v += is->add;
if (v > is->max)
v = is->max;
playsoundc(is->sound);
return v;
}
void
realpickup(int n, Player *d)
{
switch (ents[n].type) {
case I_SHELLS:
d.ammo[1] = radditem(n, d.ammo[1]);
break;
case I_BULLETS:
d.ammo[2] = radditem(n, d.ammo[2]);
|
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
|
case JUMPPAD: {
static int lastjumppad = 0;
if (lastmillis - lastjumppad < 300)
break;
lastjumppad = lastmillis;
OFVector3D v = OFMakeVector3D((int)(char)ents[n].attr3 / 10.0f,
(int)(char)ents[n].attr2 / 10.0f, ents[n].attr1 / 10.0f);
player1.velocity = OFAddVectors3D(
OFMakeVector3D(player1.velocity.x, player1.velocity.y, 0),
v);
playsoundc(S_JUMPPAD);
break;
}
}
}
void
checkitems()
{
if (editmode)
return;
[ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) {
if (e.type == NOTUSED)
return;
|
>
>
>
|
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
|
case JUMPPAD: {
static int lastjumppad = 0;
if (lastmillis - lastjumppad < 300)
break;
lastjumppad = lastmillis;
OFVector3D v = OFMakeVector3D((int)(char)ents[n].attr3 / 10.0f,
(int)(char)ents[n].attr2 / 10.0f, ents[n].attr1 / 10.0f);
Player *player1 = Player.player1;
player1.velocity = OFAddVectors3D(
OFMakeVector3D(player1.velocity.x, player1.velocity.y, 0),
v);
playsoundc(S_JUMPPAD);
break;
}
}
}
void
checkitems()
{
Player *player1 = Player.player1;
if (editmode)
return;
[ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) {
if (e.type == NOTUSED)
return;
|
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
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");
}
}
|
>
>
|
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
pickup(i, player1);
}];
}
void
checkquad(int time)
{
Player *player1 = Player.player1;
if (player1.quadMillis && (player1.quadMillis -= time) < 0) {
player1.quadMillis = 0;
playsoundc(S_PUPOUT);
conoutf(@"quad damage is over");
}
}
|