Increased magazine capacity SOLVED!

Started by Knightmare, March 05, 2012, 08:49:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Knightmare

Quote from: TheFishlord on February 28, 2012, 11:14:34 AMNext up on my to do list...figure out how to change magazine sizes...

I just discovered how to do this yesterday (and finally decided I'd register here to post this).  The setting is in each weapon's section in 41_WeaponProperties.xml, but it has a hexadecimal hash instead of a value name.  I had been searching for magazine sizes for each weapon with no success, and finally tried to do it in hexadecimal.  On that I hit paydirt, finding matching numbers in a value having the same hash under each weapon.  There are also max ammo values for each skill level, along with a text string for the ammo type.

Here are the values in the Primary.AK47 section (comments and likely names added by me).  Just search for the hash 4FBDD114, and you will immediately find the right subsection:
Spoiler
<object hash="4FBDD114"> <!-- This is the ammo section -->
  <value hash="AB258E09" type="BinHex">61737361756C747269666C6500</value> <!-- appears to be a text string for ammo type: "assaultrifle\0" -->
  <value hash="5957C8C7" type="BinHex">FC8267BC</value> <!-- this is the same for weapons with compatible ammo -->
  <value hash="88596C97" type="BinHex">1E000000</value> <!-- iAmmoInClip, 30 -->
  <value hash="2A0F1CC2" type="BinHex">96000000</value> <!-- iMaxAmmoCasual, 150 -->
  <value hash="C7DA96EA" type="BinHex">5A000000</value> <!-- iMaxAmmoExperimented, 90 -->
  <value hash="EF3C58C3" type="BinHex">5A000000</value> <!-- iMaxAmmoHardcore, 90 -->
  <value hash="DE33B3EC" type="BinHex">3C000000</value> <!-- iMaxAmmoInfamous, 60 -->
  <value hash="B72CF1A1" type="BinHex">01</value> <!-- bUsesClips? -->
  <value hash="6A9D69B4" type="BinHex">00</value> <!-- bIsAmmoVisible? -->
</object>

Note that the numbers are little-endian hexadecimal, so if you make one larger than 255 (FF), you'll need to carry over the next higher two digits in the hex pair to the right of the first two digits, and so on.  Also, the iClipsForSelfDestruct sets the weapon's life span based on magazines of ammo fired, not on total shots.  You'll want to inversely adjust this if you decrease the magazine size for any weapon.

I've edited these to change magazine size for several weapons, and also changed max ammo values.  The changes showed up in-game for every weapon I edited.  I now have a MAC-10 with a 60 round mag, and higher capacity for the USAS-12 and MGL-140 :-D  This sure beats editing the bandolier bonuses, or hacking in higher max ammo to the primary weapon crate in gamemodesconfig.xml.

BTW, I've already emailed Gibbed about this so he can hopefully release a new version of his ConvertBinary tool that properly formats and outputs value names for these values.

PZ

Excellent w@&k Knightmare (because it solves a significant problem I split into a new topic).   :-X I know that other members have been working on this issue for a while, so your instructions will keep gamers busy for quite a bit.

This find is worthy of kudos and article entry into the knowledge base.   ;)

Welcome to OWG, and we hope you enjoy your time on the site

nexor

Quote from: PZ on March 05, 2012, 09:23:56 PM
I know that other members have been working on this issue for a while, so your instructions will keep gamers busy for quite a bit.

Yes, busy trying to decipher what the man is talking about, it went so high over my head I didn't even have to duck, so gentleman speaka da inglish pleeze.......In other words,  if you tell me to take a hike then you should point me in the right direction also :D    ???  :-D


PZ

May be an opportunity to post some of the files so we can use them in our patch files.  It would be kind of nice to have a library of xml files that we can use to patch the game.  :-X

Art Blade

Hello and welcome to OWG, Knightmare - what an entrance  ^-^ Kudos from my part, too :)  :-X And thanks for stepping into the light  :-()

Nexor, I think what particularly went over your head is "Endian" (as in "big endian" or "little endian"). It is how numbers are stored when using the hexadecimal system (0-9 then A-F) and when using numbers larger than decimal 15 (hex "F") and larger than 255 (hex "FF")

Best whip out your windows calculator and switch to scientific view, then type in a number like "2012" and switch from dec to hex view which will turn that number into "7DC."

Basically it is "07 DC" and big endian (high byte first, low byte last). Now the trick is, in little endian, you need to swap those bytes so they become "DC 07" -- now we have the least significant byte (DC) first and the most significant byte (07) last.

Got it?  :-()
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

nexor


nexor

Quote from: Knightmare on March 05, 2012, 08:49:30 PM

Here are the values in the Primary.AK47 section (comments and likely names added by me).  Just search for the hash 4FBDD114, and you will immediately find the right subsection:

This is the ammo section -->
  <value hash="AB258E09" type="BinHex">61737361756C747269666C6500</value> <!-- appears to be a text string for ammo type: "assaultrifle\0" -->
<value hash="88596C97" type="BinHex">1E000000</value> <!-- iAmmoInClip, 30 -->
  <value hash="2A0F1CC2" type="BinHex">96000000</value> <!-- iMaxAmmoCasual, 150 -->
  <value hash="C7DA96EA" type="BinHex">5A000000</value> <!-- iMaxAmmoExperimented, 90 -->
  <value hash="EF3C58C3" type="BinHex">5A000000</value> <!-- iMaxAmmoHardcore, 90 -->
  <value hash="DE33B3EC" type="BinHex">3C000000</value> <!-- iMaxAmmoInfamous, 60 -->

