Detecting another NPC's Health

Post » Sun Nov 27, 2011 11:20 pm

Is it possible to have NPC 1 detect NPC 2's health?

I tried this and it didn't work:

if ( "NPC 2"-> GetHealth =< 1 )

That being put into the script of NPC 1.
User avatar
No Name
 
Posts: 3456
Joined: Mon Dec 03, 2007 2:30 am

Post » Mon Nov 28, 2011 12:07 am

That is the correct function. The arrow in a partial equals should always be on the left, and your whitespace is a bit off, which could possibly be the issue:

if ("NPC 2"->GetHealth <= 1)


Even better, remove the whitespace from the ID. You can test by setting a variable to the health value, then showing a messagebox with that.

Note that npc 2 should be loaded and active for this to work, or marked as references persist. This will also only use the first instance of NPC 2 that exists in the world.
User avatar
Stat Wrecker
 
Posts: 3511
Joined: Mon Sep 24, 2007 6:14 am

Post » Mon Nov 28, 2011 7:08 am

Awesome thank you very much! I'll test it out in about 30 minutes. Thank you!
User avatar
Sarah Unwin
 
Posts: 3413
Joined: Tue Aug 01, 2006 10:31 pm

Post » Sun Nov 27, 2011 11:58 pm

Works great! Thank you!
User avatar
Kayleigh Williams
 
Posts: 3397
Joined: Wed Aug 23, 2006 10:41 am


Return to III - Morrowind