]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mapobjects/func/breakable.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapobjects / func / breakable.qc
index a1b8c76ba42c49e736f5e742cdb1a787c4fbc3ab..6064603591492332ac4089011059b7e6f708bcbd 100644 (file)
@@ -1,7 +1,7 @@
 #include "breakable.qh"
 #ifdef SVQC
 
-#include <server/g_damage.qh>
+#include <server/damage.qh>
 #include <server/bot/api.qh>
 #include <common/csqcmodel_settings.qh>
 #include <lib/csqcmodel/sv_model.qh>
@@ -50,7 +50,7 @@ void func_breakable_damage(entity this, entity inflictor, entity attacker, float
 //
 void LaunchDebris (entity this, string debrisname, vector force)
 {
-       entity dbr = spawn();
+       entity dbr = new(debris);
        vector org = this.absmin
                   + '1 0 0' * random() * (this.absmax.x - this.absmin.x)
                   + '0 1 0' * random() * (this.absmax.y - this.absmin.y)
@@ -129,7 +129,7 @@ void func_breakable_look_restore(entity this)
 
 void func_breakable_behave_destroyed(entity this)
 {
-       SetResource(this, RES_HEALTH, this.max_health);
+       SetResourceExplicit(this, RES_HEALTH, this.max_health);
        this.takedamage = DAMAGE_NO;
        if(this.bot_attack)
                IL_REMOVE(g_bot_targets, this);
@@ -157,7 +157,7 @@ void func_breakable_think(entity this)
 void func_breakable_destroy(entity this, entity actor, entity trigger);
 void func_breakable_behave_restore(entity this)
 {
-       SetResource(this, RES_HEALTH, this.max_health);
+       SetResourceExplicit(this, RES_HEALTH, this.max_health);
        if(this.sprite)
        {
                WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health);
@@ -187,7 +187,7 @@ void func_breakable_init_for_player(entity this, entity player)
        if (this.noise1 && this.state == STATE_ALIVE && IS_REAL_CLIENT(player))
        {
                msg_entity = player;
-               soundto (MSG_ONE, this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM);
+               soundto (MSG_ONE, this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM, 0);
        }
 }
 
@@ -311,12 +311,11 @@ void func_breakable_reset(entity this)
                func_breakable_behave_restore(this);
 }
 
-// destructible walls that can be used to trigger target_objective_decrease
-spawnfunc(func_breakable)
+void func_breakable_setup(entity this)
 {
        float n, i;
        if(!GetResource(this, RES_HEALTH))
-               SetResource(this, RES_HEALTH, 100);
+               SetResourceExplicit(this, RES_HEALTH, 100);
        this.max_health = GetResource(this, RES_HEALTH);
 
        // yes, I know, MOVETYPE_NONE is not available here, not that one would want it here anyway
@@ -343,7 +342,7 @@ spawnfunc(func_breakable)
                this.dmg_force = 200;
 
        this.mdl = this.model;
-       SetBrushEntityModel(this);
+       SetBrushEntityModel(this, true);
 
        if(this.spawnflags & BREAKABLE_NODAMAGE)
                this.use = func_breakable_destroy;
@@ -355,6 +354,7 @@ spawnfunc(func_breakable)
                this.takedamage = DAMAGE_NO;
                this.event_damage = func_null;
                this.bot_attack = false;
+               this.monster_attack = false;
        }
 
        // precache all the models
@@ -375,6 +375,9 @@ spawnfunc(func_breakable)
        this.reset = func_breakable_reset;
        this.reset(this);
 
+       if(this.monster_attack)
+               IL_PUSH(g_monster_targets, this);
+
        IL_PUSH(g_initforplayer, this);
        this.init_for_player = func_breakable_init_for_player;
 
@@ -382,7 +385,8 @@ spawnfunc(func_breakable)
 }
 
 // for use in maps with a "model" key set
-spawnfunc(misc_breakablemodel) {
-       spawnfunc_func_breakable(this);
-}
+spawnfunc(misc_breakablemodel) { func_breakable_setup(this); }
+
+// destructible walls that can be used to trigger target_objective_decrease
+spawnfunc(func_breakable) { func_breakable_setup(this); }
 #endif