Simple Quest Scripting help

Post » Sun Nov 18, 2012 8:27 pm

This one shouldn't take long for someone to answer.
All I need is a general "miscellaneous" quest for item collection.
I have these "notes" that I basically just want the game to tell me how many I have collected out how how many there are total.

It's been YEARS since I last touched the Construction Set and opening the Creation Kit certainly is different, so the knowledge I do have has seemed to not help me much here, so I turned to some online tutorials and tried looking for a quest that does something similar but I am just bad at this, so I think it's time I ask for a helping hand; please and thank you :)

MF
User avatar
Quick Draw III
 
Posts: 3372
Joined: Sat Oct 20, 2007 6:27 am

Post » Sun Nov 18, 2012 11:50 pm

http://www.creationkit.com/Text_Replacement
User avatar
Lewis Morel
 
Posts: 3431
Joined: Thu Aug 16, 2007 7:40 pm

Post » Mon Nov 19, 2012 11:29 am

Well...this helped a little - getting me closer.
Spoiler
  • This tag is replaced with the original full name of the object. This only works when changing a ref alias's display text.

If a tag fails to parse for any reason (invalid format, invalid param, etc) the unparsed tag is displayed in the text instead.
Example

For example, FreeformRiften04 has an objective:
"Find 20 nirnroot for Ingun Black-Briar (/)"

This will be displayed as:
"Find 20 nirnroot for Ingun Black-Briar (0/20)"

