If the video in the other thread wasn’t a hint enough, I’m working on an rpg plugin similar to the one for Sven Coop. One of the skills you can take is the ability to increase your max armor, which changed how much you spawned with and how much you could regenerate, but you run into the limit of the engine enforcing a soft cap on the armor.
I started to work around it because I really don’t want to replace entities. I was able to get batteries working:
local meta = FindMetaTable( "Player" )
AccessorFunc( meta, "m_iMaxArmor", "MaxArmor" )
local sk_battery = GetConVar( "sk_battery" )
local function PlayerCanPickupItem( pl, item )
if not pl:GetMaxArmor( ) then
pl:SetMaxArmor( 100 )
if item:GetClass( ) == "item_battery" then
if pl:Armor( ) + sk_battery:GetInt( ) <= pl:GetMaxArmor( ) then
amt = math.min( pl:GetMaxArmor( ) - pl:Armor( ), sk_battery:GetInt( ) )
pl:SetArmor( pl:Armor( ) + amt )
pl:EmitSound( "items/battery_pickup.wav" )
hook.Add( "PlayerCanPickupItem", "Change armor cap - batteries", PlayerCanPickupItem )
This is abstracted from the code I am using ( which doesn’t account for lower than normal values ) and probably won’t work out of the box, but it gets the idea across.
You can do something similar to this with ammo if you are willing to track the default ammo amounts, which instead of running on convars are scaled by a difficulty one.
I think I’m going to have to end up replacing the suit charger entity, though, since I’d be doing just as much work to go around it.