Script to enable door when a set amount of enemies are killd

Post » Wed May 11, 2016 7:00 pm

Hi all. I am trying to write a script where a door is enabled when : 9 Spectral fiends, 6 souless husks and 2 archers have been killed. I cant find any of the papyrus functions/commands to do this. I just cant put the script together at all. Can anyone help please???

User avatar
Tom Flanagan
 
Posts: 3522
Joined: Sat Jul 21, 2007 1:51 am

Post » Wed May 11, 2016 1:57 pm



Place this script on your actors (assuming they are quest aliases)



Scriptname aaaaaBanditScript extends ReferenceAlias

aaaaa1questScript myQuestScript

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

Then Place this script on your quest(in the scripts tab)



Scriptname aaaaa1questscript extends Quest Conditional


int Property DeadBandits Auto Conditional
{tracks how many bandits are killed}

int Property TotalBandits Auto Conditional
{how many bandits do you need to kill?}

function IncrementDeadBandits()
DeadBandits = DeadBandits + 1
if DeadBandits >= TotalBandits
MyDoor.SetOpen(true)
endif
endfunction


ObjectReference Property myDoor Auto

Then Call the quest script in any stage of the quest before you need to kill the actors using the kmyQuest dropdown.


The fill the properties in the CK. Just a side note, just fill the door, and Total number of actors or bandits in the case of the example.



Then after the correct number of bandits are killed, the door will open. Make sure the door is a two state activator like a norPortcullis or similar.

User avatar
Mark
 
Posts: 3341
Joined: Wed May 23, 2007 11:59 am

Post » Wed May 11, 2016 11:51 am

Hi thanks for the reply but there are no quests in the project I am working on as I want it to be non linear gameplay. I should have specified beforehand, but how would I adapt those scripts to function without a quest? I want to attach a single script to an activator that enables the door when activated and the said enemies have been killed

User avatar
An Lor
 
Posts: 3439
Joined: Sun Feb 18, 2007 8:46 pm

Post » Wed May 11, 2016 11:43 am


A quest does not have to be a long drawn out affair. A quest can have only two stages, or 200 stages. You could place a trigger box in the cell to start the quest, create your Aliases, call the quest script on the first stage and set the final stage when the door opens and stop the quest. Don't give the quest a name or objectives or targets. Nothing will display on screen, or in your journal.

User avatar
Steve Fallon
 
Posts: 3503
Joined: Thu Aug 23, 2007 12:29 am

Post » Wed May 11, 2016 8:04 am

So what your saying is there is no way to do this unless I set up a quest?

User avatar
louise tagg
 
Posts: 3394
Joined: Sun Aug 06, 2006 8:32 am

Post » Wed May 11, 2016 3:51 pm


That is the only way I know of doing it. Not saying there is no other way to do it.

User avatar
Lauren Denman
 
Posts: 3382
Joined: Fri Jun 16, 2006 10:29 am

Post » Wed May 11, 2016 10:10 am

Damn. Well Ok thanks for your help. I'll take a note of the script in case I can't find another way.

User avatar
Imy Davies
 
Posts: 3479
Joined: Fri Jul 14, 2006 6:42 pm

Post » Wed May 11, 2016 7:36 pm

Why do you object to using a quest? There is very little you can accomplish in Skyrim modding without quests. Dialogue, for example, absolutely requires a quest.



[EDIT] Looking over johng58's examples, it would be easy to implement without resorting to a quest. Move the helper function into the actor script, and create two new global variables for the dead number and the total number in the CK and use them instead of the int properties. You can't attach a script to a leveled actor, however, so that's something to be mindful of. And the more salient point is that wanting to avoid quests is really silly and limiting.

User avatar
Mimi BC
 
Posts: 3282
Joined: Sat Oct 07, 2006 10:30 pm

Post » Wed May 11, 2016 11:59 pm


I like to keep things simple. While I appreciate the help, with the quest method I would have had to write a quest and numerous scripts attached to numerous things. I got it working with the help of ppl on the NEXUS Forums. Using only a Global variable and one script attached to the actor. Much easier and less scripts mean less potential problems and bugs

User avatar
mishionary
 
Posts: 3414
Joined: Tue Feb 20, 2007 6:19 am

Post » Wed May 11, 2016 12:48 pm


This is not true. In the quest I am working on for another author, I have added a script to a Leveled Actor, that moves them to a holding cell after they die, for this part of the quest. I have also added a script to them to delete them after they are killed with a wait to remove them from the battle field. You can also place a script on them if you are using them as a quest alias. The only thing different is you cannot select them in the render window to fill the properties, but instead you have to use the drop down windows to find them and add them that way. I have had no trouble doing this and the script works as designed in game.

User avatar
Jeffrey Lawson
 
Posts: 3485
Joined: Tue Oct 16, 2007 5:36 pm

Post » Wed May 11, 2016 7:47 pm


It is true. You can add a script to a reference and you can add a script to a quest alias, but you can't add a script to the actor.

User avatar
lucile davignon
 
Posts: 3375
Joined: Thu Mar 22, 2007 10:40 pm

Post » Wed May 11, 2016 9:21 am


When you click on an actor in the reference window or object window, and click edit base, and add the script, are you not adding the script the the actor in essence. Because every time you duplicate said actor the script is there.

User avatar
Monique Cameron
 
Posts: 3430
Joined: Fri Jun 23, 2006 6:30 am

Post » Wed May 11, 2016 9:29 am


Our difference of opinion clearly lies in the philosophy and not in the facts :P

User avatar
Marion Geneste
 
Posts: 3566
Joined: Fri Mar 30, 2007 9:21 pm

Post » Wed May 11, 2016 10:59 pm


Not looking for an argument just trying to understand. I realize you can't add a script to the ActorBase, such as LCharBanditMissle, but the actor, lvlBanditAmbushMissle has the masterambushscript attached to it in the vanilla game. Although it is not good practice to change vanilla actors, making a copy of said actor and giving it a new name for your purpose is acceptable. I have done this many times for my own mods without any problems from users.

User avatar
Ashley Campos
 
Posts: 3415
Joined: Fri Sep 22, 2006 9:03 pm

Post » Wed May 11, 2016 9:11 am

@ morrowind1979: it makes a lot of difference where your actors are.


if they're all from the same location and you can basically edit them (you'd have to add a LocationRefType to their refs for this to work), you could just go for a try with http://www.creationkit.com/index.php?title=GetRefTypeDeadCount_-_Location on the door itself

User avatar
Motionsharp
 
Posts: 3437
Joined: Sun Aug 06, 2006 1:33 am

Post » Wed May 11, 2016 9:34 am

I got it working just adding the same single script to each actor (not levelled, custom made by me) that enables the door when the global variable reaches the required number. The script was written by a helpful user on the NEXUS Forums. Its done and dusted now guys/gals. Thanks for all the help!

User avatar
Rachael Williams
 
Posts: 3373
Joined: Tue Aug 01, 2006 6:43 pm

Post » Wed May 11, 2016 11:36 am


lvlBanditAmbushMissle isn't a leveled actor and is not referenced by any leveled actor, which is why it can have a script attached to it. You obviously understand that, which is why I feel that our disconnect is likely semantic.

User avatar
JESSE
 
Posts: 3404
Joined: Mon Jul 16, 2007 4:55 am


Return to V - Skyrim