Jump to content

quest script to monitor draugr death


kane4355

Recommended Posts

The first version of DKHODFightScript in your last post (that extends Quest) looks correct. You did the right thing initialising the variable to 0.

 

For the Draugr script, try this:

 

Scriptname DKQHDDraugrdeadcountscript extends ObjectReference

import ReferenceAlias

Event OnDeath(Actor akKiller) 
     ; increment dead count 
     (GetOwningQuest() as DKHODfightscript).IncrementDeadDraugr() 
endEvent

 

I think I'm starting to get the hang of quest scripts now :thumbsup:

 

The OnDeath even is an extension of the ObjectReference script, so the script must extend it. However, the function GetOwningQuest is defined in Alias script, so you can import either Alias or ReferenceAlias. The wiki suggests that ReferenceAlias is the most common script we should use, so I've imported that one. I've rewritten slightly to remove the need for the myQuestScript variable, which was causing a compilation error because it hadn't been declared.

 

Edit: I was wondering, do you need to add a check to make sure that the draugr was killed by the player only? What if another npc kills the draugr, should that kill still count???

Edited by steve40
Link to comment
Share on other sites

good point... i figured a dead draugr is a dead draugr regardless of who kills it. there are only 3 in this room and all of them need to be killed. player or companion. now, with reference alias and importing it... what reference alias does it import? do i still need to set up aliases for the draugr, assign them then script the alias and not the npc? i am still pretty new at this but i know nothing is automatic, everything has to be defined. and the other thing is what tells this script to run at stage 10? do i need to establish a "Start" function?

 

also, the script you gave me doesnt work or at least i am still getting the same problem. here is the results:

 

Starting 1 compile threads for 1 files...

Compiling "DKQHDDraugrdeadcountscript"...

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKQHDDraugrdeadcountscript.psc(7,7): GetOwningQuest is not a function or does not exist

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKQHDDraugrdeadcountscript.psc(7,24): cannot cast a none to a dkhodfightscript, types are incompatible

No output generated for DKQHDDraugrdeadcountscript, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on DKQHDDraugrdeadcountscript

 

i really do not get why it says its not a function, especially since the script grabbed from the wiki site i copied exactly and changed names.

Link to comment
Share on other sites

Uh, silly me. You'll need to put the DKQHDDraugrdeadcountscript from my last post on the draugr's quest alias rather than on the npc, otherwise there would not be an "owning quest".

 

ReferenceAlias is the ReferenceAlias script. By importing it, it makes the GetOwningQuest function accessible. Importing is a bit like extending a script, but you only get the variables and functions, not the event calls. We can't extend two scripts at once, so we have to decide which one gets priority. The alternative is to attach two scripts that each extend a different script, but we don't need to do that here.

 

I can't believe it's so hard just to get a simple death count to work :sick:

 

The wiki example is rather vague :down: If we get this working, I'll go and update that page :smile: .

Edited by steve40
Link to comment
Share on other sites

Uh, silly me. You'll need to put the DKQHDDraugrdeadcountscript from my last post on the draugr's quest alias rather than on the npc, otherwise there would not be an "owning quest".

 

ReferenceAlias is the ReferenceAlias script. By importing it, it makes the GetOwningQuest function accessible. Importing is a bit like extending a script, but you only get the variables and functions, not the event calls. We can't extend two scripts at once, so we have to decide which one gets priority. The alternative is to attach two scripts that each extend a different script, but we don't need to do that here.

 

I can't believe it's so hard just to get a simple death count to work :sick:

 

i cant believe its hard either, but unfortunately attaching it to an alias or an NPC is not going to work. i am still getting this error:

 

Starting 1 compile threads for 1 files...

Compiling "DKQHDDraugrdeadcountscript"...

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKQHDDraugrdeadcountscript.psc(7,37): GetOwningQuest is not a function or does not exist

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKQHDDraugrdeadcountscript.psc(7,54): cannot cast a none to a dkhodfightscript, types are incompatible

No output generated for DKQHDDraugrdeadcountscript, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on DKQHDDraugrdeadcountscript

Link to comment
Share on other sites

i really don't know what is up. no matter how i use that code, it still says the function does not exist. But i see it all over vanilla scripts and those work perfectly fine. what gives?

 

also, if i put this on an alias, it wouldn't be extending an object reference anymore would it?

 

