]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Nades: move definitions alongside nade mutator
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 10 Nov 2015 02:01:18 +0000 (13:01 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 10 Nov 2015 02:01:18 +0000 (13:01 +1100)
18 files changed:
qcsrc/client/hud/hud.qc
qcsrc/client/hud/panel/ammo.qc
qcsrc/client/mutators/events.qh
qcsrc/client/progs.inc
qcsrc/client/view.qc
qcsrc/client/weapons/projectile.qc
qcsrc/common/effects/all.inc
qcsrc/common/mutators/mutator/nades/effects.inc [new file with mode: 0644]
qcsrc/common/mutators/mutator/nades/module.inc
qcsrc/common/mutators/mutator/nades/nades.inc [new file with mode: 0644]
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/nades/nades.qh [new file with mode: 0644]
qcsrc/common/mutators/mutator/nades/net.qc [new file with mode: 0644]
qcsrc/common/nades/all.inc [deleted file]
qcsrc/common/nades/all.qc [deleted file]
qcsrc/common/nades/all.qh [deleted file]
qcsrc/server/mutators/all.qc
qcsrc/server/progs.inc

index 1054e9bcb1cc8e95048dbda72fc8654ed63ce457..0860183a26aba94a3de317dab79dd04c2487ff46 100644 (file)
@@ -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
index ac8fee0f10333484529051e823aa88af64e3ecbe..236a585985e8c983696284464d02b62277feb090 100644 (file)
@@ -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)
 {
index 92f4558163156d02df204aa3a87648e66f8b7db3..898d3b28aa757c6b260454813a6bcab90086e05b 100644 (file)
@@ -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
index 4e127917aa48cb136eeb6b77b2f788f81238d670..e6fa3053338dd83e0d1837ee9645c455ddfa4364 100644 (file)
@@ -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"
index c319dfcf0bdbc339d011fe6edb13ad2958cf9d5d..699e2d8ade41b81b6da5922980f2aa4449849009 100644 (file)
@@ -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
        {
index 04a600cb694ffcfeb1be630e459f56a9a2128ef0..9609760c4a43ab168f465395bca180ec7cc45478 100644 (file)
@@ -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);
index 72d4565e4f8c0f9f6f90e52902f96afb874a325b..b34180056a1a5302c8b0fe46f50c97fe345c8e0e 100644 (file)
@@ -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 (file)
index 0000000..cde0016
--- /dev/null
@@ -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;
+    }
+}
index b9c0eb308e64240293a4a94b6f743e305cc8f634..e03900d6a5e1c7db7df258caf23fac7b81195998 100644 (file)
@@ -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 (file)
index 0000000..6d16fd1
--- /dev/null
@@ -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);
+}
index 556265f1f99699227b3d10fa85350ca234964ba7..8a061d20ffeb0a71f1a48201132b681c3fdf1486 100644 (file)
-#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 (file)
index 0000000..a218b71
--- /dev/null
@@ -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 (file)
index 0000000..072f507
--- /dev/null
@@ -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 (file)
index 90326ed..0000000
+++ /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 (file)
index 4ba1340..0000000
+++ /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 (file)
index 235dd97..0000000
+++ /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
index 542763fd28dcff1965b2cec466244f48c473e832..f2d8a084cd4005ea17e13fdac854e0896b40bd41 100644 (file)
@@ -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"
index 6ab895f21f9cd7936f78869e630d70b8b1a9f3b9..e9dc047934eac6c68ec5430eadec4c30dde5057f 100644 (file)
@@ -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"