]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
First part of a fix for untranslated item ammo names on drop: hack the item name...
authorMario <zacjardine@y7mail.com>
Wed, 5 Sep 2018 19:05:56 +0000 (05:05 +1000)
committerMario <zacjardine@y7mail.com>
Wed, 5 Sep 2018 19:05:56 +0000 (05:05 +1000)
qcsrc/common/notifications/all.inc
qcsrc/common/notifications/all.qh
qcsrc/server/miscfunctions.qh
qcsrc/server/weapons/throwing.qc
qcsrc/server/weapons/throwing.qh

index db0e0503f08b75b2fd6ffc14f050d35bbe27e094..a01718afdf2ecd5115c2496f040dc78af2c83295 100644 (file)
     MSG_INFO_NOTIF(ITEM_BUFF_GOT,                           N_CONSOLE,  0, 1, "item_buffname", "",          "",     _("^BGYou got the %s^BG buff!"), "")
 
     MSG_INFO_NOTIF(ITEM_WEAPON_DONTHAVE,                    N_DISABLE,  0, 1, "item_wepname", "",                           "",     _("^BGYou do not have the ^F1%s"), "")
-    MSG_INFO_NOTIF(ITEM_WEAPON_DROP,                        N_DISABLE,  1, 1, "item_wepname item_wepammo", "",              "",     _("^BGYou dropped the ^F1%s^BG%s"), "")
+    MSG_INFO_NOTIF(ITEM_WEAPON_DROP,                        N_DISABLE,  0, 2, "item_wepname item_wepammo", "",              "",     _("^BGYou dropped the ^F1%s^BG%s"), "")
     MSG_INFO_NOTIF(ITEM_WEAPON_GOT,                         N_DISABLE,  0, 1, "item_wepname", "",                           "",     _("^BGYou got the ^F1%s"), "")
     MSG_INFO_NOTIF(ITEM_WEAPON_NOAMMO,                      N_DISABLE,  0, 1, "item_wepname", "",                           "",     _("^BGYou don't have enough ammo for the ^F1%s"), "")
     MSG_INFO_NOTIF(ITEM_WEAPON_PRIMORSEC,                   N_DISABLE,  0, 3, "item_wepname f2primsec f3primsec", "",       "",     _("^F1%s %s^BG is unable to fire, but its ^F1%s^BG can"), "")
     MSG_CENTER_NOTIF(ITEM_FUELREGEN_GOT,                N_ENABLE,    0, 0, "",                                   CPID_ITEM, "item_centime 0", _("^BGYou got the ^F1Fuel regenerator"), "")
     MSG_CENTER_NOTIF(ITEM_JETPACK_GOT,                  N_ENABLE,    0, 0, "",                                   CPID_ITEM, "item_centime 0", _("^BGYou got the ^F1Jetpack"), "")
     MSG_CENTER_NOTIF(ITEM_WEAPON_DONTHAVE,              N_ENABLE,    0, 1, "item_wepname",                       CPID_ITEM, "item_centime 0", _("^BGYou do not have the ^F1%s"), "")
-    MSG_CENTER_NOTIF(ITEM_WEAPON_DROP,                  N_ENABLE,    1, 1, "item_wepname item_wepammo",          CPID_ITEM, "item_centime 0", _("^BGYou dropped the ^F1%s^BG%s"), "")
+    MSG_CENTER_NOTIF(ITEM_WEAPON_DROP,                  N_ENABLE,    0, 2, "item_wepname item_wepammo",          CPID_ITEM, "item_centime 0", _("^BGYou dropped the ^F1%s^BG%s"), "")
     MSG_CENTER_NOTIF(ITEM_WEAPON_GOT,                   N_ENABLE,    0, 1, "item_wepname",                       CPID_ITEM, "item_centime 0", _("^BGYou got the ^F1%s"), "")
     MSG_CENTER_NOTIF(ITEM_WEAPON_NOAMMO,                N_ENABLE,    0, 1, "item_wepname",                       CPID_ITEM, "item_centime 0", _("^BGYou don't have enough ammo for the ^F1%s"), "")
     MSG_CENTER_NOTIF(ITEM_WEAPON_PRIMORSEC,             N_ENABLE,    0, 3, "item_wepname f2primsec f3primsec",   CPID_ITEM, "item_centime 0", _("^F1%s %s^BG is unable to fire, but its ^F1%s^BG can"), "")
