Creating A Function Within A Fragment

Post » Thu Jun 21, 2012 10:23 am

One of the issues I am confronting is that I need to have something reusable.

There will be a lot of in-fighting...they're bandits :)

So if I create different fights for different quests it seems to me that it would become unwieldy.

You say something about "quest script"...is that a script you'd add to the Scripts tab in a quest?
User avatar
Neko Jenny
 
Posts: 3409
Joined: Thu Jun 22, 2006 4:29 am

Post » Thu Jun 21, 2012 12:06 pm

Yes. It's better to create a new script that use the existing script (with the quest stage fragments in), because there's no risk of messing up the fragments as you edit, and it's clearer without all those comments. But in your stage fragments you can set the kmyQuest dropdown to point to your new quest script when you want to access a function, and do

kmyQuest.StartFighting()

for example.
User avatar
Max Van Morrison
 
Posts: 3503
Joined: Sat Jul 07, 2007 4:48 pm

Post » Thu Jun 21, 2012 5:37 pm

I'm sorry, that went way over my head :)

If I set it so the fight starts at a Stage then I would have to re-do the entire quest as the fight is supposed to start during the Scene dialog, right?

I mean...the quest is finished other than the fight. I would hate to have to redo it at this point.
User avatar
James Baldwin
 
Posts: 3366
Joined: Tue Jun 05, 2007 11:11 am

Post » Thu Jun 21, 2012 9:44 pm

No, that was just an example of calling a function in a quest script from a stage. It's fine to start the fight during a scene. :)
User avatar
I love YOu
 
Posts: 3505
Joined: Wed Aug 09, 2006 12:05 pm

Post » Fri Jun 22, 2012 1:14 am

Well, that takes me back to where I was.

A fight that never ends.

:confused:
User avatar
City Swagga
 
Posts: 3498
Joined: Sat May 12, 2007 1:04 am

Post » Thu Jun 21, 2012 4:13 pm

Do you have script logging enabled? Maybe that could help show what's going on.

Where do I turn on script logging?

I've looked around and can't seem to find it

Thanks!
User avatar
Princess Johnson
 
Posts: 3435
Joined: Wed Feb 07, 2007 5:44 pm

Post » Thu Jun 21, 2012 11:32 am

Attach a script to your quest. Inside this script, define a single function that will start the fight. Then, in the quest stages tab, add a fragment to the stage where you want the fight to begin, and point at the script that you stuck on the quest. Inside this fragment, simply call your function. Getting the fight to stop is as simple as having your quest progress to another stage, calling another fragment that points to your script and runs the same function with some parameter to stop the fight or a new function to stop the fight.
User avatar
SaVino GοΜ
 
Posts: 3360
Joined: Mon Sep 17, 2007 8:00 pm

Post » Thu Jun 21, 2012 5:30 pm

To clarify, you should have a script on the quest script tab with the function. Your fragment should be kmyquest extends myquestscript where myquestscript is the script with the function. Then in the fragment you do kmyquest.myfunction()
User avatar
Chris BEvan
 
Posts: 3359
Joined: Mon Jul 02, 2007 4:40 pm

Post » Thu Jun 21, 2012 7:48 pm

I think I understand better...I think...

What you're saying is that scripts are "held" or whatever in the scripts tab, sorta like a container. The functions within those scripts can then be called throughout the quest as long as the stage has been set to the particular script you'll be needing.

Is that about right?
User avatar
mollypop
 
Posts: 3420
Joined: Fri Jan 05, 2007 1:47 am

Post » Fri Jun 22, 2012 2:29 am

No, not really. Quests, like other objects, can have scripts added to them ('extending' them). These scripts can contain functions which can be called from any stage or scene phase or dialogue fragment. The only difference is that in calling them from a stage you can use the special kmyquest variable, with the kmyquest dropdown box, to avoid having to make a cast in your script. In other words, where in a scene phase you have to use something like
(GetOwningQuest() as MyQuestScript).MyFunction()
in a stage you can set the kmyQuest dropdown to MyQuestScript and then just write
  kmyQuest.MyFunction()
It's a coding convenience, that's all.

But don't put stuff starting or stopping the brawl in your quest stages - I happen to know that those are triggered by your 'detectplayer' marker, and will foul it up. The RegisterForSingleUpdate method I showed works fine.
User avatar
Mason Nevitt
 
Posts: 3346
Joined: Fri May 11, 2007 8:49 pm

Post » Thu Jun 21, 2012 10:44 am

I think I've been over-thinking all this.

When someone says "quest script" I automatically think the source code that runs the quest itself. It's been about 30 years since I programmed and I'm not used to the meaning of the word "script" as to me it means something a lot more involved than snippets of code with functions like the CK uses and it confuses the heck out of me when people use that and some other words when talking about doing things in the CK.

edit

Heck....I'm still so used to line numbers I use NotePad++ just for that reason lol
User avatar
Darlene DIllow
 
Posts: 3403
Joined: Fri Oct 26, 2007 5:34 am

Previous

Return to V - Skyrim