How do I use OnItemRemove and HasForm from a extend Quest sc

Post » Tue Jun 19, 2012 9:50 am

I need help making this work.
The extend Quest script is "start enabled".

I just want know when the player consumes an inventory item that is on a formlist - And then do something with that in the OnUpdate event of myQuest.

I've tried to make it work in a few diferent ways, with no success.
This shows what I want to do in the simplest manner:


Scriptname myQuest extends questimport formlistform myListbool property itemMatch autoEvent OnInit()	 registerForUpdate(1)endEventEvent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)  		if akBaseItem.HasForm(MyList)			 itemMatch = true			 Debug.MessageBox("item matched")		endif			 Debug.MessageBox("inventory event")endEventEvent OnUpdate()		if itemMatch == true		itemMatch = false		Debug.MessageBox("set to false")		endifendEvent

I know OnItemRemoved needs the ObjectReference script so I tried setting the script below to the above one, and I also tried just attaching them both to the myQuest script independently, but still nothing.

Scriptname RemoveItemScript extends ObjectReference[b]myQuest Property something auto[/b]Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)		Debug.MessageBox("inventory event")		itemMatch = trueendEvent
User avatar
Ysabelle
 
Posts: 3413
Joined: Sat Jul 08, 2006 5:58 pm

Post » Tue Jun 19, 2012 10:06 am

In order to attach a script to an object, that script needs to be a descendant of a type that that object has. Every script defines a type, and native scripts like the http://www.creationkit.com/Quest_Script are automatically attached to objects of the correct type by the game engine. So, in order to attach a script to a quest with no other scripts already attached, your script must extend quest.

However, the http://www.creationkit.com/OnItemRemoved_-_ObjectReference event is only called natively for http://www.creationkit.com/ObjectReference_Script, so although you can define such an event in your quest's script, it will never be called by the game.

What you want to do is add an alias to your quest that points to the player, and attach a script to this alias that extends http://www.creationkit.com/ReferenceAlias_Script. Any events called on the player will be passed to this script, so you'll be able to detect the OnItemRemoved event on the player in this way.

Cipscis
User avatar
ANaIs GRelot
 
Posts: 3401
Joined: Tue Dec 12, 2006 6:19 pm

Post » Tue Jun 19, 2012 11:08 am

Thank you, I think I finally understand and will try that.. and then to get any data I want from the ReferenceAlias script to the Quest script i just need to set the variables as properties correct?
User avatar
Jaylene Brower
 
Posts: 3347
Joined: Tue Aug 15, 2006 12:24 pm

Post » Tue Jun 19, 2012 3:38 am

If you store values in properties in your http://www.creationkit.com/ReferenceAlias_Script script then yes, they will be accessible in your http://www.creationkit.com/Quest_Script script, with the right syntax.

Cipscis
User avatar
Scotties Hottie
 
Posts: 3406
Joined: Thu Jun 08, 2006 1:40 am

Post » Tue Jun 19, 2012 8:17 am

Well, I have the inventory event triggering, but as expected I'm having trouble with the syntax in regard to sharing values.

Here are my two scripts that illustrate my problem.

Scriptname mainQuest extends questbool Property itemMatch autoEvent OnInit()  registerForUpdate(1)endEventEvent OnUpdate()  if  itemMatch == true   itemMatch = false   Debug.MessageBox("set to false!")  endif endEvent

Scriptname removeItem extends ReferenceAlias mainQuest triggertrigger = GetOwningQuest() as mainQuestEvent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)	 trigger.itemMatch = trueendEvent
User avatar
Hairul Hafis
 
Posts: 3516
Joined: Mon Oct 29, 2007 12:22 am

Post » Tue Jun 19, 2012 7:10 am

You need to use a property for your quest, which should be associated with your quest with the Creation Kit:
mainQuest Property trigger auto

Cipscis
User avatar
Jonny
 
Posts: 3508
Joined: Wed Jul 18, 2007 9:04 am

Post » Tue Jun 19, 2012 4:42 am

I've tried this in every way i can think of...not sure whats not clicking with me here but still no dice...

I'm having trouble getting newVar = GetOwningQuest() as _testCore past the compiler.
And I cant auto fill any properties in the CK

heres what i have:

my quest script

Scriptname _testCore extends Quest _testCore Property newVar autobool Property itemMatch autoEvent OnInit()  registerForUpdate(1)endEventEvent OnUpdate()  if  itemMatch == true   itemMatch = false   Debug.MessageBox("set to false!")  endif endEvent

and here is the ReferenceAlias script

Scriptname _AliasCore extends ReferenceAlias_testCore newVarnewVar = GetOwningQuest() as _testCoreEvent OnItemRemoved(Form akBaseItem, ...)  newVar.itemMatch = trueendEvent
User avatar
Kevin Jay
 
Posts: 3431
Joined: Sun Apr 29, 2007 4:29 am

Post » Tue Jun 19, 2012 10:37 am

You don't need a property in your "_testCore" script, and you should be using a property for "newVar" in your "_AliasCore" script, which should be associated with the quest with that script attached.

Cipscis
User avatar
Jaki Birch
 
Posts: 3379
Joined: Fri Jan 26, 2007 3:16 am

Post » Tue Jun 19, 2012 1:55 pm

Sorry to beat a nearly dead horse and I really appreciate the help.

In the editor, my ReferenceAlias has _AliasCore script attached with a property named newVar of type _testCore that points to my quest.

the compiler fails with "no viable alternative" for this line in the second script below:

newVar = GetOwningQuest() as _testCore

all my syntax is coming from the http://www.creationkit.com/Variables_and_Properties_%28Papyrus%29 page.

and are my properties set correctly now?

Scriptname _testCore extends Questbool itemMatchEvent OnInit()  registerForUpdate(1)endEventEvent OnUpdate()  if  itemMatch == true   itemMatch = false   Debug.MessageBox("set to false!")  endifendEvent

and

Scriptname _AliasCore extends ReferenceAlias_testcore Property newVar autonewVar = GetOwningQuest() as _testCoreEvent OnItemRemoved(Form akBaseItem,....)  newVar.itemMatch = true   Debug.MessageBox("event!")endEvent
User avatar
Susan
 
Posts: 3536
Joined: Sun Jun 25, 2006 2:46 am

Post » Tue Jun 19, 2012 4:33 am

just wanted to update that i got it working and thank again for the help

this line was not necessary: newVar = GetOwningQuest() as _testCore

All my syntax was from an example I was following on the http://www.creationkit.com/Variables_and_Properties_%28Papyrus%29 page so it may be worth taking a look at it because it may be incorrect. (or quite possibly i mininterpreted.

Here is the example i was following:

;I have a quest script with this in it:scriptName MQ01Script extends Questint property deadCount auto;I have a result script (OWNED by MQ01) with this in it:MQ01Script myQuest					   myQuest = GetOwningQuest() as MQ01Scriptfloat myDeadCount					   myQuest.deadCount = 10
User avatar
casey macmillan
 
Posts: 3474
Joined: Fri Feb 09, 2007 7:37 pm


Return to V - Skyrim