Ran into a problem while scripting a new core that I'm not sure how to work around.
I want to use UOAbigail's Gold Encumberance system on my server along with CEP 2.3. Abigail's system is simple (code included) and replaces the default script to add weight to an item given to the character on log in pending how much gold they have. It constantly updates itself as you gain / lose gold. But CEP overwrites this script with one of its own and does not allow me to save it as default.
How should I go about implementing this? I've allready tried placing it onacquire/onunaquire to no avail. Hoping there's a scripting guru still lurking here.
#include "x2_inc_itemprop"
void main()
{
object oPC = OBJECT_SELF;
object oTool = GetItemPossessedBy(oPC,"rp_ce_marker");
if (oTool==OBJECT_INVALID) return;
int iCurrentWeight = GetLocalInt(oTool,"iGoldWeight");
//Set this variable on the module to equal the number of
//gold coins it takes to make 5 pounds of weight.
//If this is set to '0' then gold is weightless
int iGoldWeight = GetLocalInt(GetModule(),"iGoldWeight");
if (iGoldWeight==0) return;
int iGoldOnPC = GetGold(oPC);
int iWeightUnits = iGoldOnPC/iGoldWeight;
if (iGoldOnPC<iGoldWeight) iWeightUnits=0; //Make sure that less gold than '5 lbs worth' does not add weight.
if (iWeightUnits==iCurrentWeight) return; //No change.. nothing to do
SetLocalInt(oTool,"iGoldWeight",iWeightUnits);
int iWeightTotal = iWeightUnits*5;
int iWeight100;
int iWeight50;
int iWeight30;
int iWeight15;
int iWeight10;
int iWeight5;
itemproperty ipWeight100 = ItemPropertyWeightIncrease(IP_CONST_WEIGHTINCREASE_100_LBS);
itemproperty ipWeight50 = ItemPropertyWeightIncrease(IP_CONST_WEIGHTINCREASE_50_LBS);
itemproperty ipWeight30 = ItemPropertyWeightIncrease(IP_CONST_WEIGHTINCREASE_30_LBS);
itemproperty ipWeight15 = ItemPropertyWeightIncrease(IP_CONST_WEIGHTINCREASE_15_LBS);
itemproperty ipWeight10 = ItemPropertyWeightIncrease(IP_CONST_WEIGHTINCREASE_10_LBS);
itemproperty ipWeight5 = ItemPropertyWeightIncrease(IP_CONST_WEIGHTINCREASE_5_LBS);
if (iWeightTotal>99)
{
while (iWeightTotal>99)
{
iWeightTotal=iWeightTotal-100;
iWeight100++;
if (iWeightTotal<100) break;
}
}
if (iWeightTotal>49)
{
while (iWeightTotal>49)
{
iWeightTotal=iWeightTotal-50;
iWeight50++;
if (iWeightTotal<50) break;
}
}
if (iWeightTotal>29)
{
while (iWeightTotal>29)
{
iWeightTotal=iWeightTotal-30;
iWeight30++;
if (iWeightTotal<30) break;
}
}
if (iWeightTotal>14)
{
while (iWeightTotal>14)
{
iWeightTotal=iWeightTotal-15;
iWeight15++;
if (iWeightTotal<15) break;
}
}
if (iWeightTotal>9)
{
while (iWeightTotal>9)
{
iWeightTotal=iWeightTotal-10;
iWeight10++;
if (iWeightTotal<10) break;
}
}
if (iWeightTotal>4)
{
while (iWeightTotal>4)
{
iWeightTotal=iWeightTotal-5;
iWeight5++;
if (iWeightTotal<5) break;
}
}
//IPRemoveMatchingItemProperties(oTool,IP_CONST_WEIGHTINCREASE_100_LBS,DURATION_TYPE_PERMANENT,-1);
//IPRemoveMatchingItemProperties(oTool,IP_CONST_WEIGHTINCREASE_50_LBS,DURATION_TYPE_PERMANENT,-1);
//IPRemoveMatchingItemProperties(oTool,IP_CONST_WEIGHTINCREASE_30_LBS,DURATION_TYPE_PERMANENT,-1);
//IPRemoveMatchingItemProperties(oTool,IP_CONST_WEIGHTINCREASE_15_LBS,DURATION_TYPE_PERMANENT,-1);
//IPRemoveMatchingItemProperties(oTool,IP_CONST_WEIGHTINCREASE_10_LBS,DURATION_TYPE_PERMANENT,-1);
//IPRemoveMatchingItemProperties(oTool,IP_CONST_WEIGHTINCREASE_5_LBS,DURATION_TYPE_PERMANENT,-1);
itemproperty ipLoop=GetFirstItemProperty(oTool);
while (GetIsItemPropertyValid(ipLoop))
{
if (GetItemPropertyType(ipLoop)==ITEM_PROPERTY_WEIGHT_INCREASE) RemoveItemProperty(oTool, ipLoop);
ipLoop=GetNextItemProperty(oTool);
}
if (iWeight100>0)
{
for (iWeight100; iWeight100>0; iWeight100--)
{
AddItemProperty(DURATION_TYPE_PERMANENT,ipWeight100,oTool);
}
}
if (iWeight50>0)
{
AddItemProperty(DURATION_TYPE_PERMANENT,ipWeight50,oTool);
}
if (iWeight30>0)
{
AddItemProperty(DURATION_TYPE_PERMANENT,ipWeight30,oTool);
}
if (iWeight15>0)
{
AddItemProperty(DURATION_TYPE_PERMANENT,ipWeight15,oTool);
}
if (iWeight10>0)
{
AddItemProperty(DURATION_TYPE_PERMANENT,ipWeight10,oTool);
}
if (iWeight5>0)
{
AddItemProperty(DURATION_TYPE_PERMANENT,ipWeight5,oTool);
}
}