From: Mario Date: Tue, 21 Jun 2022 02:17:28 +0000 (+1000) Subject: Move handling of the nade orb overlay to the client side, resolves the need to networ... X-Git-Tag: xonotic-v0.8.6~366^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6628d3f40d45228f59960fbaeed8dbbf64ff33bf;p=xonotic%2Fxonotic-data.pk3dir.git Move handling of the nade orb overlay to the client side, resolves the need to network orb states via stats --- diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 5ea4cb49c..749b77c7f 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -41,29 +41,6 @@ entity Nade_TrailEffect(int proj, int nade_team) #ifdef CSQC REGISTER_MUTATOR(cl_nades, true); -MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay) -{ - // TODO: make a common orb state! - if (STAT(HEALING_ORB) > time) - { - M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color; - M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA); - return true; - } - if (STAT(ENTRAP_ORB) > time) - { - M_ARGV(0, vector) = NADE_TYPE_ENTRAP.m_color; - M_ARGV(1, float) = STAT(ENTRAP_ORB_ALPHA); - return true; - } - if (STAT(VEIL_ORB) > time) - { - M_ARGV(0, vector) = NADE_TYPE_VEIL.m_color; - M_ARGV(1, float) = STAT(VEIL_ORB_ALPHA); - return true; - } - return false; -} MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile) { entity proj = M_ARGV(0, entity); @@ -604,12 +581,7 @@ void nade_entrap_touch(entity this, entity toucher) if ( IS_REAL_CLIENT(toucher) || (IS_VEHICLE(toucher) && toucher.owner) ) { entity show_tint = (IS_VEHICLE(toucher) && toucher.owner) ? toucher.owner : toucher; - STAT(ENTRAP_ORB, show_tint) = time + 0.1; - - float tint_alpha = 0.75; - if(SAME_TEAM(toucher, this.realowner)) - tint_alpha = 0.45; - STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime; + show_tint.nade_entrap_time = time + 0.1; } } @@ -656,13 +628,6 @@ void nade_heal_touch(entity this, entity toucher) } } - - if ( IS_REAL_CLIENT(toucher) || (IS_VEHICLE(toucher) && toucher.owner) ) - { - entity show_red = (IS_VEHICLE(toucher) && toucher.owner) ? toucher.owner : toucher; - STAT(HEALING_ORB, show_red) = time+0.1; - STAT(HEALING_ORB_ALPHA, show_red) = 0.75 * (this.ltime - time) / this.orb_lifetime; - } } void nade_heal_boom(entity this) @@ -694,14 +659,13 @@ void nade_veil_touch(entity this, entity toucher) if(SAME_TEAM(toucher, this.realowner)) { tint_alpha = 0.45; - if(!STAT(VEIL_ORB, show_tint)) + if(!show_tint.nade_veil_time) { toucher.nade_veil_prevalpha = toucher.alpha; toucher.alpha = -1; } } - STAT(VEIL_ORB, show_tint) = time + 0.1; - STAT(VEIL_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime; + show_tint.nade_veil_time = time + 0.1; } } @@ -1343,9 +1307,9 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0; } - if(STAT(VEIL_ORB, player) && STAT(VEIL_ORB, player) <= time) + if(player.nade_veil_time && player.nade_veil_time <= time) { - STAT(VEIL_ORB, player) = 0; + player.nade_veil_time = 0; if(player.vehicle) player.vehicle.alpha = player.vehicle.nade_veil_prevalpha; else @@ -1417,7 +1381,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPhysics_UpdateStats) entity player = M_ARGV(0, entity); // these automatically reset, no need to worry - if(STAT(ENTRAP_ORB, player) > time) + if(player.nade_entrap_time > time) STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_nades_entrap_speed; } @@ -1425,16 +1389,16 @@ MUTATOR_HOOKFUNCTION(nades, MonsterMove) { entity mon = M_ARGV(0, entity); - if (STAT(ENTRAP_ORB, mon) > time) + if (mon.nade_entrap_time > time) { M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed } - if (STAT(VEIL_ORB, mon) && STAT(VEIL_ORB, mon) <= time) + if (mon.nade_veil_time && mon.nade_veil_time <= time) { mon.alpha = mon.nade_veil_prevalpha; - STAT(VEIL_ORB, mon) = 0; + mon.nade_veil_time = 0; } } @@ -1567,12 +1531,6 @@ MUTATOR_HOOKFUNCTION(nades, SpectateCopy) client.pokenade_type = spectatee.pokenade_type; STAT(NADE_BONUS, client) = STAT(NADE_BONUS, spectatee); STAT(NADE_BONUS_SCORE, client) = STAT(NADE_BONUS_SCORE, spectatee); - STAT(HEALING_ORB, client) = STAT(HEALING_ORB, spectatee); - STAT(HEALING_ORB_ALPHA, client) = STAT(HEALING_ORB_ALPHA, spectatee); - STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee); - STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee); - STAT(VEIL_ORB, client) = STAT(VEIL_ORB, spectatee); - STAT(VEIL_ORB_ALPHA, client) = STAT(VEIL_ORB_ALPHA, spectatee); } MUTATOR_HOOKFUNCTION(nades, BuildMutatorsPrettyString) diff --git a/qcsrc/common/mutators/mutator/nades/nades.qh b/qcsrc/common/mutators/mutator/nades/nades.qh index 460c21571..a129c826a 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qh +++ b/qcsrc/common/mutators/mutator/nades/nades.qh @@ -144,7 +144,9 @@ REPLICATE_INIT(string, cvar_cl_pokenade_type); .entity nade_damage_target; .float toss_time; .float nade_show_particles; +.float nade_veil_time; .float nade_veil_prevalpha; +.float nade_entrap_time; bool orb_send(entity this, entity to, int sf); diff --git a/qcsrc/common/mutators/mutator/nades/net.qc b/qcsrc/common/mutators/mutator/nades/net.qc index 02c5df7a3..296e7d115 100644 --- a/qcsrc/common/mutators/mutator/nades/net.qc +++ b/qcsrc/common/mutators/mutator/nades/net.qc @@ -5,6 +5,8 @@ #include "nades.qh" #ifdef CSQC +#include + .float ltime; void orb_draw(entity this) { @@ -18,6 +20,20 @@ void orb_draw(entity this) this.angles = this.angles + dt * this.avelocity; } +float orb_drawtime; // global storage of last drawn orb frame, to counter overlapping orbs +void orb_draw2d(entity this) +{ + if(time <= orb_drawtime) + return; + + if(boxesoverlap(view_origin - '1 1 1', view_origin + '1 1 1', this.absmin, this.absmax)) + { + orb_drawtime = time; // prevent rendering more than one of these per frame! + float orb_alpha = 0.65 * (this.ltime - time) / this.orb_lifetime; + drawfill('0 0 0', vec2(vid_conwidth, vid_conheight), this.colormod, autocvar_hud_colorflash_alpha * orb_alpha, DRAWFLAG_ADDITIVE); + } +} + void orb_setup(entity e) { setmodel(e, MDL_NADE_ORB); @@ -31,7 +47,9 @@ void orb_setup(entity e) e.orb_radius = e.orb_radius/model_radius*0.6; e.draw = orb_draw; + e.draw2d = orb_draw2d; IL_PUSH(g_drawables, e); + IL_PUSH(g_drawables_2d, e); SetResourceExplicit(e, RES_HEALTH, 255); set_movetype(e, MOVETYPE_NONE); e.solid = SOLID_NOT; diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 128f090c4..812f3e92d 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -125,19 +125,13 @@ REGISTER_STAT(MONSTERS_KILLED, int) REGISTER_STAT(NADE_BONUS, float) REGISTER_STAT(NADE_BONUS_TYPE, int) REGISTER_STAT(NADE_BONUS_SCORE, float) -REGISTER_STAT(HEALING_ORB, float) -REGISTER_STAT(HEALING_ORB_ALPHA, float) REGISTER_STAT(PLASMA, int) REGISTER_STAT(FROZEN, int) REGISTER_STAT(REVIVE_PROGRESS, float) REGISTER_STAT(ROUNDLOST, int) REGISTER_STAT(CAPTURE_PROGRESS, float) -REGISTER_STAT(ENTRAP_ORB, float) -REGISTER_STAT(ENTRAP_ORB_ALPHA, float) REGISTER_STAT(ITEMSTIME, int, autocvar_sv_itemstime) REGISTER_STAT(KILL_TIME, float) -REGISTER_STAT(VEIL_ORB, float) -REGISTER_STAT(VEIL_ORB_ALPHA, float) #ifdef SVQC float autocvar_sv_showfps = 0;