Ashenfire Posted September 30, 2012 Share Posted September 30, 2012 How do I have a script detect if a player has a specific item in inventory, like an amulet? Link to comment Share on other sites More sharing options...
Ghaunadaur Posted September 30, 2012 Share Posted September 30, 2012 Depends. Where do you want the script put at and when is it supposed to fire? Surely you will need a property for the item reference... ObjectReference Property ItemRef auto ...and a condition using GetItemCount(). If (Game.GetPlayer().GetItemCount(ItemRef) > 0) ; do stuff endif Link to comment Share on other sites More sharing options...
Ez0n3 Posted September 30, 2012 Share Posted September 30, 2012 (edited) Careful with "ObjectReference" Properties, as they are persistent. Plus GetItemCount expects a Form. That should only be used when you need a specific reference. ObjectReference Property ItemRef auto ; persistentIf (Game.GetPlayer().GetItemCount(ItemRef.GetBaseObject()) > 0) ; do stuff EndIfIf you don't need the specific reference, better to use the actual form (and a player ref property for a speed boost) Actor Property PlayerRef Auto Form Property ItemForm auto ; not persistent If (PlayerRef.GetItemCount(ItemForm) > 0) ; do stuff EndIfSometimes it must be more specific, but I'm not sure off hand what an amulet would fall under. Using a book instead: Actor Property PlayerRef Auto Book Property ItemBook Auto ; not persistent If (PlayerRef.GetItemCount(ItemBook as Form) > 0) ; do stuff EndIf Edited September 30, 2012 by Ez0n3 Link to comment Share on other sites More sharing options...
Ashenfire Posted September 30, 2012 Author Share Posted September 30, 2012 (edited) The form was a problem for me. I never got Aliases to work for me. I found a work around by naming them in the fragment scriptor using the properties button in the fragment script area. So far it works for me. I did this for the amulet and the book I wrote so I know it works. The problem is when the characters inmy mod try to detect the amulet and book they don't do it. In fact the scrtipts from wiki like the one you gave, never compile. I have an amulet aliased in the fragment script called ANAngisHeirloom. I already created the property.Amulets are listed as ARMOR property. I can't seem to get the form to work. I am still going over what you posted, I couldn't get the script to compile because the form and other parts of the codeare causing errors on compiling. I was hoping that there was another way without the form. The wiki site has 2 references on how to detect inventory itemsbut I am having difficulty making them work. I am very old school (d.o.s, basica, turbopascal) and all this new programming stuff is greek to me. I was planning to detect the amulet on a person's inventory during dialogue with an NPC, they would then at that timetake it and set a stage. I already accomplished this part, the problem is that the dialogue has an alternate option the charactercan do and its still needed to check the players inventory for the amulet and set the stage to a different number if the amulet wasnot acquired when asked to get it. Edited September 30, 2012 by Ashenfire Link to comment Share on other sites More sharing options...
Ez0n3 Posted September 30, 2012 Share Posted September 30, 2012 If it's an alias, then maybe something like this:Actor Property PlayerRef Auto ReferenceAlias Property TheAmuletAlias AutoIf (PlayerRef.GetItemCount(TheAmuletAlias.GetReference().GetBaseObject()) > 0) ; do stuff EndIfMight want to post the script if that doesn't help. Link to comment Share on other sites More sharing options...
Ashenfire Posted September 30, 2012 Author Share Posted September 30, 2012 I'll post it then, because remember the alias.getref never works for me, I just declare it in the properties. Also would you clarify 'persistant' ? Link to comment Share on other sites More sharing options...
Ashenfire Posted September 30, 2012 Author Share Posted September 30, 2012 (edited) retreated...see below Edited September 30, 2012 by Ashenfire Link to comment Share on other sites More sharing options...
Ashenfire Posted September 30, 2012 Author Share Posted September 30, 2012 (edited) The following code works, but it is too ' linear '. A lot of my items are one of a kind unique items. They only exists 1 time in the world.So am I right to believe they need a form? I want Angi to detect if the player got her amulet THEN set the stage or givethe player a reward. I don't want to anticipate every dialogue and stage for the quest.It is a bit redundent giving 3 to 5 dialogue routines just for 1 reward to take in account different probabilities like when certain npc is dead, another is alive,out of 3 amulets how many did you find....too much to keep track of. I want to be more flexible when characters find unique items it will give newspontaneous dialogue with many characters. GetOwningQuest().Setstage(20) ; Angi now likes characterGame.GetPlayer().Additem(Gold001,1000)Game.GetPlayer().RemoveItem(ANAngisHeirloom,1) ;rem define gold001 in properties as MISCOBJECT;rem define ANAngisHeirloom in properties as ARMOR As you see above, the script ASSUMES player has the amulet.Also, what if player wants to keep the amulet? I want to detect the amuletand give the player the choice to keep it, etc. Edited September 30, 2012 by Ashenfire Link to comment Share on other sites More sharing options...
Ez0n3 Posted September 30, 2012 Share Posted September 30, 2012 (edited) Persistence (Papyrus) I haven't set up quest dialogue yet, so I can only refer you to the tutorials:Radiant QuestsPlanning the Quest Can't you just put a condition on the dialogue that offers a reward? If you have multiple items and the dialogue is the same for all, you could add them to a form list and check that instead. Forms:ItemsArmorAmulet01Amulet02Amulet03[*]MiscellaneousFormListAmuletListAmulet01Amulet02Amulet03The dialogue condition would be "GetItemCount | AmuletList | > | 0 | (run on PlayerRef)". Or in a script:Actor Property PlayerRef Auto FormList Property AmuletList Auto ;... If (PlayerRef.GetItemCount(AmuletList) > 0) ; do stuff EndIfBut this should also work:Actor Property PlayerRef Auto Armor Property ANAngisHeirloom Auto ;... If (PlayerRef.GetItemCount(ANAngisHeirloom as Form) > 0) ; do stuff EndIfAssuming you have something like this:Forms:ItemsArmorANAngisHeirloomOr you are manually assigning them. I think you need one dialogue for the reward and another if the player decides to keep it. Might want to check out Calixto Corrium's quest Blood on the Ice, it sounds similar. Edited September 30, 2012 by Ez0n3 Link to comment Share on other sites More sharing options...
Ashenfire Posted September 30, 2012 Author Share Posted September 30, 2012 I don't know how to make a form list. I will check out Calixto though. I'm trying to make the characters more smart so when a player starts talking to certain npcs, they will generate new dialogue not offered otherwise. Link to comment Share on other sites More sharing options...
Recommended Posts