Skip to content

How to get Level Requirement to Equip item?

Is there a function to see what level is required to equip an item?


** Side bar ** Toasts to ya'll getting the new forums back up!

Comments

  • BuddywarriorBuddywarrior Member Posts: 62
    So I found something on https://nwn.fandom.com/wiki/Item_level_restriction and tried to work with that.

    int value = GetGoldPieceValue(oTarget);
                SendMessageToPC(oPC, "value of " + GetName(oTarget) + " is : " + IntToString(value));
                if(value < 1000){   SendMessageToPC(oPC,"Requires level 1");    }
                if(value > 1000 && value < 1500){   SendMessageToPC(oPC,"Requires level 2");    }
                if(value > 1500 && value < 2500){   SendMessageToPC(oPC,"Requires level 3");    }
                if(value > 2500 && value < 3500){   SendMessageToPC(oPC,"Requires level 4");    }
                if(value > 3500 && value < 5000){   SendMessageToPC(oPC,"Requires level 5");    }
                if(value > 5000 && value < 6500){   SendMessageToPC(oPC,"Requires level 6");    }
                if(value > 6500 && value < 9000){   SendMessageToPC(oPC,"Requires level 7");    }
                if(value > 9000 && value < 12000){   SendMessageToPC(oPC,"Requires level 8");    }
                if(value > 12000 && value < 15000){   SendMessageToPC(oPC,"Requires level 9");    }
                if(value > 15000 && value < 19500){   SendMessageToPC(oPC,"Requires level 10");    }
                if(value > 19500 && value < 25000){   SendMessageToPC(oPC,"Requires level 11");    }
                if(value > 25000 && value < 30000){   SendMessageToPC(oPC,"Requires level 12");    }
                if(value > 30000 && value < 35000){   SendMessageToPC(oPC,"Requires level 13");    }
                if(value > 35000 && value < 40000){   SendMessageToPC(oPC,"Requires level 14");    }
                if(value > 40000 && value < 50000){   SendMessageToPC(oPC,"Requires level 15");    }
                if(value > 50000 && value < 65000){   SendMessageToPC(oPC,"Requires level 16");    }
                if(value > 65000 && value < 75000){   SendMessageToPC(oPC,"Requires level 17");    }
                if(value > 75000 && value < 90000){   SendMessageToPC(oPC,"Requires level 18");    }
                if(value > 90000 && value < 110000){   SendMessageToPC(oPC,"Requires level 19");    }
                if(value > 110000 && value < 130000){   SendMessageToPC(oPC,"Requires level 20");    }
                if(value > 130000 && value < 250000){   SendMessageToPC(oPC,"Requires level 21");    }
                if(value > 250000 && value < 500000){   SendMessageToPC(oPC,"Requires level 22");    }
                if(value > 500000 && value < 750000){   SendMessageToPC(oPC,"Requires level 23");    }
                if(value > 750000 && value < 1000000){   SendMessageToPC(oPC,"Requires level 24");    }
                if(value > 1000000 && value < 1200000){   SendMessageToPC(oPC,"Requires level 25");    }
                if(value > 1200000 && value < 1400000){   SendMessageToPC(oPC,"Requires level 26");    }
                if(value > 1400000 && value < 1600000){   SendMessageToPC(oPC,"Requires level 27");    }
                if(value > 1600000 && value < 1800000){   SendMessageToPC(oPC,"Requires level 28");    }
                if(value > 1800000 && value < 2000000){   SendMessageToPC(oPC,"Requires level 29");    }
                if(value > 2000000 && value < 2200000){   SendMessageToPC(oPC,"Requires level 30");    }
                if(value > 2200000 && value < 2400000){   SendMessageToPC(oPC,"Requires level 31");    }
                if(value > 2400000 && value < 2600000){   SendMessageToPC(oPC,"Requires level 32");    }
                if(value > 2600000 && value < 2800000){   SendMessageToPC(oPC,"Requires level 33");    }
                if(value > 2800000 && value < 3000000){   SendMessageToPC(oPC,"Requires level 34");    }
                if(value > 3000000 && value < 3200000){   SendMessageToPC(oPC,"Requires level 35");    }
                if(value > 3200000 && value < 3400000){   SendMessageToPC(oPC,"Requires level 36");    }
                if(value > 3400000 && value < 3600000){   SendMessageToPC(oPC,"Requires level 37");    }
                if(value > 3600000 && value < 3800000){   SendMessageToPC(oPC,"Requires level 38");    }
                if(value > 3800000 && value < 4000000){   SendMessageToPC(oPC,"Requires level 39");    }
                if(value > 4000000 && value < 4200000){   SendMessageToPC(oPC,"Requires level 40");    }
    



  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited December 2021
    That won't work because the variable value is in gold pieces and not xp. Change the function GetGoldPieceValue(); to GetXP(). From the lexicon -
    int GetXP(object oCreature);
    

    TR
  • meaglynmeaglyn Member Posts: 151
    edited December 2021
    It's supposed to be gold pieces. ILR is based on the gp value of the item.

    Edit: I'd recommend changing to "else if" for all of those though. You can then drop all the > checks and it'll generally run faster. As it is it will have to do all the tests all the time.
  • WilliamDracoWilliamDraco Member Posts: 175
    edited December 2021
    Also can really be condensed, and proofed against 2da edits, by taking advantage of said 2da.
    int iLevel;
    int iValue = GetGoldPieceValue(oTarget);
    while(iValue > StringToInt(Get2DAString("itemvalue", "MAXSINGLEITEMVALUE", iLevel))) {
      iLevel++;
    }
    SendMessageToPC(oPC,"Requires level " + IntToString(iLevel+1));
    
    (edited per meaglyn below)
    Post edited by WilliamDraco on
  • meaglynmeaglyn Member Posts: 151
    Nice! I thought there was a 2da but was too lazy to dig it up :) I think you need to print iLevel + 1, though. Row 0 is for level 1.
  • BuddywarriorBuddywarrior Member Posts: 62
    Also can really be condensed, and proofed against 2da edits, by taking advantage of said 2da.
    int iLevel;
    int iValue = GetGoldPieceValue(oTarget);
    while(iValue > StringToInt(Get2DAString("itemvalue", "MAXSINGLEITEMVALUE", iLevel))) {
      iLevel++;
    }
    SendMessageToPC(oPC,"Requires level " + IntToString(iLevel));
    

    Perfect, I'll give that a try!

  • WilliamDracoWilliamDraco Member Posts: 175
    meaglyn wrote: »
    Nice! I thought there was a 2da but was too lazy to dig it up :) I think you need to print iLevel + 1, though. Row 0 is for level 1.
    Oop correct. Should return iLevel + 1
  • BuddywarriorBuddywarrior Member Posts: 62
    meaglyn wrote: »
    Nice! I thought there was a 2da but was too lazy to dig it up :) I think you need to print iLevel + 1, though. Row 0 is for level 1.
    Oop correct. Should return iLevel + 1

    Good catch. I just ran into that issue now. well done, and thank you.
  • GenisysGenisys Member Posts: 37
    You may need this....

    int GetIdentifiedItemGPValue(object oTargetItem){
    if(GetIdentified(oTargetItem) != TRUE){ SetIdentified(oTargetItem, TRUE);
    DelayCommand(0.1, SetIdentified(oTargetItem, FALSE)); }
    if(GetPlotFlag(oTargetItem) == TRUE) {
    SetPlotFlag(oTargetItem, FALSE);
    DelayCommand(0.1, SetPlotFlag(oTargetItem, TRUE)); }
    return GetGoldPieceValue(oTargetItem);
    }
Sign In or Register to comment.