index 7982ee01f73acfc3348bed12334f125d60af494e..5a2adba1cb984cd89e455d5294ce70e53c96e731 100644 (file)
@@ -370,7 +370,7 @@ float autocvar_notification_show_sprees_center_specialonly = true;
        spree_end: placed at the end of murder messages to show ending of sprees
        spree_lost: placed at the end of suicide messages to show losing of sprees
        item_wepname: return full name of a weapon from weaponid
-       item_wepammo: ammo display for weapon from string
+       item_wepammo: ammo display for weapon from f1
        item_centime: amount of time to display weapon message in centerprint
        item_buffname: return full name of a buff from buffid
        death_team: show the full name of the team a player is switching from
@@ -433,7 +433,7 @@ string BUFF_NAME(int i);
        ARG_CASE(ARG_CS_SV,     "item_wepname",  Weapons_from(f1).m_name) \
        ARG_CASE(ARG_CS_SV,     "item_buffname", BUFF_NAME(f1)) \
        ARG_CASE(ARG_CS_SV,     "f3buffname",    BUFF_NAME(f3)) \
-       ARG_CASE(ARG_CS_SV,     "item_wepammo",  (s1 != "" ? sprintf(_(" with %s"), s1) : "")) \
+       ARG_CASE(ARG_CS_SV,     "item_wepammo",  (f2 > 0 ? notif_arg_item_wepammo(f1, f2) : "")) \
        ARG_CASE(ARG_DC,        "item_centime",  ftos(autocvar_notification_item_centerprinttime)) \
        ARG_CASE(ARG_SV,        "death_team",    Team_ColoredFullName(f1)) \
        ARG_CASE(ARG_CS,        "death_team",    Team_ColoredFullName(f1 - 1)) \
@@ -624,6 +624,25 @@ string notif_arg_spree_inf(float type, string input, string player, float spree)
        return "";
 }
 
+string notif_arg_item_wepammo(float f1, float f2)
+{
+       if(f2 <= 0)
+               return "";
+       string ammoitems = "";
+       Weapon wep = Weapons_from(f1);
+       switch (wep.ammo_type)
+       {
+               case RESOURCE_SHELLS:  ammoitems = ITEM_Shells.m_name;      break;
+               case RESOURCE_BULLETS: ammoitems = ITEM_Bullets.m_name;     break;
+               case RESOURCE_ROCKETS: ammoitems = ITEM_Rockets.m_name;     break;
+               case RESOURCE_CELLS:   ammoitems = ITEM_Cells.m_name;       break;
+               case RESOURCE_PLASMA:  ammoitems = ITEM_Plasma.m_name;      break;
+               case RESOURCE_FUEL:    ammoitems = ITEM_JetpackFuel.m_name; break;
+               default: return ""; // doesn't use ammo
+       }
+       return sprintf(_(" with %d %s"), f2, ammoitems);
+}
+
 
 // ====================================
 //  Initialization/Create Declarations
index ff62cd1674b3487185903df618d3198459817beb..2374b4869bc6c5415c08c319a162850ca9871440 100644 (file)
@@ -96,6 +96,8 @@ float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, f
 
 string NearestLocation(vector p);
 
+string AmmoNameFromWeaponentity(Weapon wep);
+
 void play2(entity e, string filename);
 
 string playername(entity p, bool team_colorize);
