Help with script statement please

Post » Sat Nov 17, 2012 8:04 am

Sorry for the extremely elementary question, but I struggle with scripting, lol. But what I'm doing is simple, so you guru's can probably clear this up blindfolded. Basically, I need to check if my quest is at a certain stage AND the player is in a certain location. If so, I need to set the next stage of my quest. I always get confused with what some things stand for like "!=" (which I think means no or not), and else's and elseif's and so forth. But basically, it needs to check those conditions, and if not valid keep running until they are, and set the next stage for me. Here's what I have so far:

Scriptname BalokDefaultArrivalSCRIPT extends Quest  Location Property HelgenLocation AutoQuest Property MyQuest  AutoInt Property stage  AutoEvent OnLocationChange(Location akOldLoc, Location akNewLoc)		if akNewLoc == HelgenLocation && ???????  ;dont know how to ask it but need to check " I'm in helgen Location AND if my quest is a certain stage, then do the next stuff"				MyQuest.SetCurrentStageID(stage) ;would like this stage to be a property so I can change the stage if I want to				Debug.Notification("Stage has been set"); I think there needs to be an else or elseif in here somewhere to start it back over if it's not valid?		endIfendEvent
User avatar
Emmanuel Morales
 
Posts: 3433
Joined: Sat Oct 06, 2007 2:03 pm

Post » Sat Nov 17, 2012 5:33 am

Balok, actually, there are two different issues you need to answer, first is the condition check, how about this:

player.IsInLocation(locationRef) && questRef.GetCurrentStageID()==10

There are diferent ways to check for the location, so how exactly you do it will depend on the second part:

Where you put this code? You can do it in the OnLocationChange Event, if you have the player in an alias. But it really depends on the big picture of what you're doing as to when you check.

References:
http://www.creationkit.com/Quest.GetStage_(Papyrus)
http://www.creationkit.com/IsInLocation_-_ObjectReference
http://www.creationkit.com/GetCurrentLocation_-_ObjectReference
User avatar
katsomaya Sanchez
 
Posts: 3368
Joined: Tue Jun 13, 2006 5:03 am

Post » Sat Nov 17, 2012 12:23 pm

Well, the whole picture is that the player has 5 guards to recruit to go back to Helgen to help protect the town. I will have each recruit ask the player if they will escort them, and if the player chooses yes, they will follow them back to Helgen. Once in the Helgen location, the follow package will become invalid, and the recruit will sandbox in the courtyard until all the other recruits have arrived. I have a scene set up after this that will run.

So, I basically need to run the check from the time the player agrees to escort the recruit to Helgen, until they safely arrive. The player is free to do a million things and the recruit will follow them perpetually until they arrive in Helgen. So I guess the check needs to run constantly until completed. Am I going about this entirely the wrong way, lol? I thought the quest stage check would ensure that the stage wouldn't be set unless the recruit was following during stage 20 of my quest.
User avatar
Mariaa EM.
 
Posts: 3347
Joined: Fri Aug 10, 2007 3:28 am

Post » Sat Nov 17, 2012 2:48 pm

What triggers the quest stage?

Maybe you could make a trigger at the destination so when they do get there, you know their location already so you just check for the NPC? Or, depending on what triggers the quest stage, you could check for the other conditions at that time?

Putting the check on the location change isn't really so bad, at least it's an event that doesn't happen that often. (I use the location change event in my carriage mod to trigger dialog, some actually is location based, and it's not bad, so I wouldn't worry so much if this is really the best way for you to implement it.)
User avatar
ashleigh bryden
 
Posts: 3446
Joined: Thu Jun 29, 2006 5:43 am

Post » Sat Nov 17, 2012 8:16 am

Once in the Helgen location, the follow package will become invalid, and the recruit will sandbox in the courtyard until all the other recruits have arrived. I have a scene set up after this that will run.

Maybe this is where you could logically do your check? There's a package end script event and fragment - maybe hook in there?
User avatar
Crystal Birch
 
Posts: 3416
Joined: Sat Mar 03, 2007 3:34 pm

Post » Sat Nov 17, 2012 3:11 pm

What triggers the quest stage?

The quest stage that starts the follow package is set via dialog when the player agrees to escort the recruit to Helgen.

I thought about just making a large trigger that only enables during the stage where the recruit is following you back to Helgen. That way I wouldn't need to really check for anything since it's ONLY enabled during the correct stage. Once the player enters the trigger it sets the stage and completes the quest. I was looking for a simpler way to basically do the same thing with a single script. Using a trigger, I would have to actually make 5 of them since I have 5 recruits all at different places in Skyrim and all of them have their own recruit quest. The other reason I didn't really want to go that route is just the sheer amount of triggers, markers and other crap in the Helgen02 cell. It's a mess, lol.

But maybe 5 triggers is the best and simplest way to do it for me since I don't know what I'm doing otherwise, lol.
User avatar
abi
 
Posts: 3405
Joined: Sat Nov 11, 2006 7:17 am

Post » Sat Nov 17, 2012 7:13 pm

From the sound of it you already have five triggers, only you call them 'recruits'. When all five of them have finished their follow packages, you want the scene to start. No?
User avatar
Anthony Santillan
 
Posts: 3461
Joined: Sun Jul 01, 2007 6:42 am

Post » Sat Nov 17, 2012 9:19 am

From the sound of it you already have five triggers, only you call them 'recruits'. When all five of them have finished their follow packages, you want the scene to start. No?

No the scene is started when you report back to the captain after recruiting everybody. The recruits are sandboxing in the courtyard then.
User avatar
Bethany Watkin
 
