script question about something in script library

Post » Fri May 27, 2011 4:08 am

I was wondering about if it was possible to take away an item after an NPC dies so as to keep it away from the player.

Is this possible, and how?
ST
User avatar
Alexx Peace
 
Posts: 3432
Joined: Thu Jul 20, 2006 5:55 pm

Post » Fri May 27, 2011 11:05 am

Yes. Attach this script to the NPC:

if ( getHealth <= 0 )	removeitem, "ITEM_ID", 1endif


Replace "ITEM_ID" with the item you wish to remove.
User avatar
Maeva
 
Posts: 3349
Joined: Mon Mar 26, 2007 11:27 pm

Post » Fri May 27, 2011 1:30 am

I shoulda been able to figure that out, but thanx!

ST
User avatar
Cameron Garrod
 
Posts: 3427
Joined: Sat Jun 30, 2007 7:46 am

Post » Thu May 26, 2011 10:08 pm

Just an interesting alternative but you could add:

if ( OnActivate )     returnendif


As a plus it would stop any item from being removed from the NPC whilst alive or dead, as well as prevent pickpocketing it and taking it from the body whilst fatigue is depleted but on the negative side it would prevent initiating dialogue...



I shoulda been able to figure that out, but thanx!

ST

User avatar
Da Missz
 
Posts: 3438
Joined: Fri Mar 30, 2007 4:42 pm

Post » Fri May 27, 2011 12:02 pm

Yes. Attach this script to the NPC:

if ( getHealth <= 0 )	removeitem, "ITEM_ID", 1endif


Replace "ITEM_ID" with the item you wish to remove.

Technicly, it would be better to do it like so

if ( getHealth <= 0 )	if ( getItemCount "ITEM_ID" > 0 )		removeitem, "ITEM_ID", 1	endifendif


As otherwise the item is continually removed.
User avatar
Jah Allen
 
Posts: 3444
Joined: Wed Jan 24, 2007 2:09 am

Post » Fri May 27, 2011 3:19 am

Optimization, optimization.. you're right though.
User avatar
El Khatiri
 
Posts: 3568
Joined: Sat Sep 01, 2007 2:43 am

Post » Fri May 27, 2011 11:14 am

It really depends on the item which one to use doesnt it? If it was called WAF_SDS_A_DSS i think the removing immedietly would be better.
User avatar
Nicola
 
Posts: 3365
Joined: Wed Jul 19, 2006 7:57 am

Post » Thu May 26, 2011 10:18 pm

They both remove it immediately on death, but mine infinitely removes the item. This causes no error for NPCs other than giving them negative weight (removing an item that's not there doesn't cause an error, but it does remove the weight of the item from the player, allowing his weight to go below 0).

You could also use if ( onDeath == 1 ) to test for the death of the actor, which essentially does what Yacoby suggested. However, if the NPC has more than one item of that ID, it will only remove one.
User avatar
Jessica Nash
 
Posts: 3424
Joined: Tue Dec 19, 2006 10:18 pm

Post » Fri May 27, 2011 6:27 am

They both remove it immediately on death, but mine infinitely removes the item. This causes no error for NPCs other than giving them negative weight (removing an item that's not there doesn't cause an error, but it does remove the weight of the item from the player, allowing his weight to go below 0).

You could also use if ( onDeath == 1 ) to test for the death of the actor, which essentially does what Yacoby suggested. However, if the NPC has more than one item of that ID, it will only remove one.


You could removeitem id_xxx 200 on death, just to be sure ;)

The NPC is dead so what does it matter :P
User avatar
djimi
 
Posts: 3519
Joined: Mon Oct 23, 2006 6:44 am

Post » Thu May 26, 2011 10:00 pm

Better to only remove what you need to.. no need for senseless de-optimization. :)
User avatar
Gavin Roberts
 
Posts: 3335
Joined: Fri Jun 08, 2007 8:14 pm


Return to III - Morrowind