index 462af14d8e0ca151f366f9daa611f1caf3c00cc7..9aaabb05bfafa8075ea63466e89ab0996ffe53b5 100644 (file)
@@ -33,11 +33,9 @@ void thrown_wep_think(entity this)
                SUB_VanishOrRemove(this);
 }
 
-// returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
-string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo, .entity weaponentity)
+// returns amount of ammo used, or -1 for failure, or 0 for no ammo count
+float W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo, .entity weaponentity)
 {
-       float thisammo;
-       string s;
        Weapon info = Weapons_from(wpn);
        int ammotype = info.ammo_type;
 
@@ -84,7 +82,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
 
        weapon_defaultspawnfunc(wep, info);
        if(startitem_failed)
-               return string_null;
+               return -1;
        setthink(wep, thrown_wep_think);
        wep.savenextthink = wep.nextthink;
        wep.nextthink = min(wep.nextthink, time + 0.5);
@@ -93,12 +91,10 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
        //wa = W_AmmoItemCode(wpn);
        if(ammotype == RESOURCE_NONE)
        {
-               return "";
+               return 0;
        }
        else
        {
-               s = "";
-
                if(doreduce && g_weapon_stay == 2)
                {
                        // if our weapon is loaded, give its load back to the player
@@ -121,23 +117,13 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                        }
 
                        float ownderammo = GetResourceAmount(own, ammotype);
-                       thisammo = min(ownderammo, GetResourceAmount(wep, ammotype));
+                       float thisammo = min(ownderammo, GetResourceAmount(wep, ammotype));
                        SetResourceAmount(wep, ammotype, thisammo);
                        SetResourceAmount(own, ammotype, ownderammo - thisammo);
 
-                       switch (ammotype)
-                       {
-                               case RESOURCE_SHELLS:  s = sprintf("%s and %d shells", s, thisammo);  break;
-                               case RESOURCE_BULLETS: s = sprintf("%s and %d nails", s, thisammo);   break;
-                               case RESOURCE_ROCKETS: s = sprintf("%s and %d rockets", s, thisammo); break;
-                               case RESOURCE_CELLS:   s = sprintf("%s and %d cells", s, thisammo);   break;
-                               case RESOURCE_PLASMA:  s = sprintf("%s and %d plasma", s, thisammo);  break;
-                               case RESOURCE_FUEL:    s = sprintf("%s and %d fuel", s, thisammo);    break;
-                       }
-
-                       s = substring(s, 5, -1);
+                       return thisammo;
                }
-               return s;
+               return 0;
        }
 }
 
@@ -175,10 +161,10 @@ void W_ThrowWeapon(entity this, .entity weaponentity, vector velo, vector delta,
        STAT(WEAPONS, this) &= ~set;
 
        W_SwitchWeapon_Force(this, w_getbestweapon(this, weaponentity), weaponentity);
-       string a = W_ThrowNewWeapon(this, w.m_id, doreduce, this.origin + delta, velo, weaponentity);
+       float a = W_ThrowNewWeapon(this, w.m_id, doreduce, this.origin + delta, velo, weaponentity);
 
-       if(!a) return;
-       Send_Notification(NOTIF_ONE, this, MSG_MULTI, ITEM_WEAPON_DROP, a, w.m_id);
+       if(a < 0) return;
+       Send_Notification(NOTIF_ONE, this, MSG_MULTI, ITEM_WEAPON_DROP, w.m_id, a);
 }
 
 void SpawnThrownWeapon(entity this, vector org, Weapon wep, .entity weaponentity)
index 9ea5e5cb8e442c930f628f47f1e93ff29ef150de..20732753e4fe66f11c1fdd802df01eda300fc658 100644 (file)
@@ -6,8 +6,8 @@
 .float savenextthink;
 void thrown_wep_think(entity this);
 
-// returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
-string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo, .entity weaponentity);
+// returns amount of ammo used, or -1 for failure, or 0 for no ammo count
+float W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo, .entity weaponentity);
 
 bool W_IsWeaponThrowable(entity this, int w);