Jump to content

GetObjectType problem


Oblis

Recommended Posts

Hello,

This is a part from a script I wrote that will disable the use of armor to some kind of classes like monks, mages etc.

The scripts works just fine with the only problem that it removes the clothing too.

Some clothes have the same weight with fur armor and I have to allow the use of fur armor if I rise the weight allowance.

 

Thats why I thought to use the GetObjectType to tell the script not to do this when the item is Clothing.

I typed the ( Gauntlets.GetObjectType != 22 ) etc to tell the program "If the item IS NOT Clothing and its weight IS higher that 0" then DO THE SCRIPT

But the sript is bypassing this line and keeps removing the clothes from npcs.

 

I dont know what I may havent do right.

Anyone can help?

 

 

....
....

ref ItemType

ref Weapon
ref Helmet
ref Chest
ref Greaves
ref Gauntlets
ref Boots
ref Shield 

....
,,,,

set Weapon to RAIDER.GetEquippedObject 16
set Helmet to RAIDER.GetEquippedObject 0
set Chest to RAIDER.GetEquippedObject 2
set Greaves to RAIDER.GetEquippedObject 3
set Gauntlets to RAIDER.GetEquippedObject 4
set Boots to RAIDER.GetEquippedObject 5
set Shield to RAIDER.GetEquippedObject 13

....
....

If ( Helmet.GetObjectType != 22 ) && ( Raider.GetWeight Helmet > 0 )
RAIDER.RemoveItem Helmet 1
Player.Additem Helmet 1
Endif
If ( Chest.GetObjectType != 22  ) && ( Raider.GetWeight Chest > 0 )
RAIDER.RemoveItem Chest 1
Player.Additem Chest 1
Endif
If ( Greaves.GetObjectType != 22 ) && ( Raider.GetWeight Greaves > 0 )
RAIDER.RemoveItem Greaves 1
Player.Additem Greaves 1
Endif
If ( Gauntlets.GetObjectType != 22 ) && ( Raider.GetWeight Gauntlets > 0 )
RAIDER.RemoveItem Gauntlets 1
Player.Additem Gauntlets 1
Endif
If ( Boots.GetObjectType != 22 ) && ( Raider.GetWeight Boots > 0 )
RAIDER.RemoveItem Boots 1
Player.Additem Boots 1
Endif

Link to comment
Share on other sites

GetEquippedObject returns a Base Object

. . . therefore, your ref vars Helmet, Weapon, etc contain a Base Object

. . . therefore, the GetObjectType syntax must be "GetObjectType Helmet != 22", etc

 

And you are using both a reference (Raider) and an Object (Helmet) in GetWeight (like "Raider.GetWeight Helmet". I am not sure if you will get the weight of Raider or the weight of Helmet. "GetWeight Helmet > 0 " is what you want.

Edited by QQuix
Link to comment
Share on other sites

It's not always easy to debug partial scripts, but I have a question: since you have already declared (eg. set Helmet to RAIDER.GetEquippedObject 0), is there a reason that you are using

 

If ( Helmet.GetObjectType != 22 ) && ( Raider.GetWeight Helmet > 0 )

 

rather than

 

If ( GetObjectType Helmet != 22 ) && ( GetWeight Helmet > 0 )

 

 

Meanwhile, you could probably utilise a little debugging, such as (untested):

 

Set Helmet to RAIDER.GetEquippedObject 0)
Set helmetweight to ( GetWeight Helmet )

If (helmetweight == 0)
PrintToConsole "Script reports weight is zero.  Aborting."
Return
ElseIf ( GetObjectType Helmet == 22 )
PrintToConsole "Script reports helmet is clothing.  Aborting."
Return
Else
RAIDER.RemoveItem Helmet 1
Player.Additem Helmet 1
EndIf

 

 

 

Edit: Ninja'd by QQuix

Edited by Hickory
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...