Closed IAFJaeger closed 2 months ago
I have found we can get the ammo type ( also called "ammo index" ) of a weapon like this:
local nAmmoIndex = NetProps.GetPropInt( hWeapon, "m_iPrimaryAmmoType" );
And we can define a function ourself like:
function GetMaxAmmoMarineCanCarry( hMarine, nAmmoType )
{
local nMaxAmmo = 0;
for( local nSlot = 0; nSlot < 3; nSlot += 1 )
{
local hWeapon = NetProps.GetPropEntityArray( hMarine, "m_hMyWeapons", nSlot )
if( hWeapon && hWeapon.IsValid() ){
if( nAmmoType == NetProps.GetPropInt( hWeapon, "m_iPrimaryAmmoType" ) )
{
nMaxAmmo += hWeapon.GetMaxClip1();
}
if( nAmmoType == NetProps.GetPropInt( hWeapon, "m_iSecondaryAmmoType" ) )
{
nMaxAmmo += hWeapon.GetMaxClip2();
}
}
}
return nMaxAmmo;
}
We now have the function
CBaseCombatWeapon::GetMaxClips
in Vscript, but it only returns the weapon's max clips. The question is, if the marine is carrying 2 weapons which use the same ammo type, I don't know how to get the max clips that a marine can carry. For an example, if a marine carries aasw_weapon_prifle
and aasw_weapon_rifle
, then the max clips that the marine can carry is 10 because the 2 weapons use the same ammo type. But the functionCBaseCombatWeapon::GetMaxClips
only returns 5.I wish there would be some vscripts functions like: