X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmapobjects%2Ffunc%2Fbreakable.qc;h=6064603591492332ac4089011059b7e6f708bcbd;hb=2aba0552fdf2acdebd1ac96fa9ad218605b3742e;hp=d49f210784c589988e80700146bcfeb0f7735022;hpb=a3cf497caaf1b3e7e07d9d1e4051bf9ae2e55eca;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mapobjects/func/breakable.qc b/qcsrc/common/mapobjects/func/breakable.qc index d49f210784..6064603591 100644 --- a/qcsrc/common/mapobjects/func/breakable.qc +++ b/qcsrc/common/mapobjects/func/breakable.qc @@ -1,7 +1,7 @@ #include "breakable.qh" #ifdef SVQC -#include +#include #include #include #include @@ -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) @@ -83,7 +83,7 @@ void func_breakable_colormod(entity this) float h; if (!(this.spawnflags & BREAKABLE_INDICATE_DAMAGE)) return; - h = GetResourceAmount(this, RESOURCE_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) @@ -129,7 +129,7 @@ void func_breakable_look_restore(entity this) void func_breakable_behave_destroyed(entity this) { - SetResourceAmountExplicit(this, RESOURCE_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,11 +157,11 @@ void func_breakable_think(entity this) void func_breakable_destroy(entity this, entity actor, entity trigger); void func_breakable_behave_restore(entity this) { - SetResourceAmountExplicit(this, RESOURCE_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, GetResourceAmount(this, RESOURCE_HEALTH)); + WaypointSprite_UpdateHealth(this.sprite, GetResource(this, RES_HEALTH)); } if(!(this.spawnflags & BREAKABLE_NODAMAGE)) { @@ -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); } } @@ -272,15 +272,15 @@ void func_breakable_damage(entity this, entity inflictor, entity attacker, float if(attacker.team == this.team) return; this.pain_finished = time; - TakeResource(this, RESOURCE_HEALTH, damage); + TakeResource(this, RES_HEALTH, damage); if(this.sprite) { WaypointSprite_Ping(this.sprite); - WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RESOURCE_HEALTH)); + WaypointSprite_UpdateHealth(this.sprite, GetResource(this, RES_HEALTH)); } func_breakable_colormod(this); - if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0) + if(GetResource(this, RES_HEALTH) <= 0) { debrisforce = force; @@ -311,13 +311,12 @@ 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(!GetResourceAmount(this, RESOURCE_HEALTH)) - SetResourceAmountExplicit(this, RESOURCE_HEALTH, 100); - this.max_health = GetResourceAmount(this, RESOURCE_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; @@ -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; @@ -386,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