Jump to content

quest script to monitor draugr death


kane4355

Recommended Posts

I am at odds end here due to the fact im a noob when it comes to quests and scripting. I am trying to create a quest where the objective is to kill all the draugr in a room (3 being the number). Since i have no clue what i am doing myself as far as creating a scripot, i found cwmonitordeathquestscript and cwmonitdeathsoldierscript. They seem to be generic, however there is no properties to set except on the questscript for a setstage value which i think is only for if the count =0 (if i read the scripts correctly). I am wondering if this is the best course of action to create my quest or if i should do one from scratch, with help of course.

 

the scripts mention something about monitordeath being true or false and was wondering if i needed a fragment code in the quest itself in order to make this value true. also, what sets the number value for the number of dead draugr to monitor, which will set the stage higher for the next questline? i created 3 aliases that are referenced to leveled draugr in game and each of these aliases are scripted with the soldierscript. the quest stage that gives you the objective to kill the draugr is stage 10.

 

the scripts are as followed:

 

Scriptname CWMonitorDeathQuestScript extends Quest  
{Used with aliases who's death you want to monitor using the CWMonitorDeathSoldierScript}

int Count	;count of how many soldiers we are monitoring deaths for

int property StageToSet = 100 auto 	;what stage should be set if Count is 0 when we check for it
{Default = 100; What stage to set when all the soldiers are dead.}

Function IncrementCount()
count += 1

EndFunction

Function DecrementCount()
count -= 1
CheckCount()

EndFunction

Function CheckCount()
if Count <= 0
	setStage(StageToSet)
EndIf

EndFunction

 

Scriptname CWMonitorDeathSoldierScript extends ReferenceAlias  
{Script attached to soldier aliases in quests where the player has objective to kill all the enemy soldiers in a garrison (ex: CWMission01)}

bool MonitorDeath			;when true I should start monitoring for my death, if false I don't care if I die yet

Event OnDeath(Actor akKiller)
if MonitorDeath == True
; 		CWScript.Log("CWMonitorDeathSoldierScript", Self + "OnDeath() MonitorDeath = True, calling DecrementCount on my owning quest, and setting my variable MonitorDeath = false")

	(GetOwningQuest() as CWMonitorDeathQuestScript).DecrementCount()
	MonitorDeath = False	;this is largely irrelevant, but just incase player resurrects and kills again or something
	
EndIf

EndEvent

function StartMonitoringForDeath(bool ResetRef = True)

if ResetRef
; 		CWScript.Log("CWMonitorDeathSoldierScript", Self + "StartMonitoringForDeath() ResetRef == true, calling TryToReset()")
	TryToReset()
EndIf

if GetReference() ;If I'm not an empty alias	
; 		CWScript.Log("CWMonitorDeathSoldierScript", Self + "StartMonitoringForDeath() calling IncrementCount() on my owning quest, and setting my variable MonitorDeath = true")
	(GetOwningQuest() as CWMonitorDeathQuestScript).IncrementCount()
	MonitorDeath = True

EndIf

EndFunction

Link to comment
Share on other sites

I haven't worked with quests yet, apart from some very basic stuff.

 

From what I can tell, you should have a quest, and you should create quest aliases for each of the Draugrs you want to monitor, then attach script "CWMonitorDeathSoldierScript" to each of these aliases (which you've done correctly :thumbsup: ).

 

The script "CWMonitorDeathQuestScript" would be attached to your quest (= the owning quest). Then set the "StageToSet" property on this script to 10.

 

The number of draugr to monitor (int Count) is set by the function "StartMonitoringForDeath" on the CWMonitorDeathSoldierScript, which basically calls a function called IncrementCount() on the quest script. Calling "StartMonitoringForDeath" also sets the variable MonitorDeath to true. So it looks like you will need a fragment that calls StartMonitoringForDeath() on each of your three draugr quest aliases.

Link to comment
Share on other sites

yea thats what i thought, each alias would need the value to be true. except you cant fragment aliases, i dont think. Only fragment the stages. plus looking at the scripts, the maximum value is 100 so what tells the program to stop counting and set the higher stage? the fact that 3 draugr are tagged with the scripts? so that gives the computer its number? i cant find anything on the StartMonitoringForDeath syntax. Edited by kane4355
Link to comment
Share on other sites

So i made an attempt to see where this script works in game and the example it gives in the code, the quest doesnt exist. However, the first quest in the civil war campaign does have a "kill these dudes at the fort" quest but the break down is totally different. it just does a checkalivecount on a location reference. So i attempted to remake that on mine. However, the location reference alias can only be done on world cells and not interior cells so i am stumped >.< here is what i managed to get so far:

 

Scriptname DKHODfightscript extends Quest  Conditional

LocationRefType Property CWFortMonster Auto
LocationAlias Property myDungeon Auto

int SuccessStage = 20

Quest Property myQuest Auto

function checkLocRefTypeAliveCount()

int aliveCount = myDungeon.GetLocation().GetRefTypeAliveCount(CWFortMonster)

if aliveCount > 0
	;do nothing	
Else	
	SetStage(SuccessStage)
endif

EndFunction

 

this would have course be attached to the owning quest, however, the quest i had this on did not define it as the owning quest but it was selected as kmyQuest. if anyone wants to see what im referencing, refer to quest CW01A.

Link to comment
Share on other sites

Here is another one:

 

Scriptname DKHODfightscript extends Quest

int Property DraugrKilled auto
int Property TotalDraugr auto
ObjectReference Property DraugrMarker auto
Quest Property DKQHD01 Auto

Function KilledDraugr()
DraugrKilled += 1
if (DraugrKilled >= TotalDraugr)
	DKQHD01.SetStage(20)
endif
EndFunction

 

this one might be better to try then the others. I got it off the companion quest to kill the witches. I hope it will work and will test later. Since the quest itself was optional I am not sure if i have it coded right to be implented as essential. Also, I need to do a bit more research into what fragment needs to be used if any at all.

Link to comment
Share on other sites

Looks like you would need to put a script on each draugr, with an OnDeath event that calls KilledDraugr() on DKHODfightscript for it to work. If DKHODfightscript isn't your main quest script, you could probably just Import that script at the beginning of your main quest script code.

 

Not sure what the DraugrMarker property is for, it looks redundant.

Edited by steve40
Link to comment
Share on other sites

There was line of code i removed, thats where the Draugrmarker came in. I thought i may have needed it but i was wrong. i looked over the companion quest again and not one of the qitches has scripting on them at all - nothing that resembles a dead counter. However, looking at the aliases and objectives; the witches were aliased and set as an objective, with a condition set and that condition set was GETDEAD. So i can set mine up the same way. however here is the tricky part - this quest im working on was an optional setting and the looks of it to me is that completing it didint not bring anything forth except the availability of the heads for the later quest line. The objective index is 25 for the quest but there is no quest stage for 25, only 20 and 30. So even though you kill the witches, this script im using may prove invaluable as there is nothing of use to push it along, nor does the counter really work... or does it? i dont know and i am at a bit of amix up. havent had a chance to test it with work and all. once i can sit down to do so i can give a clear and decisive view of how I can get this to work - unless someone has a clear coat way of doing it that they can pass on?
Link to comment
Share on other sites

ok so this did set me in the right direction and i can use this. however, the script for the quest itself still leaves me with some questions: I can clearly define the property for the ttoal amount (in my case TotalDraugr), but the DeadDraugr amount must be set to a default, im assuming? when compiling it says i have to define it so i am assuming the compiler wants a default value, so i set it to 0, in hopes that it defaults to 0 and then the +1 stacks on top of that UNTIL it adds up to the TotalDraugr amount. thank god for programming essentials in college otherwise i would never understand how these things would work. I wonder if you can set arrays that can be passed on amongst scripts..... but anyways here is my quest script for all to see:

 

Scriptname DKHODfightscript extends Quest

int Property TotalDraugr Auto
int DeadDraugr = 0

 function IncrementDeadDraugr()
      DeadDraugr = DeadDraugr + 1
      if DeadDraugr >= TotalDraugr
            setStage(20)
      endif
endFunction

 

now the further question is this: do I need a fragment on stage 10 to initiate this quest or do i just select my script from the kmyQuest and assume it works?

 

now onto the draugr script itself. my question on it is this: does this script extend object reference OR Quest? How do you define a script in an object or do you point towards the quest that runs the script? i entered in the below script and i got the errors below it:

 

Scriptname DKQHDDraugrdeadcountscript extends ObjectReference  

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

 

Starting 1 compile threads for 1 files...

Compiling "DKQHDDraugrdeadcountscript"...

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKQHDDraugrdeadcountscript.psc(5,6): variable myQuestScript is undefined

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

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

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKQHDDraugrdeadcountscript.psc(5,6): type mismatch while assigning to a none (cast missing or types unrelated)

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKQHDDraugrdeadcountscript.psc(6,6): variable myQuestScript is undefined

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKQHDDraugrdeadcountscript.psc(6,20): none is not a known user-defined type

No output generated for DKQHDDraugrdeadcountscript, compilation failed.

 

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

 

 

 

SO it wants me to define myQuestScript and i have to figure out why GetOwningQuest is not a function... but yet i have seen it before. mispelling?

 

Edit: On CWMonitorDeathSoldierScript, GetOwningQuest is used a bit differently. it is used twice but as shown below:

 

(GetOwningQuest() as CWMonitorDeathQuestScript).IncrementCount()

 

totally different way of incrementing the count and on save does not mention anything about that being a misguided function. it could also be a fault because myQuestScript is not defined. and why do i need to define it IF the "as" portion sits there and tells you what script?

 

Edit2: I was able to define the property for the script - however i still get the error on the GetOwningQuest(). here is the script i have so far:

 

Scriptname DKQHDDraugrdeadcountscript extends ObjectReference 

DKHODfightscript Property myQuestScript auto 

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

 

with 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,23): GetOwningQuest is not a function or does not exist

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DKQHDDraugrdeadcountscript.psc(7,40): 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

Edited by kane4355
Link to comment
Share on other sites

  • Recently Browsing   0 members

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