Jump to content

GetEquippedItemType. Are duplicates the same type?


antstubell

Recommended Posts

Made a carriable lantern by duplicating torch01, altering mesh in Nifskope, duplicating torch01 and using my new lantern .nif. Works perfect... but... I now realise that adding a new object to the game when existing scripting has not taken into account that this object ever existed is a problem. I'll explain.

In one of my scripts which is used a lot in the mod player is checked to see if they are holding a torch...

GetEquippedItemType(0) == 11

It appears that my new lantern is not treated as the same type. The script is way more complex than this but for now I'm trying to resolve the question "Is my lantern treated as a torch?" and then I can proceed to iron out any conditional checks. It seems item types are fixed and are limited. Is there a way to assign an item type value to an object? How can I check the item type ID of my lantern?

Thanks.

Link to comment
Share on other sites

Duplicates should be caught as the same type as the original else mod add weapons, shields, spells etc would never be recognized. But it is always possible that with enough changes to the record, it may not be recognized. Unfortunately, I do not know what GetEquippedItemType actually looks for. Is it a pre-defined keyword? Is it a value on the NIF file itself? Is it the type of animation used? Is it a combination of these things? No idea. Perhaps the only way to know would be to dig into the EXE and see what data makes an item qualify for one of the item types.

 

All that said, your lantern is a known object. Can you not add an additional condition to check for it?

 

;myLantern -- either make a property and assign the base light record or use GetFormFromFile to assign the correct base light record
If (PlayerRef.GetEquippedItemType(0) == 11) || (PlayerRef.GetEquippedObject(0) as Light == myLantern)
  Debug.Notification("Player is carrying a light")
EndIf
Link to comment
Share on other sites

The condition function that runs on spells and perks and returns the same numerical values detects animation type, but if that was the case for the papyrus version then I would have thought your lantern would be treated as a torch. I know for example IsTorchOut recognizes other lights besides the basic torch.

 

"Is my lantern a torch" sounds like a very challenging philosophical question.

Link to comment
Share on other sites

GetEquippedObject does indeed exist. You may not be compiling with SKSE source scripts available.

 

If you are wanting to avoid SKSE, you're going to have to go about things the "long way". On a player alias script use the OnObjectEquipped and OnObjectUnequipped events and compare the equipped / unequipped object to your known lantern. Set a global variable to 1 when equipped and to 0 when unequipped. Use the global variable on the script being discussed in this thread to catch whether the player has a torch or your known lantern equipped.

Link to comment
Share on other sites

I wrote a small script to check that the lantern I made from a torch .nif are the same. Getting strange result.

 

Light Property Torch01 Auto
Light Property My_LanternCarry2m Auto
String Property NoFlame Auto
String Property EquipFlame Auto

Auto State Waiting

Event OnActivate(ObjectReference akActionRef)
; check if player has naked flame in inventory
If (Game.GetPlayer().GetItemCount(Torch01) < 1) && (Game.GetPlayer().GetItemCount(My_LanternCarry2m) < 1)
debug.notification(NoFlame)
; check player has either torch or lantern equipped
ElseIf (Game.GetPlayer().GetItemCount(Torch01) > 0) || (Game.GetPlayer().GetItemCount(My_LanternCarry2m) > 0) && (Game.GetPlayer().GetEquippedItemType(0) != 11)
debug.notification(EquipFlame)
EndIf

GoToState("Waiting")
EndEvent
EndState

 

 

What happens is this. If player has no flame source then the message "You Need A Naked Flame" appears. If player has a lantern that is not equipped then the message "Equip Your Flame Source" appears. Player equips lantern and well nothing... because I haven't scripted that far ahead but no message is good. If player equips a vanilla Torch01 then the message "Equip Your Flame Source" appears.

This script is way to simple to have an error isn't it?

Why isn't the torch recognised as type 11?

 

EDIT: I added this condition to the script.

 

If (Game.GetPlayer().GetEquippedItemType(0) == 11)
Debug.Notification ("Type 11 equipped")
EndIf

 

Now when torch is equipped I get both messages "Equip Your Flame Source" and "Type 11 equipped"

Edited by antstubell
Link to comment
Share on other sites

Try this for your debug testing purposes:

 

 

Light Property Torch01 Auto
Light Property My_LanternCarry2m Auto
String Property NoFlame Auto
String Property EquipFlame Auto

Auto State Waiting

    Event OnActivate(ObjectReference akActionRef)
        If akActionRef == Game.GetPlayer()

            ; check if player does not have torch or lantern in inventory
            If (akActionRef.GetItemCount(Torch01) < 1) && (akActionRef.GetItemCount(My_LanternCarry2m) < 1)
                debug.notification(NoFlame)

            ; check if player has either torch or lantern in inventory
            ElseIf (akActionRef.GetItemCount(Torch01) > 0) || (akActionRef.GetItemCount(My_LanternCarry2m) > 0)

                ; check if light is not equipped
                If (akActionRef.GetEquippedItemType(0) != 11)
                    debug.notification(EquipFlame)

                ; check if light is equipped
                ElseIf (akActionRef.GetEquippedItemType(0) == 11)
                    Debug.Notification ("Type 11 equipped")
                EndIf

            EndIf

        EndIf

    EndEvent

EndState

 

 

 

Link to comment
Share on other sites

Got these errors-

 

(21,32): GetEquippedItemType is not a function or does not exist

(21,55): cannot compare a none to a int (cast missing or types unrelated)

(25,36): GetEquippedItemType is not a function or does not exist

(25,59): cannot compare a none to a int (cast missing or types unrelated)

Link to comment
Share on other sites

I've another example to show. Same problem but a little more confusing it seems that the lantern is 'treated' differently depending on if it is equipped or not.

This video will explain more.

https://onedrive.live.com/?cid=B60C11D037429D8E&id=B60C11D037429D8E%2153141&parId=B60C11D037429D8E%21191&o=OneUp

 

Oops. Forgot the script.

 

ObjectReference Property LitMarker Auto
ObjectReference Property UnlitMarker Auto
Light Property HasTorch Auto
Light Property HasLantern Auto
ObjectReference Property LSource Auto
ObjectReference Property PlaySNDHere Auto
Message Property EquipTorch Auto
Message Property NeedFlame Auto
Sound Property CandleSND Auto

Bool Property SelfDis = True Auto
Bool Property SelfDel = True Auto

Auto State Waiting
Event OnActivate(ObjectReference akActionRef)

If (Game.GetPlayer().GetEquippedItemType(0) == 11)
LitMarker.disable()
UnlitMarker.enable(); optional
LSource.enable()
CandleSND.Play(PlaySNDHere); optional
; player has torch or lantern equipped candle lights

If SelfDis == True
self.Disable()
EndIf
If SelfDel == True
self.Delete()
EndIf

ElseIf (Game.GetPlayer().GetItemCount(HasTorch) < 1) && (Game.GetPlayer().GetItemCount(HasLantern) < 1)
NeedFlame.show()
; player does not have a torch or lantern

ElseIf (Game.GetPlayer().GetItemCount(HasTorch) >= 1) || (Game.GetPlayer().GetItemCount(HasTorch) >= 1) && (Game.GetPlayer().GetEquippedItemType(0) != 11)
EquipTorch.show()
; player has torch or lantern but not equipped

Endif
EndEvent
EndState

 

Edited by antstubell
Link to comment
Share on other sites

  • Recently Browsing   0 members

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