BioWare Atari
BioWare Info BioWare Games Support Forums Visit the BioWare Store
Neverwinter Nights Home
Neverwinter Nights Home

NWN 1: Scripting

New Topic    Post Reply


    Add this To My Topics

   Go To Bottom

Author Checking items on NPC corpse
Mithrandir666
Game Owner
Profile: Mithrandir666NWN
NWN: SoU
NWN: HotU
NWN 2


Joined: 21 Jan 2003
From: UK
Posted: Wednesday, 04 November 2009 09:33AM
I've been trying to get a script to work that checks whether an NPC corpse has an item on it after it's been killed, but it doesn't seem to work.

I'm wondering if anyone knows whether a corpse cannot be checked for items for some reason?

This is the script:
Code:

View Post/Code in separate window



If I put this on the heartbeat of the creature, the item check works fine, but when called from an ondeath script it fails. The creature's corpse is destroyed however, which implies that oTarget is correct.

Any thoughts appreciated
_________________
http://www.silver-spire.com
  Profile: Mithrandir666   Send Message To: Mithrandir666
ChocoBlok
Game Owner
Profile: ChocoBlokNWN
NWN: SoU
NWN 2


Joined: 27 Jun 2003
From: England
Posted: Thursday, 05 November 2009 12:33AM
Hi there,

I did some testing on this, by doing the following:

I attached the following script to the death event on several monsters, and tried killing a horde of them.

Code:

View Post/Code in separate window



Since every time I got a "found", I decided to try something a little closer to your code:

Code:

View Post/Code in separate window



And this worked fine for me, although I didn't try killing more than one monster at a time.

Hope it helps.

~S
  Profile: ChocoBlok   Send Message To: ChocoBlok
Mithrandir666
Game Owner
Profile: Mithrandir666NWN
NWN: SoU
NWN: HotU
NWN 2


Joined: 21 Jan 2003
From: UK
Posted: Friday, 06 November 2009 01:47PM
Ok, that inspired me to have another look at this, and whereas previously our script was split into 2 scripts, having it as one script did help. However, have run into an issue (which is I believe related to my original issue).

In summary, what I'm looking for is a creature that has a heart in its inventory. When it dies, the script should check whether this heart is present and if it is then it spawns a new creature, and destroys the corpse. However, there needs to be a delay in checking for the heart, so the PCs have time to get it off the corpse.

So my issue is that this script:
Code:

View Post/Code in separate window


.. works fine in that it does create a new creature. However, because the heart check is done instantly, but the creation not for 8 seconds, there's no time for the PC to get the heart, and hence a new creature is created every time.

But, this script:
Code:

View Post/Code in separate window


... never creates a new creature. Putting some debug messages into there shows that oTarget is valid, but oHeart is not.

So, to me it looks like a lootable corpse can be queried directly in a script, but cannot if a subsequent script or function is called.

Perhaps passing a parameter into a function or script passes in a copy of the item, but in this case without any inventory?

Bit confused! Serves me right for thinking I was getting the hang of this!!
_________________
http://www.silver-spire.com

Edited By Mithrandir666 on 11/06/09 13:51

  Profile: Mithrandir666   Send Message To: Mithrandir666
Cereborn
Game Owner
Profile: CerebornNWN
NWN: SoU
NWN: HotU


Joined: 06 Jun 2002
Posted: Friday, 06 November 2009 06:33PM
In the onDeath script, you're not querying the lootable corpse (which hasn't been created yet) you're querying the creature, which at that point still has it's inventory. After the onDeath script, the lootable corpse is created (a body bag placeable, actually) and the creature's inventory is moved to the placeable (because you can't open a creature's inventory). You can find the placeable by using GetNearestObjectByTag (nearest the creature) - the tag will be "BodyBag" iirc (or maybe "Body Bag". Try both...)
_________________
The NESS User's Guild:
  Profile: Cereborn   Send Message To: Cereborn
Mithrandir666
Game Owner
Profile: Mithrandir666NWN
NWN: SoU
NWN: HotU
NWN 2


Joined: 21 Jan 2003
From: UK
Posted: Friday, 06 November 2009 08:18PM
I was heading towards the lootable corpse being a different object, but I never would have got the BodyBag thing - so many thanks for that! It now works pretty much flawlessly!

For reference, here's the core bits of the script, placed in the onDeath of the creature:

Code:

View Post/Code in separate window



This gives the PC 15-20 seconds to rip out the heart from the creature, else it "rises" again.

Many thanks for the help - much appreciated!
_________________
http://www.silver-spire.com

Edited By Mithrandir666 on 11/06/09 20:20

  Profile: Mithrandir666   Send Message To: Mithrandir666

New Topic    Post Reply

What do these icons mean?
Where can I learn how to use the forums?

Jump To:

Search Forums | Forums FAQ | Forum Archives

 

 

Dragon Age: Origins Preorder
Neverwinter Nights 2 Forums
Hide/Show

English
Deutsch
Français
Español
Italiano

Hide/Show

View Latest Screenshots 

View Latest Screenshots
Hide/Show

Multiplayer Games at Neverwinter Connections

Today
Schedule a Game...



Current time is: (set time)
Sun, 22 November 2009 09:07AM

Hide/Show

Buy Premium Modules

Top NWN: HotU Modules:
1. Good vs Evil III
2. More...

Top NWN: SoU Modules:
1. Good vs Evil III
2. More...

Top CEP Modules:
1. The Lord of Terror The Diablo Campa...
2. More...

Top Modules - NWVault:
1. Hall of Fame
2. More...

Total Modules: 4423

Hide/Show

5,052,460 BioWare Users:
  34 Logged In
  4 Hidden
  157 Guests

712 Playing Online
  100% NWN
  100% NWN: SoU
  100% NWN: HotU

444 Registered Guilds

8,768,815 posts in forums

Newest Forum Topics:
1. Transfering Shepard's appearance (Mass Effect 2 General Discussion (No Spoilers Allowed))

2. Jade Empire's History (Jade Empire Xbox General Discussion (Spoilers Will Be Moved))

3. can't change language (Web Site Help)

4. which script launches the crafti... (NWN 1: Scripting)

5. Killing Morag (NWN 1: General Discussion (No Spoilers Allowed))