QuentinVance Posted August 4, 2017 Share Posted August 4, 2017 (edited) So, just as the topic's title says, I'm searching for a way to check if a group of characters are dead.âI'm currently using a Trigger which, while the player stands in it, simply checks if all characters are dead f getStage QUEST == 15 if Character1.GetDead == 1 if Character2.GetDead == 1 if Character3.GetDead == 1 setStage QUEST 20 setObjectiveCompleted QUEST 21 1 setObjectiveDisplayed QUEST 30 1 endif endif endifendifEND Might not look like the best way (and I admit, when I used to code stuff I wasn't quite a good coder) but I figured out that since they all need to be dead at the same time, I don't really need to GECK to check different possible combinations of who's dead and who's not. One more thing: this stage of the quest has influence on the last one, during which a different message is displayed depending on which stage was achieved when completing this part of the quest.What happens is, the script works (the Geck does not give any errors), the last part of the quest actually changes showing the correct message, but the objective itself doesn't gray out as if it was completed and the objective markers still point to the corpses of the characters. So I'm wondering, is there a better way to check if the characters are dead and be sure objective markers stop pointing at them if they are? EDIT: I don't understand why the code button keeps putting the code outside its box, let's say I'll just leave it that way. Edited August 4, 2017 by QuentinVance Link to comment Share on other sites More sharing options...
GimmeBackMyMoney Posted August 4, 2017 Share Posted August 4, 2017 Not sure on answering your original question completely, but you can definitely simplify that code block to: if Character1.GetDead && Character2.GetDead && Character3.GetDead setStage QUEST 20 setObjectiveCompleted QUEST 21 1 setObjectiveDisplayed QUEST 30 1 endif That way, the code within the block will only execute if all three are dead. So far, multiple conditions are the only way I know of doing this, though I wonder if anyone could suggest a way of doing this with JIP's NVSE extended functions. Link to comment Share on other sites More sharing options...
QuentinVance Posted August 4, 2017 Author Share Posted August 4, 2017 I guess that's great already, I didn't expect the Geck to allow AND or OR conditions. I guess I've underestimated it. Link to comment Share on other sites More sharing options...
dubiousintent Posted August 4, 2017 Share Posted August 4, 2017 NVSE adds "While ... Do" and "ForEach" loops. You could use those to check an unknown number of individuals and set flags/counters, and then process individual conditions as appropriate. Also, don't overlook the additional functionality provided by the "JIP LN" extension to NVSE. -Dubious- Link to comment Share on other sites More sharing options...
Ladez Posted August 5, 2017 Share Posted August 5, 2017 Not sure on answering your original question completely, but you can definitely simplify that code block to: if Character1.GetDead && Character2.GetDead && Character3.GetDead setStage QUEST 20 setObjectiveCompleted QUEST 21 1 setObjectiveDisplayed QUEST 30 1 endif That way, the code within the block will only execute if all three are dead.It's simpler, but it doesn't perform as well. The whole line is evaluated, even if the first function call returns false. Not that it's a big deal with event-type blocks like OnTriggerEnter, but it's something to consider when writing quest/object scripts that run every frame or at a low enough interval. So far, multiple conditions are the only way I know of doing this, though I wonder if anyone could suggest a way of doing this with JIP's NVSE extended functions.I'll give it a try. Here's a user defined function: scn GetAllDead array_var aPeople array_var aEntry ref rActor int iDead begin Function {aPeople} foreach (aEntry <- aPeople) let rActor := *aEntry let iDead += rActor.GetDead loop SetFunctionValue (iDead == ar_Size aPeople) end And then you could do this: if eval (Call GetAllDead (ar_List Character1, Character2, Character3)) SetObjectiveCompleted QUEST 21 1 SetObjectiveDisplayed QUEST 30 1 endif Or use a form list: if eval (Call GetAllDead (GetListForms MyHitList)) SetObjectiveCompleted QUEST 21 1 SetObjectiveDisplayed QUEST 30 1 endif All using NVSE, no JIP. Although, I wouldn't do this unless I was using NVSE anyways. No reason to add a dependency when a bunch of GetDead calls is going to work just fine. Link to comment Share on other sites More sharing options...
GimmeBackMyMoney Posted August 5, 2017 Share Posted August 5, 2017 (edited) That's awesome, thanks Ladez! It's simpler, but it doesn't perform as well. The whole line is evaluated, even if the first function call returns false. Not that it's a big deal with event-type blocks like OnTriggerEnter, but it's something to consider when writing quest/object scripts that run every frame or at a low enough interval. That's something I hadn't considered and I have quite a few GameMode scripts with multiple If conditions, so this is definitely useful to know. Edited August 5, 2017 by GimmeBackMyMoney Link to comment Share on other sites More sharing options...
SGTbayk47 Posted August 7, 2017 Share Posted August 7, 2017 To stop the objective markers from displaying once the NPC is dead, add a 'GetDead 'NPCRef' == 0' condition to the marker in the quest. So if they are not dead, the marker will show, but will disappear when the NPC dies. Link to comment Share on other sites More sharing options...
Recommended Posts