Jump to content

Scripting Question


David Brasher

Recommended Posts

The wiki is really short on examples. The page on AddItem only has two examples and neither one is exactly the type of thing I want to do.

; Add a two diamonds to the player's inventory, silently
Game.GetPlayer().AddItem(Diamond, 2, true)

; Move the special gem reference from wherever it is into the chest
Chest.AddItem(SpecialGemRef)

 

Source: http://www.creationkit.com/AddItem_-_ObjectReference

 

What I want to do is add one non-reference item to a vendor chest at the time when the questgiver tells you to go buy the item. But the example script with a chest only talks about moving special references. I don't want that. I want to create an item out of thin air from the object list and put it in the chest. It is what they do with the diamonds, which did not exist before the command gave them to the player.

 

So no matter how I write my quest stage result script, it never compiles. Here is one example attempt:

 

AAMyChest.AddItem(AAMyDiamond, 1)

 

The properties:

 

MiscObject Property AAMyDiamond  Auto  

Container Property AAMyChest  Auto 

Edited by David Brasher
Link to comment
Share on other sites

What errors does it give you when you say it doesn't compile? I may miss something but on first sight your example should work.

If that really doesn't work try to first create the reference with PlaceAtMe(...) then add it to the container, or if you might find it more elegant without using papyrus create the reference directly in the container from the Quest Alias window...I suppose you have the quest already and need an alias for your item.

Link to comment
Share on other sites

My gut tells me its because AddItem() is not a member function of containers. Only ObjectReference Script + Actor Script + ActiveMagicEffect Script.

 

What I would try is adding a blank leveledlist to your target merchant and calling AddForm() on it. Something like this.

Event OnInit()
xxAdditemList.AddForm(AAMyDiamond, 1, 1)
EndEvent

MiscObject Property AAMyDiamond  Auto  ;Filled to GemDiamond
LeveledItem Property xxAdditemList  Auto  ;Filled to empty leveled list

 

http://www.creationkit.com/AddForm_-_LeveledItem

http://www.creationkit.com/Revert_-_LeveledItem

 

If auiLevel gives you trouble you can try setting this parameter to whatever the players current level is like this.

Event OnInit()
xxAdditemList.AddForm(AAMyDiamond, auiLevel, auiCount)
int auiLevel = Game.GetPlayer().GetLevel()
int auiCount = 1 ;leave this static I guess?
EndEvent

 

Code compiles but I havent tested. Hope this gives you some ideas. :turned:

 

edit: I think Lukes onto something with those aliases. Aliases confuse me.. :psyduck:

Link to comment
Share on other sites

My gut tells me its because AddItem() is not a member function of containers.

You are right, I missed that on the first read, Container is the type of all containers, he needs an ObjectReference of a container.

Just need to change his "Container Property AAMyChest Auto" to "ObjectReference Property AAMyChest Auto", this way is what will allow to fill the property with the particular container, using Container there won't allow that even if it had the method.

 

edit: I think Lukes onto something with those aliases. Aliases confuse me..

 

http://www.creationkit.com/Quest_Alias_Tab to be more detailed I suggested to use "Fill type" -> "Create Reference to Object" (names in wiki may be different from actual CK, I think this was the case but I don't have the CK with me)

Edited by LukeH
Link to comment
Share on other sites

@Luke: i tried that way one time. I was trying to create a conditioned alias, making a letter spawn in a barrell only after a particular stage of the quest.

 

Unfortunately, as long as the "letter alias" was conditioned, all the other alias seemed to stop working O.o

 

I ended up putting the letter ON the barrell, so i was able to "disable" it and call enable() after the quest stage was reached lol :P

Link to comment
Share on other sites

@Luke: i tried that way one time. I was trying to create a conditioned alias, making a letter spawn in a barrell only after a particular stage of the quest.

 

Unfortunately, as long as the "letter alias" was conditioned, all the other alias seemed to stop working O.o

 

I ended up putting the letter ON the barrell, so i was able to "disable" it and call enable() after the quest stage was reached lol :P

 

By conditioned you mean optional too end you ended up with no result? In that case, right, it will have problems if used in other aliases, also remember you can refer it in aliases below itself in the list. Also all aliases are filled on quest initialization, and I believe "Initially disable" will save you the step of disabling from script, but you still have to script the enable() on the desired quest stage.

Link to comment
Share on other sites

Didn't tried that "initially disabled" stuff on the alias itself (just on the obj ref when i putted it ON the barrell).

 

I think the culprit was not checking "optional". By not doing this, the story manager didn't filled the alias and so the quest didn't start. Am I right?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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