From 1aa19d915356eb193c008173416b71c0553fe57f Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 25 May 2023 19:07:18 +0200 Subject: [PATCH] Crylink: delay link explosion a little to allow spikes to hit the enemy rather than exploding them immediately a little farther and deal less damage on direct hit --- qcsrc/common/weapons/weapon/crylink.qc | 35 ++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 6a69a7c57..9ae892b90 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -234,6 +234,23 @@ float W_Crylink_Touch_WouldHitFriendly(entity projectile, float rad) return (hit_enemy ? false : hit_friendly); } +.entity spike_toucher; +void W_Crylink_Explode_Think(entity this) +{ + float isprimary = !(this.projectiledeathtype & HITTYPE_SECONDARY); + float f = bound(0, 1 - (time - this.fade_time) * this.fade_rate, 1); + RadiusDamage(this, this.realowner, WEP_CVAR_BOTH(crylink, isprimary, damage) * f, WEP_CVAR_BOTH(crylink, isprimary, edgedamage) * f, WEP_CVAR_BOTH(crylink, isprimary, radius), + NULL, NULL, WEP_CVAR_BOTH(crylink, isprimary, force) * f, this.projectiledeathtype, this.weaponentity_fld, this.spike_toucher); + + .entity weaponentity = this.weaponentity_fld; + if(this == this.crylink_owner.(weaponentity).crylink_lastgroup) + this.crylink_owner.(weaponentity).crylink_lastgroup = NULL; + W_Crylink_LinkExplode(this.queuenext, this, this.spike_toucher); + this.classname = "spike_oktoremove"; + delete(this); + return; +} + // NO bounce protection, as bounces are limited! void W_Crylink_Touch(entity this, entity toucher) { @@ -258,11 +275,19 @@ void W_Crylink_Touch(entity this, entity toucher) if(totaldamage && ((WEP_CVAR_BOTH(crylink, isprimary, linkexplode) == 2) || ((WEP_CVAR_BOTH(crylink, isprimary, linkexplode) == 1) && !W_Crylink_Touch_WouldHitFriendly(this, WEP_CVAR_BOTH(crylink, isprimary, radius))))) { - .entity weaponentity = this.weaponentity_fld; - if(this == this.crylink_owner.(weaponentity).crylink_lastgroup) - this.crylink_owner.(weaponentity).crylink_lastgroup = NULL; - W_Crylink_LinkExplode(this.queuenext, this, toucher); - this.classname = "spike_oktoremove"; + entity it = this; + while ((it = it.queuenext) && it != this) + { + it.spike_toucher = toucher; + // delay link explosion a little because when one spike hit the enemy, other spikes + // may have their origin not updated yet and explode a little farther from enemy, + // especially with high speed, dealing less damage than expected on direct hit + setthink(it, W_Crylink_Explode_Think); + // NOTE: only one of the spikes not hitting the enemy will actually call + // W_Crylink_Explode_Think and remove recursively all spikes + it.nextthink = time + 0.05; + } + delete(this); return; } -- 2.39.2