From 2c3033450c21ac40dfb7e7c27ba0f872b1a54d3b Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 2 Jun 2020 08:01:52 +1000 Subject: [PATCH] Restore preliminary support for headshots to the rifle --- bal-wep-mario.cfg | 2 ++ bal-wep-nexuiz25.cfg | 2 ++ bal-wep-samual.cfg | 2 ++ bal-wep-xdf.cfg | 2 ++ bal-wep-xonotic.cfg | 2 ++ .../common/mutators/mutator/overkill/okhmg.qc | 2 +- .../mutators/mutator/overkill/okmachinegun.qc | 2 +- .../turrets/turret/machinegun_weapon.qc | 2 +- qcsrc/common/turrets/turret/walker_weapon.qc | 2 +- qcsrc/common/vehicles/vehicle/spiderbot.qc | 2 +- qcsrc/common/weapons/weapon/machinegun.qc | 8 +++---- qcsrc/common/weapons/weapon/rifle.qc | 8 +++---- qcsrc/common/weapons/weapon/rifle.qh | 1 + qcsrc/common/weapons/weapon/shotgun.qc | 2 +- qcsrc/server/weapons/tracing.qc | 22 ++++++++++++++++--- qcsrc/server/weapons/tracing.qh | 4 ++-- 16 files changed, 46 insertions(+), 19 deletions(-) diff --git a/bal-wep-mario.cfg b/bal-wep-mario.cfg index 5cfa34882..52dfc5f12 100644 --- a/bal-wep-mario.cfg +++ b/bal-wep-mario.cfg @@ -557,6 +557,7 @@ set g_balance_rifle_primary_bullethail 0 set g_balance_rifle_primary_burstcost 0 set g_balance_rifle_primary_damage 80 set g_balance_rifle_primary_force 100 +set g_balance_rifle_primary_headshot_multiplier 0 set g_balance_rifle_primary_refire 1.2 set g_balance_rifle_primary_shots 1 set g_balance_rifle_primary_solidpenetration 62.2 @@ -571,6 +572,7 @@ set g_balance_rifle_secondary_bullethail 0 set g_balance_rifle_secondary_burstcost 0 set g_balance_rifle_secondary_damage 20 set g_balance_rifle_secondary_force 50 +set g_balance_rifle_secondary_headshot_multiplier 0 set g_balance_rifle_secondary_refire 0.9 set g_balance_rifle_secondary_reload 0 set g_balance_rifle_secondary_shots 4 diff --git a/bal-wep-nexuiz25.cfg b/bal-wep-nexuiz25.cfg index f9659814b..7bc8de485 100644 --- a/bal-wep-nexuiz25.cfg +++ b/bal-wep-nexuiz25.cfg @@ -557,6 +557,7 @@ set g_balance_rifle_primary_bullethail 0 set g_balance_rifle_primary_burstcost 0 set g_balance_rifle_primary_damage 80 set g_balance_rifle_primary_force 100 +set g_balance_rifle_primary_headshot_multiplier 1.25 set g_balance_rifle_primary_refire 1.2 set g_balance_rifle_primary_shots 1 set g_balance_rifle_primary_solidpenetration 62.2 @@ -571,6 +572,7 @@ set g_balance_rifle_secondary_bullethail 0 set g_balance_rifle_secondary_burstcost 0 set g_balance_rifle_secondary_damage 20 set g_balance_rifle_secondary_force 50 +set g_balance_rifle_secondary_headshot_multiplier 0.1875 set g_balance_rifle_secondary_refire 0.9 set g_balance_rifle_secondary_reload 0 set g_balance_rifle_secondary_shots 4 diff --git a/bal-wep-samual.cfg b/bal-wep-samual.cfg index 6896f5f5e..a89f48021 100644 --- a/bal-wep-samual.cfg +++ b/bal-wep-samual.cfg @@ -557,6 +557,7 @@ set g_balance_rifle_primary_bullethail 0 set g_balance_rifle_primary_burstcost 0 set g_balance_rifle_primary_damage 80 set g_balance_rifle_primary_force 100 +set g_balance_rifle_primary_headshot_multiplier 0 set g_balance_rifle_primary_refire 1.2 set g_balance_rifle_primary_shots 1 set g_balance_rifle_primary_solidpenetration 62.2 @@ -570,6 +571,7 @@ set g_balance_rifle_secondary_animtime 0.3 set g_balance_rifle_secondary_bullethail 0 set g_balance_rifle_secondary_burstcost 0 set g_balance_rifle_secondary_damage 20 +set g_balance_rifle_secondary_headshot_multiplier 0 set g_balance_rifle_secondary_force 50 set g_balance_rifle_secondary_refire 0.9 set g_balance_rifle_secondary_reload 0 diff --git a/bal-wep-xdf.cfg b/bal-wep-xdf.cfg index ec8029c74..007a36cf5 100644 --- a/bal-wep-xdf.cfg +++ b/bal-wep-xdf.cfg @@ -557,6 +557,7 @@ set g_balance_rifle_primary_bullethail 0 set g_balance_rifle_primary_burstcost 0 set g_balance_rifle_primary_damage 80 set g_balance_rifle_primary_force 100 +set g_balance_rifle_primary_headshot_multiplier 0 set g_balance_rifle_primary_refire 1.2 set g_balance_rifle_primary_shots 1 set g_balance_rifle_primary_solidpenetration 62.2 @@ -571,6 +572,7 @@ set g_balance_rifle_secondary_bullethail 0 set g_balance_rifle_secondary_burstcost 0 set g_balance_rifle_secondary_damage 20 set g_balance_rifle_secondary_force 50 +set g_balance_rifle_secondary_headshot_multiplier 0 set g_balance_rifle_secondary_refire 0.9 set g_balance_rifle_secondary_reload 0 set g_balance_rifle_secondary_shots 4 diff --git a/bal-wep-xonotic.cfg b/bal-wep-xonotic.cfg index c38ea832f..2f7b598b7 100644 --- a/bal-wep-xonotic.cfg +++ b/bal-wep-xonotic.cfg @@ -557,6 +557,7 @@ set g_balance_rifle_primary_bullethail 0 set g_balance_rifle_primary_burstcost 0 set g_balance_rifle_primary_damage 80 set g_balance_rifle_primary_force 100 +set g_balance_rifle_primary_headshot_multiplier 0 set g_balance_rifle_primary_refire 1.2 set g_balance_rifle_primary_shots 1 set g_balance_rifle_primary_solidpenetration 62.2 @@ -570,6 +571,7 @@ set g_balance_rifle_secondary_animtime 0.3 set g_balance_rifle_secondary_bullethail 0 set g_balance_rifle_secondary_burstcost 0 set g_balance_rifle_secondary_damage 20 +set g_balance_rifle_secondary_headshot_multiplier 0 set g_balance_rifle_secondary_force 50 set g_balance_rifle_secondary_refire 0.9 set g_balance_rifle_secondary_reload 0 diff --git a/qcsrc/common/mutators/mutator/overkill/okhmg.qc b/qcsrc/common/mutators/mutator/overkill/okhmg.qc index 68d69ab2f..8994dda66 100644 --- a/qcsrc/common/mutators/mutator/overkill/okhmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/okhmg.qc @@ -36,7 +36,7 @@ void W_OverkillHeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity } float okhmg_spread = bound(WEP_CVAR_PRI(okhmg, spread_min), WEP_CVAR_PRI(okhmg, spread_min) + (WEP_CVAR_PRI(okhmg, spread_add) * actor.(weaponentity).misc_bulletcounter), WEP_CVAR_PRI(okhmg, spread_max)); - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, okhmg_spread, WEP_CVAR_PRI(okhmg, solidpenetration), WEP_CVAR_PRI(okhmg, damage), WEP_CVAR_PRI(okhmg, force), WEP_OVERKILL_HMG.m_id, EFFECT_RIFLE); + fireBullet(actor, weaponentity, w_shotorg, w_shotdir, okhmg_spread, WEP_CVAR_PRI(okhmg, solidpenetration), WEP_CVAR_PRI(okhmg, damage), 0, WEP_CVAR_PRI(okhmg, force), WEP_OVERKILL_HMG.m_id, EFFECT_RIFLE); actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1; diff --git a/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc b/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc index 817e36981..698fb6f85 100644 --- a/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc +++ b/qcsrc/common/mutators/mutator/overkill/okmachinegun.qc @@ -30,7 +30,7 @@ void W_OverkillMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weap } okmachinegun_spread = bound(WEP_CVAR_PRI(okmachinegun, spread_min), WEP_CVAR_PRI(okmachinegun, spread_min) + (WEP_CVAR_PRI(okmachinegun, spread_add) * actor.(weaponentity).misc_bulletcounter), WEP_CVAR_PRI(okmachinegun, spread_max)); - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, okmachinegun_spread, WEP_CVAR_PRI(okmachinegun, solidpenetration), WEP_CVAR_PRI(okmachinegun, damage), WEP_CVAR_PRI(okmachinegun, force), WEP_OVERKILL_MACHINEGUN.m_id, EFFECT_RIFLE); + fireBullet(actor, weaponentity, w_shotorg, w_shotdir, okmachinegun_spread, WEP_CVAR_PRI(okmachinegun, solidpenetration), WEP_CVAR_PRI(okmachinegun, damage), 0, WEP_CVAR_PRI(okmachinegun, force), WEP_OVERKILL_MACHINEGUN.m_id, EFFECT_RIFLE); actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1; diff --git a/qcsrc/common/turrets/turret/machinegun_weapon.qc b/qcsrc/common/turrets/turret/machinegun_weapon.qc index a56e7de38..725a4fb66 100644 --- a/qcsrc/common/turrets/turret/machinegun_weapon.qc +++ b/qcsrc/common/turrets/turret/machinegun_weapon.qc @@ -17,7 +17,7 @@ METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, .ent actor.tur_head = actor; weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready); } - fireBullet(actor, weaponentity, actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, actor.shot_force, DEATH_TURRET_MACHINEGUN.m_id, EFFECT_BULLET); + fireBullet(actor, weaponentity, actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, 0, actor.shot_force, DEATH_TURRET_MACHINEGUN.m_id, EFFECT_BULLET); W_MachineGun_MuzzleFlash(actor, weaponentity); setattachment(actor.(weaponentity).muzzle_flash, actor.tur_head, "tag_fire"); } diff --git a/qcsrc/common/turrets/turret/walker_weapon.qc b/qcsrc/common/turrets/turret/walker_weapon.qc index bbe59aeac..c16d13014 100644 --- a/qcsrc/common/turrets/turret/walker_weapon.qc +++ b/qcsrc/common/turrets/turret/walker_weapon.qc @@ -16,7 +16,7 @@ METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } sound (actor, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM); - fireBullet(actor, weaponentity, actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, actor.shot_force, DEATH_TURRET_WALK_GUN.m_id, EFFECT_BULLET); + fireBullet(actor, weaponentity, actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, 0, actor.shot_force, DEATH_TURRET_WALK_GUN.m_id, EFFECT_BULLET); Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, actor.tur_shotorg, actor.tur_shotdir_updated * 1000, 1); } } diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qc b/qcsrc/common/vehicles/vehicle/spiderbot.qc index ca72ec1b2..e03122271 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qc @@ -266,7 +266,7 @@ bool spiderbot_frame(entity this, float dt) .entity weaponentity = weaponentities[0]; // TODO: unhardcode fireBullet(this, weaponentity, v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration, - autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN.m_id, EFFECT_BULLET); + autocvar_g_vehicle_spiderbot_minigun_damage, 0, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN.m_id, EFFECT_BULLET); sound (gun, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM); //trailparticles(this, _particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos); diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 86de79f60..9d5ed09ef 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -51,9 +51,9 @@ void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity we ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor); if(actor.(weaponentity).misc_bulletcounter == 1) - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, first_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, first_damage), WEP_CVAR(machinegun, first_force), deathtype, EFFECT_BULLET); + fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, first_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, first_damage), 0, WEP_CVAR(machinegun, first_force), deathtype, EFFECT_BULLET); else - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, sustained_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), deathtype, EFFECT_BULLET); + fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, sustained_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), 0, WEP_CVAR(machinegun, sustained_force), deathtype, EFFECT_BULLET); Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -127,7 +127,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity } machinegun_spread = bound(WEP_CVAR(machinegun, spread_min), WEP_CVAR(machinegun, spread_min) + (WEP_CVAR(machinegun, spread_add) * actor.(weaponentity).misc_bulletcounter), WEP_CVAR(machinegun, spread_max)); - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, machinegun_spread, WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), thiswep.m_id, EFFECT_BULLET); + fireBullet(actor, weaponentity, w_shotorg, w_shotdir, machinegun_spread, WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), 0, WEP_CVAR(machinegun, sustained_force), thiswep.m_id, EFFECT_BULLET); actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1; @@ -155,7 +155,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit actor.punchangle_y = random() - 0.5; } - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, burst_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), thiswep.m_id, EFFECT_BULLET); + fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, burst_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), 0, WEP_CVAR(machinegun, sustained_force), thiswep.m_id, EFFECT_BULLET); Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 7daf4ec40..57cb67e12 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -2,7 +2,7 @@ #ifdef SVQC -void W_Rifle_FireBullet(Weapon thiswep, .entity weaponentity, float pSpread, float pDamage, float pForce, float pSolidPenetration, float pAmmo, int deathtype, float pTracer, float pShots, Sound pSound, entity actor) +void W_Rifle_FireBullet(Weapon thiswep, .entity weaponentity, float pSpread, float pDamage, float pHeadshotDamage, float pForce, float pSolidPenetration, float pAmmo, int deathtype, float pTracer, float pShots, Sound pSound, entity actor) { float i; @@ -19,7 +19,7 @@ void W_Rifle_FireBullet(Weapon thiswep, .entity weaponentity, float pSpread, flo } for(i = 0; i < pShots; ++i) - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, pSpread, pSolidPenetration, pDamage, pForce, deathtype, (pTracer ? EFFECT_RIFLE : EFFECT_RIFLE_WEAK)); + fireBullet(actor, weaponentity, w_shotorg, w_shotdir, pSpread, pSolidPenetration, pDamage, pHeadshotDamage, pForce, deathtype, (pTracer ? EFFECT_RIFLE : EFFECT_RIFLE_WEAK)); if(autocvar_g_casings >= 2) { @@ -30,12 +30,12 @@ void W_Rifle_FireBullet(Weapon thiswep, .entity weaponentity, float pSpread, flo void W_Rifle_Attack(Weapon thiswep, entity actor, .entity weaponentity) { - W_Rifle_FireBullet(thiswep, weaponentity, WEP_CVAR_PRI(rifle, spread), WEP_CVAR_PRI(rifle, damage), WEP_CVAR_PRI(rifle, force), WEP_CVAR_PRI(rifle, solidpenetration), WEP_CVAR_PRI(rifle, ammo), thiswep.m_id, WEP_CVAR_PRI(rifle, tracer), WEP_CVAR_PRI(rifle, shots), SND_CAMPINGRIFLE_FIRE, actor); + W_Rifle_FireBullet(thiswep, weaponentity, WEP_CVAR_PRI(rifle, spread), WEP_CVAR_PRI(rifle, damage), WEP_CVAR_PRI(rifle, headshot_multiplier), WEP_CVAR_PRI(rifle, force), WEP_CVAR_PRI(rifle, solidpenetration), WEP_CVAR_PRI(rifle, ammo), thiswep.m_id, WEP_CVAR_PRI(rifle, tracer), WEP_CVAR_PRI(rifle, shots), SND_CAMPINGRIFLE_FIRE, actor); } void W_Rifle_Attack2(Weapon thiswep, entity actor, .entity weaponentity) { - W_Rifle_FireBullet(thiswep, weaponentity, WEP_CVAR_SEC(rifle, spread), WEP_CVAR_SEC(rifle, damage), WEP_CVAR_SEC(rifle, force), WEP_CVAR_SEC(rifle, solidpenetration), WEP_CVAR_SEC(rifle, ammo), thiswep.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(rifle, tracer), WEP_CVAR_SEC(rifle, shots), SND_CAMPINGRIFLE_FIRE2, actor); + W_Rifle_FireBullet(thiswep, weaponentity, WEP_CVAR_SEC(rifle, spread), WEP_CVAR_SEC(rifle, damage), WEP_CVAR_SEC(rifle, headshot_multiplier), WEP_CVAR_SEC(rifle, force), WEP_CVAR_SEC(rifle, solidpenetration), WEP_CVAR_SEC(rifle, ammo), thiswep.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(rifle, tracer), WEP_CVAR_SEC(rifle, shots), SND_CAMPINGRIFLE_FIRE2, actor); } .void(Weapon thiswep, entity actor, .entity weaponentity) rifle_bullethail_attackfunc; diff --git a/qcsrc/common/weapons/weapon/rifle.qh b/qcsrc/common/weapons/weapon/rifle.qh index ae9a3b9aa..3fbe1a287 100644 --- a/qcsrc/common/weapons/weapon/rifle.qh +++ b/qcsrc/common/weapons/weapon/rifle.qh @@ -27,6 +27,7 @@ CLASS(Rifle, Weapon) P(class, prefix, bursttime, float, NONE) \ P(class, prefix, damage, float, BOTH) \ P(class, prefix, force, float, BOTH) \ + P(class, prefix, headshot_multiplier, float, BOTH) \ P(class, prefix, refire, float, BOTH) \ P(class, prefix, reload, float, SEC) \ P(class, prefix, reload_ammo, float, NONE) \ diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index b8cae5fd5..6ffaf7965 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -26,7 +26,7 @@ void W_Shotgun_Attack(Weapon thiswep, entity actor, .entity weaponentity, float antilag_takeback_all(actor, lag); for(int sc = 0;sc < bullets;sc = sc + 1) - fireBullet_antilag(actor, weaponentity, w_shotorg, w_shotdir, spread, solidpenetration, damage, force, thiswep.m_id, bullet_trail_effect, false); + fireBullet_antilag(actor, weaponentity, w_shotorg, w_shotdir, spread, solidpenetration, damage, 0, force, thiswep.m_id, bullet_trail_effect, false); if(lag && bullets > 0) antilag_restore_all(actor); diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index 6209710b6..b1dbd5d59 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -211,6 +211,17 @@ void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float p // Ballistics Tracing // ==================== +bool Headshot(entity targ, entity ent, vector start, vector end) +{ + if(!IS_PLAYER(targ) || IS_DEAD(targ) || STAT(FROZEN, targ) || !targ.takedamage) + return false; + vector org = targ.origin; // antilag is already taken into consideration //antilag_takebackorigin(targ, CS(targ), time - ANTILAG_LATENCY(ent)); + vector headmins = org + '0.6 0 0' * targ.mins_x + '0 0.6 0' * targ.mins_y + '0 0 1' * (1.3 * targ.view_ofs_z - 0.3 * targ.maxs_z); + vector headmaxs = org + '0.6 0 0' * targ.maxs_x + '0 0.6 0' * targ.maxs_y + '0 0 1' * targ.maxs_z; + + return trace_hits_box(start, end, headmins, headmaxs); +} + void FireRailgunBullet (entity this, .entity weaponentity, vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype) { vector dir = normalize(end - start); @@ -330,7 +341,7 @@ void fireBullet_trace_callback(vector start, vector hit, vector end) fireBullet_last_hit = NULL; } -void fireBullet_antilag(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect, bool do_antilag) +void fireBullet_antilag(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float headshot_multiplier, float force, float dtype, entity tracer_effect, bool do_antilag) { dir = normalize(dir + randomvec() * spread); vector end = start + dir * max_shot_distance; @@ -400,6 +411,11 @@ void fireBullet_antilag(entity this, .entity weaponentity, vector start, vector yoda = 0; MUTATOR_CALLHOOK(FireBullet_Hit, this, hit, start, end, damage, this.(weaponentity)); damage = M_ARGV(4, float); + if(headshot_multiplier && Headshot(hit, this, start, end)) + { + damage *= headshot_multiplier; + // TODO: sound/announcement + } bool gooddamage = accuracy_isgooddamage(this, hit); Damage(hit, this, this, damage * damage_fraction, dtype, weaponentity, start, force * dir * damage_fraction); // calculate hits for ballistic weapons @@ -467,7 +483,7 @@ void fireBullet_antilag(entity this, .entity weaponentity, vector start, vector this.dphitcontentsmask = oldsolid; } -void fireBullet(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect) +void fireBullet(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float headshot_multiplier, float force, float dtype, entity tracer_effect) { - fireBullet_antilag(this, weaponentity, start, dir, spread, max_solid_penetration, damage, force, dtype, tracer_effect, true); + fireBullet_antilag(this, weaponentity, start, dir, spread, max_solid_penetration, damage, headshot_multiplier, force, dtype, tracer_effect, true); } diff --git a/qcsrc/server/weapons/tracing.qh b/qcsrc/server/weapons/tracing.qh index 94bd5b503..b622b25d9 100644 --- a/qcsrc/server/weapons/tracing.qh +++ b/qcsrc/server/weapons/tracing.qh @@ -69,5 +69,5 @@ void FireRailgunBullet (entity this, .entity weaponentity, vector start, vector entity fireBullet_trace_callback_eff; entity fireBullet_last_hit; void fireBullet_trace_callback(vector start, vector hit, vector end); -void fireBullet_antilag(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect, bool do_antilag); -void fireBullet(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect); +void fireBullet_antilag(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float headshot_multiplier, float force, float dtype, entity tracer_effect, bool do_antilag); +void fireBullet(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float headshot_multiplier, float force, float dtype, entity tracer_effect); -- 2.39.2