Remove item from dead unit

Post » Tue Jun 19, 2012 11:05 am

Hi.

I'm trying to remove a certain item from a dead unit. But I don't know how to get the dead unit.
I want to attach the script to unit types (all the guards in my cell), then when a guard dies run the script to remove a certain item from the guard.

I looked through the wiki and so far my script looks like this:

Event OnDeath(Actor akKiller)  if (akKiller == Game.GetPlayer())    RemoveItem(BM_GuardScimitar, 1, true, none)  endIfendEvent

I "stole" this code from the wiki and realized that the killer doesn't have to be the player, so long as the script runs when the guard dies. -To prevent the player from looting the scimitar.
User avatar
Gill Mackin
 
Posts: 3384
Joined: Sat Dec 16, 2006 9:58 pm

Post » Tue Jun 19, 2012 6:21 am

I think you need to go to script properties and link ref it to your guards.
User avatar
Joanne
 
Posts: 3357
Joined: Fri Oct 27, 2006 1:25 pm

Post » Tue Jun 19, 2012 4:19 am

You could set the scimitar as unplayable. That would keep the player from looting it.
User avatar
Joanne
 
Posts: 3357
Joined: Fri Oct 27, 2006 1:25 pm

Post » Tue Jun 19, 2012 6:26 am

I managed to solve it myself.
In case anyone searches for something similar here's my solution:

Scriptname BM_GuardReplaceWeaponScript extends ObjectReference  Conditional{}WEAPON Property BM_GuardWeapon  AutoWEAPON Property BM_GuardNewWeapon  AutoEvent OnDeath(Actor akKiller)RemoveItem(BM_GuardWeapon, 1, true)AddItem(BM_GuardNewWeapon, 1, true)endEvent

The only "problem" is that when one of the guards die, their ragdoll falls to the floor and the sword rolls away from their body. Then a few seconds later (when my script runs, and when the body becomes loot-able) the sword "magically" disappears from the floor. -When I open the loot menu the correct sword is there, but it disappears from the floor which looks kinda bugged. I guess I can live with that, though.

EDIT: Wow, the code tags on this forum indents poorly.
EDIT #2: I'm not sure if "Actor akKiller" is needed in "Event OnDeath(Actor akKiller)", feel free to correct me on this if I'm wrong.
User avatar
Joie Perez
 
Posts: 3410
Joined: Fri Sep 15, 2006 3:25 pm


Return to V - Skyrim