Scripting Question

Post » Fri May 27, 2011 2:21 pm

I have a quick question regarding a scripted amulet.

I made a quest which involves the player looking for and amulet and returning it to the quest giver. I put a script on this amulet, based on the one in the tutorial by Skydiver ( http://www.themcnews.com/Script.htm ). Now my problem is, if the player finds the amulet before receiving the quest, it will update to the journal entry saying he has found the amulet and should return it.
While I think the quest can be completed anyway (haven't tested), it messes up the context/consistency/reality of the quest, of course.

What can I do to avoid this problem? Add more to the script so it only updates when the quest is active? (If so, will it automatically update if the amulet has been picked up and is in the players inventory when receiving the quest?)

Delete the journal update entry script on the amulet? (Might be easiest)

Or make a script that adds the amulet to the game only after the quest has started?

Thanks for any help :)
User avatar
Nicole M
 
Posts: 3501
Joined: Thu Jun 15, 2006 6:31 am

Post » Fri May 27, 2011 11:05 am

It sounds as if the object is already placed in the world. One common solution is to disable the object until the quest is active. Without knowing the exact structure of your current script or the name of the journal you might try something along this line:

Begin AmuletScript; Attached to amuletshort doOnceif ( doOnce == 3 )   returnendifif ( OnActivate == 1 )   set doOnce to 3   Journal "YourJournal" 20 ; or whatever the name and index isendifif ( doOnce == 1 )   if ( ( GetJournalIndex "YourJournal" ) >= 10 ) ; edit as appropriate      set doOnce to 2      Enable   endifendifif ( doOnce == 0 )   set doOnce to 1   DisableendifEnd AmuletScript

User avatar
Ysabelle
 
Posts: 3413
Joined: Sat Jul 08, 2006 5:58 pm

Post » Fri May 27, 2011 8:43 am

One common solution is to disable the object until the quest is active.

That is a common solution, and the easiest to implement, but it kind of breaks immersion if the player had been to the same location before receiving the quest, the item wasn't there, and now after receiving the quest the item is in the same place he'd already looked. (Unless there's something in the quest storyline which explains this.)

An alternate method would be to script the amulet so that the journal entry for picking it up only appears if the player had received the quest. If he receives the quest after picking up the amulet, another script (probably attached to the quest giver) can give him a journal entry (something like "I already have the amulet").
User avatar
Mandi Norton
 
Posts: 3451
Joined: Tue Jan 30, 2007 2:43 pm

Post » Fri May 27, 2011 4:02 am

@cyran0
Thanks for the help. Yes, the object was placed in the world. I've tried your script but haven't managed to get it to work.. probably I've put in the wrong variables, overlooked something or spelt something wrong..

The quest outline is like this:

NPC 1: points you to questgiver = Journal entry index 10
NPC 2/Questgiver gives you the quest = Journal entry index 20
You find the amulet = Journal entry index 30
You return the amulet = Journal entry index 40

This is what I changed your script to:

begin aiy_amuletnori  short doOnce  if ( doOnce == 3 ) 	     return endif  if ( onactivate == 1 ) 	    set doOnce to 3 	   Journal "Aiy_norisamulet" 30 endif  if ( doOnce == 1 ) 	     if ( ( GetJournalIndex "Aiy_norisamulet" ) >= 20 ) 		             set doOnce to 2 		             Enable 	     endif endif  if ( doOnce == 0 ) 	     set doOnce to 1 	     Disable endif  end aiy_amuletnori


When I load the game I get the error message "EXPRESSION in aiy_amuletnori" and "Left eval" (or cval?)
But the amulet is gone from the game (I assume that's what you mean by disable), so that part must be working at least =D

@Rex, I like that idea too.. and would make more sense, yeh. I might try looking for a scripting tutorial tomorrow and see if it's not too much of a headache to learn how to write a script that does that.

Unless someone can write me one like that, of course :blush:
User avatar
Budgie
 
Posts: 3518
Joined: Sat Oct 14, 2006 2:26 pm

Post » Fri May 27, 2011 9:13 am

'Disable' means that the object is still in the game but is not being rendered so it does not appear in the world. However its script still runs and that is why this works... usually.

I cannot see an error in my syntax and the only think I cannot know with certainty is the ID of the journal. I suspect the error is there since the object disabled and in the next frame the script would begin checking the journal index. Please confirm that the ID of your journal Aiy_norisamulet is the correct spelling (is there really an 's' between 'nori' and 'amulet' for instance?).

Rex's suggestion has merit and if you choose to go in that direction he, I or anyone else may be able to help you script it, however there are two things you might consider first. I misplace my keys regularly and I can readily believe that they were always where I finally discovered them no matter how many times I checked that location before. I do not as a result doubt that my world is any less real. I accept the explanation that I merely overlooked the keys. Secondly, modders use this approach to assure that the object will be available when the quest is active. Should a player pick the object up beforehand it may be lost or sold long before it is needed to advance the quest. Do so if you wish, but be prepared to help players that no longer have the amulet.
User avatar
kasia
 
Posts: 3427
Joined: Sun Jun 18, 2006 10:46 pm

Post » Fri May 27, 2011 6:02 pm

I triple checked the ID of the journal, it is correct. Maybe I've broken something else :P I took ages getting the dialogues right earlier and changed a lot, maybe I changed something I shouldn't have (I get error messages about strings being different for topic "XXX" when I load the plugin in the CS - though it doesn't seem to affect the game). So tomorrow I'll go back to work on a previous backed up version of the plugin (before I got the errors), correct the dialogue (since I know how now) and try adding your script again to see if it works.

I see what you mean about the amulet getting lost or sold.. I'll think my options over. Thanks for your help on this so far! :)
User avatar
Josephine Gowing
 
Posts: 3545
Joined: Fri Jun 30, 2006 12:41 pm

Post » Fri May 27, 2011 11:59 am

This is a puzzle. I have recreated the elements in the construction set and I am not experiencing any error. I did discover on dumb mistake on my part - my script has no provision to pick up the amulet. Here is an updated version of the script that works perfectly in my game:

Begin Aiy_amuletnorishort doOnce if ( OnActivate == 1 ) 	if ( doOnce < 3 )		set doOnce to 3 		Journal "Aiy_norisamulet" 30 	endif	Activateendif if ( doOnce == 3 ) 	return endif if ( doOnce == 1 ) 	if ( ( GetJournalIndex "Aiy_norisamulet" ) >= 20 ) 		set doOnce to 2 		Enable 	endif endif if ( doOnce == 0 ) 	set doOnce to 1 	Disable endif End Aiy_amuletnori

The string error message you receive when starting the game (and loading the mod in the construction set) is typical after cleaning the official dialog entries that are flagged as changed where new dialog is inserted (ironic). You are correct in cleaning these supposed changes. That does not mean there are not real errors, but I seriously doubt it.

Anyone who has been modding for very long has encountered inexplicable errors that go away when you start fresh. That does not mean that you have to recreate your mod from the beginning, but you might clean everything related to the problem (objects, scripts, and journal) and reenter them. Naturally you will preserve a record of these things so you can easily recreate them. Good luck.
User avatar
Zualett
 
Posts: 3567
Joined: Mon Aug 20, 2007 6:36 pm

Post » Fri May 27, 2011 5:59 pm

Good news - I managed to get it to work :)

I did the following:
- Went to a backed up plugin before I cleaned it with Tesame the first time (so, before I cleaned the changed greeting entries)
- Corrected the false topics, greetings etc.
- Also noticed that the ID of the amulet was practically identical to the journal ID, except for a capital letter, so I changed that
- For testing, deleted my previous mod tester savegames and started fresh

Now it all works fine :) I suppose the error lay in one of the above, possibly corrupt savegame?
I've decided to keep your method of disabling the object to avoid the problem of the amulet getting lost or sold. Since it is located on a shore, one could easily say the tides moved it to where it appeared :P

Thanks for your help cyran. Now I just need to learn what the script is doing, exactly, so I can write such scripts myself some day :D
User avatar
Dylan Markese
 
Posts: 3513
Joined: Sat Dec 01, 2007 11:58 am


Return to III - Morrowind