From a3f0e2d068109a0fe84d3a037f6f07b065d3347c Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 18 Jul 2017 23:58:47 +1000 Subject: [PATCH] Port ballistics_density to PlayerState --- qcsrc/server/client.qc | 2 +- qcsrc/server/client.qh | 1 + qcsrc/server/player.qc | 3 +-- qcsrc/server/weapons/tracing.qc | 9 +++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 8f28e294d..804868fa0 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -578,7 +578,7 @@ void PutPlayerInServer(entity this) setthink(this, func_null); // players have no think function this.nextthink = 0; this.dmg_team = 0; - this.ballistics_density = autocvar_g_ballistics_density_player; + PS(this).ballistics_density = autocvar_g_ballistics_density_player; this.deadflag = DEAD_NO; diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index af4d3d693..3218b4449 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -153,6 +153,7 @@ CLASS(Player, Client) ATTRIB(Player, dual_weapons, vector, this.dual_weapons); // TODO: actually WepSet! ATTRIB(Player, itemkeys, int, this.itemkeys); + ATTRIB(Player, ballistics_density, float, this.ballistics_density); INIT(Player) { this.classname = STR_PLAYER; diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index c40f87de3..4e8663d24 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -97,7 +97,6 @@ void CopyBody(entity this, float keepvelocity) clone.move_qcphysics = false; // don't run gamecode logic on clones, too many set_movetype(clone, this.move_movetype); clone.solid = this.solid; - clone.ballistics_density = this.ballistics_density; clone.takedamage = this.takedamage; setcefc(clone, getcefc(this)); clone.uncustomizeentityforclient = this.uncustomizeentityforclient; @@ -610,7 +609,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, set_movetype(this, MOVETYPE_TOSS); // shootable corpse this.solid = SOLID_CORPSE; - this.ballistics_density = autocvar_g_ballistics_density_corpse; + PS(this).ballistics_density = autocvar_g_ballistics_density_corpse; // don't stick to the floor UNSET_ONGROUND(this); // dying animation diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index 4c6304a1b..475eb3d26 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -438,16 +438,17 @@ void fireBullet(entity this, .entity weaponentity, vector start, vector dir, flo break; float maxdist; + entity hitstore = IS_PLAYER(hit) ? PS(hit) : hit; if(max_solid_penetration < 0) break; - else if(hit.ballistics_density < -1) + else if(hitstore.ballistics_density < -1) break; // -2: no solid penetration, ever - else if(hit.ballistics_density < 0) + else if(hitstore.ballistics_density < 0) maxdist = vlen(hit.maxs - hit.mins) + 1; // -1: infinite travel distance - else if(hit.ballistics_density == 0) + else if(hitstore.ballistics_density == 0) maxdist = max_solid_penetration * solid_penetration_left; else - maxdist = max_solid_penetration * solid_penetration_left * hit.ballistics_density; + maxdist = max_solid_penetration * solid_penetration_left * hitstore.ballistics_density; if(maxdist <= autocvar_g_ballistics_mindistance) break; -- 2.39.2