How to add an entry journal when a npc is killed

Post » Thu Jan 14, 2010 12:18 am

Hi!

I′m having some problems at writing an script for this. I want when a npc is killed by the player, the player gets "your journal has been updated"... can anyone write it for me? Many thanks!
User avatar
Ruben Bernal
 
Posts: 3364
Joined: Sun Nov 18, 2007 5:58 pm

Post » Wed Jan 13, 2010 7:05 pm

Begin script_name        if ( OnDeath == 1 ) 	             Journal Journal_Index 10        endif  End


Most basic one i can think of.

If you wanted them to say something before they died (last words sort of thing) then you would need to use something slightly different. Just say if youre interested

Goodluck
User avatar
Kay O'Hara
 
Posts: 3366
Joined: Sun Jan 14, 2007 8:04 pm

Post » Wed Jan 13, 2010 7:11 pm

I'd go with GetHealth < 1 instead of OnDeath because OnDeath can be missed by the engine, plus it can interfere with mods that monitor deaths like C&E.
User avatar
Sylvia Luciani
 
Posts: 3380
Joined: Sun Feb 11, 2007 2:31 am

Post » Wed Jan 13, 2010 5:47 pm

Jac's suggestion will make it somewhat more reliable. You will need a doOnce guard, though:

begin "DM_Script"short doOnceif ( doOnce == false )    if ( GetHealth < 1 )        Set doOnce To 1        Journal "DM_Topic" index    endifendifend "DM_Script"

User avatar
Mari martnez Martinez
 
Posts: 3500
Joined: Sat Aug 11, 2007 9:39 am

Post » Thu Jan 14, 2010 9:09 am

I normally use get health functions too, but i figured my suggestion was fairly explicit and simply.

Also, in my experience OnDeath has never failed. But then i have excellent performance so maybe this is only a problem for less than amazing computorz?
User avatar
MISS KEEP UR
 
Posts: 3384
Joined: Sat Aug 26, 2006 6:26 am

Post » Thu Jan 14, 2010 1:09 am

So, is rally needed to use gethealth 1 instad of Ondeath?
User avatar
Alada Vaginah
 
Posts: 3368
Joined: Sun Jun 25, 2006 8:31 pm

Post » Thu Jan 14, 2010 4:43 am

Performance has nothing to do with it. OnDeath and some other special flag variables (OnPCEquip, OnPCAdd, etc) and commands (OnCellChanged) can have finicky states. It's best to avoid them if there's a guaranteed-reliable method, and GetHealth is just that.

You need to do "GetHealth < 1" to make sure the NPC has 0 health. 0 is the typical dead state, although in some cases 1 or 2 health is also considered dead.
User avatar
James Smart
 
Posts: 3362
Joined: Sun Nov 04, 2007 7:49 pm


Return to III - Morrowind