Posts: 3445
Joined: Sun Jul 23, 2006 4:13 pm

Post » Sat Nov 17, 2012 4:21 pm

From the sound of it you already have five triggers, only you call them 'recruits'. When all five of them have finished their follow packages, you want the scene to start. No?

I think Ingenue is also saying the what I said earlier... you already have the trigger condition set up because "something" has to change the follower package to go in to sandbox mode.

I agree, I would not want to have 5 triggers set up if I didn't have to.. kind of messy and more work to maintain/fix. So how about using the package trigger? Or the package itself? As I mentioned earlier, you could tie in to the package end script fragment and call your code there, or use the OnPackageEnd Event. (I find the OnPackageEnd event very useful in my mods.) If you don't have any code already running for those NPC's, then just use the script fragment. When the follower package ends for that NPC, call your code.
User avatar
naomi
 
Posts: 3400
Joined: Tue Jul 11, 2006 2:58 pm

Post » Sat Nov 17, 2012 11:59 am

The script I need IS what would change the follower package and make them sandbox there in the courtyard. Sorry, perhaps I was unclear in my explanation.

Stage 20 is the stage where the recruit follows you back to Helgen, stage 30 is where they sandbox in the courtyard. So I need a script that says "if my recruit quest is in stage 20 (which means the recruit is following) AND the player is in the Helgen Location, set my recruit quest to stage 30 (which invalidates the follow package and validates the sandbox package), if not, then repeat this script until all of those things are true.

I was using something similar to the code I posted with the OnLocationChange bit to check whether the player was in Helgen to enable some stuff I don't want them to see get enabled. It's essentially doing the same thing I need except it used the != instead of == so the player could NOT be in Helgen for this stuff to swap. That was a quest script that runs when I start that particular quest at the proper time and works correctly. I thought I could use something similar to do this follow quest. So I was going to try using this script we're working on as a quest script for each of my recruiting quests (I have 5 of them).
User avatar
MR.BIGG
 
Posts: 3373
Joined: Sat Sep 08, 2007 7:51 am

Post » Sat Nov 17, 2012 12:04 pm

The script I need IS what would change the follower package and make them sandbox there in the courtyard. Sorry, perhaps I was unclear in my explanation.

Lol, okay, that makes sense then. Sorry ;)

In that case, I would go with your OnChangeLocation event code, and as Ingenue suggested, attach it to the recruits (in an alias?). Then you don't have triggers and markers cluttering up Helgen and more importantly, that code is for those recruits anyway (keeps it encapsulated). So if you change the drop-off location, like having a recruit be dropped off just before Helgen, it would be easy to change for just that recruit.
User avatar
Michael Russ
 
Posts: 3380
Joined: Thu Jul 05, 2007 3:33 am

Post » Sat Nov 17, 2012 10:17 am

Why not just make these conditions on the follow packages for the recruits? GetStage MyQuest == 20 (or whatever) and e.g. GetWithinDistance Something in the courtyard > 300 - or IsInSameCurrentLocAsRef whatever, or LocationHasKeyword whatever.
User avatar
CYCO JO-NATE
 
Posts: 3431
Joined: Fri Sep 21, 2007 12:41 pm

Post » Sat Nov 17, 2012 7:07 pm

Why not just make these conditions on the follow packages for the recruits? GetStage MyQuest == 20 (or whatever) and e.g. GetWithinDistance Something in the courtyard > 300 - or IsInSameCurrentLocAsRef whatever, or LocationHasKeyword whatever.
Good idea! I really do forget what can be done with the conditions.

Balok, you will still need some code to move to the next stage which could go in your Package End fragment. If each recruit is a seperate stage, then a simple SetStageDone() call would be enough. If each recruit is not a stage and they can be recruited in any order, then you need a bit more advanced checking (still simple though). I'd put a call like "HaveAllRecruitsArrived()" in the fragment end, then in your HaveAllRecruitsArrived() function, you would check to see if all the recruits have arrived and if so, advance to the next state. How you check could be as simple as a counter or just check each recruit reference and make sure they are in the new location, or running the correct package, or whatever you know is a safe condition check.
User avatar
Jani Eayon
 
Posts: 3435
Joined: Sun Mar 25, 2007 12:19 pm

Post » Sat Nov 17, 2012 3:59 am

God, I an such an IDIOT sometimes! :swear:

NOTES TO SELF:

1) Don't assume you remember how to do something you did WEEKS ago, and double check how you did it!
2) See No. 1 before bothering the fine folks at the CK forum!
3) Don't do any of the above if you're extremely tired or stressed out, lol! (Go have a few beers, watch some tube or crank up some Queensryche instead!)

Anyway, after a good nights sleep, it occurred to my dumb ass that by using the OnLocationChange event it eliminates the need for else's, elseif's and returns or whatever. Then after reading your suggestions, I simply added a script to my recruit's alias checking where we were, and viola, it worked the first time we got to Helgen. So, I'm off to refine my quest markers and get my recruit counters plugged in. Luckily, I already had a global for them and working so it should be easy to change over.

Sometimes, I feel as if I'm hacking this stuff together with duct tape and chicken wire!

Thanks again!

:biggrin:
User avatar
Guy Pearce
 
Posts: 3499
Joined: Sun May 20, 2007 3:08 pm

Post » Sat Nov 17, 2012 12:41 pm

Lol...

2) See No. 1 before bothering the fine folks at the CK forum!

Well, that's what we're here for, to laugh at you...

I mean, to congratulate you when you get it working ;)
User avatar
Ludivine Dupuy
 
Posts: 3418
Joined: Tue Mar 27, 2007 6:51 pm


Return to V - Skyrim