https://fodev.net/forum/index.php/topic,30344.msg263772.html#msg263772Check that on how to change carry weight from extensions.
Once it works, all you need to do is change the formula based on your idea, an example would be if character has backpack in Slot 1 or Slot 2, they would receive extra carry weight and also this solution would be moderately simple to implement. Keep in mind to write simple changes or you will leave server hanging, crashing etc.
This is your current extension function for it:
EXPORT int getParam_MaxWeight(CritterMutual& cr, uint)
{
int val = max(cr.Params[ST_CARRY_WEIGHT] + cr.Params[ST_CARRY_WEIGHT_EXT], 0);
val += CONVERT_GRAMM(25 + getParam_Strength(cr, 0) * 25);
if(cr.Params[PE_PACK_RAT])
{
val*=4;
val/=3;
}
val+=20000;
const Item* armor=cr.ItemSlotArmor;
val+=checkBonus(armor, BONUS_ARMOR_CARRY_WEIGHT)*1000;
return CLAMP(val, 0, 2000000000);
}
You might want to add your change before where the conversion to gramms is called, for example to make the bag add 50 extra, you could do something like:
#define PID_BAG (46)
#define PID_BACKPACK (90)
#define PID_BROWN_BAG (93)
EXPORT int getParam_MaxWeight(CritterMutual& cr, uint)
{
int val = max(cr.Params[ST_CARRY_WEIGHT] + cr.Params[ST_CARRY_WEIGHT_EXT], 0);
int extra = 0;
if (cr.ItemSlotExt->Proto->ProtoId == PID_BACKPACK || cr.ItemSlotMain->Proto->ProtoId == PID_BACKPACK) {
extra += 50;
}
val += CONVERT_GRAMM(25 + getParam_Strength(cr, 0) * 25 + extra);
if(cr.Params[PE_PACK_RAT])
{
val*=4;
val/=3;
}
val+=20000;
const Item* armor=cr.ItemSlotArmor;
val+=checkBonus(armor, BONUS_ARMOR_CARRY_WEIGHT)*1000;
return CLAMP(val, 0, 2000000000);
}
So here I only change for backpack, but you would need to add the all the defines that your server uses for backpacks and change to code accordingly.
NOTE: I did not test it, as I want to make a more complex version, but should be able to get started from here.