You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's stated in xOBSE documentation that IsAmmo and GetWeaponType can be called on reference. But it seems they only work if weapon reference is passed as an argument.
scn MyOnHitWithHandler
Ref target
Ref weapon
Int weaponType
Int isWeaponAmmo
begin Function { target, weapon }
PrintC "OnHit target %n, weapon %n" target weapon
let weaponType := weapon.GetWeaponType
let isWeaponAmmo := weapon.IsAmmo
PrintC "weapon %n isAmmo = %g, type = %g" weapon isWeaponAmmo weaponType
end
Run the game and hit someone
Open your logs, you'll see something like this:
[OnHit target Commoner, weapon Silver Shortsword
Error in script b24cd8c4
Attempting to call a function on a NULL reference or base object: GetWeaponType
File: IIC_AGFM.esp Offset: 0x0062 Command: GetWeaponType
Let @0062 script B24CD8C4
Error in script b24cd8c4
Attempting to call a function on a NULL reference or base object: IsAmmo
File: IIC_AGFM.esp Offset: 0x0079 Command: IsAmmo
Let @0079 script B24CD8C4
weapon Silver Shortsword isAmmo = 0, type = 0
The text was updated successfully, but these errors were encountered:
Reflecting a but: this may even not be a bug. In this context weapon is the weapon used to attack, this means that it's in the inventory. Items in inventory doesn't have a reference attached (items that already exist in the word and if I recall correctly are persistent, save their original reference in ExtraData)
So the variable passed to the item is not a reference is a base form, and the error message make perfectly sense.
Maybe I can enhance the event to pass a InventoryReference.
It's stated in xOBSE documentation that IsAmmo and GetWeaponType can be called on reference. But it seems they only work if weapon reference is passed as an argument.
Steps to reproduce:
SetEventHandler "OnHitWith" MyOnHitWithHandler
The text was updated successfully, but these errors were encountered: