Aller au contenu

Photo

GetBaseItemType function's problem


  • Veuillez vous connecter pour répondre
8 réponses à ce sujet

#1
1Ombra1

1Ombra1
  • Members
  • 24 messages
I used the GateItemBaseType function in a script, but when I tested it the script result was incorrect.
I made some tests and I found the function is returning the Column "WeaponType" from baseitem.2da not the row number.
If I use the function with a Long Sword the function returns 4, not 1 and 2 for a mace... and so on.
There is someone else with the same problem with toolset?

#2
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Can i see your code, if that is the case most of what i am doing would have some major issues.



Just to be sure, you are using GetBaseItemType(object oItem); and not something with some other name.

#3
1Ombra1

1Ombra1
  • Members
  • 24 messages
Yes I used the function GetBaseItemType

to test the returned value I used simithing like this



int MyFunction(object oItem){

int nType = GetItemBaseType(oItem); //oItem is passed

object oPC = GetFirstPC(); // used by my test



....



SendMessageToPC(oPC,"My Test message to print the nType: "+IntToString(nType));

....

}



This code prints 4 with a Long Sword, and prints 2 with a Mace, 1 for a Short Sword, 0 for Gloves... the same number in WeaponType column, not the baseitem.2da row.

#4
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
I had problems with the function before, but eventually it started working. See this thread for the scripts I used.



Regards

#5
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
I'd want to see the code you are not showing me, the "...." portion, just to make sure it's not some other issue. The devil is in the details and it means i can see the exact code copy pasted which you are trying to compile.



Just being able to review it in it's entirety might help quite a bit, might just see the solution is not altogether obvious and the only thing i know from your post is this function does not work as you expect, no way of seeing what happened to fill up nType or how you reference that weapon to begin with. I'd suggest adding



SendMessageToPC(oPC,"nType="+IntToString(nType)+" Name="+GetName(oItem) );



Where oItem is the object which you used nType on, and do this right next to where you are using said function.

#6
1Ombra1

1Ombra1
  • Members
  • 24 messages
The script is similar, I take nType with GetItemBaseType and compared it with BASE_ITEM_*

The problem is that the function return 4 with long sword not 1, 2 with a club or mace (two items with the same number returned), and the constant number in toolset for Mace Item i 113... but 113 in baseitem.2da is deleted.


#7
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Can you post the complete script?

#8
MasterChanger

MasterChanger
  • Members
  • 686 messages
Yeah, I just did a quick test and I think you've got something else going on. I'm able to use GetBaseItemType without any problems. Here's my code:

void main()
{
    object oPC = GetFirstPC();
    object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
    
    if (!GetIsObjectValid(oItem))
    {
        SendMessageToPC(oPC, "No valid item in right hand.");
        return;
    }
    
    int nType = GetBaseItemType(oItem);
    string sWepMsg = "The base item type for " + GetName(oItem) + " is: " + IntToString(nType);
    SendMessageToPC(oPC, sWepMsg);
    
}

I picked up a longsword, a greatsword, a light hammer, a battle axe, and a bastard sword. I ran this script using "rs <scriptname>" in the Console. The feedback all matched the row #'s exactly.

#9
1Ombra1

1Ombra1
  • Members
  • 24 messages
I rewrite the code in a new module and now it works fine