From b974a7cdcce185eede9dcf22d2c95772cab31401 Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 6 Oct 2015 21:50:58 +1100 Subject: [PATCH] Nades: rename registry globals --- qcsrc/client/hud.qc | 6 +- qcsrc/client/main.qc | 2 +- qcsrc/client/progs.inc | 2 +- qcsrc/client/view.qc | 2 +- qcsrc/client/weapons/projectile.qc | 2 +- qcsrc/common/nades.qh | 142 ---------------------- qcsrc/common/nades/all.inc | 58 +++++++++ qcsrc/common/{nades.qc => nades/all.qc} | 22 ++-- qcsrc/common/nades/all.qh | 82 +++++++++++++ qcsrc/server/mutators/mutator_nades.qc | 22 ++-- qcsrc/server/mutators/mutators_include.qc | 2 +- qcsrc/server/progs.inc | 2 +- 12 files changed, 171 insertions(+), 173 deletions(-) delete mode 100644 qcsrc/common/nades.qh create mode 100644 qcsrc/common/nades/all.inc rename qcsrc/common/{nades.qc => nades/all.qc} (82%) create mode 100644 qcsrc/common/nades/all.qh diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 1636b11e7..eb577f46b 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -14,7 +14,7 @@ #include "../common/deathtypes.qh" #include "../common/items/all.qc" #include "../common/mapinfo.qh" -#include "../common/nades.qh" +#include "../common/nades/all.qh" #include "../server/mutators/gamemode_ctf.qh" @@ -858,8 +858,8 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan float bonusNades = getstatf(STAT_NADE_BONUS); float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE); float bonusType = getstati(STAT_NADE_BONUS_TYPE); - vector nadeColor = NADES[bonusType].m_color; - string nadeIcon = NADES[bonusType].m_icon; + vector nadeColor = Nades[bonusType].m_color; + string nadeIcon = Nades[bonusType].m_icon; vector iconPos, textPos; diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 5ed049c60..e3f07b275 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -30,7 +30,7 @@ #include "../common/effects/effects.qh" #include "../common/mapinfo.qh" #include "../common/monsters/all.qh" -#include "../common/nades.qh" +#include "../common/nades/all.qh" #include "../common/net_notice.qh" #include "../common/notifications.qh" #include "../common/stats.qh" diff --git a/qcsrc/client/progs.inc b/qcsrc/client/progs.inc index fb5853f07..ec5c31844 100644 --- a/qcsrc/client/progs.inc +++ b/qcsrc/client/progs.inc @@ -40,7 +40,6 @@ #include "../common/effects/effectinfo.qc" #include "../common/mapinfo.qc" #include "../common/movetypes/include.qc" -#include "../common/nades.qc" #include "../common/net_notice.qc" #include "../common/notifications.qc" #include "../common/physics.qc" @@ -56,6 +55,7 @@ #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 60fb4b0c5..9c20747fb 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -12,7 +12,7 @@ #include "../common/constants.qh" #include "../common/mapinfo.qh" -#include "../common/nades.qh" +#include "../common/nades/all.qh" #include "../common/stats.qh" #include "../common/triggers/target/music.qh" #include "../common/teams.qh" diff --git a/qcsrc/client/weapons/projectile.qc b/qcsrc/client/weapons/projectile.qc index 051bc4098..fc08f7ffd 100644 --- a/qcsrc/client/weapons/projectile.qc +++ b/qcsrc/client/weapons/projectile.qc @@ -5,7 +5,7 @@ #include "../main.qh" #include "../../common/constants.qh" -#include "../../common/nades.qh" +#include "../../common/nades/all.qh" #include "../../common/movetypes/movetypes.qh" #include "../../common/util.qh" diff --git a/qcsrc/common/nades.qh b/qcsrc/common/nades.qh deleted file mode 100644 index be9d353f3..000000000 --- a/qcsrc/common/nades.qh +++ /dev/null @@ -1,142 +0,0 @@ -#ifndef NADES_H -#define NADES_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; - -void RegisterNades(); -const int NADES_MAX = 8; -entity NADES[NADES_MAX], NADES_first, NADES_last; -int NADES_COUNT; -#define REGISTER_NADE(id) REGISTER(RegisterNades, NADE_TYPE, NADES, NADES_COUNT, id, m_id, NEW(Nade)) -REGISTER_REGISTRY(RegisterNades) - -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); - -#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); -} - -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; -} - -#ifdef SVQC -float healer_send(entity to, int sf); -#endif - -#endif diff --git a/qcsrc/common/nades/all.inc b/qcsrc/common/nades/all.inc new file mode 100644 index 000000000..90326ede1 --- /dev/null +++ b/qcsrc/common/nades/all.inc @@ -0,0 +1,58 @@ +#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.qc b/qcsrc/common/nades/all.qc similarity index 82% rename from qcsrc/common/nades.qc rename to qcsrc/common/nades/all.qc index a6b000025..86e6d278b 100644 --- a/qcsrc/common/nades.qc +++ b/qcsrc/common/nades/all.qc @@ -1,17 +1,17 @@ #if defined(CSQC) - #include "../dpdefs/csprogsdefs.qh" - #include "../client/defs.qh" - #include "nades.qh" - #include "buffs/all.qh" - #include "../common/movetypes/movetypes.qh" - #include "../client/main.qh" - #include "../csqcmodellib/cl_model.qh" + #include "../../dpdefs/csprogsdefs.qh" + #include "../../client/defs.qh" + #include "all.qh" + #include "../buffs/all.qh" + #include "../movetypes/movetypes.qh" + #include "../../client/main.qh" + #include "../../csqcmodellib/cl_model.qh" #elif defined(MENUQC) #elif defined(SVQC) - #include "../dpdefs/progsdefs.qh" - #include "constants.qh" - #include "../server/constants.qh" - #include "../common/turrets/sv_turrets.qh" + #include "../../dpdefs/progsdefs.qh" + #include "../constants.qh" + #include "../../server/constants.qh" + #include "../turrets/sv_turrets.qh" #endif diff --git a/qcsrc/common/nades/all.qh b/qcsrc/common/nades/all.qh new file mode 100644 index 000000000..f5a274d98 --- /dev/null +++ b/qcsrc/common/nades/all.qh @@ -0,0 +1,82 @@ +#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, 8) +REGISTER_REGISTRY(RegisterNades) +#define REGISTER_NADE(id) REGISTER(RegisterNades, NADE_TYPE, Nades, Nades_COUNT, 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 +float healer_send(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/mutator_nades.qc b/qcsrc/server/mutators/mutator_nades.qc index f31bff4dc..d4cebf9d7 100644 --- a/qcsrc/server/mutators/mutator_nades.qc +++ b/qcsrc/server/mutators/mutator_nades.qc @@ -5,7 +5,7 @@ #include "gamemode_keyhunt.qh" #include "gamemode_freezetag.qh" -#include "../../common/nades.qh" +#include "../../common/nades/all.qh" #include "../../common/monsters/spawn.qh" #include "../../common/monsters/sv_monsters.qh" @@ -23,7 +23,7 @@ void nade_timer_think() void nade_burn_spawn(entity _nade) { - CSQCProjectile(_nade, true, NADES[_nade.nade_type].m_projectile[true], true); + CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[true], true); } void nade_spawn(entity _nade) @@ -42,7 +42,7 @@ void nade_spawn(entity _nade) _nade.effects |= EF_LOWPRECISION; - CSQCProjectile(_nade, true, NADES[_nade.nade_type].m_projectile[false], true); + CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[false], true); } void napalm_damage(float dist, float damage, float edgedamage, float burntime) @@ -477,7 +477,7 @@ void nade_boom() entity expef = NULL; bool nade_blast = true; - switch ( NADES[self.nade_type] ) + switch ( Nades[self.nade_type] ) { case NADE_TYPE_NAPALM: nade_blast = autocvar_g_nades_napalm_blast; @@ -529,7 +529,7 @@ void nade_boom() } if(self.takedamage) - switch ( NADES[self.nade_type] ) + switch ( Nades[self.nade_type] ) { case NADE_TYPE_NAPALM: nade_napalm_boom(); break; case NADE_TYPE_ICE: nade_ice_boom(); break; @@ -772,7 +772,7 @@ float nade_customize() { //self.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; if(!self.traileffectnum) - self.traileffectnum = _particleeffectnum(Nade_TrailEffect(NADES[self.nade_type].m_projectile[false], self.team).eent_eff_name); + self.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[self.nade_type].m_projectile[false], self.team).eent_eff_name); self.alpha = 1; } @@ -810,14 +810,14 @@ void nade_prime() n.pokenade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type); } - n.nade_type = bound(1, n.nade_type, NADES_COUNT); + n.nade_type = bound(1, n.nade_type, Nades_COUNT); setmodel(n, MDL_PROJECTILE_NADE); //setattachment(n, self, "bip01 l hand"); n.exteriormodeltoclient = self; n.customizeentityforclient = nade_customize; - n.traileffectnum = _particleeffectnum(Nade_TrailEffect(NADES[n.nade_type].m_projectile[false], self.team).eent_eff_name); - n.colormod = NADES[n.nade_type].m_color; + n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[n.nade_type].m_projectile[false], self.team).eent_eff_name); + n.colormod = Nades[n.nade_type].m_color; n.realowner = self; n.colormap = self.colormap; n.glowmod = self.glowmod; @@ -830,7 +830,7 @@ void nade_prime() setmodel(fn, MDL_NADE_VIEW); setattachment(fn, self.weaponentity, ""); fn.realowner = fn.owner = self; - fn.colormod = NADES[n.nade_type].m_color; + fn.colormod = Nades[n.nade_type].m_color; fn.colormap = self.colormap; fn.glowmod = self.glowmod; fn.think = SUB_Remove; @@ -993,7 +993,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink) self.pokenade_type = autocvar_g_nades_pokenade_monster_type; } - self.nade_type = bound(1, self.nade_type, NADES_COUNT); + self.nade_type = bound(1, self.nade_type, Nades_COUNT); if(self.bonus_nade_score >= 0 && autocvar_g_nades_bonus_score_max) nades_GiveBonus(self, time_score / autocvar_g_nades_bonus_score_max); diff --git a/qcsrc/server/mutators/mutators_include.qc b/qcsrc/server/mutators/mutators_include.qc index 8b432d3bf..8564d34c5 100644 --- a/qcsrc/server/mutators/mutators_include.qc +++ b/qcsrc/server/mutators/mutators_include.qc @@ -11,7 +11,7 @@ #include "../../common/stats.qh" #include "../../common/teams.qh" #include "../../common/util.qh" - #include "../../common/nades.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 d9dec8f6f..adb8cf632 100644 --- a/qcsrc/server/progs.inc +++ b/qcsrc/server/progs.inc @@ -89,7 +89,6 @@ #include "../common/minigames/minigames.qc" #include "../common/minigames/sv_minigames.qc" #include "../common/movetypes/include.qc" -#include "../common/nades.qc" #include "../common/net_notice.qc" #include "../common/notifications.qc" #include "../common/physics.qc" @@ -102,6 +101,7 @@ #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" -- 2.39.2