Fix projectiles

FossilOrigin-Name: be136b699f19297f19ff807c028ad6977fcf27d245ed99d8288f59e35d0be1bd
This commit is contained in:
Jonathan Schleifer 2025-03-20 10:52:08 +00:00
parent 875c395ce1
commit 12bf5923b0

View file

@ -148,6 +148,11 @@ newprojectile(OFVector3D &from, OFVector3D &to, float speed, bool local,
for (size_t i = 0; i < MAXPROJ; i++) { for (size_t i = 0; i < MAXPROJ; i++) {
Projectile *p = projs[i]; Projectile *p = projs[i];
if (p == nil) {
p = [[Projectile alloc] init];
projs[i] = p;
}
if (p.inuse) if (p.inuse)
continue; continue;
@ -205,6 +210,7 @@ splash(Projectile *p, const OFVector3D &v, const OFVector3D &vold,
{ {
particle_splash(0, 50, 300, v); particle_splash(0, 50, 300, v);
p.inuse = false; p.inuse = false;
if (p.gun != GUN_RL) { if (p.gun != GUN_RL) {
playsound(S_FEXPLODE, &v); playsound(S_FEXPLODE, &v);
// no push? // no push?
@ -212,27 +218,28 @@ splash(Projectile *p, const OFVector3D &v, const OFVector3D &vold,
playsound(S_RLHIT, &v); playsound(S_RLHIT, &v);
newsphere(v, RL_RADIUS, 0); newsphere(v, RL_RADIUS, 0);
dodynlight(vold, v, 0, 0, p.owner); dodynlight(vold, v, 0, 0, p.owner);
if (!p.local) if (!p.local)
return; return;
radialeffect(player1, v, -1, qdam, p.owner); radialeffect(player1, v, -1, qdam, p.owner);
size_t i = 0; [players enumerateObjectsUsingBlock:^(
for (id player in players) { id player, size_t i, bool *stop) {
if (i == notthisplayer) { if (i == notthisplayer)
i++; return;
continue;
}
if (player != [OFNull null]) if (player == [OFNull null])
radialeffect(player, v, i, qdam, p.owner); return;
i++; radialeffect(player, v, i, qdam, p.owner);
} }];
i = 0; [getmonsters() enumerateObjectsUsingBlock:^(
for (DynamicEntity *monster in getmonsters()) DynamicEntity *monster, size_t i, bool *stop) {
if (i != notthismonster) if (i != notthismonster)
radialeffect(monster, v, i, qdam, p.owner); radialeffect(monster, v, i, qdam, p.owner);
}];
} }
} }
@ -242,6 +249,7 @@ projdamage(
{ {
if (o.state != CS_ALIVE) if (o.state != CS_ALIVE)
return; return;
if (intersect(o, p.o, v)) { if (intersect(o, p.o, v)) {
splash(p, v, p.o, i, im, qdam); splash(p, v, p.o, i, im, qdam);
hit(i, qdam, o, p.owner); hit(i, qdam, o, p.owner);
@ -265,8 +273,8 @@ moveprojectiles(float time)
if (time > dtime) if (time > dtime)
dtime = time; dtime = time;
vmul(v, time / dtime); vmul(v, time / dtime);
vadd(v, p.o) if (p.local) vadd(v, p.o);
{ if (p.local) {
for (id player in players) for (id player in players)
if (player != [OFNull null]) if (player != [OFNull null])
projdamage(player, p, v, i, -1, qdam); projdamage(player, p, v, i, -1, qdam);