Author Topic: Frog's Weaponry ammo weirding out, need info [SOLVED]  (Read 6288 times)

So I've been working on fixing up Tier Tactical and Frog's Weaponry lately (Bushido ignored my PMs, Frog gave me permission to release a fix for his weaponpack assuming I can actually fix anything). One thing I've noticed is that Frog's Weaponry ammo has a bizarre tendency to suddenly spaz out.
Here's an example. You're holding the Heavy RL (called the Payload Launcher in older versions). Your ammo count says 1/3. You fire the Heavy RL. Your ammo count says 0/3. You reload. Your ammo count says 1/-6.
It APPEARS that I managed to fix the problem on the Pop Gun, but in the process, I introduced a different problem, in which instead of reducing the reserve ammo by ridiculous amounts, it increases the main ammo by ridiculous amounts. At the moment, in the single-player testing server I'm running, the pop-gun's ammo count reads "97/0". Even if I switch weapons and switch back, it still reads "97/0".
I still can't get this issue to happen consistently, and I haven't yet gotten it to happen with Tier Tactical (though that doesn't rule out the possibility). Does anyone know what's up with all this?
« Last Edit: April 15, 2015, 09:22:10 AM by King of the Bill »

Try using the add-on(s) in question and nothing else but default add-ons. If you're fixing Frogs then just have his weapons on. If the problem still persists then someone will need to assist you in the coding, if the problem doesn't persist then you have a conflicting add-on somewhere.

you might have an older version of frog's wep pack, ive noticed that the heavy rl is the older version
not the payload, its the new one found in the facelift thing dont know about that

right now the problem youre experiencing is showing you that you forgeted up one of the ammo things badly and it seems that you might have to redownload the ammo system or restore the old .cs back

host a server online and ill try to join if i can

i live in singapore so i dont think i might have the best ping :/

I'll take a look at the alternate version that I also have downloaded; there's two versions out there and neither of them seem to be entirely complete.
#1 has the Heavy RL, Light RL, and Break Shotgun, and also includes ammo models and individual pickups for Heavy Rocket ammo, Light Rocket ammo, and some other type of ammo that escapes me at the moment. It includes an additional type of ammo pile. It also includes a duplicate .cs file for the auto shotgun, for reasons unclear.
#2 has the Payload Launcher, the Strike Launcher, and lacks a Break Shotgun equivalent entirely (the exec line is commented out), and also lacks at least three individual ammo type models.
As far as I can tell, neither one uses RTB max ammo prefs; the max ammo limits are hardcoded.

Now, it's important to note that BOTH versions suffer from some variant of this issue, and they both did so before I modified them. This issue with the ammo system does NOT appear to be a result of the tweaks I made to the max ammo system.

I'm still not sure what the issue is, though it does appear on cursory inspection that #2 is newer.
« Last Edit: March 16, 2015, 03:16:47 PM by King of the Bill »

Found at least PART of the issue. With Frog's Weaponry, if you use up some ammo for an item in a given slot, then chuck the weapon without reloading, then pick up a new weapon, it counts the spent ammo from the old weapon against the ammo count for the new weapon when you reload. I'll see if I can figure out why.

It also includes a duplicate .cs file for the auto shotgun, for reasons unclear.
also lacks at least three individual ammo type models.
As far as I can tell, neither one uses RTB max ammo prefs; the max ammo limits are hardcoded.
possibly for a backup for the autoshotgun, the break action shotgun was a little op ( maybe ) and thats why it was commented out

3 ammo type models got removed probably to save datablock usage

lol, they are not hardcoded actually
its inside the config/server/prefs.cs | let me show you how it looks like
$Pref::Server::FW1Ammo = "5994";
$Pref::Server::FW1Drop = "1";
$Pref::Server::FW2Ammo = "5994";
$Pref::Server::FW2Drop = "1";
$Pref::Server::FW3Ammo = "999";
$Pref::Server::FW4Ammo = "5994";
$Pref::Server::FW5Ammo = "1998";
$Pref::Server::FW5Drop = "1";
$Pref::Server::FW6Ammo = "4995";
$Pref::Server::FW6Drop = "1";
$Pref::Server::FW7Ammo = "3996";
$Pref::Server::FW7Drop = "1";
$Pref::Server::FW8Ammo = "999";

dont ask me why it has a huge amount

Found at least PART of the issue. With Frog's Weaponry, if you use up some ammo for an item in a given slot, then chuck the weapon without reloading, then pick up a new weapon, it counts the spent ammo from the old weapon against the ammo count for the new weapon when you reload. I'll see if I can figure out why.
i dont really understand this
could you give me your older and newer version of frogs weaponry?
ill look into it since ive modded the same weapon packs as you did but for a different goal

Actually, I've gotten everything solved now. I started off knowing nothing whatsoever but I guess I figured things out.

First off: If you do what you listed above, then pick up an Ammo Pile for FW ammo, it will REDUCE your current ammo amounts to certain numbers listed in the packages for picking up ammo. That's what I meant by max ammo.
Check Item_FWAmmo.cs:
Code: [Select]
package FWAmmoPileStaticPackage
{
function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
{
if(%col.dataBlock $= "FwPilestaticItem" && %col.canPickup && %obj.getDamagePercent() < 1.0 && minigameCstar fishe(%obj.client, %col))
{
   %obj.client.quantity["21Gauge"] = $Pref::Server::FW1Max;
   %obj.client.quantity["45Caliber"] = $Pref::Server::FW2Max;
   %obj.client.quantity["ImpactGrenade"] = $Pref::Server::FW5Max;
   %obj.client.quantity["Slugs"] = $Pref::Server::FW6Max;  
   %obj.client.quantity["BlastRounds"] = $Pref::Server::FW7Max;

serverPlay3D(FWammogetSound,%obj.getPosition());
if(isObject(%col.spawnbrick))
{
%col.fadeOut();
%col.schedule(%col.spawnbrick.itemrespawntime, "fadeIn");
}else{
%col.schedule(10, delete);
}
%this.onPickup(%obj, %player);
return;
}
Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
}
};
activatePackage(FwAmmoPileStaticPackage);
In the unmodified version(s) of Frog's Weaponry, there are no $Pref::Server::FW#Max prefs (above is my own modified version). There are just specific numbers that everything is set to. Note that ALL ammo packages in Frog's Weaponry are like this, so that if you do what you just described above, and pick up any of the dropped ammo for a given ammo type, your ammo for that type will be reduced to whatever that specific number was.
That was NOT the problem I was discussing with this topic, and I evidently didn't make things clear enough.

Second off, the issue was one with the reloading system.

If you open up one of Frog's weapons and one of Bushido's Tier Tac weapons at the same time, you'll notice some differences in their reload functions.
Frog's Weaponry reload sequence has
Code: [Select]
%obj.client.quantity["whatever"] -= %obj.AmmoSpent[%obj.currTool]instead of
Code: [Select]
%obj.client.quantity["whatever"] -= %this.item.maxAmmo;.
Frog's Weaponry weapons also lack the
Code: [Select]
%obj.client.quantity["whatever"] += %obj.toolAmmo[%obj.currTool];
%obj.toolAmmo[%obj.currTool] = 0;
parts at the beginning of the reload function.

To see the issue in action, as an example:
Using an unmodified copy of Frog's Weaponry (doesn't matter whether it's the old or new version), do the following:
Pick up a Heavy Pistol. Fire four shots, then throw it away using Control+W, without reloading it first.
Then pick up a Heavy SMG, making sure it goes into the same weapon slot that the Heavy Pistol was in. Fire three more shots. Then reload the Heavy SMG. The "reserve ammo" for the Heavy SMG will be depleted by seven, even though the Heavy SMG only got three ammo back.

The issue, as it turns out, is that %obj.AmmoSpent[%obj.currTool] is stored by slot rather than by item, and is not cleared when you throw away or pick up a weapon. Adjusting the reload function such that it doesn't need that variable fixes the problem that I outlined above. I have successfully set up and tested a fix, and it works. The two grenades are unaffected by this due to their nature, and the way the Ballistic Shotgun reloads means that if there's actually a problem in it, I can't find it.

On a side note, Heedicalking's Impact Rifle has the same problem with its reload function.

Anyway, this thread is now solved.