Eh...I'm not even sure that one uses bioware's values - my post took it from someplace I linked in it, which purported to use bioware values, but with the links no longer working, I have no way of checking, other than going to the 2da. And, if I'm going to do that...
int GetItemLevel(object oItem) {
int i, nMax, nValue = GetGoldPieceValue(oItem);
for (i = 0; i < 39; i++) {
nMax = StringToInt(Get2DAString("ITEMVALUE", "MAXSINGLEITEMVALUE", i));
if (nMax >= nValue)
break;
}
return i + 1;
}
EDIT: Lest you be confused, the i is row value - 0 is level one. This function will never return a 40 - 39 is considered the highest in our setup - everything else is handled by variable. If you want it to go up to 40, just add an = in the for loop, like so:
for (i = 0; i <= 39; i++) {
That's the code I yanked from our !itemlevel SIMTools command. I'm not totally sure about that, because we don't use it that often, as our ILR is mostly handled by variables, but it's likely to be correct. The only reason for my uncertainty is the existance of the TOTAL VALUEFILTER column in that 2da. If you're curious, here's our full !itemlevel code:
if (sCText == "itemlevel") {
DeleteLocalString(oCPC, "FKY_CHAT_LOCAL_CTEXT");
oCTarget = GetLocalObject(oCPC, "FKY_CHAT_TARGET");
if (!GetIsObjectValid(oCTarget)) {
FloatingTextStringOnCreature(COLOR_GOLD + REQUIRES_TARGET + COLOR_END, oCPC, FALSE);
SetLocalString(oCPC, "FKY_CHAT_COMMAND", OBJECT_TARGET + "!" + sCText);
if (!GetIsObjectValid(GetItemPossessedBy(oCPC, "fky_chat_target")))
CreateItemOnObject("fky_chat_target", oCPC);
return;
} else
DeleteLocalObject(oCPC, "FKY_CHAT_TARGET");
if (GetObjectType(oCTarget) != OBJECT_TYPE_ITEM) {
FloatingTextStringOnCreature(COLOR_RED + "You can only check requirements on items!" + COLOR_END, oCPC, FALSE);
return;
}
string sMessage = "Requirements for " + GetName(oCTarget) + ":\\n";
int i, nMax, nValue = GetGoldPieceValue(oCTarget);
int nLevel = GetLocalInt(oCTarget, "HCLevel");
if (nLevel)
sMessage += COLOR_ORANGE + " Requires level " + IntToString((nLevel > 46 ? 41 : nLevel - 6)) +
" for a hardcore character to use.\\n";
nLevel = GetLocalInt(oCTarget, "ILR");
if (nLevel <= 0) {
for (i = 0; i < 39; i++) {
nMax = StringToInt(Get2DAString("ITEMVALUE", "MAXSINGLEITEMVALUE", i));
if (nMax >= nValue)
break;
}
nLevel = i + 1;
}
sMessage += COLOR_LT_YELLOW + " Requires level " + IntToString(nLevel) + " to use.\\n";
if (GetBaseItemType(oCTarget) != BASE_ITEM_SCROLL && GetBaseItemType(oCTarget) != BASE_ITEM_SPELLSCROLL) {
nLevel = -1;
for (i = 0; i < 64; i++) {
nMax = StringToInt(Get2DAString("SKILLVSITEMCOST", "DeviceCostMax", i));
if (nMax >= nValue) {
nLevel = StringToInt(Get2DAString("SKILLVSITEMCOST", "SkillReq_class", i));
break;
}
}
if (nLevel > 0)
sMessage += COLOR_LT_YELLOW + " Requires UMD " + IntToString(nLevel) + "/" +
IntToString(nLevel + 5) + "/" + IntToString(nLevel + 10) + " to use.\\n";
else
sMessage += COLOR_LT_YELLOW + " Cannot be used with UMD.\\n";
}
SendSystemMessage(oCPC, sMessage);
}
Funky
Modifié par FunkySwerve, 22 octobre 2011 - 08:38 .