X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fturrets%2Fcl_turrets.qc;h=84812fc4605cb2d34fb8497b975e1b9b7d6bafa3;hb=1a366da10ff6cc0740b9c7754cc0d8c0fac356a4;hp=a57719b82c070a14870f57fba365c55f7bebf6fa;hpb=e97de604c9a9a8e86f9aa5851a5c24ecff86cc35;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/turrets/cl_turrets.qc b/qcsrc/common/turrets/cl_turrets.qc index a57719b82..84812fc46 100644 --- a/qcsrc/common/turrets/cl_turrets.qc +++ b/qcsrc/common/turrets/cl_turrets.qc @@ -1,4 +1,5 @@ #include "cl_turrets.qh" + void turret_remove(entity this) { delete(this.tur_head); @@ -37,7 +38,7 @@ void turret_draw(entity this) this.tur_head.angles += dt * this.tur_head.avelocity; - if (this.health < 127) + if (GetResource(this, RES_HEALTH) < 127) { dt = random(); @@ -45,11 +46,11 @@ void turret_draw(entity this) te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16); } - if(this.health < 85) + if(GetResource(this, RES_HEALTH) < 85) if(dt < 0.01) pointparticles(EFFECT_SMOKE_LARGE, (this.origin + (randomvec() * 80)), '0 0 0', 1); - if(this.health < 32) + if(GetResource(this, RES_HEALTH) < 32) if(dt < 0.015) pointparticles(EFFECT_SMOKE_SMALL, (this.origin + (randomvec() * 80)), '0 0 0', 1); @@ -175,25 +176,37 @@ void turret_draw2d(entity this) t = t * (1 - (1 - waypointsprite_crosshairfadescale) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1))); } - o = drawspritearrow(o, M_PI, rgb, a, SPRITE_ARROW_SCALE * t); - o = drawsprite_TextOrIcon(true, o, M_PI, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt); - drawhealthbar( - o, - 0, - this.health / 255, - '0 0 0', - '0 0 0', - 0.5 * SPRITE_HEALTHBAR_WIDTH * t, - 0.5 * SPRITE_HEALTHBAR_HEIGHT * t, - SPRITE_HEALTHBAR_MARGIN * t + 0.5 * waypointsprite_fontsize, - SPRITE_HEALTHBAR_BORDER * t, - 0, - rgb, - a * SPRITE_HEALTHBAR_BORDERALPHA, - rgb, - a * SPRITE_HEALTHBAR_HEALTHALPHA, - DRAWFLAG_NORMAL - ); + bool draw_healthbar = ((this.helpme && time < this.helpme) || !autocvar_g_waypointsprite_turrets_onlyhurt || hud != HUD_NORMAL); + bool draw_text = autocvar_g_waypointsprite_turrets_text; + + if(draw_healthbar || draw_text) // make sure it's actually being drawn + { + o = drawspritearrow(o, M_PI, rgb, a, SPRITE_ARROW_SCALE * t); + } + if(draw_text) + { + o = drawsprite_TextOrIcon(true, o, M_PI, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt); + } + if(draw_healthbar) + { + drawhealthbar( + o, + 0, + GetResource(this, RES_HEALTH) / 255, + '0 0 0', + '0 0 0', + 0.5 * SPRITE_HEALTHBAR_WIDTH * t, + 0.5 * SPRITE_HEALTHBAR_HEIGHT * t, + SPRITE_HEALTHBAR_MARGIN * t + 0.5 * waypointsprite_fontsize, + SPRITE_HEALTHBAR_BORDER * t, + 0, + rgb, + a * SPRITE_HEALTHBAR_BORDERALPHA, + rgb, + a * SPRITE_HEALTHBAR_HEALTHALPHA, + DRAWFLAG_NORMAL + ); + } } void turret_construct(entity this, bool isnew) @@ -221,7 +234,7 @@ void turret_construct(entity this, bool isnew) set_movetype(this.tur_head, MOVETYPE_NOCLIP); set_movetype(this, MOVETYPE_NOCLIP); this.tur_head.angles = this.angles; - this.health = 255; + SetResourceExplicit(this, RES_HEALTH, 255); this.solid = SOLID_BBOX; this.tur_head.solid = SOLID_NOT; set_movetype(this, MOVETYPE_NOCLIP); @@ -361,13 +374,10 @@ NET_HANDLE(ENT_CLIENT_TURRET, bool isnew) { this.m_id = ReadByte(); - this.origin_x = ReadCoord(); - this.origin_y = ReadCoord(); - this.origin_z = ReadCoord(); + this.origin = ReadVector(); setorigin(this, this.origin); - this.angles_x = ReadAngle(); - this.angles_y = ReadAngle(); + this.angles = ReadAngleVector2D(); turret_construct(this, isnew); this.colormap = 1024; @@ -397,14 +407,10 @@ NET_HANDLE(ENT_CLIENT_TURRET, bool isnew) if(sf & TNSF_MOVE) { - this.origin_x = ReadShort(); - this.origin_y = ReadShort(); - this.origin_z = ReadShort(); + this.origin = ReadVector(); setorigin(this, this.origin); - this.velocity_x = ReadShort(); - this.velocity_y = ReadShort(); - this.velocity_z = ReadShort(); + this.velocity = ReadVector(); this.angles_y = ReadShort(); @@ -428,13 +434,15 @@ NET_HANDLE(ENT_CLIENT_TURRET, bool isnew) } _tmp = ReadByte(); - if(_tmp == 0 && this.health != 0) + float myhp = GetResource(this, RES_HEALTH); + if(_tmp == 0 && myhp != 0) turret_die(this); - else if(this.health && this.health != _tmp) + else if(myhp && myhp > _tmp) this.helpme = servertime + 10; + else if(myhp && myhp < _tmp) + this.helpme = 0; // we're being healed, don't spam help me waypoints - this.health = _tmp; + SetResourceExplicit(this, RES_HEALTH, _tmp); } - //this.enemy.health = this.health / 255; return true; }