Page 1 of 1
New Modder: Input
Posted: Sun Dec 02, 2012 8:13 am
by Muralin
Hey everyone at Tamriel Rebuilt. I have recently started modding using the Morrowind CS. Having used the Oblivion one before there was really a big difference. The hardest part about the Morrowind CS is that it doesn't give any hints of your scripts having problems when you save them.
So I have a script error in my mod and im not sure how to fix it. The quest is simple: the script enables mudcrabs at the correct stage, then the player gets a quest update when the 3 mudcrabs are dead. The problem is that the quest doesn't update. I followed the enchanters rats quest scripts because it follows the same questline I am doing so im not sure what happened.
Here are my scripts:
Begin MudcrabScript
;if ( CellChanged == 0 )
; Return
;endif
short doonce
if ( doonce == -1 )
return
endif
if ( GetJournalIndex FaiythMain01 >= 20 )
if ( GetDisabled == 1 )
Enable
endif
else
if ( GetDisabled == 0 )
Disable
endif
endif
If ( OnDeath == 1 )
set crabskilled to crabskilled + 1
endif
if ( GetJournalIndex FaiythMain01 >=20 )
if ( GetJournalIndex FaiythMain01 <= 30 )
if ( crabskilled == 3 )
Journal "FaiythMain01" 30
set doonce to -1
endif
endif
endif
End
And:
Begin MudcrabKilledScript
short crabskilled
short doonce
if ( doonce == -1 )
return
endif
If ( OnDeath == 1 )
set crabskilled to crabskilled + 1
endif
if ( GetJournalIndex FaiythMain01 >=20 )
if ( GetJournalIndex FaiythMain01 <= 30 )
if ( crabskilled == 3 )
Journal "FaiythMain01" 30
set doonce to -1
endif
endif
endif
End Script
Sorry if the post is long.
Any help is appreciated and thanks in advance.
Posted: Sun Dec 02, 2012 10:36 am
by 6plus
At first glance: you need to declare crabskilled as variable
Posted: Sun Dec 02, 2012 11:04 am
by Why
Hi, welcome to the forums!
If all these scripts need to do is enable the crabs at the right stage, and update the journal once three have been killed, you're overcomplicating things a bit if you ask me. There are several ways to go about keeping track of kills - the easiest is probably to use GetDeadCount, a vanilla function that simply counts how many instances of the reference have died. If you want to use that, you can give your crabs a script like this:
Code: Select all
Begin MuralinMudcrabScript
if ( GetEnabled == 1 ) ;this block disables them initially
if ( GetJournalIndex MuralinMudcrabQuest < 20 )
Disable
endif
else ;and enables them for the quest
if ( GetJournalIndex MuralinMudcrabQuest >= 20 )
Enable
endif
endif
if ( GetJournalIndex MuralinMudcrabQuest == 20 ) ;this one counts dead crabs and updates the journal
if ( GetDeadCount MuralinMudcrab >= 3 )
Journal MuralinMudcrabQuest 30
endif
endif
End
However, GetDeadCount is known to be a slow function once your save file size increases, so you might want to consider using a global variable instead. You'll have to declare that one through the World menu if I'm not mistaken, and make each crab add 1 to its value on their death, after which they update the journal if the value reaches 3. Remember to use a global variable though - if you don't know what I mean by that, consult Morrowind Scripting For Dummies, it's a great resource - because it looks like in your own scripts you use a local variable, which is unique for each crab and thus will only record the crab's own death.
Posted: Mon Dec 03, 2012 8:20 am
by Muralin
Thank you for the help, I was able to get it to work using your much simpler script (but I had to use the GetDisabled function because it would not let me use GetEnabled). I have looked at the Morrowind Scripting for Dummies and it has shown me a lot so far. Once I get a better understanding on globals I will be switching to that instead of GetDeadCount.
For now though I am happy all the bugs have been fixed.
Thanks for helping me start my quest mod, but I have a feeling that the quests I try to make will be tougher and the bugs even worse but ill keep going.
Edit: I have another question, how would you make the script for a player and an NPC to talk to each other after they reach the required interior (the NPC follows the player until they reach the interior), I know there is a force greeting command and GetPCCell command, but how would I piece these together? I am thinking of a way but it seems like I am over-complicating the scripts again.
Posted: Mon Dec 03, 2012 11:33 am
by Why
Oops, it's GetDisabled indeed - I was doing that from memory. Good catch!
I always try to think of scripts as logical problem. If you and the NPC are in the specified cell, you want him to talk to you you, once, I assume. Since your NPC is following the player we can assume they're always in the same cell (and if your follower is lagging behind, by attaching the script to your NPC you make sure the script only runs when the NPC is in the same cell anyway, so we don't really need to worry about the NPC and the player being in different cells. All in all, the section that makes the talking happen should look something like this:
Code: Select all
short doOnce
if ( doOnce == 0 )
if ( GetPCCell "Your cell" == 1 )
ForceGreeting
set doOnce to 1
endif
endif
That should make him talk to you, once, if you're both in that cell. You can use other thing for doOnce, too, for instance, if you want this NPC to stop following you once he's talked to you, you can use GetAIPackage instead of doOnce and AIWander instead of setting doOnce to 1.
It's also a good idea to incorporate a MenuMode check in there somewhere - we don't want the NPC to greet the player over and over, and dialog technically counts as a menu. In the example above it's not really necessary since it only ever greets once anyway, but I can imagine situations where it is important.
Posted: Thu Dec 06, 2012 7:20 am
by Muralin
Thanks for helping this beginning modder Why, Tamriel Rebuilt is such a great community. My mod is on its way and I hope it turns out to be a great quest mod. Is it okay to keep posting on this thread if I have any problems in the future?
Posted: Thu Dec 06, 2012 11:17 am
by Why
sure, good luck with your mod, feel free to consider showcasing it once it's near-finished some time. We could use more questers.