]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/nades/nades.qc
Show nade throw message when it explodes while holding it in hand.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / nades / nades.qc
index 6924947f05c0c821b5558648ef471c42fda5be4b..67e3d4ad1c02ccb86afa812b194ada6bf25e43c2 100644 (file)
@@ -10,6 +10,9 @@ float autocvar_g_nades_spread = 0.04;
 REGISTER_STAT(NADES_SMALL, int, autocvar_g_nades_nade_small)
 
 #ifdef GAMEQC
+REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
+REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
+
 entity Nade_TrailEffect(int proj, int nade_team)
 {
     switch (proj)
@@ -891,15 +894,18 @@ void nade_damage(entity this, entity inflictor, entity attacker, float damage, i
                damage = this.max_health * 0.1;
        else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
        {
-               if(deathtype & HITTYPE_SECONDARY)
-               {
-                       damage = this.max_health * 0.1;
-                       force *= 10;
-               }
-               else
+               if(!(deathtype & HITTYPE_SECONDARY))
                        damage = this.max_health * 1.15;
        }
 
+       // melee slaps
+       entity death_weapon = DEATH_WEAPONOF(deathtype);
+       if(((deathtype & HITTYPE_SECONDARY) ? (death_weapon.spawnflags & WEP_TYPE_MELEE_SEC) : (death_weapon.spawnflags & WEP_TYPE_MELEE_PRI)))
+       {
+               damage = this.max_health * 0.1;
+               force *= 10;
+       }
+
        this.velocity += force;
        UpdateCSQCProjectile(this);
 
@@ -1030,7 +1036,7 @@ void nades_GiveBonus(entity player, float score)
                if ( STAT(NADE_BONUS_SCORE, player) >= 1 )
                {
                        Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
-                       play2(player, SND(KH_ALARM));
+                       play2(player, SND(NADE_BONUS));
                        STAT(NADE_BONUS, player)++;
                        STAT(NADE_BONUS_SCORE, player) -= 1;
                }
@@ -1161,7 +1167,7 @@ bool CanThrowNade(entity this)
        if (!autocvar_g_nades)
                return false; // allow turning them off mid match
 
-       if(forbidWeaponUse(this))
+       if (weaponLocked(this))
                return false;
 
        if (!IS_PLAYER(this))
@@ -1183,7 +1189,6 @@ void nades_CheckThrow(entity this)
                this.nade_altbutton = true;
                if(time > this.nade_refire)
                {
-                       Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_NADE_THROW);
                        nade_prime(this);
                        this.nade_refire = time + autocvar_g_nades_nade_refire;
                }
@@ -1247,7 +1252,8 @@ CLASS(NadeOffhand, OffhandWeapon)
                }
     }
 ENDCLASS(NadeOffhand)
-NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); }
+NadeOffhand OFFHAND_NADE;
+STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); }
 
 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
 {
@@ -1287,7 +1293,10 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
                held_nade.angles_y = player.angles.y;
 
                if (time + 0.1 >= held_nade.wait)
+               {
                        toss_nade(player, false, '0 0 0', time + 0.05);
+                       Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_THROW);
+               }
        }
 
        if(IS_PLAYER(player))
@@ -1444,8 +1453,8 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
 
        if(IS_PLAYER(frag_attacker))
        {
-               float killcount_bonus = ((CS(frag_attacker).killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * CS(frag_attacker).killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor);
-
+               float killcount_bonus = ((CS(frag_attacker).killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * CS(frag_attacker).killcount, autocvar_g_nades_bonus_score_medium) 
+                                                                                                                                       : autocvar_g_nades_bonus_score_minor);
                if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
                        nades_RemoveBonus(frag_attacker);
                else if(GameRules_scoring_is_vip(frag_target))
@@ -1541,9 +1550,6 @@ MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
        STAT(VEIL_ORB_ALPHA, client) = STAT(VEIL_ORB_ALPHA, spectatee);
 }
 
-REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
-REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
-
 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
 {
        M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
@@ -1551,7 +1557,7 @@ MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
 
 MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString)
 {
-       M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' to use them\n");
+       M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' (dropweapon) to use them\n");
 }
 
 #endif