From 637cfe4d5f9a39b70b26d00fe6ae24cc68886ad4 Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Sat, 18 Mar 2017 08:53:46 +0000 Subject: [PATCH] Allow setting off triggers when a turret is destroyed --- qcsrc/common/turrets/sv_turrets.qc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index 99f9f8032..5604b2354 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -2,6 +2,12 @@ #ifdef SVQC #include +// Entity damaging the turrent when it reaches 0 health +.entity killer; + +// Target triggered when the turret is destoryed +.string target_death; + // Generic aiming vector turret_aim_generic(entity this) { @@ -190,6 +196,19 @@ void turret_die(entity this) //RadiusDamage (this,this, min(this.ammo,50),min(this.ammo,50) * 0.25,250,NULL,min(this.ammo,50)*5,DEATH_TURRET,NULL); Turret tur = get_turretinfo(this.m_id); + + // Trigger target_death + if ( this.target_death != "" ) + { + for(entity t = NULL; (t = find(t, targetname, this.target_death)); ) + { + if ( t.use ) + { + t.use(t, this.killer, this); + } + } + } + if(this.damage_flags & TFL_DMG_DEATH_NORESPAWN) { tur.tr_death(tur, this); @@ -246,6 +265,7 @@ void turret_damage(entity this, entity inflictor, entity attacker, float damage, this.tur_head.event_damage = func_null; this.takedamage = DAMAGE_NO; this.nextthink = time; + this.killer = attacker; setthink(this, turret_die); } @@ -302,7 +322,6 @@ void turrets_setframe(entity this, float _frame, float client_only) bool turret_send(entity this, entity to, float sf) { - WriteHeader(MSG_ENTITY, ENT_CLIENT_TURRET); WriteByte(MSG_ENTITY, sf); if(sf & TNSF_SETUP) -- 2.39.2