From: TimePath Date: Tue, 10 Nov 2015 02:01:18 +0000 (+1100) Subject: Nades: move definitions alongside nade mutator X-Git-Tag: xonotic-v0.8.2~1685 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5a935f5c767deb9151a2e7b4f2bc190766190ab7;p=xonotic%2Fxonotic-data.pk3dir.git Nades: move definitions alongside nade mutator --- 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/mutators/mutator/nades/nades.inc b/qcsrc/common/mutators/mutator/nades/nades.inc new file mode 100644 index 000000000..6d16fd150 --- /dev/null +++ b/qcsrc/common/mutators/mutator/nades/nades.inc @@ -0,0 +1,62 @@ +#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'; + NADE_PROJECTILE(0, PROJECTILE_NADE, EFFECT_Null); + NADE_PROJECTILE(1, PROJECTILE_NADE_BURN, EFFECT_Null); +} + +REGISTER_NADE(NAPALM) { + this.m_color = '2 0.5 0'; + this.m_name = _("Napalm grenade"); + this.m_icon = "nade_napalm"; + NADE_PROJECTILE(0, PROJECTILE_NADE_NAPALM, EFFECT_TR_ROCKET); + NADE_PROJECTILE(1, PROJECTILE_NADE_NAPALM_BURN, EFFECT_SPIDERBOT_ROCKET_TRAIL); +} + +REGISTER_NADE(ICE) { + this.m_color = '0 0.5 2'; + this.m_name = _("Ice grenade"); + this.m_icon = "nade_ice"; + NADE_PROJECTILE(0, PROJECTILE_NADE_ICE, EFFECT_TR_NEXUIZPLASMA); + NADE_PROJECTILE(1, PROJECTILE_NADE_ICE_BURN, EFFECT_RACER_ROCKET_TRAIL); +} + +REGISTER_NADE(TRANSLOCATE) { + this.m_color = '1 0 1'; + this.m_name = _("Translocate grenade"); + this.m_icon = "nade_translocate"; + NADE_PROJECTILE(0, PROJECTILE_NADE_TRANSLOCATE, EFFECT_TR_CRYLINKPLASMA); + NADE_PROJECTILE(1, PROJECTILE_NADE_TRANSLOCATE, EFFECT_TR_CRYLINKPLASMA); +} + +REGISTER_NADE(SPAWN) { + this.m_color = '1 0.9 0'; + this.m_name = _("Spawn grenade"); + this.m_icon = "nade_spawn"; + NADE_PROJECTILE(0, PROJECTILE_NADE_SPAWN, EFFECT_NADE_TRAIL_YELLOW); + NADE_PROJECTILE(1, PROJECTILE_NADE_SPAWN, EFFECT_NADE_TRAIL_YELLOW); +} + +REGISTER_NADE(HEAL) { + this.m_color = '1 0 0'; + this.m_name = _("Heal grenade"); + this.m_icon = "nade_heal"; + NADE_PROJECTILE(0, PROJECTILE_NADE_HEAL, EFFECT_NADE_TRAIL_RED); + NADE_PROJECTILE(1, PROJECTILE_NADE_HEAL_BURN, EFFECT_NADE_TRAIL_BURN_RED); +} + +REGISTER_NADE(MONSTER) { + this.m_color = '0.25 0.75 0'; + this.m_name = _("Monster grenade"); + this.m_icon = "nade_monster"; + NADE_PROJECTILE(0, PROJECTILE_NADE_MONSTER, EFFECT_NADE_TRAIL_RED); + NADE_PROJECTILE(1, PROJECTILE_NADE_MONSTER_BURN, EFFECT_NADE_TRAIL_BURN_RED); +} 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/mutators/mutator/nades/nades.qh b/qcsrc/common/mutators/mutator/nades/nades.qh new file mode 100644 index 000000000..a218b71a6 --- /dev/null +++ b/qcsrc/common/mutators/mutator/nades/nades.qh @@ -0,0 +1,103 @@ +#ifndef NADES_ALL_H +#define NADES_ALL_H + +#include "../../../teams.qh" + +// use slots 70-100 +const int PROJECTILE_NADE = 71; +const int PROJECTILE_NADE_BURN = 72; +const int PROJECTILE_NADE_NAPALM = 73; +const int PROJECTILE_NADE_NAPALM_BURN = 74; +const int PROJECTILE_NAPALM_FOUNTAIN = 75; +const int PROJECTILE_NADE_ICE = 76; +const int PROJECTILE_NADE_ICE_BURN = 77; +const int PROJECTILE_NADE_TRANSLOCATE = 78; +const int PROJECTILE_NADE_SPAWN = 79; +const int PROJECTILE_NADE_HEAL = 80; +const int PROJECTILE_NADE_HEAL_BURN = 81; +const int PROJECTILE_NADE_MONSTER = 82; +const int PROJECTILE_NADE_MONSTER_BURN = 83; + +REGISTRY(Nades, BITS(4)) +#define Nades_from(i) _Nades_from(i, NADE_TYPE_Null) +REGISTER_REGISTRY(RegisterNades) +REGISTRY_CHECK(Nades) + +#define REGISTER_NADE(id) REGISTER(RegisterNades, NADE_TYPE, Nades, id, m_id, NEW(Nade)) + +CLASS(Nade, Object) + ATTRIB(Nade, m_id, int, 0) + ATTRIB(Nade, m_color, vector, '0 0 0') + ATTRIB(Nade, m_name, string, _("Grenade")) + ATTRIB(Nade, m_icon, string, "nade_normal") + ATTRIBARRAY(Nade, m_projectile, int, 2) + ATTRIBARRAY(Nade, m_trail, entity, 2) + METHOD(Nade, display, void(entity this, void(string name, string icon) returns)) { + returns(this.m_name, sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon)); + } +ENDCLASS(Nade) + +REGISTER_NADE(Null); + +Nade Nade_FromProjectile(int proj) +{ + FOREACH(Nades, true, LAMBDA( + for (int j = 0; j < 2; j++) + { + if (it.m_projectile[j] == proj) return it; + } + )); + return NADE_TYPE_Null; +} + +#ifndef MENUQC +#include "effects.inc" +#endif + +#include "nades.inc" + +.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; + +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/mutators/mutator/nades/net.qc b/qcsrc/common/mutators/mutator/nades/net.qc new file mode 100644 index 000000000..072f5072f --- /dev/null +++ b/qcsrc/common/mutators/mutator/nades/net.qc @@ -0,0 +1,84 @@ +#include "nades.qh" + +#ifdef IMPLEMENTATION + +#ifdef CSQC +.float ltime; +void healer_draw(entity this) +{ + float dt = time - self.move_time; + self.move_time = time; + if(dt <= 0) + return; + + self.alpha = (self.ltime - time) / self.healer_lifetime; + self.scale = min((1 - self.alpha)*self.healer_lifetime*4,1)*self.healer_radius; +} + +void healer_setup(entity e) +{ + setmodel(e, MDL_NADE_HEAL); + + setorigin(e, e.origin); + + float model_radius = e.maxs.x; + vector size = '1 1 1' * e.healer_radius / 2; + setsize(e,-size,size); + e.healer_radius = e.healer_radius/model_radius*0.6; + + e.draw = healer_draw; + e.health = 255; + e.movetype = MOVETYPE_NONE; + e.solid = SOLID_NOT; + e.drawmask = MASK_NORMAL; + e.scale = 0.01; + e.avelocity = e.move_avelocity = '7 0 11'; + e.colormod = '1 0 0'; + e.renderflags |= RF_ADDITIVE; +} +#endif + +REGISTER_NET_LINKED(Nade_Heal) + +#ifdef CSQC +NET_HANDLE(Nade_Heal, bool isNew) +{ + Net_Accept(Nade_Heal); + int sf = ReadByte(); + if (sf & 1) { + this.origin_x = ReadCoord(); + this.origin_y = ReadCoord(); + this.origin_z = ReadCoord(); + setorigin(this, this.origin); + this.healer_lifetime = ReadByte(); + this.healer_radius = ReadShort(); + this.ltime = time + ReadByte()/10.0; + // this.ltime = time + this.healer_lifetime; + healer_setup(this); + } + return true; +} +#endif + +#ifdef SVQC +bool healer_send(entity this, entity to, int sf) +{ + int channel = MSG_ENTITY; + WriteHeader(channel, Nade_Heal); + WriteByte(channel, sf); + if (sf & 1) { + WriteCoord(channel, this.origin.x); + WriteCoord(channel, this.origin.y); + WriteCoord(channel, this.origin.z); + + WriteByte(channel, this.healer_lifetime); + //WriteByte(MSG_ENTITY, this.ltime - time + 1); + WriteShort(channel, this.healer_radius); + // round time delta to a 1/10th of a second + WriteByte(channel, (this.ltime - time)*10.0+0.5); + } + return true; +} +#endif + +#endif diff --git a/qcsrc/common/nades/all.inc b/qcsrc/common/nades/all.inc deleted file mode 100644 index 90326ede1..000000000 --- a/qcsrc/common/nades/all.inc +++ /dev/null @@ -1,58 +0,0 @@ -#define NADE_PROJECTILE(i, projectile, trail) do { \ - this.m_projectile[i] = projectile; \ - this.m_trail[i] = trail; \ -} while (0) - -REGISTER_NADE(NORMAL) { - this.m_color = '1 1 1'; - NADE_PROJECTILE(0, PROJECTILE_NADE, EFFECT_Null); - NADE_PROJECTILE(1, PROJECTILE_NADE_BURN, EFFECT_Null); -} - -REGISTER_NADE(NAPALM) { - this.m_color = '2 0.5 0'; - this.m_name = _("Napalm grenade"); - this.m_icon = "nade_napalm"; - NADE_PROJECTILE(0, PROJECTILE_NADE_NAPALM, EFFECT_TR_ROCKET); - NADE_PROJECTILE(1, PROJECTILE_NADE_NAPALM_BURN, EFFECT_SPIDERBOT_ROCKET_TRAIL); -} - -REGISTER_NADE(ICE) { - this.m_color = '0 0.5 2'; - this.m_name = _("Ice grenade"); - this.m_icon = "nade_ice"; - NADE_PROJECTILE(0, PROJECTILE_NADE_ICE, EFFECT_TR_NEXUIZPLASMA); - NADE_PROJECTILE(1, PROJECTILE_NADE_ICE_BURN, EFFECT_RACER_ROCKET_TRAIL); -} - -REGISTER_NADE(TRANSLOCATE) { - this.m_color = '1 0 1'; - this.m_name = _("Translocate grenade"); - this.m_icon = "nade_translocate"; - NADE_PROJECTILE(0, PROJECTILE_NADE_TRANSLOCATE, EFFECT_TR_CRYLINKPLASMA); - NADE_PROJECTILE(1, PROJECTILE_NADE_TRANSLOCATE, EFFECT_TR_CRYLINKPLASMA); -} - -REGISTER_NADE(SPAWN) { - this.m_color = '1 0.9 0'; - this.m_name = _("Spawn grenade"); - this.m_icon = "nade_spawn"; - NADE_PROJECTILE(0, PROJECTILE_NADE_SPAWN, EFFECT_NADE_TRAIL_YELLOW); - NADE_PROJECTILE(1, PROJECTILE_NADE_SPAWN, EFFECT_NADE_TRAIL_YELLOW); -} - -REGISTER_NADE(HEAL) { - this.m_color = '1 0 0'; - this.m_name = _("Heal grenade"); - this.m_icon = "nade_heal"; - NADE_PROJECTILE(0, PROJECTILE_NADE_HEAL, EFFECT_NADE_TRAIL_RED); - NADE_PROJECTILE(1, PROJECTILE_NADE_HEAL_BURN, EFFECT_NADE_TRAIL_BURN_RED); -} - -REGISTER_NADE(MONSTER) { - this.m_color = '0.25 0.75 0'; - this.m_name = _("Monster grenade"); - this.m_icon = "nade_monster"; - NADE_PROJECTILE(0, PROJECTILE_NADE_MONSTER, EFFECT_NADE_TRAIL_RED); - NADE_PROJECTILE(1, PROJECTILE_NADE_MONSTER_BURN, EFFECT_NADE_TRAIL_BURN_RED); -} diff --git a/qcsrc/common/nades/all.qc b/qcsrc/common/nades/all.qc deleted file mode 100644 index 4ba13408a..000000000 --- a/qcsrc/common/nades/all.qc +++ /dev/null @@ -1,93 +0,0 @@ -#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 - - -#ifdef CSQC -.float ltime; -void healer_draw(entity this) -{ - float dt = time - self.move_time; - self.move_time = time; - if(dt <= 0) - return; - - self.alpha = (self.ltime - time) / self.healer_lifetime; - self.scale = min((1 - self.alpha)*self.healer_lifetime*4,1)*self.healer_radius; -} - -void healer_setup(entity e) -{ - setmodel(e, MDL_NADE_HEAL); - - setorigin(e, e.origin); - - float model_radius = e.maxs.x; - vector size = '1 1 1' * e.healer_radius / 2; - setsize(e,-size,size); - e.healer_radius = e.healer_radius/model_radius*0.6; - - e.draw = healer_draw; - e.health = 255; - e.movetype = MOVETYPE_NONE; - e.solid = SOLID_NOT; - e.drawmask = MASK_NORMAL; - e.scale = 0.01; - e.avelocity = e.move_avelocity = '7 0 11'; - e.colormod = '1 0 0'; - e.renderflags |= RF_ADDITIVE; -} -#endif // CSQC - -REGISTER_NET_LINKED(Nade_Heal) -#ifdef CSQC -NET_HANDLE(Nade_Heal, bool isNew) -{ - Net_Accept(Nade_Heal); - int sf = ReadByte(); - if (sf & 1) { - this.origin_x = ReadCoord(); - this.origin_y = ReadCoord(); - this.origin_z = ReadCoord(); - setorigin(this, this.origin); - this.healer_lifetime = ReadByte(); - this.healer_radius = ReadShort(); - this.ltime = time + ReadByte()/10.0; - // this.ltime = time + this.healer_lifetime; - healer_setup(this); - } - return true; -} -#endif - -#ifdef SVQC -bool healer_send(entity this, entity to, int sf) -{ - int channel = MSG_ENTITY; - WriteHeader(channel, Nade_Heal); - WriteByte(channel, sf); - if (sf & 1) { - WriteCoord(channel, this.origin.x); - WriteCoord(channel, this.origin.y); - WriteCoord(channel, this.origin.z); - - WriteByte(channel, this.healer_lifetime); - //WriteByte(MSG_ENTITY, this.ltime - time + 1); - WriteShort(channel, this.healer_radius); - // round time delta to a 1/10th of a second - WriteByte(channel, (this.ltime - time)*10.0+0.5); - } - return true; -} -#endif // SVQC diff --git a/qcsrc/common/nades/all.qh b/qcsrc/common/nades/all.qh deleted file mode 100644 index 235dd97dd..000000000 --- a/qcsrc/common/nades/all.qh +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef NADES_ALL_H -#define NADES_ALL_H - -#include "../teams.qh" - -.float healer_lifetime; -.float healer_radius; - -// use slots 70-100 -const int PROJECTILE_NADE = 71; -const int PROJECTILE_NADE_BURN = 72; -const int PROJECTILE_NADE_NAPALM = 73; -const int PROJECTILE_NADE_NAPALM_BURN = 74; -const int PROJECTILE_NAPALM_FOUNTAIN = 75; -const int PROJECTILE_NADE_ICE = 76; -const int PROJECTILE_NADE_ICE_BURN = 77; -const int PROJECTILE_NADE_TRANSLOCATE = 78; -const int PROJECTILE_NADE_SPAWN = 79; -const int PROJECTILE_NADE_HEAL = 80; -const int PROJECTILE_NADE_HEAL_BURN = 81; -const int PROJECTILE_NADE_MONSTER = 82; -const int PROJECTILE_NADE_MONSTER_BURN = 83; - -REGISTRY(Nades, BITS(4)) -#define Nades_from(i) _Nades_from(i, NADE_TYPE_Null) -REGISTER_REGISTRY(RegisterNades) -REGISTRY_CHECK(Nades) - -#define REGISTER_NADE(id) REGISTER(RegisterNades, NADE_TYPE, Nades, id, m_id, NEW(Nade)) - -CLASS(Nade, Object) - ATTRIB(Nade, m_id, int, 0) - ATTRIB(Nade, m_color, vector, '0 0 0') - ATTRIB(Nade, m_name, string, _("Grenade")) - ATTRIB(Nade, m_icon, string, "nade_normal") - ATTRIBARRAY(Nade, m_projectile, int, 2) - ATTRIBARRAY(Nade, m_trail, entity, 2) - METHOD(Nade, display, void(entity this, void(string name, string icon) returns)) { - returns(this.m_name, sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon)); - } -ENDCLASS(Nade) - -REGISTER_NADE(Null); - -#ifdef SVQC -bool healer_send(entity this, entity to, int sf); -#endif - -entity Nade_FromProjectile(float proj) -{ - FOREACH(Nades, true, LAMBDA( - for (int j = 0; j < 2; j++) - { - if (it.m_projectile[j] == proj) return it; - } - )); - 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); - } - - 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; -} - -#include "all.inc" - -#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"