From c79dda69d6e603500a5681430172b5152041af0a Mon Sep 17 00:00:00 2001 From: xolatile Date: Thu, 17 Jul 2025 23:28:55 +0200 Subject: Big changed mentioned in IRC channel... --- src/fpsgame/weapon.cpp | 52 ++++++++++++-------------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) (limited to 'src/fpsgame/weapon.cpp') diff --git a/src/fpsgame/weapon.cpp b/src/fpsgame/weapon.cpp index 3c7f575..b062609 100644 --- a/src/fpsgame/weapon.cpp +++ b/src/fpsgame/weapon.cpp @@ -3,7 +3,6 @@ namespace game { - static const int MONSTERDAMAGEFACTOR = 4; static const int OFFSETMILLIS = 500; vec rays[MAXRAYS]; @@ -15,7 +14,6 @@ namespace game vector hits; VARP(maxdebris, 10, 25, 1000); - VARP(maxbarreldebris, 5, 10, 1000); ICOMMAND(getweapon, "", (), intret(player1->gunselect)); @@ -135,7 +133,7 @@ namespace game loopi(guns[gun].rays) offsetray(from, to, guns[gun].spread, guns[gun].range, rays[i]); } - enum { BNC_GRENADE, BNC_GIBS, BNC_DEBRIS, BNC_BARRELDEBRIS }; + enum { BNC_GRENADE, BNC_GIBS, BNC_DEBRIS }; struct bouncer : physent { @@ -171,7 +169,7 @@ namespace game if(bouncetype == BNC_GRENADE && offsetmillis > 0 && offset.z < 0) offsetheight = raycube(vec(o.x + offset.x, o.y + offset.y, o.z), vec(0, 0, -1), -offset.z); else offsetheight = -1; - } + } }; vector bouncers; @@ -195,7 +193,7 @@ namespace game switch(type) { case BNC_GRENADE: bnc.collidetype = COLLIDE_ELLIPSE_PRECISE; break; - case BNC_DEBRIS: case BNC_BARRELDEBRIS: bnc.variant = rnd(4); break; + case BNC_DEBRIS: bnc.variant = rnd(4); break; case BNC_GIBS: bnc.variant = rnd(3); break; } @@ -227,7 +225,7 @@ namespace game b->bounces++; adddecal(DECAL_BLOOD, vec(b->o).sub(vec(surface).mul(b->radius)), surface, 2.96f/b->bounces, bvec(0x60, 0xFF, 0xFF), rnd(4)); } - + void updatebouncers(int time) { loopv(bouncers) @@ -358,12 +356,6 @@ namespace game lasthit = lastmillis; } - if(d->type==ENT_INANIMATE) - { - hitmovable(damage, (movable *)d, at, vel, gun); - return; - } - fpsent *f = (fpsent *)d; f->lastpain = lastmillis; @@ -371,8 +363,7 @@ namespace game if(f->type==ENT_AI || !m_mp(gamemode) || f==at) f->hitpush(damage, vel, at, gun); - if(f->type==ENT_AI) hitmonster(damage, (monster *)f, at, vel, gun); - else if(!m_mp(gamemode)) damaged(damage, f, at); + if(!m_mp(gamemode)) damaged(damage, f, at); else { hitmsg &h = hits.add(); @@ -435,7 +426,7 @@ namespace game if(gun==GUN_RL) adddynlight(v, 1.15f*guns[gun].exprad, vec(2, 1.5f, 1), 700, 100, 0, guns[gun].exprad/2, vec(1, 0.75f, 0.5f)); else if(gun==GUN_GL) adddynlight(v, 1.15f*guns[gun].exprad, vec(0.5f, 1.5f, 2), 600, 100, 0, 8, vec(0.25f, 1, 1)); else adddynlight(v, 1.15f*guns[gun].exprad, vec(2, 1.5f, 1), 700, 100); - int numdebris = gun==GUN_BARREL ? rnd(max(maxbarreldebris-5, 1))+5 : rnd(maxdebris-5)+5; + int numdebris = rnd(maxdebris-5)+5; vec debrisvel = vec(owner->o).sub(v).safenormalize(), debrisorigin(v); if(gun==GUN_RL) debrisorigin.add(vec(debrisvel).mul(8)); if(numdebris) @@ -443,7 +434,7 @@ namespace game entitylight light; lightreaching(debrisorigin, light.color, light.dir); loopi(numdebris) - spawnbouncer(debrisorigin, debrisvel, owner, gun==GUN_BARREL ? BNC_BARRELDEBRIS : BNC_DEBRIS, &light); + spawnbouncer(debrisorigin, debrisvel, owner, BNC_DEBRIS, &light); } if(!local) return; int numdyn = numdynents(); @@ -527,9 +518,8 @@ namespace game projectile &p = projs[i]; p.offsetmillis = max(p.offsetmillis-time, 0); int qdam = guns[p.gun].damage*(p.owner->quadmillis ? 4 : 1); - if(p.owner->type==ENT_AI) qdam /= MONSTERDAMAGEFACTOR; vec dv; - float dist = p.to.dist(p.o, dv); + float dist = p.to.dist(p.o, dv); dv.mul(time/max(dist*1000/p.speed, float(time))); vec v = vec(p.o).add(dv); bool exploded = false; @@ -560,17 +550,7 @@ namespace game { vec pos(v); pos.add(vec(p.offset).mul(p.offsetmillis/float(OFFSETMILLIS))); - if(guns[p.gun].part) - { - regular_particle_splash(PART_SMOKE, 2, 300, pos, 0x404040, 0.6f, 150, -20); - int color = 0xFFFFFF; - switch(guns[p.gun].part) - { - case PART_FIREBALL1: color = 0xFFC8C8; break; - } - particle_splash(guns[p.gun].part, 1, 1, pos, color, 4.8f, 150, 20); - } - else regular_particle_splash(PART_SMOKE, 2, 300, pos, 0x404040, 2.4f, 50, -20); + regular_particle_splash(PART_SMOKE, 2, 300, pos, 0x404040, 2.4f, 50, -20); } } if(exploded) @@ -628,11 +608,7 @@ namespace game case GUN_RL: if(muzzleflash && d->muzzle.x >= 0) particle_flare(d->muzzle, d->muzzle, 250, PART_MUZZLE_FLASH2, 0xFFFFFF, 3.0f, d); - case GUN_FIREBALL: - case GUN_ICEBALL: - case GUN_SLIMEBALL: pspeed = guns[gun].projspeed; - if(d->type==ENT_AI) pspeed /= 2; newprojectile(from, to, (float)pspeed, local, id, d, gun); break; @@ -739,14 +715,13 @@ namespace game { int qdam = guns[d->gunselect].damage; if(d->quadmillis) qdam *= 4; - if(d->type==ENT_AI) qdam /= MONSTERDAMAGEFACTOR; dynent *o; float dist; if(guns[d->gunselect].rays > 1) { dynent *hits[MAXRAYS]; int maxrays = guns[d->gunselect].rays; - loopi(maxrays) + loopi(maxrays) { if((hits[i] = intersectclosest(from, rays[i], d, dist))) shorten(from, rays[i], dist); else adddecal(DECAL_BULLET, rays[i], vec(from).sub(rays[i]).safenormalize(), 2.0f); @@ -769,7 +744,7 @@ namespace game shorten(from, to, dist); hitpush(qdam, o, d, from, to, d->gunselect, 1); } - else if(d->gunselect!=GUN_FIST && d->gunselect!=GUN_BITE) adddecal(DECAL_BULLET, to, vec(from).sub(to).safenormalize(), d->gunselect==GUN_RIFLE ? 3.0f : 2.0f); + else if(d->gunselect!=GUN_FIST) adddecal(DECAL_BULLET, to, vec(from).sub(to).safenormalize(), d->gunselect==GUN_RIFLE ? 3.0f : 2.0f); } void shoot(fpsent *d, const vec &targ) @@ -849,14 +824,12 @@ namespace game static const char * const projnames[2] = { "projectiles/grenade", "projectiles/rocket" }; static const char * const gibnames[3] = { "gibs/gib01", "gibs/gib02", "gibs/gib03" }; static const char * const debrisnames[4] = { "debris/debris01", "debris/debris02", "debris/debris03", "debris/debris04" }; - static const char * const barreldebrisnames[4] = { "barreldebris/debris01", "barreldebris/debris02", "barreldebris/debris03", "barreldebris/debris04" }; - + void preloadbouncers() { loopi(sizeof(projnames)/sizeof(projnames[0])) preloadmodel(projnames[i]); loopi(sizeof(gibnames)/sizeof(gibnames[0])) preloadmodel(gibnames[i]); loopi(sizeof(debrisnames)/sizeof(debrisnames[0])) preloadmodel(debrisnames[i]); - loopi(sizeof(barreldebrisnames)/sizeof(barreldebrisnames[0])) preloadmodel(barreldebrisnames[i]); } void renderbouncers() @@ -887,7 +860,6 @@ namespace game { case BNC_GIBS: mdl = gibnames[bnc.variant]; cull |= MDL_LIGHT|MDL_LIGHT_FAST|MDL_DYNSHADOW; break; case BNC_DEBRIS: mdl = debrisnames[bnc.variant]; break; - case BNC_BARRELDEBRIS: mdl = barreldebrisnames[bnc.variant]; break; default: continue; } rendermodel(&bnc.light, mdl, ANIM_MAPMODEL|ANIM_LOOP, pos, yaw, pitch, cull, NULL, NULL, 0, 0, fade); -- cgit v1.2.3