I think if you set an item to a negative weight, it increases the players capacity when worn.
So.. you'd just want to adjust the backpacks weight whenever
Player:onInventoryUpdate
is called.. and whenever you equip/deEquip the backpack (assuming the inventory is updated when you add/remove an item inside the backpack as well.. so that items given via script/npc will also trigger the update. Never used it before.. so idk)
You'll get some mixed results at the bottom of the capacity.. when an item could technically fit.. if the backpack weight were adjusted before the item went in.. but meh. I don't see a good solution for that.
Anyway, something like this should work
Lua:
local backpackId = 1111
local percentReduction = 0.25 -- 25%
local backpack = findTheBackpackItemHoweverYouNeedTo
backpack:setAttribute(ITEM_ATTRIBUTE_WEIGHT, 0) -- minor hack, so we can get the weight of stuff inside, ignoring the backpack itself, since we can't know it's current weight
local backpackContentsWeight = backpack:getWeight()
local newBackpackWeight = ItemType(backpackId):getWeight() - (backpackContentsWeight * percentReduction)
backpack:setAttribute(ITEM_ATTRIBUTE_WEIGHT, newBackpackWeight)