]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/func/breakable.qc
Merge branch 'master' into terencehill/hud_cleanups
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / breakable.qc
index 0430db2d4104e49901f32b80549e144f8fcba45c..4164f8341ac8feaa2969f18a879d635ae7433676 100644 (file)
@@ -1,12 +1,10 @@
 #ifdef SVQC
 
-#include "../../../server/_all.qh"
-
 #include "../../../server/g_subs.qh"
 #include "../../../server/g_damage.qh"
 #include "../../../server/bot/bot.qh"
 #include "../../../common/csqcmodel_settings.qh"
-#include "../../../csqcmodellib/sv_model.qh"
+#include "../../../lib/csqcmodel/sv_model.qh"
 #include "../../../server/weapons/common.qh"
 
 .entity sprite;
@@ -162,7 +160,7 @@ void func_breakable_behave_restore()
        self.nextthink = 0; // cancel auto respawn
        func_breakable_colormod();
        if (self.noise1)
-               sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
 }
 
 void func_breakable_init_for_player(entity player)
@@ -207,10 +205,10 @@ void func_breakable_destroy()
        func_breakable_destroyed();
 
        if(self.noise)
-               sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
+               _sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
 
        if(self.dmg)
-               RadiusDamage(self, activator, self.dmg, self.dmg_edge, self.dmg_radius, self, world, self.dmg_force, DEATH_HURTTRIGGER, world);
+               RadiusDamage(self, activator, self.dmg, self.dmg_edge, self.dmg_radius, self, world, self.dmg_force, DEATH_HURTTRIGGER.m_id, world);
 
        if(self.cnt) // TODO
                pointparticles(self.cnt, self.absmin * 0.5 + self.absmax * 0.5, '0 0 0', self.count);
@@ -249,7 +247,20 @@ void func_breakable_damage(entity inflictor, entity attacker, float damage, int
        if(self.health <= 0)
        {
                debrisforce = force;
-               W_PrepareExplosionByDamage(attacker, func_breakable_destroy);
+
+               self.takedamage = DAMAGE_NO;
+               self.event_damage = func_null;
+
+               if(IS_CLIENT(attacker) && self.classname == "func_assault_destructible")
+               {
+                       self.owner = attacker;
+                       self.realowner = attacker;
+               }
+
+               // do not explode NOW but in the NEXT FRAME!
+               // because recursive calls to RadiusDamage are not allowed
+               self.nextthink = time;
+               self.think = func_breakable_destroy;
        }
 }
 
@@ -266,8 +277,8 @@ void func_breakable_reset()
 }
 
 // destructible walls that can be used to trigger target_objective_decrease
-void spawnfunc_func_breakable()
-{SELFPARAM();
+spawnfunc(func_breakable)
+{
        float n, i;
        if(!self.health)
                self.health = 100;
@@ -335,7 +346,7 @@ void spawnfunc_func_breakable()
 }
 
 // for use in maps with a "model" key set
-void spawnfunc_misc_breakablemodel() {
-       spawnfunc_func_breakable();
+spawnfunc(misc_breakablemodel) {
+       spawnfunc_func_breakable(this);
 }
 #endif