Jump to content

Item tracking script not working correctly, help :)


Recommended Posts

Ok I'm baffled. I have a quest that needs you to go and collect X of one item, Y of another item, Z of another item, etc.

 

First thing that happens is I have a quest with a player alias with a script that has an inventory event filtered check for the list of items coming or going from the player. This works fine. When the item arrives or leaves, this code section fires:

 

 

if MyQuest2.GetStage() == 20
     if akBaseItem == DwarvenCog
        CogCNT = 5
        MyObj = 20
        CogCheck()

 

checks if the main quest is at stage 20 when the item enters or leave the player, which it is. Checks if that items was the dwemer cog, which it is. Then the code sets CogCNT to 5 (the goal number of cogs to get) Sets the current Objective number from the quest for the function, then it runs the function:

 

 

Function CogCheck()
        int DwarvenCogAMT = Game.GetPlayer().GetItemCount(DwarvenCog)
        DBM_PQ_Cogs.SetValue(DwarvenCogAMT)
        if DBM_PQ_Cogs.GetValue() > CogCNT
            DBM_PQ_Cogs.SetValue(CogCNT)
        endif
        MyQuest.UpdateCurrentInstanceGlobal(DBM_PQ_Cogs)
        MyQuest.SetObjectiveDisplayed(MyObj, 1, 1)
        if DBM_PQ_Cogs.getValue() == CogCNT
            MyQuest.SetObjectiveCompleted(MyObj)
        endif
EndFunction

 

basically it checks your cog count, and if you have more cogs than are needed, it sets the quest cog count variable to the maximum (so it will show 5/5 and not 13/5 if you have more than the 5 needed) This all appears to work fine. Then if the cog count is equal to the target goal it completes the objective. This works fine as well.

 

problem is that the next line of code is screwing up somehow and progressing the base quest for this (the above stuff is on a count handler quest), and it progresses the primary quest after you have gathered enough of only ONE of the given items, rather than all of them:

 

 

    if DBM_PQ_Cogs.getValue() == CogCNT && DBM_PQ_Gears.GetValue() == GearCNT && DBM_PQ_Gyros.GetValue() == GyroCNT && DBM_PQ_Ingots.GetValue() == IngotCNT
        MyQuest2.SetStage(25)
    endif

 

It compares the variable for number of cogs found (which is set by a getitemcount on the player that is passed through to other variables to compare it to the global), to the variable for the total target. Somehow it appears to be passing all of these conditions even though it SHOULD only pass the one item and then fail until each of the item quantities are all found. I'm tearing my hair out lol. Any ideas?

Link to comment
Share on other sites

Even debugged and found that yes in fact this is the line of code which is firing the quest stage change, but there is no way it could be passing as true as all of the total goal item count properties are set at 5 or more, so getting all of what you need for one of them should not be advancing the damned stage! omg I am in smack-my-head-into-the-desk mode right now :P

 

even swapped out the condition check to be a direct item count from the player compared to the total count and it still doesn't work.

 

 

    if Game.GetPlayer().GetItemCount(DwarvenCog) >= CogCNT && Game.GetPlayer().GetItemCount(DwarvenGear) >= GearCNT && Game.GetPlayer().GetItemCount(DwarvenGyro) >= GyroCNT && Game.GetPlayer().GetItemCount(IngotDwarven) >= IngotCNT
        MyQuest2.SetStage(25)
        Debug.Notification("Skipping ahead")
    endif
Link to comment
Share on other sites

What values do the *CNT variables get initialized with? I was wondering if perhaps the GearCNT, GyroCNT, and IngotCNT might be zero when the if-statement determines if the quest should be advanced or not.

Link to comment
Share on other sites

I figured out the problem, I was defining the CNT variables inside of each conditional stage, so essentially it was registering the count of each item that WASN'T being added or removed as zero which is why they were passing. I went ahead and stuck all of the CNT defining functions at the top of the event and it began to function property. Thanks for the help folks :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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