Anytime FFR04NirnCount changes, a script needs to call:
FreeformRiften04.http://www.creationkit.com/UpdateCurrentInstanceGlobal_-_Quest(FFR04NirnCount)
And then redisplay the objective. (The helper function http://www.creationkit.com/ModObjectiveGlobal_-_Quest can handle all of this in a single function call.)

Now...how does the count know what the total amount is? I imagine this is handled through the quest...so I got a new quest, now how do I make the quest start? I'd set it to start at stage 0 right? This is where it would check conditions whether to run or not, which currently I have these conditions:
GetQuestRunning [quest name obviously] == 0.00
GetIsUsedItem [thenote] == 1.00

I will probably need to set up an alias for it, right?
User avatar
Lavender Brown
 
Posts: 3448
Joined: Tue Jul 25, 2006 9:37 am

Post » Mon Nov 19, 2012 7:41 am

Yup.
User avatar
Janeth Valenzuela Castelo
 
Posts: 3411
Joined: Wed Jun 21, 2006 3:03 am

Post » Mon Nov 19, 2012 11:14 am

Yup.

If you could expand on that thought I'd appreciate it.
User avatar
Katie Pollard
 
Posts: 3460
Joined: Thu Nov 09, 2006 11:23 pm

Post » Mon Nov 19, 2012 4:58 am

I actually touched GlobalVariables for the first time with my last mod, they are really cool. You need to create a GlobalVariable specific to your quest, such as ForkCount (if forks are your item, extend this as it works for your mod). To create a GlobalVariable, you need to go under Miscellaneous -> Global. In your script, you will need to setup a property Global that points to your new GlobalVariable, before you can use it in response to the events you have listed. Properties are also needed to reference your quest and the item you are checking, if you do not already have them.
User avatar
Siobhan Wallis-McRobert
 
Posts: 3449
Joined: Fri Dec 08, 2006 4:09 pm

Post » Sun Nov 18, 2012 9:46 pm

I actually touched GlobalVariables for the first time with my last mod, they are really cool. You need to create a GlobalVariable specific to your quest, such as ForkCount (if forks are your item, extend this as it works for your mod). To create a GlobalVariable, you need to go under Miscellaneous -> Global. In your script, you will need to setup a property Global that points to your new GlobalVariable, before you can use it in response to the events you have listed. Properties are also needed to reference your quest and the item you are checking, if you do not already have them.

I'm starting out pretty raw here. I tried following a tutorial for a quest I watched but it was doing something different than I was - and I was trying to work around that until I realized they don't "count" in their quest.
So, the GlobalVariable, I imagine, will be the "note" (as I will refer to it), so what exactly do I set up in the script?

Also, again, and I am sorry if I am asking a lot more, but I need to know how to start this off - how to tell the quest to begin - which I imagine it would start on getting the first note, and then from there it just needs to count until the player receives all the notes and then the quest ends. So, where do I begin with setting this up?
User avatar
rheanna bruining
 
Posts: 3415
Joined: Fri Dec 22, 2006 11:00 am

Post » Mon Nov 19, 2012 8:42 am

A global (Global Variable) is a container that will let you save a number during a gaming session. Sometimes it will persist between save/load and sometimes it won't. Most times it will. You'll have to post again if it does not.

1. So, first create a Global - called CountMyNotes in the CK: http://www.creationkit.com/Globals (read the first section)
2. Then, add this script to each note object:

Event OnRead()GlobalVariable Property CountMyNotes  autofloat myNotes = CountMyNotes.Getvalue() + 1;so we get the current number ^^^  and then add 1CountMyNotes.Setvalue(myNotes);and then we put that value in the global-containerendEvent

NOTE: This only adds to the count if the player READS the Note. Not adds it to their inventory. But it will add 1 every time they read any of the notes ... so nothing here is handling reading Unique Notes. You could change the condition to be something other than reads ... You'd have to post again if you can't see how ...


You can see above how to retrieve the value, if you want to show it to the player in a Debug.notification (or OnScreen Help Message ... or whatever)

Hope that helps and is what you were looking for :smile:
User avatar
Trista Jim
 
Posts: 3308
Joined: Sat Aug 25, 2007 10:39 pm

Post » Sun Nov 18, 2012 9:15 pm

A global (Global Variable) is a container that will let you save a number during a gaming session. Sometimes it will persist between save/load and sometimes it won't. Most times it will. You'll have to post again if it does not.

1. So, first create a Global - called CountMyNotes in the CK: http://www.creationkit.com/Globals (read the first section)
2. Then, add this script to each note object:

Event OnRead()GlobalVariable Property CountMyNotes  autofloat myNotes = CountMyNotes.Getvalue() + 1;so we get the current number ^^^  and then add 1CountMyNotes.Setvalue(myNotes);and then we put that value in the global-containerendEvent

NOTE: This only adds to the count if the player READS the Note. Not adds it to their inventory. But it will add 1 every time they read any of the notes ... so nothing here is handling reading Unique Notes. You could change the condition to be something other than reads ... You'd have to post again if you can't see how ...


You can see above how to retrieve the value, if you want to show it to the player in a Debug.notification (or OnScreen Help Message ... or whatever)

Hope that helps and is what you were looking for :smile:

Thanks friend! I think that got pretty close to what I am looking for. It's really late (or early depending on how you look at things) here so I need to get some shut eye - not to mention sleepiness is a bad time to try and puzzle solve - but in the morning I will give it a go and see what results I turn up. At the very least I will be a few steps closer.

Now, I can tell - before ending this - there is one thing that might need to be changed on the script.
Let me explain the scenario for you so this makes a little more sense,
This is just a simple "treasure hunt" and each treasure chest contains a note. Now I am certain there is a more graceful way of keeping tally of found chests out of total chests, but I figured the easiest way would be to keep a tally of found chests by tallying the number of notes plucked from the chests.
That said, I think the best way to go about the script would not be when the player reads the note, but rather when the player retrieves the note...also, 2 questions:
(using your current script) If the player continually reads the same note over and over, would that increase the value?
(using player receiving the note script) If the player drops and picks the same note back up, that won't increase the tallied notes will it?

Thank you for your help! :smile:
User avatar
Big Homie
 
Posts: 3479
Joined: Sun Sep 16, 2007 3:31 pm

Post » Mon Nov 19, 2012 9:13 am

OK. So you would think this would be dead-easy? But it's not ... well,

FormLists. Ever used one?

So, in the CK you would create a FormList (they are in miscellaneous objects).

Then, on each Note you would add a script that used: http://www.creationkit.com/AddForm_-_FormList to add the Reference of the Note to that list. Either when onread, or oncontainerchanged, or both; that's up to you.

However, I think it would be better if you did this in a quest, you could then use Create-In Aliases to place the notes in your chests and use the Alias as the reference to add to the lists. If you did this you would add the scripts to the Alias, not to the Note-Object.



But, BEFORE you add the reference though, you would loop through any items already in the List to see if you had previously added it. If you look at this example script, maybe you can see how you would do such a test? http://www.creationkit.com/Complete_Example_Scripts#Cycle_Through_a_List_of_Objects_and_Perform_an_Action_on_Each_Object.28FormLists.29

(That's all a bit codey ... hopefully you can figure out what is going on?)


If it was not present in the list then you add it, if it was then you don't

And to report the number of "unopened chests" (or letters not read) to the player, you just have a script that counts the number in the List and subtracts that from 43 (or whatever is the total of your chests)




(this may or may not be the best way to do a treasurer hunt ... but I think it will work)
User avatar
Glu Glu
 
Posts: 3352
Joined: Sun Apr 01, 2007 5:39 am

Post » Sun Nov 18, 2012 8:23 pm

If you are only seeking to keep track of the treasure chests activated, you do not need to force the player to read the note for the update, you can query the treasure chest being activated by the player instead.

You will want to use: http://www.creationkit.com/OnActivate_-_ObjectReference

If you are stumped, here is what I came up with based on what you described.
Actor Property PlayerRefGlobalVariable Property TreasureChestCountEvent OnActivate(ObjectReference akActionRef)  if akActionRef == PlayerRef  ;This checks if the NPC/Person using the chest is the player  int treasureChestCountTemp = TreasureChestCount.GetValue() + 1  ;assigns a temporary value to the current count and adds to that count the current  TreasureChestCount.SetValue(treasureChestCountTemp)  ;sets the global count to the new value  endifEndEvent
User avatar
Jonathan Windmon
 
Posts: 3410
Joined: Wed Oct 10, 2007 12:23 pm

Post » Mon Nov 19, 2012 9:45 am

If you are only seeking to keep track of the treasure chests activated, you do not need to force the player to read the note for the update, you can query the treasure chest being activated by the player instead.

You will want to use: http://www.creationkit.com/OnActivate_-_ObjectReference

If you are stumped, here is what I came up with based on what you described.
Actor Property PlayerRefGlobalVariable Property TreasureChestCountEvent OnActivate(ObjectReference akActionRef)  if akActionRef == PlayerRef  ;This checks if the NPC/Person using the chest is the player  int treasureChestCountTemp = TreasureChestCount.GetValue() + 1  ;assigns a temporary value to the current count and adds to that count the current  TreasureChestCount.SetValue(treasureChestCountTemp)  ;sets the global count to the new value  endifEndEvent
Yeah is true ... like I hinted this is probably not the best way to do a treasurer hunt.

But given he got so far with it this way, I figured I'd continue with it and not confuse him with OnActivate on the chests

(you are correct though ... my plan was to introduce some "changes/improvements" after it's working with the (unnecessary) notes ;))
User avatar
Holli Dillon
 
Posts: 3397
Joined: Wed Jun 21, 2006 4:54 am

Post » Mon Nov 19, 2012 12:09 pm

Sorry for a delayed response - been busy with work -

At first I was thinking Arron's method would be fine, but then it occured to me that it would probably better - still - by using the number of notes as reference, this way upon loading the mod (or really the update) the number will be updated automatically according to the number of notes already in the inventory (although I am certain most people toss those scraps of paper)
-which is why I said this is probably the least graceful method of keeping track of the number of treasure chests found, but I figured it would be the easiest method since I am not very good at the CK, although this is beginning to sound really complicated something very simple...well...one would think it would be simple.
User avatar
NIloufar Emporio
 
Posts: 3366
Joined: Tue Dec 19, 2006 6:18 pm

Post » Sun Nov 18, 2012 8:15 pm

Sorry for a delayed response - been busy with work -

At first I was thinking Arron's method would be fine, but then it occured to me that it would probably better - still - by using the number of notes as reference, this way upon loading the mod (or really the update) the number will be updated automatically according to the number of notes already in the inventory (although I am certain most people toss those scraps of paper)
-which is why I said this is probably the least graceful method of keeping track of the number of treasure chests found, but I figured it would be the easiest method since I am not very good at the CK, although this is beginning to sound really complicated something very simple...well...one would think it would be simple.
Yeah, this is one of those things that you would think is dead-simple; until you try to do it.

Keeping Score: You could "force" players to keep your notes (like the jewels are stored for the ... whatever quest it is, I forget!). If you check an item as being a Quest Item, players will not be able to drop it (unless they are running one of a couple of mods which get around that "feature"). However, people will probably go hating on you, if you do.

So, the "best" way to keep score is to use a persistant global-variable ... Whether you make use of the notes, or just the chests being opened.

But, because you want to count the number of unique chests opened (and/or notes read) we have to do some work to store what object has - and so has not - been previously "used" by the player.

And a FormList is probably the easiest way to do that ...



... If this is your first mod-project then it is a reasonably difficult one to attempt - But it is achieveable (and will work) and you'll have gained some good experience with the CK and scripting if you get it done.

Post up if you need some more help :)
User avatar
Eileen Collinson
 
Posts: 3208
Joined: Thu Dec 28, 2006 2:42 am


Return to V - Skyrim