X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ffunc%2Fbreakable.qc;h=d09ccd5e00a8cede8584138723c607d37637ea9c;hb=960a31b121488256a7eebcd6a22d0157b88643a7;hp=dc2e6f7dc0a062a2a19e8c2a611ee12b8cb14ea2;hpb=5352a65c86ae185b0ff5c412d1eb1208912c17ab;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/func/breakable.qc b/qcsrc/common/triggers/func/breakable.qc index dc2e6f7dc..d09ccd5e0 100644 --- a/qcsrc/common/triggers/func/breakable.qc +++ b/qcsrc/common/triggers/func/breakable.qc @@ -34,15 +34,16 @@ // target = targets to trigger when broken // health = amount of damage it can take // spawnflags: -// 1 = start disabled (needs to be triggered to activate) -// 2 = indicate damage -// 4 = don't take direct damage (needs to be triggered to 'explode', then triggered again to restore) +// START_DISABLED: needs to be triggered to activate +// BREAKABLE_INDICATE_DAMAGE: indicate damage +// BREAKABLE_NODAMAGE: don't take direct damage (needs to be triggered to 'explode', then triggered again to restore) +// NOSPLASH: don't take splash damage // notes: // for mdl_dead to work, origin must be set (using a common/origin brush). // Otherwise mdl_dead will be displayed at the map origin, and nobody would // want that! -void func_breakable_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force); +void func_breakable_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force); // // func_breakable @@ -67,7 +68,8 @@ void LaunchDebris (entity this, string debrisname, vector force) dbr.velocity_x = this.debrisvelocity.x + this.debrisvelocityjitter.x * crandom(); dbr.velocity_y = this.debrisvelocity.y + this.debrisvelocityjitter.y * crandom(); dbr.velocity_z = this.debrisvelocity.z + this.debrisvelocityjitter.z * crandom(); - this.velocity = this.velocity + force * this.debrisdamageforcescale; + dbr.velocity = dbr.velocity + force * this.debrisdamageforcescale; + dbr.angles = this.angles; dbr.avelocity_x = random()*this.debrisavelocityjitter.x; dbr.avelocity_y = random()*this.debrisavelocityjitter.y; dbr.avelocity_z = random()*this.debrisavelocityjitter.z; @@ -80,7 +82,7 @@ void LaunchDebris (entity this, string debrisname, vector force) void func_breakable_colormod(entity this) { float h; - if (!(this.spawnflags & 2)) + if (!(this.spawnflags & BREAKABLE_INDICATE_DAMAGE)) return; h = this.health / this.max_health; if(h < 0.25) @@ -134,8 +136,8 @@ void func_breakable_behave_destroyed(entity this) IL_REMOVE(g_bot_targets, this); this.bot_attack = false; this.event_damage = func_null; - this.state = 1; - if(this.spawnflags & 4) + this.state = STATE_BROKEN; + if(this.spawnflags & BREAKABLE_NODAMAGE) this.use = func_null; func_breakable_colormod(this); if (this.noise1) @@ -157,7 +159,7 @@ void func_breakable_behave_restore(entity this) WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health); WaypointSprite_UpdateHealth(this.sprite, this.health); } - if(!(this.spawnflags & 4)) + if(!(this.spawnflags & BREAKABLE_NODAMAGE)) { this.takedamage = DAMAGE_AIM; if(!this.bot_attack) @@ -165,9 +167,9 @@ void func_breakable_behave_restore(entity this) this.bot_attack = true; this.event_damage = func_breakable_damage; } - if(this.spawnflags & 4) + if(this.spawnflags & BREAKABLE_NODAMAGE) this.use = func_breakable_destroy; // don't need to set it usually, as .use isn't reset - this.state = 0; + this.state = STATE_ALIVE; //this.nextthink = 0; // cancel auto respawn setthink(this, func_breakable_think); this.nextthink = time + 0.1; @@ -178,7 +180,7 @@ void func_breakable_behave_restore(entity this) void func_breakable_init_for_player(entity this, entity player) { - if (this.noise1 && this.state == 0 && clienttype(player) == CLIENTTYPE_REAL) + 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); @@ -222,7 +224,7 @@ void func_breakable_destroy(entity this, entity actor, entity trigger) _sound (this, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM); if(this.dmg) - RadiusDamage(this, act, this.dmg, this.dmg_edge, this.dmg_radius, this, NULL, this.dmg_force, DEATH_HURTTRIGGER.m_id, NULL); + RadiusDamage(this, act, this.dmg, this.dmg_edge, this.dmg_radius, this, NULL, this.dmg_force, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, NULL); if(this.cnt) // TODO __pointparticles(this.cnt, this.absmin * 0.5 + this.absmax * 0.5, '0 0 0', this.count); @@ -245,11 +247,11 @@ void func_breakable_destroy_self(entity this) func_breakable_destroy(this, NULL, NULL); } -void func_breakable_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +void func_breakable_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { - if(this.state == 1) + if(this.state == STATE_BROKEN) return; - if(this.spawnflags & DOOR_NOSPLASH) + if(this.spawnflags & NOSPLASH) if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH)) return; if(this.team) @@ -271,7 +273,7 @@ void func_breakable_damage(entity this, entity inflictor, entity attacker, float this.takedamage = DAMAGE_NO; this.event_damage = func_null; - if(IS_CLIENT(attacker) && this.classname == "func_assault_destructible") + if(IS_CLIENT(attacker)) //&& this.classname == "func_assault_destructible") { this.owner = attacker; this.realowner = attacker; @@ -289,7 +291,7 @@ void func_breakable_reset(entity this) { this.team = this.team_saved; func_breakable_look_restore(this); - if(this.spawnflags & 1) + if(this.spawnflags & START_DISABLED) func_breakable_behave_destroyed(this); else func_breakable_behave_restore(this); @@ -329,12 +331,12 @@ spawnfunc(func_breakable) this.mdl = this.model; SetBrushEntityModel(this); - if(this.spawnflags & 4) + if(this.spawnflags & BREAKABLE_NODAMAGE) this.use = func_breakable_destroy; else this.use = func_breakable_restore; - if(this.spawnflags & 4) + if(this.spawnflags & BREAKABLE_NODAMAGE) { this.takedamage = DAMAGE_NO; this.event_damage = func_null; @@ -353,6 +355,7 @@ spawnfunc(func_breakable) precache_sound(this.noise1); this.team_saved = this.team; + IL_PUSH(g_saved_team, this); this.dropped_origin = this.origin; this.reset = func_breakable_reset;