Ok I got that part right Art,  the tricky part is how does " <value hash="C7DA96EA" type="BinHex">5A000000</value>" give you 90 rounds in the mag      ??? :D   :-D

Ok  hang on   5A000000  or 5A changed from Hex to Dec gives you 90   :lamp:
All these values are present on all weapons, so how do I change the M16 mag from 30 to say 90
Damn ! i'm getting clever..... :-D

Art Blade

[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

Knightmare

All weapons appear to have these values (even the machete!).  To change the M16 mag size to 90, you'd change the 88596C97 value from 1E to 5A.  The C7DA96EA value is the ammo maximum on normal difficulty. 

But I've now found a way to make this easier.  The ammo values can be changed to normal numbers and thus made easier to edit.

Just change the type for the clip size and max ammo values from BinHex to UInt32, and convert the numbers from hexadecimal using Windows calculator.  Like Art Blade said, use scientific view under XP, or programmer mode under Windows 7, and I dunno about Vista's calculator.

The last two values can be changed to Bool, and will be True for 01, or False for 00.  In addition, the first value in this section (ammo name) can be converted to a proper text string, but decoding it is tedious.  I had to do it char-by-char in XVI32 (a hex editor), as it wouldn't let me paste the hex digits.  Getting the string wrong could break ammo compatibility between weapons.  And the second value seems to correlate with ammo type, but I don't yet know exactly what it does.

Gibbed's ConvertBinary util will correctly compile the reformatted section, and it works right in game.

The second to last value seems to determine if the weapon requires reloading, or has a visible magazine capacity on the HUD.  Only the flamethrower has this set to false.

Here's the ammo section for the AK-47 reformatted:
Spoiler
<object hash="4FBDD114"> <!-- This is the ammo section -->
   <value hash="AB258E09" type="String">assaultrifle</value> <!-- text string for ammo type -->
   <value hash="5957C8C7" type="BinHex">FC8267BC</value> <!-- this is the same for weapons with compatible ammo -->
   <value hash="88596C97" type="UInt32">30</value> <!-- iAmmoInClip -->
   <value hash="2A0F1CC2" type="UInt32">150</value> <!-- iMaxAmmoCasual -->
   <value hash="C7DA96EA" type="UInt32">90</value> <!-- iMaxAmmoExperimented -->
   <value hash="EF3C58C3" type="UInt32">90</value> <!-- iMaxAmmoHardcore -->
   <value hash="DE33B3EC" type="UInt32">60</value> <!-- iMaxAmmoInfamous -->
   <value hash="B72CF1A1" type="Bool">True</value> <!-- bUsesClips? -->
   <value hash="6A9D69B4" type="Bool">False</value> <!-- bIsAmmoVisible? -->
</object>

It's doable to reformat every ammo section in 41_WeaponProperties to have a ready-to-edit version, but it would be very time consuming.

Oh, and thanks to PZ for moving this into its own thread.  There were already a few threads on weapon editing and I didn't know if it would be appropriate to start a new one.


PZ

Great w@&k again Knightmare  :-X

By the way, we're really relaxed here at OWG, so feel free to start any kind of topic - if something needs to be moved or incorporated into another area, one of the moderators or admins will gladly do so.  Relaxed rules of communication is what we pride ourselves on.  ;)

nexor

I seem to pick up another problem on the M16, whatever changes I make cancel out the full burst mod Gibbed did back to 3 round burst    :'(

disregard, I found a tiny error, fixed it, it works....thank you Knightmare    :bow
This weapon is close to how shelmez described his shotgun, "lawnmower" now the mercs are gonna s#!t :-D >:D :angel:

Knightmare

I've run into a few errors myself reformatting ammo sections.  Gibbed's ConvertBinary util doesn't output any error messages with a line number, instead it crashes with a stack trace  :o  I would recommend saving the file and running ConvertBinary (with a separate batch file just for it) after editing/reformatting each section, so you'll know right then whether you made an error.

TheFishlord

WOW!  :-X THANK YOU! I give you this halo in recognition of your ingenuity.  :angel:

I thought it had something to do with those hashes but I had no idea how to decode them. Well I'm getting to w@&k on changing them, once that's done, be ready for the release of Realistic Weapons Pack 1.0... ^-^

nexor

Quote from: TheFishlord on March 07, 2012, 12:50:56 PM
WOW!  :-X THANK YOU! I give you this halo in recognition of your ingenuity.  :angel:

I discovered it was an error I made when I followed gibbed's instructions on the full auto of the M16.

I also used your first method to change the ammo clip, will post a clip or two showing the effect    :-D

Knightmare

I found what the last value (the one I tagged as bIsAmmoVisible) is used for.  It's only set to true for the PKM and the M249, which have visible bets of ammunition.  When you empty a belt, the last few rounds are shown being used up.  By setting this to false, it prevents this from happening, and the ammo belt is still there when you run out.

Also, I just noticed for the first time that the M249 ejects the disintegrating links.  Good attention to detail there.

nexor

Here are a few clips after I did theM16 clip mod to 90 rounds, still getting used to it.

http://www.youtube.com/watch?v=gfzsxAJekMw#ws
Stopping a assault jeep from the side

http://www.youtube.com/watch?v=SfuYsv6DvXE#ws
Fired a few shots just to draw them out.

http://www.youtube.com/watch?v=U4sE6GZ9wr0#ws
Stopping another assault jeep head on

Tags:
🡱 🡳

Similar topics (2)