Magazine style reloads
Hello, this will be a short and extremely simple one! Say you want to make each shot and each reload count? In CS you can reload anytime you feel like. Some bullets will be deducted and that is all. However, in real life, you will not start to load the half-empty mag, you pull out a new one, and throw away the used one. OK you don't throw it away but anyway. This system can be found in BF2, and some other games. So now to the code: Look up the basecombatweapon_shared.cpp and go to the FinishReload procedure. You will mod this part:
if ( UsesClipsForAmmo1() ) { int primary = min( GetMaxClip1() - m_iClip1, pOwner->GetAmmoCount(m_iPrimaryAmmoType)); m_iClip1 += primary; pOwner->RemoveAmmo( primary, m_iPrimaryAmmoType); }
to look like this:
if (pOwner) { // If I use primary clips, reload primary if ( UsesClipsForAmmo1() ) { // int primary = min( GetMaxClip1() - m_iClip1, pOwner->GetAmmoCount(m_iPrimaryAmmoType)); m_iClip1 = GetMaxClip1(); pOwner->RemoveAmmo( 1, m_iPrimaryAmmoType); }
This tells the game to fully reload the gun and deduct 1 from the iPrimaryAmmoType. From now on, the iPrimaryAmmoType will contain the number of full clips instead of the number of bullets.
You will notice, that the game will still grant you 30 or more bullets if you pick up an ammo crate. Now go to the items.h and mod this part to your liking. You will receive the amount of full clips, you specify here. Whenever you pick up an ammo crate.
#define SIZE_AMMO_PISTOL 12 #define SIZE_AMMO_PISTOL_LARGE 100 #define SIZE_AMMO_SMG1 30 #define SIZE_AMMO_SMG1_LARGE 225 #define SIZE_AMMO_AR2 20 #define SIZE_AMMO_AR2_LARGE 100 #define SIZE_AMMO_RPG_ROUND 1 #define SIZE_AMMO_SMG1_GRENADE 1 #define SIZE_AMMO_BUCKSHOT 20 #define SIZE_AMMO_357 6 #define SIZE_AMMO_357_LARGE 20 #define SIZE_AMMO_CROSSBOW 6 #define SIZE_AMMO_AR2_ALTFIRE 1
You get some ammo at the start. That should be modded as well. Go to the hl2mp_player.cpp and look up the GiveDefaultItems procedure. Mod the part below to your liking. You will get the specified amount of clips at start.
CBasePlayer::GiveAmmo( 255, "Pistol"); CBasePlayer::GiveAmmo( 45, "SMG1"); CBasePlayer::GiveAmmo( 1, "grenade" ); CBasePlayer::GiveAmmo( 6, "Buckshot");
CBasePlayer::GiveAmmo( 6, "357" );