From 5a935f5c767deb9151a2e7b4f2bc190766190ab7 Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 10 Nov 2015 13:01:18 +1100 Subject: [PATCH] Nades: move definitions alongside nade mutator --- qcsrc/client/hud/hud.qc | 1 - qcsrc/client/hud/panel/ammo.qc | 36 +--- qcsrc/client/mutators/events.qh | 7 + qcsrc/client/progs.inc | 1 - qcsrc/client/view.qc | 17 +- qcsrc/client/weapons/projectile.qc | 33 +--- qcsrc/common/effects/all.inc | 48 ------ .../common/mutators/mutator/nades/effects.inc | 47 ++++++ .../common/mutators/mutator/nades/module.inc | 3 +- .../mutator/nades/nades.inc} | 4 + qcsrc/common/mutators/mutator/nades/nades.qc | 154 +++++++++++++----- .../mutator/nades/nades.qh} | 78 +++++---- .../all.qc => mutators/mutator/nades/net.qc} | 23 +-- qcsrc/server/mutators/all.qc | 1 - qcsrc/server/progs.inc | 1 - 15 files changed, 246 insertions(+), 208 deletions(-) create mode 100644 qcsrc/common/mutators/mutator/nades/effects.inc rename qcsrc/common/{nades/all.inc => mutators/mutator/nades/nades.inc} (96%) rename qcsrc/common/{nades/all.qh => mutators/mutator/nades/nades.qh} (60%) rename qcsrc/common/{nades/all.qc => mutators/mutator/nades/net.qc} (81%) diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index 1054e9bcb..0860183a2 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -10,7 +10,6 @@ #include "../common/items/all.qc" #include "../common/mapinfo.qh" #include "../common/mutators/mutator/waypoints/all.qh" -#include "../common/nades/all.qh" #include "../common/stats.qh" #include "../lib/csqcmodel/cl_player.qh" // TODO: remove diff --git a/qcsrc/client/hud/panel/ammo.qc b/qcsrc/client/hud/panel/ammo.qc index ac8fee0f1..236a58598 100644 --- a/qcsrc/client/hud/panel/ammo.qc +++ b/qcsrc/client/hud/panel/ammo.qc @@ -10,41 +10,7 @@ void DrawNadeProgressBar(vector myPos, vector mySize, float progress, vector col autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } -void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time) -{ - float bonusNades = getstatf(STAT_NADE_BONUS); - float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE); - float bonusType = getstati(STAT_NADE_BONUS_TYPE); - Nade def = Nades_from(bonusType); - vector nadeColor = def.m_color; - string nadeIcon = def.m_icon; - - vector iconPos, textPos; - - if(autocvar_hud_panel_ammo_iconalign) - { - iconPos = myPos + eX * 2 * mySize.y; - textPos = myPos; - } - else - { - iconPos = myPos; - textPos = myPos + eX * mySize.y; - } - - if(bonusNades > 0 || bonusProgress > 0) - { - DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor); - - if(autocvar_hud_panel_ammo_text) - drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - - if(draw_expanding) - drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time); - - drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - } -} +void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time); // TODO: mutator void DrawAmmoItem(vector myPos, vector mySize, .int ammoType, bool isCurrent, bool isInfinite) { diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index 92f455816..898d3b28a 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -112,4 +112,11 @@ MUTATOR_HOOKABLE(WantEventchase, EV_WantEventchase); MUTATOR_HOOKABLE(AnnouncerOption, EV_AnnouncerOption); MUTATOR_HOOKABLE(Ent_Init, EV_NO_ARGS); + +#define EV_HUD_Draw_overlay(i, o) \ + /**/ o(vector, MUTATOR_ARGV_0_vector) \ + /**/ o(float, MUTATOR_ARGV_0_float) \ + /**/ +MUTATOR_HOOKABLE(HUD_Draw_overlay, EV_HUD_Draw_overlay); + #endif diff --git a/qcsrc/client/progs.inc b/qcsrc/client/progs.inc index 4e127917a..e6fa30533 100644 --- a/qcsrc/client/progs.inc +++ b/qcsrc/client/progs.inc @@ -47,7 +47,6 @@ #include "../common/items/all.qc" #include "../common/monsters/all.qc" #include "../common/mutators/all.qc" -#include "../common/nades/all.qc" #include "../common/turrets/all.qc" #include "../common/vehicles/all.qc" #include "../common/weapons/all.qc" diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index c319dfcf0..699e2d8ad 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -13,7 +13,6 @@ #include "../common/debug.qh" #include "../common/mapinfo.qh" #include "../common/gamemodes/all.qh" -#include "../common/nades/all.qh" #include "../common/stats.qh" #include "../common/triggers/target/music.qh" #include "../common/teams.qh" @@ -1005,10 +1004,18 @@ void HUD_Crosshair() void HUD_Draw() { - if(getstati(STAT_FROZEN)) - drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, ((getstatf(STAT_REVIVE_PROGRESS)) ? ('0.25 0.90 1' + ('1 0 0' * getstatf(STAT_REVIVE_PROGRESS)) + ('0 1 1' * getstatf(STAT_REVIVE_PROGRESS) * -1)) : '0.25 0.90 1'), autocvar_hud_colorflash_alpha, DRAWFLAG_ADDITIVE); - else if (getstatf(STAT_HEALING_ORB)>time) - drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, NADE_TYPE_HEAL.m_color, autocvar_hud_colorflash_alpha*getstatf(STAT_HEALING_ORB_ALPHA), DRAWFLAG_ADDITIVE); + vector rgb = '0 0 0'; + float a = 1; + if (MUTATOR_CALLHOOK(HUD_Draw_overlay)) + { + rgb = MUTATOR_ARGV(0, vector); + a = MUTATOR_ARGV(0, float); + } + else if(getstati(STAT_FROZEN)) + { + rgb = ((getstatf(STAT_REVIVE_PROGRESS)) ? ('0.25 0.90 1' + ('1 0 0' * getstatf(STAT_REVIVE_PROGRESS)) + ('0 1 1' * getstatf(STAT_REVIVE_PROGRESS) * -1)) : '0.25 0.90 1'); + } + drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, rgb, autocvar_hud_colorflash_alpha * a, DRAWFLAG_ADDITIVE); if(!intermission) if(getstatf(STAT_NADE_TIMER) && autocvar_cl_nade_timer) // give nade top priority, as it's a matter of life and death { diff --git a/qcsrc/client/weapons/projectile.qc b/qcsrc/client/weapons/projectile.qc index 04a600cb6..9609760c4 100644 --- a/qcsrc/client/weapons/projectile.qc +++ b/qcsrc/client/weapons/projectile.qc @@ -7,7 +7,6 @@ #include "../../common/constants.qh" #include "../../common/movetypes/movetypes.qh" -#include "../../common/nades/all.qh" #include "../../lib/csqcmodel/interpolate.qh" @@ -49,6 +48,8 @@ void Projectile_DrawTrail(entity this, vector to) } } +bool Projectile_isnade(int proj); // TODO: remove + void Projectile_Draw(entity this) { vector rot; @@ -112,7 +113,7 @@ void Projectile_Draw(entity this) break; } - if (Nade_FromProjectile(self.cnt) != NADE_TYPE_Null) + if (Projectile_isnade(self.cnt)) rot = self.avelocity; self.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(self.angles), rot * (t - self.spawntime))); @@ -140,7 +141,7 @@ void Projectile_Draw(entity this) break; } - if (Nade_FromProjectile(self.cnt) != NADE_TYPE_Null) + if (Projectile_isnade(self.cnt)) trailorigin += v_up * 4; if (drawn) @@ -295,7 +296,6 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew) CASE(HOOKBOMB) self.traileffect = EFFECT_TR_KNIGHTSPIKE.m_id; break; CASE(HAGAR) self.traileffect = EFFECT_HAGAR_ROCKET.m_id; self.scale = 0.75; break; CASE(HAGAR_BOUNCING) self.traileffect = EFFECT_HAGAR_ROCKET.m_id; self.scale = 0.75; break; - CASE(NAPALM_FOUNTAIN) // fallthrough // sself.modelindex = 0; self.traileffect = _particleeffectnum("torch_small"); break; CASE(FIREBALL) self.modelindex = 0; self.traileffect = EFFECT_FIREBALL.m_id; break; // particle effect is good enough CASE(FIREMINE) self.modelindex = 0; self.traileffect = EFFECT_FIREMINE.m_id; break; // particle effect is good enough CASE(TAG) self.traileffect = EFFECT_TR_ROCKET.m_id; break; @@ -324,13 +324,6 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew) if (MUTATOR_CALLHOOK(Ent_Projectile, self)) break; - if (Nade_FromProjectile(self.cnt) != NADE_TYPE_Null) - { - setmodel(self, MDL_PROJECTILE_NADE); - entity trail = Nade_TrailEffect(self.cnt, self.team); - if (trail.eent_eff_name) self.traileffect = trail.m_id; - break; - } error("Received invalid CSQC projectile, can't work with this!"); break; } @@ -402,7 +395,6 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew) self.move_movetype = MOVETYPE_BOUNCE; self.move_touch = func_null; break; - case PROJECTILE_NAPALM_FOUNTAIN: case PROJECTILE_FIREBALL: loopsound(self, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM); self.mins = '-16 -16 -16'; @@ -460,23 +452,6 @@ NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew) break; } - if (Nade_FromProjectile(self.cnt) != NADE_TYPE_Null) - { - entity nade_type = Nade_FromProjectile(self.cnt); - self.mins = '-16 -16 -16'; - self.maxs = '16 16 16'; - self.colormod = nade_type.m_color; - self.move_movetype = MOVETYPE_BOUNCE; - self.move_touch = func_null; - self.scale = 1.5; - self.avelocity = randomvec() * 720; - - if (nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN) - self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; - else - self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY; - } - MUTATOR_CALLHOOK(EditProjectile, self); setsize(self, self.mins, self.maxs); diff --git a/qcsrc/common/effects/all.inc b/qcsrc/common/effects/all.inc index 72d4565e4..b34180056 100644 --- a/qcsrc/common/effects/all.inc +++ b/qcsrc/common/effects/all.inc @@ -147,54 +147,6 @@ EFFECT(0, SPAWN_PINK, "spawn_event_pink") EFFECT(0, SPAWNPOINT_NEUTRAL, "spawn_point_neutral") EFFECT(0, SPAWN_NEUTRAL, "spawn_event_neutral") -EFFECT(0, NADE_EXPLODE_RED, "nade_red_explode") -EFFECT(0, NADE_EXPLODE_BLUE, "nade_blue_explode") -EFFECT(0, NADE_EXPLODE_YELLOW, "nade_yellow_explode") -EFFECT(0, NADE_EXPLODE_PINK, "nade_pink_explode") -EFFECT(0, NADE_EXPLODE_NEUTRAL, "nade_neutral_explode") -entity EFFECT_NADE_EXPLODE(int teamid) -{ - switch (teamid) { - case NUM_TEAM_1: return EFFECT_NADE_EXPLODE_RED; - case NUM_TEAM_2: return EFFECT_NADE_EXPLODE_BLUE; - case NUM_TEAM_3: return EFFECT_NADE_EXPLODE_YELLOW; - case NUM_TEAM_4: return EFFECT_NADE_EXPLODE_PINK; - default: return EFFECT_NADE_EXPLODE_NEUTRAL; - } -} - -EFFECT(1, NADE_TRAIL_RED, "nade_red") -EFFECT(1, NADE_TRAIL_BLUE, "nade_blue") -EFFECT(1, NADE_TRAIL_YELLOW, "nade_yellow") -EFFECT(1, NADE_TRAIL_PINK, "nade_pink") -EFFECT(1, NADE_TRAIL_NEUTRAL, "nade_neutral") -entity EFFECT_NADE_TRAIL(int teamid) -{ - switch (teamid) { - case NUM_TEAM_1: return EFFECT_NADE_TRAIL_RED; - case NUM_TEAM_2: return EFFECT_NADE_TRAIL_BLUE; - case NUM_TEAM_3: return EFFECT_NADE_TRAIL_YELLOW; - case NUM_TEAM_4: return EFFECT_NADE_TRAIL_PINK; - default: return EFFECT_NADE_TRAIL_NEUTRAL; - } -} - -EFFECT(1, NADE_TRAIL_BURN_RED, "nade_red_burn") -EFFECT(1, NADE_TRAIL_BURN_BLUE, "nade_blue_burn") -EFFECT(1, NADE_TRAIL_BURN_YELLOW, "nade_yellow_burn") -EFFECT(1, NADE_TRAIL_BURN_PINK, "nade_pink_burn") -EFFECT(1, NADE_TRAIL_BURN_NEUTRAL, "nade_neutral_burn") -entity EFFECT_NADE_TRAIL_BURN(int teamid) -{ - switch (teamid) { - case NUM_TEAM_1: return EFFECT_NADE_TRAIL_BURN_RED; - case NUM_TEAM_2: return EFFECT_NADE_TRAIL_BURN_BLUE; - case NUM_TEAM_3: return EFFECT_NADE_TRAIL_BURN_YELLOW; - case NUM_TEAM_4: return EFFECT_NADE_TRAIL_BURN_PINK; - default: return EFFECT_NADE_TRAIL_BURN_NEUTRAL; - } -} - EFFECT(0, ICEORGLASS, "iceorglass") EFFECT(0, ICEFIELD, "icefield") EFFECT(0, FIREFIELD, "firefield") diff --git a/qcsrc/common/mutators/mutator/nades/effects.inc b/qcsrc/common/mutators/mutator/nades/effects.inc new file mode 100644 index 000000000..cde0016f1 --- /dev/null +++ b/qcsrc/common/mutators/mutator/nades/effects.inc @@ -0,0 +1,47 @@ +EFFECT(0, NADE_EXPLODE_RED, "nade_red_explode") +EFFECT(0, NADE_EXPLODE_BLUE, "nade_blue_explode") +EFFECT(0, NADE_EXPLODE_YELLOW, "nade_yellow_explode") +EFFECT(0, NADE_EXPLODE_PINK, "nade_pink_explode") +EFFECT(0, NADE_EXPLODE_NEUTRAL, "nade_neutral_explode") +entity EFFECT_NADE_EXPLODE(int teamid) +{ + switch (teamid) { + case NUM_TEAM_1: return EFFECT_NADE_EXPLODE_RED; + case NUM_TEAM_2: return EFFECT_NADE_EXPLODE_BLUE; + case NUM_TEAM_3: return EFFECT_NADE_EXPLODE_YELLOW; + case NUM_TEAM_4: return EFFECT_NADE_EXPLODE_PINK; + default: return EFFECT_NADE_EXPLODE_NEUTRAL; + } +} + +EFFECT(1, NADE_TRAIL_RED, "nade_red") +EFFECT(1, NADE_TRAIL_BLUE, "nade_blue") +EFFECT(1, NADE_TRAIL_YELLOW, "nade_yellow") +EFFECT(1, NADE_TRAIL_PINK, "nade_pink") +EFFECT(1, NADE_TRAIL_NEUTRAL, "nade_neutral") +entity EFFECT_NADE_TRAIL(int teamid) +{ + switch (teamid) { + case NUM_TEAM_1: return EFFECT_NADE_TRAIL_RED; + case NUM_TEAM_2: return EFFECT_NADE_TRAIL_BLUE; + case NUM_TEAM_3: return EFFECT_NADE_TRAIL_YELLOW; + case NUM_TEAM_4: return EFFECT_NADE_TRAIL_PINK; + default: return EFFECT_NADE_TRAIL_NEUTRAL; + } +} + +EFFECT(1, NADE_TRAIL_BURN_RED, "nade_red_burn") +EFFECT(1, NADE_TRAIL_BURN_BLUE, "nade_blue_burn") +EFFECT(1, NADE_TRAIL_BURN_YELLOW, "nade_yellow_burn") +EFFECT(1, NADE_TRAIL_BURN_PINK, "nade_pink_burn") +EFFECT(1, NADE_TRAIL_BURN_NEUTRAL, "nade_neutral_burn") +entity EFFECT_NADE_TRAIL_BURN(int teamid) +{ + switch (teamid) { + case NUM_TEAM_1: return EFFECT_NADE_TRAIL_BURN_RED; + case NUM_TEAM_2: return EFFECT_NADE_TRAIL_BURN_BLUE; + case NUM_TEAM_3: return EFFECT_NADE_TRAIL_BURN_YELLOW; + case NUM_TEAM_4: return EFFECT_NADE_TRAIL_BURN_PINK; + default: return EFFECT_NADE_TRAIL_BURN_NEUTRAL; + } +} diff --git a/qcsrc/common/mutators/mutator/nades/module.inc b/qcsrc/common/mutators/mutator/nades/module.inc index b9c0eb308..e03900d6a 100644 --- a/qcsrc/common/mutators/mutator/nades/module.inc +++ b/qcsrc/common/mutators/mutator/nades/module.inc @@ -1,3 +1,4 @@ -#ifdef SVQC #include "nades.qc" +#ifndef MENUQC +#include "net.qc" #endif diff --git a/qcsrc/common/nades/all.inc b/qcsrc/common/mutators/mutator/nades/nades.inc similarity index 96% rename from qcsrc/common/nades/all.inc rename to qcsrc/common/mutators/mutator/nades/nades.inc index 90326ede1..6d16fd150 100644 --- a/qcsrc/common/nades/all.inc +++ b/qcsrc/common/mutators/mutator/nades/nades.inc @@ -1,7 +1,11 @@ +#ifndef MENUQC #define NADE_PROJECTILE(i, projectile, trail) do { \ this.m_projectile[i] = projectile; \ this.m_trail[i] = trail; \ } while (0) +#else +#define NADE_PROJECTILE(i, projectile, trail) +#endif REGISTER_NADE(NORMAL) { this.m_color = '1 1 1'; diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 556265f1f..8a061d20f 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -1,50 +1,123 @@ -#ifndef MUTATOR_NADES_H -#define MUTATOR_NADES_H +#include "nades.qh" -#ifdef SVQC -#include "../../../../server/mutators/mutator/gamemode_freezetag.qc" +#ifdef IMPLEMENTATION + +#ifndef MENUQC +entity Nade_TrailEffect(int proj, int nade_team) +{ + switch (proj) + { + case PROJECTILE_NADE: return EFFECT_NADE_TRAIL(nade_team); + case PROJECTILE_NADE_BURN: return EFFECT_NADE_TRAIL_BURN(nade_team); + } + + FOREACH(Nades, true, LAMBDA( + for (int j = 0; j < 2; j++) + { + if (it.m_projectile[j] == proj) + { + string trail = it.m_trail[j].eent_eff_name; + if (trail) return it.m_trail[j]; + break; + } + } + )); + + return EFFECT_Null; +} #endif -.entity nade; -.entity fake_nade; -.float nade_timer; -.float nade_refire; -.float bonus_nades; -.float nade_special_time; -.float bonus_nade_score; -.float nade_type; -.string pokenade_type; -.entity nade_damage_target; -.float cvar_cl_nade_type; -.string cvar_cl_pokenade_type; -.float toss_time; -.float stat_healing_orb; -.float stat_healing_orb_alpha; -.float nade_show_particles; - -// Remove nades that are being thrown -void nades_Clear(entity player); - -// Give a bonus grenade to a player -void(entity player, float score) nades_GiveBonus; - -/** - * called to adjust nade damage and force on hit - */ -#define EV_Nade_Damage(i, o) \ - /** weapon */ i(entity, MUTATOR_ARGV_0_entity) \ - /** force */ i(vector, MUTATOR_ARGV_0_vector) \ - /**/ o(vector, MUTATOR_ARGV_0_vector) \ - /** damage */ i(float, MUTATOR_ARGV_0_float) \ - /**/ o(float, MUTATOR_ARGV_0_float) \ - /**/ -MUTATOR_HOOKABLE(Nade_Damage, EV_Nade_Damage); +#ifdef CSQC +REGISTER_MUTATOR(cl_nades, true); +MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay) +{ + if (getstatf(STAT_HEALING_ORB) <= time) return false; + MUTATOR_ARGV(0, vector) = NADE_TYPE_HEAL.m_color; + MUTATOR_ARGV(0, float) = getstatf(STAT_HEALING_ORB_ALPHA); + return true; +} +MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile) +{ + if (self.cnt == PROJECTILE_NAPALM_FOUNTAIN) + { + self.modelindex = 0; + self.traileffect = EFFECT_FIREBALL.m_id; + } + if (Nade_FromProjectile(self.cnt) != NADE_TYPE_Null) + { + setmodel(self, MDL_PROJECTILE_NADE); + entity trail = Nade_TrailEffect(self.cnt, self.team); + if (trail.eent_eff_name) self.traileffect = trail.m_id; + return true; + } +} +MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile) +{ + if (self.cnt == PROJECTILE_NAPALM_FOUNTAIN) + { + loopsound(self, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM); + self.mins = '-16 -16 -16'; + self.maxs = '16 16 16'; + } + entity nade_type = Nade_FromProjectile(self.cnt); + if (nade_type == NADE_TYPE_Null) return; + self.mins = '-16 -16 -16'; + self.maxs = '16 16 16'; + self.colormod = nade_type.m_color; + self.move_movetype = MOVETYPE_BOUNCE; + self.move_touch = func_null; + self.scale = 1.5; + self.avelocity = randomvec() * 720; + + if (nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN) + self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; + else + self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY; +} +bool Projectile_isnade(int p) +{ + return Nade_FromProjectile(p) != NADE_TYPE_Null; +} +void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time) +{ + float bonusNades = getstatf(STAT_NADE_BONUS); + float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE); + float bonusType = getstati(STAT_NADE_BONUS_TYPE); + Nade def = Nades_from(bonusType); + vector nadeColor = def.m_color; + string nadeIcon = def.m_icon; + + vector iconPos, textPos; + + if(autocvar_hud_panel_ammo_iconalign) + { + iconPos = myPos + eX * 2 * mySize.y; + textPos = myPos; + } + else + { + iconPos = myPos; + textPos = myPos + eX * mySize.y; + } + + if(bonusNades > 0 || bonusProgress > 0) + { + DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor); + + if(autocvar_hud_panel_ammo_text) + drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + + if(draw_expanding) + drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time); + + drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + } +} #endif -#ifdef IMPLEMENTATION +#ifdef SVQC -#include "../../../nades/all.qh" #include "../../../gamemodes/all.qh" #include "../../../monsters/spawn.qh" #include "../../../monsters/sv_monsters.qh" @@ -1246,3 +1319,4 @@ MUTATOR_HOOKFUNCTION(nades, BuildMutatorsPrettyString) return false; } #endif +#endif diff --git a/qcsrc/common/nades/all.qh b/qcsrc/common/mutators/mutator/nades/nades.qh similarity index 60% rename from qcsrc/common/nades/all.qh rename to qcsrc/common/mutators/mutator/nades/nades.qh index 235dd97dd..a218b71a6 100644 --- a/qcsrc/common/nades/all.qh +++ b/qcsrc/common/mutators/mutator/nades/nades.qh @@ -1,10 +1,7 @@ #ifndef NADES_ALL_H #define NADES_ALL_H -#include "../teams.qh" - -.float healer_lifetime; -.float healer_radius; +#include "../../../teams.qh" // use slots 70-100 const int PROJECTILE_NADE = 71; @@ -42,11 +39,7 @@ ENDCLASS(Nade) REGISTER_NADE(Null); -#ifdef SVQC -bool healer_send(entity this, entity to, int sf); -#endif - -entity Nade_FromProjectile(float proj) +Nade Nade_FromProjectile(int proj) { FOREACH(Nades, true, LAMBDA( for (int j = 0; j < 2; j++) @@ -57,29 +50,54 @@ entity Nade_FromProjectile(float proj) return NADE_TYPE_Null; } -entity Nade_TrailEffect(int proj, int nade_team) -{ - switch (proj) - { - case PROJECTILE_NADE: return EFFECT_NADE_TRAIL(nade_team); - case PROJECTILE_NADE_BURN: return EFFECT_NADE_TRAIL_BURN(nade_team); - } +#ifndef MENUQC +#include "effects.inc" +#endif - FOREACH(Nades, true, LAMBDA( - for (int j = 0; j < 2; j++) - { - if (it.m_projectile[j] == proj) - { - string trail = it.m_trail[j].eent_eff_name; - if (trail) return it.m_trail[j]; - break; - } - } - )); +#include "nades.inc" - return EFFECT_Null; -} +.float healer_lifetime; +.float healer_radius; + +#ifdef SVQC + +.entity nade; +.entity fake_nade; +.float nade_timer; +.float nade_refire; +.float bonus_nades; +.float nade_special_time; +.float bonus_nade_score; +.float nade_type; +.string pokenade_type; +.entity nade_damage_target; +.float cvar_cl_nade_type; +.string cvar_cl_pokenade_type; +.float toss_time; +.float stat_healing_orb; +.float stat_healing_orb_alpha; +.float nade_show_particles; -#include "all.inc" +bool healer_send(entity this, entity to, int sf); + +// Remove nades that are being thrown +void nades_Clear(entity player); + +// Give a bonus grenade to a player +void(entity player, float score) nades_GiveBonus; + +/** + * called to adjust nade damage and force on hit + */ +#define EV_Nade_Damage(i, o) \ + /** weapon */ i(entity, MUTATOR_ARGV_0_entity) \ + /** force */ i(vector, MUTATOR_ARGV_0_vector) \ + /**/ o(vector, MUTATOR_ARGV_0_vector) \ + /** damage */ i(float, MUTATOR_ARGV_0_float) \ + /**/ o(float, MUTATOR_ARGV_0_float) \ + /**/ +MUTATOR_HOOKABLE(Nade_Damage, EV_Nade_Damage); + +#endif #endif diff --git a/qcsrc/common/nades/all.qc b/qcsrc/common/mutators/mutator/nades/net.qc similarity index 81% rename from qcsrc/common/nades/all.qc rename to qcsrc/common/mutators/mutator/nades/net.qc index 4ba13408a..072f5072f 100644 --- a/qcsrc/common/nades/all.qc +++ b/qcsrc/common/mutators/mutator/nades/net.qc @@ -1,18 +1,6 @@ -#include "all.qh" - -#if defined(CSQC) - #include "../../client/defs.qh" - #include "../buffs/all.qh" - #include "../movetypes/movetypes.qh" - #include "../../client/main.qh" - #include "../../lib/csqcmodel/cl_model.qh" -#elif defined(MENUQC) -#elif defined(SVQC) - #include "../constants.qh" - #include "../../server/constants.qh" - #include "../turrets/sv_turrets.qh" -#endif +#include "nades.qh" +#ifdef IMPLEMENTATION #ifdef CSQC .float ltime; @@ -48,9 +36,10 @@ void healer_setup(entity e) e.colormod = '1 0 0'; e.renderflags |= RF_ADDITIVE; } -#endif // CSQC +#endif REGISTER_NET_LINKED(Nade_Heal) + #ifdef CSQC NET_HANDLE(Nade_Heal, bool isNew) { @@ -90,4 +79,6 @@ bool healer_send(entity this, entity to, int sf) } return true; } -#endif // SVQC +#endif + +#endif diff --git a/qcsrc/server/mutators/all.qc b/qcsrc/server/mutators/all.qc index 542763fd2..f2d8a084c 100644 --- a/qcsrc/server/mutators/all.qc +++ b/qcsrc/server/mutators/all.qc @@ -9,7 +9,6 @@ #include "../../common/stats.qh" #include "../../common/teams.qh" #include "../../common/util.qh" - #include "../../common/nades/all.qh" #include "../../common/buffs/all.qh" #include "../../common/command/markup.qh" #include "../../common/command/rpn.qh" diff --git a/qcsrc/server/progs.inc b/qcsrc/server/progs.inc index 6ab895f21..e9dc04793 100644 --- a/qcsrc/server/progs.inc +++ b/qcsrc/server/progs.inc @@ -78,7 +78,6 @@ #include "../common/gamemodes/all.qc" #include "../common/items/all.qc" #include "../common/monsters/all.qc" -#include "../common/nades/all.qc" #include "../common/turrets/all.qc" #include "../common/vehicles/all.qc" #include "../common/weapons/all.qc" -- 2.39.2