Jump to content

Scripting detection that enemies in cell are dead


csbx

Recommended Posts

Working on a basic quest that requires killing all ghouls in a given area that this mod adds. I'm assuming one option for detection that the player has completed this is to have a script on each added enemy with:

Event ondeath()

if ghoul1 and ghoul2 and ghoul3 and ghoul4 is dead

setstage(x) <----player has killed all quest stage

endif

 

Is there a more lightweight way of doing this ?

Link to comment
Share on other sites

AddRef() all of the hostiles to a Quest ReferenceCollection with an attached script that

Event OnDeath(ObjectReference akVictimRef, Actor akKiller)

	Self.RemoveRef(akVictimRef)
	
	If Self.GetCount() == 0 
		Self.GetOwningQuest().SetStage(X)
	Endif

EndEvent

EDIT to add my usual rider: if your spawning a large number which can OnDeath in a short period or with 3d unloaded, you may need to add a scavenge process on a timer that checks for dead refs that are still hanging in the collection.

Edited by SKK50
Link to comment
Share on other sites

@ladyonthemoon--Thanks. that looks useful, but I wasn't able to find examples of this.

 

@SKK50--That indeed looks lightweight. I've never used reference collections before so am unclear about a couple of things: 1) do you create the refcollection alias and just leave it unfilled (for the moment) in the menu ? 2) where does one Addref() enemies ? A script on each enemy (but then aren't they just re-added after death ?) ? Or within the refcollalias script ?

 

Thanks !

Link to comment
Share on other sites

hey I was assuming you are already creating the spawns in a quest script, are they individually placed in the world ? if not there are two ways of spawning:

 

1. Create a quest RefCollAlias and use that to generate the Ghouls using "Create Ref To Object" to lvlFeralGhoul on a "max Initial Fill Count". Tricky to manage timing appearance if that's delayed after quest start.

 

2. Create a MainScript on the quest [scripts] button with code to loop the creation. You can call the function from a stage or event:

While iIndex < iCount
  ObjectReference ActorRef = ThingToSpawnAt.PlaceActorAtMe(plvlFeralGhoul,  aiLevelMod)
  Alias_Baddies.Addref(ActorRef)
  iIndex +=1
EndWhile

3. if the hostiles are placed you just need a quest stage with a list of:

 

Alias_Baddies.Addref(pPropertyLinkedtoObjectRerenceOfGhoul1)

Alias_Baddies.Addref(pPropertyLinkedtoObjectRerenceOfGhoul2)

& etc

Link to comment
Share on other sites

One of the things I love about Skyrim and Fallout is that they provide you with tons of interesting and gracefully implemented mechanis to work with.

 

Don't always think straight, try to be creative. In the end it will teach you much more than you can imagine and you will better understand how the game operates.

 

What you are up to can be achieved in a more elegant way. You don't have to keep a long list of reference aliases to call a script on. Instead, you can have one location alias, that recieves OnLocationCleared() event in its script. Just mark the desired ghouls in the render window to have "Boss" Loc Ref Type - a red square above them should pop up. And set you location (object type - Location) to be Clearable. The rest is a miracle of Bethesda's game logic. Once you kill all of the bosses, the location will recieve 'Cleared' flag and your alias will get the event in which you can execute further whatever you want.

Edited by werr92
Link to comment
Share on other sites

What you are up to can be achieved in a more elegant way. You don't have to keep a long list of reference aliases to call a script on. Instead, you can have one location alias, that recieves OnLocationCleared() event in its script. Just mark the desired ghouls in the render window to have "Boss" Loc Ref Type - a red square above them should pop up. And set you location (object type - Location) to be Clearable. The rest is a miracle of Bethesda's game logic. Once you kill all of the bosses, the location will recieve 'Cleared' flag and your alias will get the event in which you can execute further whatever you want.

 

I've asked about how locations "clear" a few weeks ago, now I find the answer here. Thank you kind sir!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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