I have a custom ILR script currently in place but I would like to expand the functionality to include all levels for the local Int check at the bottom of the script. So if I place the int “LEVEL_ONE” on an item with a value of 1 the item is flagged as being level 1 required regardless of value of the item.
int GetRequiredLevel(object oItem);
int StartingConditional(){return 0;}
// Define the ForceDrop function
void SHA_ActionForceUnequipItem(object oItem)
{
FloatingTextStringOnCreature("You are too inexperienced to use " + GetName(oItem), OBJECT_SELF, FALSE);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectCutsceneImmobilize(), OBJECT_SELF, 0.1);
ClearAllActions(TRUE);
ActionUnequipItem(oItem);
ActionDoCommand(SetCommandable(TRUE));
SetCommandable(FALSE);
}
void CheckAndUnequip(object oItem, object oPlayer)
{
int iLevPC = GetHitDice(oPlayer);
int iLevItem = GetRequiredLevel(oItem);
if (GetIsPC(oPlayer) && !GetIsDM(oPlayer) && GetIsObjectValid(oItem))
{
int iType = GetBaseItemType(oItem);
if(iType == BASE_ITEM_CREATUREITEM)
{
return;
}
else if (iLevPC < iLevItem)
{
FloatingTextStringOnCreature("You are too inexperienced to use " + GetName(oItem), OBJECT_SELF, FALSE);
DelayCommand(0.1, AssignCommand(oPlayer, ActionUnequipItem(oItem)));
}
}
}
void CheckItemLevelRestriction(object oPlayer)
{
object oItem = GetItemInSlot(INVENTORY_SLOT_ARMS, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_ARROWS, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_BELT, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_BOLTS, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_BOOTS, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_BULLETS, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_CHEST, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_CLOAK, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_HEAD, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_LEFTRING, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_NECK, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPlayer);
CheckAndUnequip(oItem, oPlayer);
oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTRING, oPlayer);
CheckAndUnequip(oItem, oPlayer);
}
int GetRequiredLevel(object oItem)
{
// Initial flag
int bIdent = GetIdentified(oItem);
int bPlot = GetPlotFlag(oItem);
// If not already, set to identfied
if (!bIdent) SetIdentified(oItem, TRUE);
if (bPlot) SetPlotFlag(oItem, FALSE);
// Get the GP value
int nGP = GetGoldPieceValue(oItem);
string oName = GetStringLowerCase(GetName(oItem));
// Re-set the identification and plot flag to its original
SetIdentified(oItem, bIdent);
SetPlotFlag(oItem, bPlot);
int ReqLevel = 1;
if(nGP<=400) ReqLevel = 1;
else if(nGP>400 && nGP<=800) ReqLevel = 2;
else if(nGP>800 && nGP<=1200) ReqLevel = 3;
else if(nGP>1200 && nGP<=2000) ReqLevel = 4;
else if(nGP>2000 && nGP<=3500) ReqLevel = 5;
else if(nGP>3500 && nGP<=6500) ReqLevel = 6;
else if(nGP>6500 && nGP<=8500) ReqLevel = 7;
else if(nGP>8500 && nGP<=10000) ReqLevel = 8;
else if(nGP>10000 && nGP<=11000) ReqLevel = 9;
else if(nGP>11000 && nGP<=13000) ReqLevel = 10;
else if(nGP>13000 && nGP<=15000) ReqLevel = 11;
else if(nGP>15000 && nGP<=17000) ReqLevel = 11;
else if(nGP>17000 && nGP<=19500) ReqLevel = 12;
else if(nGP>19500 && nGP<=20000) ReqLevel = 12;
else if(nGP>20000 && nGP<=25000) ReqLevel = 12;
else if(nGP>25000 && nGP<=30000) ReqLevel = 12;
else if(nGP>30000 && nGP<=35000) ReqLevel = 13;
else if(nGP>35000 && nGP<=40000) ReqLevel = 13;
else if(nGP>40000 && nGP<=50000) ReqLevel = 14;
else if(nGP>50000 && nGP<=60000) ReqLevel = 14;
else if(nGP>60000 && nGP<=65000) ReqLevel = 15;
else if(nGP>65000 && nGP<=75000) ReqLevel = 15;
else if(nGP>75000 && nGP<=80000) ReqLevel = 15;
else if(nGP>80000 && nGP<=90000) ReqLevel = 16;
else if(nGP>90000 && nGP<=100000) ReqLevel = 16;
else if(nGP>100000 && nGP<=110000) ReqLevel = 16;
else if(nGP>110000 && nGP<=130000) ReqLevel = 16;
else if(nGP>130000 && nGP<=150000) ReqLevel = 16;
else if(nGP>150000 && nGP<=200000) ReqLevel = 17;
else if(nGP>200000 && nGP<=250000) ReqLevel = 18;
else if(nGP>250000 && nGP<=300000) ReqLevel = 18;
else if(nGP>300000 && nGP<=350000) ReqLevel = 19;
else if(nGP>350000 && nGP<=400000) ReqLevel = 20;
else if(nGP>400000 && nGP<=500000) ReqLevel = 21;
else if(nGP>500000 && nGP<=600000) ReqLevel = 22;
else if(nGP>600000 && nGP<=700000) ReqLevel = 22;
else if(nGP>700000 && nGP<=750000) ReqLevel = 23;
else if(nGP>750000 && nGP<=800000) ReqLevel = 23;
else if(nGP>800000 && nGP<=900000) ReqLevel = 24;
else if(nGP>900000 && nGP<=1000000) ReqLevel = 25;
else if(nGP>1000000 && nGP<=1100000) ReqLevel = 25;
else if(nGP>1100000 && nGP<=1200000) ReqLevel = 26;
else if(nGP>1200000 && nGP<=1300000) ReqLevel = 27;
else if(nGP>1300000 && nGP<=1400000) ReqLevel = 29;
else if(nGP>1400000 && nGP<=1500000) ReqLevel = 30;
else if(nGP>1500000 && nGP<=1600000) ReqLevel = 30;
else if(nGP>1600000 && nGP<=1700000) ReqLevel = 31;
else if(nGP>1700000 && nGP<=1800000) ReqLevel = 32;
else if(nGP>1800000 && nGP<=1900000) ReqLevel = 32;
else if(nGP>1900000 && nGP<=2000000) ReqLevel = 33;
else if(nGP>2000000 && nGP<=2100000) ReqLevel = 33;
else if(nGP>2100000 && nGP<=2200000) ReqLevel = 34;
else if(nGP>2200000 && nGP<=2300000) ReqLevel = 34;
else if(nGP>2300000 && nGP<=2400000) ReqLevel = 35;
else if(nGP>2400000 && nGP<=2600000) ReqLevel = 35;
else if(nGP>2600000 && nGP<=2800000) ReqLevel = 36;
else if(nGP>2800000 && nGP<=3000000) ReqLevel = 36;
else if(nGP>3000000 && nGP<=3200000) ReqLevel = 37;
else if(nGP>3200000 && nGP<=3400000) ReqLevel = 37;
else if(nGP>3400000 && nGP<=3600000) ReqLevel = 38;
else if(nGP>3600000 && nGP<=4200000) ReqLevel = 38;
else if(nGP>4200000 && nGP<=4300000) ReqLevel = 39;
else if(nGP>4300000 && nGP<=4500000) ReqLevel = 39;
else if(nGP > 4500000) ReqLevel = 40;
// if(FindSubString(oName, "epic ") >= 0)
if (GetLocalInt(oItem, "LEVEL_THIRTYSIX")== 1)
{
if(ReqLevel < 36)
{
ReqLevel = 36;
}
}
return ReqLevel;
}