Add Item On Death SCR

Post » Wed Jun 20, 2012 4:00 pm

In another thread I asked about how to keep an actor from opening a door that he has a key to and it led to a script that will add the key to the actor. I am trying to get the script set to add the key after he is killed.

Here is the script:

Scriptname antreAddItemKeyOnDeathScript extends defaultAddItemScriptKey property _KeyToAdd Autobool property unique = True Auto{If the player already has this item, don't give the actor one. Defaults to True for keys.};Stores the key. DefaultAddItemScript takes care of the rest.;Event OnInit()Event OnDeath(Actor killer)        ParentUnique = Unique        ItemToAdd = _KeyToAddEndEvent

OnInit works and the key is added but OnDeath is not working.

It compiles ok so I am at a loss to what the problem is.

Any ideas on what is keeping this from working?
User avatar
Sista Sila
 
Posts: 3381
Joined: Fri Mar 30, 2007 12:25 pm

Post » Wed Jun 20, 2012 8:04 pm

Does it work if you use OnDying instead of OnDeath?

EDIT:

Nevermind, just took a look at the defaultAddItemScript. It only adds items OnLoad, and OnReset. So since you're only setting the properties OnDeath, it won't do anything.
User avatar
Lexy Dick
 
Posts: 3459
Joined: Mon Feb 12, 2007 12:15 pm

Post » Thu Jun 21, 2012 1:10 am

A blatant quick way of doing something like this would be to simply set the actors Death Item to that key. Then when he dies, he gets the key. Though he will no matter what, which may not be what you want?
User avatar
Jeffrey Lawson
 
Posts: 3485
Joined: Tue Oct 16, 2007 5:36 pm

Post » Wed Jun 20, 2012 3:56 pm

In another thread I asked about how to keep an actor from opening a door that he has a key to and it led to a script that will add the key to the actor. I am trying to get the script set to add the key after he is killed.

Here is the script:

Scriptname antreAddItemKeyOnDeathScript extends defaultAddItemScriptKey property _KeyToAdd Autobool property unique = True Auto{If the player already has this item, don't give the actor one. Defaults to True for keys.};Stores the key. DefaultAddItemScript takes care of the rest.;Event OnInit()Event OnDeath(Actor killer)		ParentUnique = Unique		ItemToAdd = _KeyToAddEndEvent

OnInit works and the key is added but OnDeath is not working.

It compiles ok so I am at a loss to what the problem is.

Any ideas on what is keeping this from working?
I think that OnDeath is fired only for script that extends Actor.
User avatar
Emma-Jane Merrin
 
Posts: 3477
Joined: Fri Aug 08, 2008 1:52 am

Post » Wed Jun 20, 2012 12:56 pm

Thanks guys!

Before I reply to y'all I want to test something but I think a certain line won't allow the script to fire if placed on something other than the player:

    if (Game.GetPlayer().GetItemCount(ItemToAdd) == 0 || !parentUnique)

Would the correct line be?...:

    if (Game.Actor().GetItemCount(ItemToAdd) == 0 || !parentUnique)

Thanks!
User avatar
Cagla Cali
 
Posts: 3431
Joined: Tue Apr 10, 2007 8:36 am

Post » Wed Jun 20, 2012 11:31 pm

Or maybe this:

if (Game.GetActor().GetItemCount(ItemToAdd) == 0 || !parentUnique)

Oh yea....How do you declare a variable that is a non-integer, like an object (the key for example)?
User avatar
StunnaLiike FiiFii
 
Posts: 3373
Joined: Tue Oct 31, 2006 2:30 am

Post » Thu Jun 21, 2012 12:51 am

oK...

In case someone else happens across this post here is what worked for me:

Scriptname CustomAddItemKeyOnDeathScript extends Actor  {Adds only a key to the actor.}Key property _KeyToAdd Autoauto STATE WaitingToBeActivatedEvent OnDeath(Actor killer)	Self.AddItem(_KeyToAdd)EndEventEndStateSTATE done	;done doing stuffendSTATE

It will ONLY add a key to the actor upon his death.

I forgot to say thank you guys!

You led me in the right direction and I appreciate it :)
User avatar
Rachel Briere
 
Posts: 3438
Joined: Thu Dec 28, 2006 9:09 am

Post » Wed Jun 20, 2012 7:19 pm

A blatant quick way of doing something like this would be to simply set the actors Death Item to that key. Then when he dies, he gets the key. Though he will no matter what, which may not be what you want?

I thought of that too but you can't add custom items, like the key I'm using, using that method.

It would be a nice addition for gamesas to do though :)
User avatar
Beth Belcher
 
Posts: 3393
Joined: Tue Jun 13, 2006 1:39 pm

Post » Wed Jun 20, 2012 11:59 pm

I thought of that too but you can't add custom items, like the key I'm using, using that method.

It would be a nice addition for gamesas to do though :smile:
Wat? You can't add custom items? You've got to be able to, that wouldn't make any sense... (Though, I admit, I haven't actually used it in Skyrim yet.)
User avatar
Natalie J Webster
 
Posts: 3488
Joined: Tue Jul 25, 2006 1:35 pm

Post » Thu Jun 21, 2012 4:53 am

Wat? You can't add custom items? You've got to be able to, that wouldn't make any sense... (Though, I admit, I haven't actually used it in Skyrim yet.)

Yea, I too thought it was odd that custom objects aren't listed in the drop down for Death Items.

It would save some time if it were

According to the Wiki:

"Must be a leveled item list."

http://www.creationkit.com/Traits_Tab_-_NPC
User avatar
Fiori Pra
 
Posts: 3446
Joined: Thu Mar 15, 2007 12:30 pm


Return to V - Skyrim