From: Mario Date: Tue, 3 Jul 2018 03:16:23 +0000 (+0000) Subject: Merge branch 'martin-t/rpc-acc' into 'master' X-Git-Tag: xonotic-v0.8.5~1964 X-Git-Url: http://de.git.xonotic.org/?a=commitdiff_plain;h=070ebb9d95214bf817392d9286608c812a2a7bd9;hp=6c3c66fc33bdc66054660c4a038b183681157cd2;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'martin-t/rpc-acc' into 'master' Fix RPC accuracy See merge request xonotic/xonotic-data.pk3dir!535 --- diff --git a/qcsrc/common/mutators/mutator/overkill/okrpc.qc b/qcsrc/common/mutators/mutator/overkill/okrpc.qc index 37d82e22e..3174fa7ff 100644 --- a/qcsrc/common/mutators/mutator/overkill/okrpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/okrpc.qc @@ -2,12 +2,20 @@ #ifdef SVQC +.float m_chainsaw_damage; // accumulated damage of the missile as it passes trough enemies + void W_OverkillRocketPropelledChainsaw_Explode(entity this, entity directhitentity) { this.event_damage = func_null; this.takedamage = DAMAGE_NO; - RadiusDamage(this, this.realowner, WEP_CVAR_PRI(okrpc, damage), WEP_CVAR_PRI(okrpc, edgedamage), WEP_CVAR_PRI(okrpc, radius), NULL, NULL, WEP_CVAR_PRI(okrpc, force), this.projectiledeathtype, this.weaponentity_fld, directhitentity); + float explosion_damage = RadiusDamage(this, this.realowner, WEP_CVAR_PRI(okrpc, damage), WEP_CVAR_PRI(okrpc, edgedamage), WEP_CVAR_PRI(okrpc, radius), NULL, NULL, WEP_CVAR_PRI(okrpc, force), this.projectiledeathtype, this.weaponentity_fld, directhitentity); + if (explosion_damage > 0 && this.m_chainsaw_damage > 0) + { + // if chainsaw hit something, it removed fired damage (so that direct hit is 100%) + // now that we also damaged something by explosion we'd go over 100% so let's add the fired damage back + accuracy_add(this.realowner, DEATH_WEAPONOF(this.projectiledeathtype).m_id, WEP_CVAR(okrpc, damage), 0); + } delete(this); } @@ -53,8 +61,22 @@ void W_OverkillRocketPropelledChainsaw_Think(entity this) vector mydir = normalize(this.velocity); tracebox(this.origin, this.mins, this.maxs, this.origin + mydir * (2 * myspeed_accel), MOVE_NORMAL, this); - if(IS_PLAYER(trace_ent)) + if (IS_PLAYER(trace_ent)) + { + if (accuracy_isgooddamage(this.realowner, trace_ent)) + { + if (this.m_chainsaw_damage == 0) // first hit + { + // The fired damage of the explosion is already counted in the statistics (when launching the chainsaw). + // We remove it here so that a direct hit that passes through and doesn't damage anything by the explosion later is still 100%. + float fired_damage = WEP_CVAR_PRI(okrpc, damage2) - WEP_CVAR_PRI(okrpc, damage); + float hit_damage = WEP_CVAR_PRI(okrpc, damage2); + accuracy_add(this.realowner, DEATH_WEAPONOF(this.projectiledeathtype).m_id, fired_damage, hit_damage); + } + this.m_chainsaw_damage += WEP_CVAR_PRI(okrpc, damage2); + } Damage(trace_ent, this, this.realowner, WEP_CVAR_PRI(okrpc, damage2), this.projectiledeathtype, this.weaponentity_fld, this.origin, normalize(this.origin - trace_ent.origin) * WEP_CVAR_PRI(okrpc, force)); + } this.velocity = mydir * (myspeed + (WEP_CVAR_PRI(okrpc, speedaccel) * sys_frametime)); @@ -106,6 +128,7 @@ void W_OverkillRocketPropelledChainsaw_Attack (Weapon thiswep, entity actor, .en SUB_SetFade (flash, time, 0.1); flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; W_AttachToShotorg(actor, weaponentity, flash, '5 0 0'); + missile.m_chainsaw_damage = 0; MUTATOR_CALLHOOK(EditProjectile, actor, missile); } diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 38284c30d..a25ae5bec 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -35,7 +35,7 @@ void UpdateFrags(entity player, int f) GameRules_scoring_add_team(player, SCORE, f); } -void GiveFrags (entity attacker, entity targ, float f, int deathtype, .entity weaponentity) +void GiveFrags(entity attacker, entity targ, float f, int deathtype, .entity weaponentity) { // TODO route through PlayerScores instead if(game_stopped) return; @@ -566,7 +566,7 @@ void Unfreeze(entity targ) MUTATOR_CALLHOOK(Unfreeze, targ); } -void Damage (entity targ, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) +void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { float complainteamdamage = 0; float mirrordamage = 0; @@ -1040,9 +1040,9 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in } if(targ == directhitentity || DEATH_ISSPECIAL(deathtype)) - Damage (targ, inflictor, attacker, finaldmg, deathtype, weaponentity, nearest, force); + Damage(targ, inflictor, attacker, finaldmg, deathtype, weaponentity, nearest, force); else - Damage (targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, weaponentity, nearest, force); + Damage(targ, inflictor, attacker, finaldmg, deathtype | HITTYPE_SPLASH, weaponentity, nearest, force); } } } @@ -1058,9 +1058,9 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in return total_damage_to_creatures; } -float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float forceintensity, int deathtype, .entity weaponentity, entity directhitentity) +float RadiusDamage(entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float forceintensity, int deathtype, .entity weaponentity, entity directhitentity) { - return RadiusDamageForSource (inflictor, (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5), inflictor.velocity, attacker, coredamage, edgedamage, rad, cantbe, mustbe, false, forceintensity, deathtype, weaponentity, directhitentity); + return RadiusDamageForSource(inflictor, (inflictor.origin + (inflictor.mins + inflictor.maxs) * 0.5), inflictor.velocity, attacker, coredamage, edgedamage, rad, cantbe, mustbe, false, forceintensity, deathtype, weaponentity, directhitentity); } bool Heal(entity targ, entity inflictor, float amount, float limit) diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index ddf1ff262..b023180a1 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -138,7 +138,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vect ent.punchangle_x = recoil * -1; if (snd != SND_Null) { - sound (ent, chan, snd, (W_DualWielding(ent) ? VOL_BASE * 0.7 : VOL_BASE), ATTN_NORM); + sound(ent, chan, snd, (W_DualWielding(ent) ? VOL_BASE * 0.7 : VOL_BASE), ATTN_NORM); W_PlayStrengthSound(ent); }