Jump to content

[LE] Requesting help with 'if(NPC.isDead)'


Recommended Posts

I am trying to finish up this quest , and this is the last piece.

 

The quest is pretty simple..

 

  • Stage 00 - Quest giver asks you to retrieve something from an NPC
  • Stage 10 - Find NPC
  • Stage 20 - Obtain item he's holding (you can either kill him or help him)
  • Stage 30 - Do NPC a favor (ending with him giving you the item from (20))
  • Stage 40 - Kill NPC (and take the item from his body)
  • Stage 50 - Meet up with quest giver and complete

____________________________________________________________________________________

 

I had to add a script for the scenario that the Player pickpockets the NPC (skips you to stage 50)

 

However theres a bigger hole I've left ... and this is where I'm asking for help

 

if you've accepted the NPCs offer to do him a favor, it sets you to stage 30
But if you kill him or pick pocket him after this moment, it activates both stages 30 & 50, causing two quest markers.

 

The idea here is If you kill/pickpocket him in between stages 30 & 40, and it forces you to complete stage 30 before 50 will activate.

I'm sure its simple but I'm new to C# and would really appreciate the advice !! Thanks

Edited by javaplaza
Link to comment
Share on other sites

So this is what I've thrown together, I placed in in the Papyrus of Stage 40.

..but I'm getting a crazy error that I can't figure out.

if (game.getPlayer().GetItemCount(A027_Q1Tools) == 1)
	SetObjectiveDisplayed(40)
else (A027_Q1Beggar.IsDead() == True) && (GetStageDone(20) == True )
	SetObjectiveDisplayed(40)
EndIf

the error ..

 

 

 

Starting 1 compile threads for 1 files...

Compiling "QF_A027_Q1Quest_02000D67"...
E:\SteamLibrary\steamapps\common\skyrim\Data\Scripts\Source\temp\QF_A027_Q1Quest_02000D67.psc(69,5): required (...)+ loop did not match anything at input '('
No output generated for QF_A027_Q1Quest_02000D67, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on QF_A027_Q1Quest_02000D67
Edited by javaplaza
Link to comment
Share on other sites

the issue is here ::

if (game.getPlayer().GetItemCount(Alias_Tools) == 1)
	SetObjectiveDisplayed(40)
endif

the errors ::

 

type mismatch on parameter 1 (did you forget a cast?)

cannot compare a none to a int (cast missing or types unrelated)

Edited by javaplaza
Link to comment
Share on other sites

removed this from Scene 40 papyrus and decided it might be better placed in the hook of the NPC (A027_Q1Beggar).

Scriptname A027_Q1BeggarScript2 extends ObjectReference  

Quest Property A027_Q1BeggarProp01  Auto  

Event OnDeath(ActorKiller)
	if (A027_Q1Beggar.IsDead() == True) && (A027_Q1Quest.GetStageDone(20) == True )
		A027_Q1BeggarProp01.SetObjectiveDisplayed(40)
		A027_Q1BeggarProp01.SetStage(40)
	else
		A027_Q1BeggarProp01.SetObjectiveDisplayed(30)
		A027_Q1BeggarProp01.SetStage(30)
endif
endEvent

and still getting a simliar error

 

 

A027_Q1BeggarScript2.psc(5,25): missing ID at ')'

 

 

ive tried changing quite a few different things, its obviously missing something.
any guidance would be forever appreciated

Edited by javaplaza
Link to comment
Share on other sites

If the script is attached to the reference, it needs to extend actor, otherwise OnDeath event will not work. Maybe even better to attach it to the alias, so it will only trigger while the quest is active. The check for IsDead seems redundant to me, since the NPC is already dead when OnDeath triggers.

This compiles, but not sure if it's doing what you want

Scriptname A027_Q1BeggarScript2 extends ReferenceAlias

Quest Property A027_Q1Quest  Auto  

Event OnDeath(Actor akKiller)
	if (A027_Q1Quest.GetStageDone(20) == True )
		A027_Q1Quest.SetObjectiveDisplayed(40)
		A027_Q1Quest.SetStage(40)
	else
		A027_Q1Quest.SetObjectiveDisplayed(30)
		A027_Q1Quest.SetStage(30)
	endif
endEvent
Link to comment
Share on other sites

There is something in mess with your code. Maybe next brings light to you.

 

your code

if (A027_Q1Beggar.IsDead() == True) && (A027_Q1Quest.GetStageDone(20) == True )

better coding as

if A027_Q1Beggar.IsDead() && A027_Q1Quest.IsStageDone(20)

the fragment code you provide us

QF_A027_Q1Quest_02000D67

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 10
Scriptname QF_A027_Q1Quest_02000D67 extends Quest Hidden
; https://forums.nexusmods.com/index.php?/topic/7612678-requesting-help-with-ifnpcisdead/


;BEGIN FRAGMENT Fragment_00
Function Fragment_00()
;BEGIN CODE
; Stage 00 - Quest giver asks you to retrieve something from an NPC

;END CODE
EndFunction
;END FRAGMENT


;BEGIN FRAGMENT Fragment_10
Function Fragment_10()
;BEGIN CODE
; Stage 10 - Find NPC

;END CODE
EndFunction
;END FRAGMENT