EDIT: ok so ur gonna love this - once i changed the heading to "extends ReferenceAlias" - the damn thing compiled successfully. So, im willing to say that object references cannot have a Getowningquest function... why? prollie because no objects really have an owningquest, their aliases do (just a thought)

Edited by kane4355
Link to comment
Share on other sites

and to even top off the cherry, this script also compiles successfully WHEN it extends ReferenceAlias and not objectreference:

 

Scriptname DKQHDDraugrdeadcountscript extends ReferenceAlias

DKHODfightscript Property myQuestScript auto 

Event OnDeath(Actor akKiller)
       ; increment dead count
       myQuestScript = GetOwningQuest() as DKHODfightscript
       myQuestScript.IncrementDeadDraugr()
endEvent

 

still though, why i need to define myQuestScript when the "as" syntax is used and defines it... or maybe i have no clue really what that does BUT i will try out both your scripts steve, and the one above and see what really happens.

Link to comment
Share on other sites

The two scripts are essentially the same. Here's another one:

 

Scriptname DKQHDDraugrdeadcountscript extends ReferenceAlias

Event OnDeath(Actor akKiller)
       ; increment dead count
       DKHODfightscript myQuestScript = GetOwningQuest() as DKHODfightscript
       myQuestScript.IncrementDeadDraugr()
endEvent

 

Note: "as" just casts the owning quest (which would be a Quest form by default (I think), as it's main script, DKHODfightscript. It's still necessary to also initialize the variable myQuestScript before something is assigned to it. It' can be defined as a property, like you did, but it can also be defined as a local variable, like I've done here, since we don't really need it to be a property in this case.

 

The script compiles, but does the death count work though? I suspect it won't because OnDeath is an event of ObjectReference script, not ReferenceAlias script (or its parent, Alias script). :wacko:

I'm confused why importing ReferenceAlias didn't work.

Edited by steve40
Link to comment
Share on other sites

The two scripts are essentially the same. Here's another one:

 

Scriptname DKQHDDraugrdeadcountscript extends ReferenceAlias

Event OnDeath(Actor akKiller)
       ; increment dead count
       DKHODfightscript myQuestScript = GetOwningQuest() as DKHODfightscript
       myQuestScript.IncrementDeadDraugr()
endEvent

 

The script compiles, but does the death count work though? I suspect it won't because OnDeath is an event of ObjectReference script, not ReferenceAlias script (or its parent, Alias script). :wacko:

I'm confused why importing ReferenceAlias didn't work.

 

i don't know either but im gonna find out and let you know when i test it IF it works... also, the script you just shown above will not work - myQuestScript has to be defined, at least on my end otherwise it will not compile. it looks at it as a value that's undefined and targets it with "none" then says that none is an incorrect value. This what i am gathering from the errors i receive. if you look at the last script i posted, myQuestScript is defined manually within the script, so it doesn't need to be defined within the properties in the creation kit (i don't think but i will test that theory). the function for getowningquest apparently does not work at all with objectreference extensions nor does it work on imports. it has to be specific to a reference alias extension, or so this troubleshooting has shown.

Link to comment
Share on other sites

It might help you if you add debug messags to the scripts:

 

Scriptname DKQHDDraugrdeadcountscript extends ReferenceAlias

DKHODfightscript Property myQuestScript auto 

Event OnDeath(Actor akKiller)
       ; increment dead count
       Debug.Messagebox("[DKQHDDraugrdeadcountscript] OnDeath was successfully called!")
       myQuestScript = GetOwningQuest() as DKHODfightscript
       myQuestScript.IncrementDeadDraugr()
endEvent

 

Scriptname DKHODfightscript extends Quest

int Property TotalDraugr Auto
int DeadDraugr = 0
       
 function IncrementDeadDraugr()
      Debug.Messagebox("[DKHODfightscript] IncrementDeadDraugr was successfuly called!")
      DeadDraugr = DeadDraugr + 1
      if DeadDraugr >= TotalDraugr
            setStage(20)
      endif
endFunction

Link to comment
Share on other sites

okay so the verdict is out! it works. they should put a note on the wiki about how exactly that script should be assigned and that the myquestscript should be defined AND that it has to be selected under kmyquest AND that its a referencealias and not a objectreference AND it has to be attached to the alises and not the actors.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...