Differences From Artifact [7fa0099398]:
- File
src/weapon.m
— part of check-in
[304230c1e1]
at
2025-03-23 21:52:54
on branch trunk
— Avoid pointless pointers
Passing OFVector3D by reference is annoying and is worse at passing via registers. (user: js, size: 10546) [annotate] [blame] [check-ins using]
To Artifact [d5d4aa755b]:
- File src/weapon.m — part of check-in [75095b4f6e] at 2025-03-23 22:14:48 on branch trunk — Fix wrong argument order for calculating distance (user: js, size: 10545) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
69 70 71 72 73 74 75 | (a3.length > 0 ? a3.cube_intValue : -1)); }) // create random spread of rays for the shotgun void createrays(OFVector3D from, OFVector3D to) { | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | (a3.length > 0 ? a3.cube_intValue : -1)); }) // create random spread of rays for the shotgun void createrays(OFVector3D from, OFVector3D to) { float dist = OFDistanceOfVectors3D(to, from); float f = dist * SGSPREAD / 1000; for (int i = 0; i < SGRAYS; i++) #define RNDD (rnd(101) - 50) * f sg[i] = OFAddVectors3D(to, OFMakeVector3D(RNDD, RNDD, RNDD)); } // if lineseg hits entity bounding box |
︙ | ︙ | |||
181 182 183 184 185 186 187 | radialeffect( DynamicEntity *o, OFVector3D v, int cn, int qdam, DynamicEntity *at) { if (o.state != CS_ALIVE) return; OFVector3D origin = o.origin; | | | < | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | radialeffect( DynamicEntity *o, OFVector3D v, int cn, int qdam, DynamicEntity *at) { if (o.state != CS_ALIVE) return; OFVector3D origin = o.origin; float dist = OFDistanceOfVectors3D(origin, v); OFVector3D temp = OFSubtractVectors3D(origin, v); 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 = OFMultiplyVector3D(temp, (RL_DAMRAD - dist) * damage / 800); o.velocity = OFAddVectors3D(o.velocity, temp); } } static void |
︙ | ︙ | |||
263 264 265 266 267 268 269 | if (!p.inuse) continue; int qdam = guns[p.gun].damage * (p.owner.quadMillis ? 4 : 1); if ([p.owner isKindOfClass:Monster.class]) qdam /= MONSTERDAMAGEFACTOR; | | | | | | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | if (!p.inuse) continue; int qdam = guns[p.gun].damage * (p.owner.quadMillis ? 4 : 1); if ([p.owner isKindOfClass:Monster.class]) qdam /= MONSTERDAMAGEFACTOR; OFVector3D po = p.o, pto = p.to; float dist = OFDistanceOfVectors3D(pto, po); OFVector3D v = OFSubtractVectors3D(pto, po); float dtime = dist * 1000 / p.speed; if (time > dtime) dtime = time; v = OFMultiplyVector3D(v, time / dtime); v = OFAddVectors3D(v, po); 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); |
︙ | ︙ | |||
346 347 348 349 350 351 352 | } void hitpush(int target, int damage, DynamicEntity *d, DynamicEntity *at, OFVector3D from, OFVector3D to) { hit(target, damage, d, at); | | | | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | } void hitpush(int target, int damage, DynamicEntity *d, DynamicEntity *at, OFVector3D from, OFVector3D to) { hit(target, damage, d, at); float dist = OFDistanceOfVectors3D(to, from); OFVector3D v = OFSubtractVectors3D(to, from); v = OFMultiplyVector3D(v, damage / dist / 50); d.velocity = OFAddVectors3D(d.velocity, v); } void raydamage( DynamicEntity *o, OFVector3D from, OFVector3D to, DynamicEntity *d, int i) |
︙ | ︙ | |||
397 398 399 400 401 402 403 | } if (d.gunSelect) d.ammo[d.gunSelect]--; OFVector3D from = d.origin; OFVector3D to = targ; from.z -= 0.2f; // below eye | | | | 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | } if (d.gunSelect) d.ammo[d.gunSelect]--; OFVector3D from = d.origin; OFVector3D to = targ; from.z -= 0.2f; // below eye float dist = OFDistanceOfVectors3D(to, from); OFVector3D unitv = OFSubtractVectors3D(to, from); 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; |
︙ | ︙ |