Jump to content

How to end quest when NPCs die?


Nutulator

Recommended Posts

You can put a script on all of them(just make one script and just add it to all of them) and use a count that increments after each death.

Scriptname myNPCAliasScript extends ReferenceAlias
 
Int property iDeathCount  auto
 
Event OnDeath(Actor akKiller)
if iDeathCount == 12
   GetOwningQuest().Stop() ; or SetCurrentStageID(stage you want the quest to complete on), etc
else
   iDeathCount += 1
Endif
EndEvent
Edited by TummaSuklaa
Link to comment
Share on other sites

Ah okay, thanks! I've put in the script on all the NPCs but I'm missing something--it's not exactly working. You mentioned a count that increments after each death, is that iDeathCount += 1, or would I have to set that up separately?

Edited by Nutulator
Link to comment
Share on other sites

Yes, the thing the event will check is if iDeathCount is already 12, and if not, iDeathCount will add 1 to itself every time an alias dies with that script attached, until it reaches 12.

 

All you have to do is copy the script or at least include the lines if you have other things you want to happen when they die.

 

Post if you have problems, there's more than one way to do what you want - that way however is easier for me.

Edited by TummaSuklaa
Link to comment
Share on other sites

Alright, this one is a little more complicating.

 

You need to add a ReferenceAlias array property to a quest script. If your quest doesn't have one, create it. Make sure it's not "const".

 

Once you set up the property make sure to fill the array with your 12 aliases, and be sure to remove the last element after the 12th.

 

You'll need a way to call a quest stage that calls one function I've made(out of three). You can use the script above for that but put it on ONE alias. Otherwise all 12 could potentially be calling OnDeath/SetCurrentStageID/Stop() unnecessarily.

 

So with that said.. put this in your quest script.

ReferenceAlias[] property myAliases auto

Int Function CheckForDeadAliases()
int iCount
int i = 0
int iIndex = myAliases.Length
While i < iIndex
    if myAliases[i].isDead()
        iCount += 1
        i += 1
    else
        i += 1
    endif
EndWhile

return iCount

EndFunction

Function RunTimer()
if CheckForDeadAliases() == 12
    Stop() ; again or just SetCurrentStageID(stagehere)
else
    StartTimer(10)
endif
EndFunction

Event OnTimer(Int aiTimerID)
    if CheckForDeadAliases() == 12
        Stop()
    else
        StartTimer(10)
    endif
EndEvent

The function "RunTimer" needs to go in a stage fragment that your alias with the OnDeath script will set upon death.

 

In the stage fragment is a drop down to select your quest script(not sure how much you know, so I'm explaining everything).

Then put this in the field:

kmyQuest.RunTimer()

This should in theory check every 10 seconds if all of them are dead. RunTimer is only called once. The event will keep calling itself until CheckForDeadAliases reaches 12.

Edited by TummaSuklaa
Link to comment
Share on other sites

Ahh, okay. It compiles now but the quest still isn't ending--there's something very simple which I'm screwing up on. I'll keep at it and I'll figure it out eventually; thanks for all the help, I really appreciate it.

Edited by Nutulator
Link to comment
Share on other sites

  • Recently Browsing   0 members

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