Simon Volpert zdoomrl / 522ee7c
Fix dropping double ammo for dedicated backpack Simon Volpert 4 years ago
1 changed file(s) with 19 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
995995 int CellCapacity = GetAmmoCapacity("Cell");
996996 int amount, multiplier, large, small, capacity;
997997 int SelectedType = -1;
998 // Cache special backpack type (dedicated backpack only)
999 str BackpackTypes[4] = {"RLBackpackClipChosen", "RLBackpackShellChosen", "RLBackpackRocketChosen", "RLBackpackCellChosen"};
1000 if (CheckInventory("RLBackpackType") == 4) {
1001 for (SelectedType = 0; SelectedType < 4; SelectedType++) {
1002 if (CheckInventory(BackpackTypes[SelectedType])) {
1003 if (GetCvar("Debug")) {
1004 Log(s:"dedicated backpack set to ", s:AmmoTypes[SelectedType]);
1005 }
1006 break;
1007 }
1008 }
1009 }
9981010 while (TRUE) {
9991011 // Capacities unchanged, update ammo counts
10001012 if (BulletCapacity == GetAmmoCapacity("Clip") && ShellCapacity == GetAmmoCapacity("Shell") && RocketCapacity == GetAmmoCapacity("RocketAmmo") && CellCapacity == GetAmmoCapacity("Cell")) {
10071019 }
10081020 // Lower capacity backpack, drop any extraneous ammo
10091021 else if (BulletCapacity > GetAmmoCapacity("Clip") || ShellCapacity > GetAmmoCapacity("Shell") || RocketCapacity > GetAmmoCapacity("RocketAmmo") || CellCapacity > GetAmmoCapacity("Cell")) {
1010 // Cache special backpack type (dedicated backpack only)
1011 str BackpackTypes[4] = {"RLBackpackClipChosen", "RLBackpackShellChosen", "RLBackpackRocketChosen", "RLBackpackCellChosen"};
1012 if (CheckInventory("RLBackpackType") == 4) {
1013 for (SelectedType = 0; SelectedType < 4; SelectedType++) {
1014 if (CheckInventory(BackpackTypes[SelectedType])) {
1015 if (GetCvar("Debug")) {
1016 Log(s:"dedicated backpack is set to ", s:AmmoTypes[SelectedType]);
1017 }
1018 break;
1019 }
1020 }
1021 }
10221022 for (int ammo = 0; ammo < 4; ammo++) {
10231023 large = 0;
10241024 small = 0;
10391039 multiplier = 1;
10401040 if (SelectedType == ammo) {
10411041 multiplier = 2;
1042 Log(s:"double ammo for ", s:AmmoTypes[Ammo]);
10421043 }
10431044 // Drop ammo packs until within maximum capacity
10441045 capacity = GetAmmoCapacity(AmmoTypes[ammo]);
10481049 SpawnProjectile(0, AmmoSpawns[ammo][0], random(0, 255), random(10, 40), random(40, 60), 1.0, 0);
10491050 amount -= AmmoPacks[ammo][0] * multiplier;
10501051 large++;
1052 if (GetCvar("Debug")) {
1053 Log(s:"dropped ", i:AmmoPacks[ammo][0] * multiplier, s:" ", s:AmmoTypes[ammo], s:" ", i:amount, s:" left");
1054 }
10511055 }
10521056 // Small packs
10531057 else if (amount - capacity >= AmmoPacks[ammo][1] * multiplier) {
10541058 SpawnProjectile(0, AmmoSpawns[ammo][1], random(0, 255), random(10, 40), random(40, 60), 1.0, 0);
10551059 amount -= AmmoPacks[ammo][1] * multiplier;
10561060 small++;
1061 if (GetCvar("Debug")) {
1062 Log(s:"dropped ", i:AmmoPacks[ammo][0] * multiplier, s:" ", s:AmmoTypes[ammo], s:" ", i:amount, s:" left");
1063 }
10571064 }
10581065 // Discard any leftovers
10591066 else {