Jump to content

OnItemAdded works for 1 keyword not for the other...


Recommended Posts

Hey all.

 

I'm a bit stumped on the OnItemEvent not firing for the PerkMagKeyword. The things is, the properties seem to be filling up, the code runs the exact same for the pFruitOrVegetable keyword and works beautifully for that, but it does not fire for the pPerkMag keyword and for the life of me I can't figure out why.

 

At first I thought this was an issue with the topic, but I added a message display as debug, this is not displaying. It's simply getting through my 'if item.hasKeyWord' statement.

 

Does anyone know what could be causing this?

I know the player alias is working, otherwise the fruit topic would not be firing.

I know all perkmags have this keyword.

 

The boolean IsWaitingtoSpeak is to prevent my character from interrupting herself when you pick up multiple items.

 

Could it perhaps be that another event is interfering... 'stealing' this particular event before I can catch it?

 

Properties:

 

 

Script:

 

Scriptname IvyPlayerInventoryFollower extends ReferenceAlias
ReferenceAlias Property p_IvyCompQAlias Auto Const

Bool Property IvyIsWaitingToSpeak = False Auto

Topic Property p_ivy_player_pickup_mlurkeggs Auto Const
Topic Property p_ivy_player_pickup_wildflowers Auto Const
Topic Property p_ivy_player_reads_skillbook Auto Const

Message Property p_ivy_sees_you_pickup_skillbook Auto Const

Potion Property pMirelurkEgg Auto Const
Keyword Property pPerkMagKeyword Auto Const
Keyword Property pFruitOrVegetable Auto Const

Event oninit()

    Addinventoryeventfilter(pMirelurkEgg)
    Addinventoryeventfilter(pPerkMagKeyword)
    Addinventoryeventfilter(pFruitOrVegetable)

Endevent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

    ;PLAYER PICKS UP MIRELURK EGGS
    Actor Ivy = p_IvyCompQAlias.GetActorRef()

    if IvyIsWaitingToSpeak == False && akBaseItem == pMirelurkEgg && Game.GetPlayer().IsInIronSights() == False && Ivy.IsInScene() == False && Game.GetPlayer().IsTalking() == False && Ivy.IsDoingFavor() == False && Ivy.IsTalking() == False
        IvyIsWaitingToSpeak = True
        Utility.Wait(1.5)
        Ivy.Say(p_ivy_player_pickup_mlurkeggs, Ivy, False, Game.GetPlayer())
        IvyIsWaitingToSpeak = False
    endif

    ;PLAYER PICKS UP WILD FLOWERS OR FRUIT
    if IvyIsWaitingToSpeak == False && akBaseItem.HasKeyword(pFruitOrVegetable) && Game.GetPlayer().IsInIronSights() == False && Ivy.IsInScene() == False && Game.GetPlayer().IsTalking() == False && Ivy.IsDoingFavor() == False && Ivy.IsTalking() == False
        IvyIsWaitingToSpeak = True
        Utility.Wait(1.5)
        Ivy.Say(p_ivy_player_pickup_wildflowers, Ivy, False, Game.GetPlayer())
        IvyIsWaitingToSpeak = False
    endif

    ;PLAYER PICKS UP A SKILL BOOK
    if akBaseItem.HasKeyword(pPerkMagKeyword)
        p_ivy_sees_you_pickup_skillbook.Show()
    endif

    if IvyIsWaitingToSpeak == False && akBaseItem.HasKeyword(pPerkMagKeyword) && Game.GetPlayer().IsInIronSights() == False && Ivy.IsInScene() == False && Game.GetPlayer().IsTalking() == False && Ivy.IsDoingFavor() == False && Ivy.IsTalking() == False
        IvyIsWaitingToSpeak = True    
        Utility.Wait(1.5)
        IvyIsWaitingToSpeak = False
        Ivy.Say(p_ivy_player_reads_skillbook, Ivy, False, Game.GetPlayer())
        IvyIsWaitingToSpeak = False
    endif
Endevent
Link to comment
Share on other sites

OK. Weird.. But fixed it after 5 minutes..

 

So this is what was happening:

 

- Ivy would not speak unless "Ivy.IsInScene() == False"

- No scenes would kick off for fruit, or mirelurks.

- A 'regular' follower scene kicks off for the companion, firing a topic about skillbooks.

- This caused Ivy to be 'In a scene'.

- By removing the 'Ivy.IsInScene() == False' from the IF statement, it suddenly worked like a charm.

 

Mystery solved!

 

Just for completion the working script:

    if IvyIsWaitingToSpeak == False && akBaseItem.HasKeyword(pPerkMagKeyword) && Game.GetPlayer().IsInIronSights() == False && Ivy.IsTalking() == False
        IvyIsWaitingToSpeak = True    
        Utility.Wait(1.5)
        IvyIsWaitingToSpeak = False
        Ivy.Say(p_ivy_player_reads_skillbook, Ivy, False, Game.GetPlayer())
        IvyIsWaitingToSpeak = False
    endif
Edited by Reginald001
Link to comment
Share on other sites

  • Recently Browsing   0 members

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