Author Topic: On Equip Check Skills - Can't get this to work.  (Read 310 times)

Legacy_Peepsy

  • Jr. Member
  • **
  • Posts: 55
  • Karma: +0/-0
On Equip Check Skills - Can't get this to work.
« on: March 19, 2012, 07:24:32 pm »


                So, what I did was bundled Hide and Move Silently together as Stealth, Bluff and persuade together as Diplomacy, ect... The issue I am having, is that the script I need to make the skills artificially bump the other, will not work and I can not figure out why. 

The script

#include "nwnx_funcs"#include "x0_i0_stringlib"#include "pp_skills_inc"void main(){
    object oPC = GetPCItemLastEquippedBy();    object oItem = GetPCItemLastEquipped();
    if(!GetItemHasItemProperty(oItem, ITEM_PROPERTY_SKILL_BONUS)) {        SendMessageToPC(oPC, "No item props, returning.");        return;
    }
    int nStealth = GetItemPropertySkill(oItem, SKILL_HIDE);    int nDiplomacy = GetItemPropertySkill(oItem, SKILL_BLUFF);    int nPerception = GetItemPropertySkill(oItem, SKILL_SPOT);    int nDisableDevice = GetItemPropertySkill(oItem, SKILL_DISABLE_TRAP) ;    int nCraft = GetItemPropertySkill(oItem, SKILL_CRAFT_ARMOR);
    SendMessageToPC(oPC, "The Hide Property is: " + IntToString(nStealth));
    //Modify the skills    NWNXFuncs_ModSkill(oPC, SKILL_MOVE_SILENTLY, nStealth);    NWNXFuncs_ModSkill(oPC, SKILL_LISTEN, nPerception);    NWNXFuncs_ModSkill(oPC, SKILL_OPEN_LOCK, nDisableDevice);    NWNXFuncs_ModSkill(oPC, SKILL_PERSUADE, nDiplomacy);    NWNXFuncs_ModSkill(oPC, SKILL_SEARCH, nPerception);    NWNXFuncs_ModSkill(oPC, SKILL_SET_TRAP, nDisableDevice);    NWNXFuncs_ModSkill(oPC, SKILL_CRAFT_TRAP, nCraft);    NWNXFuncs_ModSkill(oPC, SKILL_CRAFT_WEAPON, nCraft);
    SendMessageToPC(oPC, "Successfully set skills.");    SendMessageToPC(oPC, "MS: "+IntToString(GetSkillRank(SKILL_MOVE_SILENTLY, oPC, FALSE)));    SendMessageToPC(oPC, "Listen: "+IntToString(GetSkillRank(SKILL_LISTEN, oPC, FALSE)));    SendMessageToPC(oPC, "Open Lock: "+IntToString(GetSkillRank(SKILL_OPEN_LOCK, oPC, FALSE)));    SendMessageToPC(oPC, "Persuade: "+IntToString(GetSkillRank(SKILL_PERSUADE, oPC, FALSE)));    SendMessageToPC(oPC, "Search "+IntToString(GetSkillRank(SKILL_SEARCH, oPC, FALSE)));    SendMessageToPC(oPC, "SetTrap: "+IntToString(GetSkillRank(SKILL_SET_TRAP, oPC, FALSE)));
    SetLocalInt(oItem, "Stealth_Boost", nStealth);    SetLocalInt(oItem, "Diplomacy_Boost", nDiplomacy);    SetLocalInt(oItem, "Perception_Boost", nPerception);    SetLocalInt(oItem, "DisableDevice_Boost", nDisableDevice);    SetLocalInt(oItem, "Craft_Boost", nCraft);
}

