︙ | | |
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
|
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
|
-
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
|
// create random spread of rays for the shotgun
void
createrays(const OFVector3D *from, const OFVector3D *to)
{
vdist(dist, dvec, *from, *to);
float f = dist * SGSPREAD / 1000;
for (int i = 0; i < SGRAYS; i++) {
for (int i = 0; i < SGRAYS; i++)
#define RNDD (rnd(101) - 50) * f
OFVector3D r = OFMakeVector3D(RNDD, RNDD, RNDD);
sg[i] = OFAddVectors3D(*to, OFMakeVector3D(RNDD, RNDD, RNDD));
sg[i] = *to;
vadd(sg[i], r);
}
}
// if lineseg hits entity bounding box
static bool
intersect(DynamicEntity *d, const OFVector3D *from, const OFVector3D *to)
{
OFVector3D v = *to, w = d.origin;
const OFVector3D *p;
vsub(v, *from);
vsub(w, *from);
v = OFSubtractVectors3D(v, *from);
w = OFSubtractVectors3D(w, *from);
float c1 = dotprod(w, v);
if (c1 <= 0)
p = from;
else {
float c2 = dotprod(v, v);
if (c2 <= c1)
p = to;
else {
float f = c1 / c2;
v = OFMultiplyVector3D(v, c1 / c2);
vmul(v, f);
vadd(v, *from);
v = OFAddVectors3D(v, *from);
p = &v;
}
}
return (p->x <= d.origin.x + d.radius &&
p->x >= d.origin.x - d.radius && p->y <= d.origin.y + d.radius &&
p->y >= d.origin.y - d.radius && p->z <= d.origin.z + d.aboveEye &&
|
︙ | | |
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
+
-
-
+
+
|
vdist(dist, temp, *v, o.origin);
dist -= 2; // account for eye distance imprecision
if (dist < RL_DAMRAD) {
if (dist < 0)
dist = 0;
int damage = (int)(qdam * (1 - (dist / RL_DAMRAD)));
hit(cn, damage, o, at);
temp =
vmul(temp, (RL_DAMRAD - dist) * damage / 800);
vadd(o.velocity, temp);
OFMultiplyVector3D(temp, (RL_DAMRAD - dist) * damage / 800);
o.velocity = OFAddVectors3D(o.velocity, temp);
}
}
static void
splash(Projectile *p, const OFVector3D *v, const OFVector3D *vold,
int notthisplayer, int notthismonster, int qdam)
{
|
︙ | | |
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
-
-
+
+
|
int qdam = guns[p.gun].damage * (p.owner.quadMillis ? 4 : 1);
if ([p.owner isKindOfClass:Monster.class])
qdam /= MONSTERDAMAGEFACTOR;
vdist(dist, v, p.o, p.to);
float dtime = dist * 1000 / p.speed;
if (time > dtime)
dtime = time;
vmul(v, time / dtime);
vadd(v, p.o);
v = OFMultiplyVector3D(v, time / dtime);
v = OFAddVectors3D(v, p.o);
if (p.local) {
for (id player in players)
if (player != [OFNull null])
projdamage(player, p, &v, i, -1, qdam);
if (p.owner != player1)
projdamage(player1, p, &v, -1, -1, qdam);
|
︙ | | |
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
-
-
+
+
|
void
hitpush(int target, int damage, DynamicEntity *d, DynamicEntity *at,
const OFVector3D *from, const OFVector3D *to)
{
hit(target, damage, d, at);
vdist(dist, v, *from, *to);
vmul(v, damage / dist / 50);
vadd(d.velocity, v);
v = OFMultiplyVector3D(v, damage / dist / 50);
d.velocity = OFAddVectors3D(d.velocity, v);
}
void
raydamage(DynamicEntity *o, const OFVector3D *from, const OFVector3D *to,
DynamicEntity *d, int i)
{
if (o.state != CS_ALIVE)
|
︙ | | |
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
|
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
-
-
-
-
+
+
+
+
-
+
-
-
+
|
if (d.gunSelect)
d.ammo[d.gunSelect]--;
OFVector3D from = d.origin;
OFVector3D to = *targ;
from.z -= 0.2f; // below eye
vdist(dist, unitv, from, to);
vdiv(unitv, dist);
OFVector3D kickback = unitv;
vmul(kickback, guns[d.gunSelect].kickamount * -0.01f);
vadd(d.velocity, kickback);
unitv = OFMultiplyVector3D(unitv, 1.0f / dist);
OFVector3D kickback =
OFMultiplyVector3D(unitv, guns[d.gunSelect].kickamount * -0.01f);
d.velocity = OFAddVectors3D(d.velocity, kickback);
if (d.pitch < 80.0f)
d.pitch += guns[d.gunSelect].kickamount * 0.05f;
if (d.gunSelect == GUN_FIST || d.gunSelect == GUN_BITE) {
vmul(unitv, 3); // punch range
unitv = OFMultiplyVector3D(unitv, 3); // punch range
to = from;
vadd(to, unitv);
to = OFAddVectors3D(from, unitv);
}
if (d.gunSelect == GUN_SG)
createrays(&from, &to);
if (d.quadMillis && attacktime > 200)
playsoundc(S_ITEMPUP);
shootv(d.gunSelect, &from, &to, d, true);
|
︙ | | |