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?
GetBaseItemType function's problem
Débuté par
1Ombra1
, déc. 20 2010 09:30
#1
Posté 20 décembre 2010 - 09:30
#2
Posté 20 décembre 2010 - 09:50
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.
Just to be sure, you are using GetBaseItemType(object oItem); and not something with some other name.
#3
Posté 20 décembre 2010 - 10:14
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.
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
Posté 20 décembre 2010 - 10:42
I had problems with the function before, but eventually it started working. See this thread for the scripts I used.
Regards
Regards
#5
Posté 20 décembre 2010 - 10:59
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.
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
Posté 20 décembre 2010 - 11:05
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.
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
Posté 20 décembre 2010 - 11:43
Can you post the complete script?
#8
Posté 21 décembre 2010 - 12:37
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:
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.
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
Posté 21 décembre 2010 - 10:46
I rewrite the code in a new module and now it works fine





Retour en haut






