#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>
//
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)
float h;
if (!(this.spawnflags & BREAKABLE_INDICATE_DAMAGE))
return;
- h = this.health / this.max_health;
+ h = GetResource(this, RES_HEALTH) / this.max_health;
if(h < 0.25)
this.colormod = '1 0 0';
else if(h <= 0.75)
void func_breakable_behave_destroyed(entity this)
{
- this.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);
void func_breakable_destroy(entity this, entity actor, entity trigger);
void func_breakable_behave_restore(entity this)
{
- this.health = this.max_health;
+ SetResourceExplicit(this, RES_HEALTH, this.max_health);
if(this.sprite)
{
WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health);
- WaypointSprite_UpdateHealth(this.sprite, this.health);
+ WaypointSprite_UpdateHealth(this.sprite, GetResource(this, RES_HEALTH));
}
if(!(this.spawnflags & BREAKABLE_NODAMAGE))
{
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);
}
}
if(attacker.team == this.team)
return;
this.pain_finished = time;
- this.health = this.health - damage;
+ TakeResource(this, RES_HEALTH, damage);
if(this.sprite)
{
WaypointSprite_Ping(this.sprite);
- WaypointSprite_UpdateHealth(this.sprite, this.health);
+ WaypointSprite_UpdateHealth(this.sprite, GetResource(this, RES_HEALTH));
}
func_breakable_colormod(this);
- if(this.health <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
{
debrisforce = force;
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(!this.health)
- this.health = 100;
- this.max_health = this.health;
+ if(!GetResource(this, RES_HEALTH))
+ 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
if(!this.debrismovetype) this.debrismovetype = MOVETYPE_BOUNCE;
this.dmg_force = 200;
this.mdl = this.model;
- SetBrushEntityModel(this);
+ SetBrushEntityModel(this, true);
if(this.spawnflags & BREAKABLE_NODAMAGE)
this.use = func_breakable_destroy;
this.takedamage = DAMAGE_NO;
this.event_damage = func_null;
this.bot_attack = false;
+ this.monster_attack = false;
}
// precache all the models
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;
}
// 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