;BEGIN FRAGMENT Fragment_20
Function Fragment_20()
;BEGIN CODE
; Stage 20 - Obtain item he is holding (you can either kill him or help him)

;END CODE
EndFunction
;END FRAGMENT


;BEGIN FRAGMENT Fragment_30
Function Fragment_30()
;BEGIN CODE
; Stage 30 - Do NPC a favor (ending with him giving you the item from (20))

;END CODE
EndFunction
;END FRAGMENT


;BEGIN FRAGMENT Fragment_40
Function Fragment_40()
;BEGIN CODE
; Stage 40 - Kill NPC (and take the item from his body)

    IF (Game.GetPlayer().GetItemCount(A027_Q1Tools) > 0)
        SetObjectiveDisplayed(40)

    ELSEIF IsStageDone(20) && A027_Q1Beggar.IsDead()
        SetObjectiveDisplayed(40)

    ELSE
        ; nothing here
    ENDIF

;END CODE
EndFunction
;END FRAGMENT


;BEGIN FRAGMENT Fragment_50
Function Fragment_50()
;BEGIN CODE
; Stage 50 - Meet up with quest giver and complete

;END CODE
EndFunction
;END FRAGMENT


;BEGIN FRAGMENT Fragment_100
Function Fragment_100()
;BEGIN CODE
; stage 100 - stop quest

    STOP()
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

 

 

 

the actor script as follow (you has taken ObjectReference to observe the Beggar)

A027_Q1BeggarScript2

 

Scriptname A027_Q1BeggarScript2 extends Actor
; https://forums.nexusmods.com/index.php?/topic/7612678-requesting-help-with-ifnpcisdead/

; "But if you kill him or pick pocket him after this moment, it activates both stages 30 & 50, causing two quest markers."
;

  Quest PROPERTY myQuest      auto        ; myQuest == A027_Q1BeggarProp01 == A027_Q1Quest

; -- EVENT -- *** FORGET THIS ACTOR SCRIPT !! USE REFERENCEALIAS like Ghaunadaur posting above ***

EVENT OnDeath(Actor akKiller)
    IF myQuest.IsStageDone(20)
        myQuest.SetObjectiveDisplayed(40)
        myQuest.setStage(40)
    ELSE
        myQuest.SetObjectiveDisplayed(30)
        myQuest.setStage(30)
    ENDIF
ENDEVENT

 

 

 

Keep in mind objects and actors can be deleted, but only actors may die!

Edited by ReDragon2013
Link to comment
Share on other sites

I'm going to collapse (30) and (40) into one stage, I was going about this all wrong.


This is the point in the quest where the Player has to make a choice, but I set them as two separate stages (newb mistake)




Stage 30

-Option 1 : Help the old man and progress to stage 30

this is already working with no problems

-Option 2 : Kill the old man. Upon his death trigger stage 40

not sure how to set this condition since the Papyrus doesn't use Event triggers


i did add the script you provided @Ghaun , to the beggar.. and smh you're right about ondeath>ifdead ? its been quite a ride :laugh:



im going to run this and see what happens

Edited by javaplaza
Link to comment
Share on other sites

its going well honestly im learning a lot
there is just one thing in common with all my problems right now lol
  1. on npc death, scene doesn't advance [ this script is on two npcs, one death works, the other doesn't ]
  2. on picking up the tools, scene doesn't advance [ this script is on the item itself ]
  3. on taking a letter out of a satchel, scene doesn't advance [ new stage i added at the end , has also tried onRead but it didn't work either . this script is on the item itself AND the alias ]
these are Events that are written in the scripts, theyre copied perfectly so could be something ive overlooked
im calling it for today though, time to relax... heres the 3 scrips giving me a hard time. I will check back in the morning !!
Scriptname A027_Q1BeggarScript2 extends ObjectReference  

Quest Property A027_Q1BeggarProp01  Auto  

Event OnDeath(Actor Killer)
		A027_Q1BeggarProp01.SetObjectiveDisplayed(40)
		A027_Q1BeggarProp01.SetStage(40)
endEvent
Scriptname A027__Q1ToolsScript extends ObjectReference  
Quest Property A027_Q1ToolScriptProp  Auto  
Actor Property PlayerREF Auto
Quest property A027_Q1Quest Auto
Int Property iStagetoSet Auto
 
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	If akNewContainer == PlayerREF
		A027_Q1Quest.SetObjectiveCompleted(40)
		A027_Q1Quest.SetObjectiveDisplayed(45)
		A027_Q1Quest.SetStage(45)
		GoToState("Taken")
	EndIf
EndEvent
 
State Taken
	; Do nothing
EndState
Scriptname A027_Q1C_SCript extends Quest  
Quest Property A027_Q1FinalNote_Prop  Auto  
Quest Property A027_Q1Quest  Auto  
Actor Property PlayerREF Auto
Int Property iStageToSet Auto
 
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	If akNewContainer == PlayerREF
		A027_Q1Quest.SetObjectiveCompleted(60)
		A027_Q1Quest.SetObjectiveDisplayed(65)
		A027_Q1Quest.SetStage(65)
		GoToState("Taken")
	EndIf
EndEvent
 
State Taken
	; Do nothing
EndState

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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