The include
// iprp_getskills - Functions to get skill bonus stats from an item.//// 2012 - eeriegeek
// Get the nth skill bonus on item oItem. Return -1 if no skill found.// Values match the SKILL_* constants and index column of skills.2da.//int GetItemPropertySkill(object oItem, int nth=1);
// Get the nth skill numeric bonus on item oItem. Return -1 if no skill found.//int GetItemPropertySkillValue(object oItem, int nth=1);
// Get the nth skill display name on item oItem. Return "" if no skill found.//string GetItemPropertySkillDisplayName(object oItem, int nth=1);
int GetItemPropertySkill(object oItem, int nth=1){    int i = 1;    itemproperty ipFoo = GetFirstItemProperty(oItem);    while (GetIsItemPropertyValid(ipFoo)) {        int nItemPropertyType = GetItemPropertyType(ipFoo);        if (nItemPropertyType == 52) {            if (i == nth) {                int nItemPropertySubType = GetItemPropertySubType(ipFoo);                return (nItemPropertySubType);            } else {                i += 1;            }        }        ipFoo = GetNextItemProperty(oItem);    }    return  -1;}int GetItemPropertySkillValue(object oItem, int nth=1){    int i = 1;    itemproperty ipFoo = GetFirstItemProperty(oItem);    while (GetIsItemPropertyValid(ipFoo)) {        int nItemPropertyType = GetItemPropertyType(ipFoo);        if (nItemPropertyType == 52) {            if (i == nth) {                int nItemPropertySubType = GetItemPropertySubType(ipFoo);                int nCostTable = GetItemPropertyCostTable(ipFoo);                int nCostTableValue = GetItemPropertyCostTableValue(ipFoo);                string sCostTable_2DA_ResRef = Get2DAString("iprp_costtable","Name",nCostTable);                string sCostTableValue_2DA_Value = Get2DAString(sCostTable_2DA_ResRef,"Value",nCostTableValue);                int iCostTableValue_2DA_Value = StringToInt(sCostTableValue_2DA_Value);                return (iCostTableValue_2DA_Value);            } else {                i += 1;            }        }        ipFoo = GetNextItemProperty(oItem);    }    return  -1;}string GetItemPropertySkillDisplayName(object oItem, int nth=1){    int i = 1;    itemproperty ipFoo = GetFirstItemProperty(oItem);    while (GetIsItemPropertyValid(ipFoo)) {        int nItemPropertyType = GetItemPropertyType(ipFoo);        if (nItemPropertyType == 52) {            if (i == nth) {                int nItemPropertySubType = GetItemPropertySubType(ipFoo);                string sItemPropertySubtype2DA = Get2DAString("itempropdef","SubTypeResRef",nItemPropertyType);                string sItemPropertySubTypeName = Get2DAString(sItemPropertySubtype2DA,"Name",nItemPropertySubType);                string sItemPropertySubTypeDialogName = GetStringByStrRef(StringToInt(sItemPropertySubTypeName));                int nCostTable = GetItemPropertyCostTable(ipFoo);                int nCostTableValue = GetItemPropertyCostTableValue(ipFoo);                string sCostTable_2DA_ResRef = Get2DAString("iprp_costtable","Name",nCostTable);                string sCostTableValue_2DA_Name = Get2DAString(sCostTable_2DA_ResRef,"Name",nCostTableValue);                string sCostTableValue_2DA_Value = Get2DAString(sCostTable_2DA_ResRef,"Value",nCostTableValue);                string sCostTableValue_Dialog_Name = GetStringByStrRef(StringToInt(sCostTableValue_2DA_Name));                int iCostTableValue_2DA_Value = StringToInt(sCostTableValue_2DA_Value);                return (sItemPropertySubTypeDialogName + " " + sCostTableValue_Dialog_Name);            } else {                i += 1;            }        }        ipFoo = GetNextItemProperty(oItem);    }    return  "";}

               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
On Equip Check Skills - Can't get this to work.
« Reply #1 on: March 19, 2012, 08:53:27 pm »


               From just a Quick look, This part:

    int nStealth = GetItemPropertySkill(oItem, SKILL_HIDE);
    int nDiplomacy = GetItemPropertySkill(oItem, SKILL_BLUFF);
    int nPerception = GetItemPropertySkill(oItem, SKILL_SPOT);
    int nDisableDevice = GetItemPropertySkill(oItem, SKILL_DISABLE_TRAP) ;
    int nCraft = GetItemPropertySkill(oItem, SKILL_CRAFT_ARMOR);

Will not work.   The Function is returning the nTh Skill Prop, Not the Skill for the Skill constant.  You will need to do something more like:

    int nStealth, nDiplomacy, nPerception, nDisableDevice, nCraft;
    int nCount,IpSkill;
    nCount =1;
    IpSkill = GetItemPropertySkill(oItem,nCount);
    while (IpSkill!= -1)
    {
      switch(IpSkill)
      {
         Case SKILL_HIDE:
            nStealth = GetItemPropertySkillValue(oItem,nCount);
            break;
         Case SKILL_BLUFF:
            nDiplomacy = GetItemPropertySkillValue(oItem,nCount);
            break;
         Case SKILL_SPOT:
            nPerception = GetItemPropertySkillValue(oItem,nCount);
            break;
         Case SKILL_DISABLE_TRAP:
             nDisableDevice = GetItemPropertySkillValue(oItem,nCount);
             break;
         Case SKILL_CRAFT_ARMOR:
            nCraft = GetItemPropertySkillValue(oItem,nCount);
            break;
      }
     nCount++;
     IpSkill = GetItemPropertySkill(oItem,nCount);
    }

Or you may just be better off ditching the current include and writing something more efficent.  Like a single function that will return the values you are looking for.  without loopint through the props twice for every skill you have on the item.  
               
               

               
            

Legacy_Peepsy

  • Jr. Member
  • **
  • Posts: 55
  • Karma: +0/-0
On Equip Check Skills - Can't get this to work.
« Reply #2 on: March 19, 2012, 09:55:03 pm »


               Thank you lightfoot. This script is working as intended now!