Server Totals
Elysia - (2)
Le'Or - (1)
M'Chek - (1)
Visimontium - (1)
Underdark - (0)
Wilderness - (0)
Ferrell - (0)
Deglos - (0)
Mikona - (0)
Total players: 5
Gallery
  • Winter Ball 2015
    Album name: DM Events
    Uploaded by: Ronan
    Uploaded: Sat Jan 03, 2015 4:15 pm

Links Menu

Trying to create placeables

Moderators: Nighthawk4, Dungeon Masters

Trying to create placeables

PostAuthor: Titanium Dragon » Sat Dec 13, 2003 3:18 am

Alright, I'm having trouble creating a placeable. I'm trying to write a script so that when someone dies, they leave behind a corpse. Why? Because I want to know how to do it! Looking at others' scripts don't help me; I have to do it myself to understand it well.

Here is the bit of script that I am having trouble with:

if (GetCurrentHitPoints() <= -10)
{
location lDying;
lDying = GetLocation(oDying);
PlayVoiceChat(VOICE_CHAT_DEATH);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DEATH), OBJECT_SELF);
CreateObject(OBJECT_TYPE_PLACEABLE, "q_pccorpse01", lDying, FALSE, GetName(oDying)+"corpse");
SendMessageToPC(oDying, "Your soul flows out of your body.");
DelayCommand(1.0, AssignCommand(oDying, ClearAllActions()));
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oDying);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oDying)), oDying);
AssignCommand(oDying, JumpToLocation(GetLocation(GetObjectByTag("wp_deathtravel"))));
}

What am I doing wrong? I suspect I am making some sort of mistake on this line:

CreateObject(OBJECT_TYPE_PLACEABLE, "q_pccorpse01", lDying, FALSE, GetName(oDying)+"corpse");

The thing I am trying to create has both a tag and resref of "q_pccorpse01" (without the quotes). Maybe I should use GetObjectByTag("q_pccorpse01"), but that seems like it wouldn't work any better? What am I doing wrong?
User avatar
Titanium Dragon
Sage
 
Posts: 2917
Joined: Sun Apr 27, 2003 5:18 pm
Location: Corvallis, OR (GMT - 7)

PostAuthor: Aloro » Sat Dec 13, 2003 5:00 am

OK, first off, forget the bit about the hitpoints. In NWN, there's an event that fires off when a player dies - OnPlayerDeath. Whatever script you're writing should go in that module-wide event. This script doesn't need to check if the player is dead - it is called up only in such a case anyhow.

Second... hmm. You want to make a death corpse, but have the player keep all his or her items? Because there's nothing here to strip the inventory and place it on the death corpse. That's not terribly difficult, but it does involve a whole different layer of complexity (e.g. is the corpse persistent).

Third, creating the death corpse... here's the line of code we use in Avlis:

oDeathCorpse = CreateObject(OBJECT_TYPE_PLACEABLE, "DeathCorpse", lDiedHere);


One thing you'll notice immediately is that we assign the newly created corpse to a local object variable (oDeathCorpse), because we have a lot of other things we do with the corpse after creating it. Assigning the variable at the time of creation is much easier than doing it later.

This is a fairly complex task, honestly, in terms of the number of different things to deal with at the time of player death. Don't take this the wrong way... I'm not saying you can't do it on your own... but I'd strongly suggest looking over some examples then reverse-engineering them. That is to say, as you read the code, try to figure out why this or that command was used instead of another, and follow all the various steps. You're missing, well, about 90% of the process here, and there isn't a short and easy answer to what else needs to be included. I want to encourage you, but can't give you a short answer to this question. We use a fairly long include file loaded with functions to do all the things you're trying to compress into a few lines of code, and I don't know what to say to help. :)

- Aloro
Aleksandr Solzhenitsyn wrote:The meaning of earthly existence lies, not as we have grown used to thinking, in prosperity, but in the development of the soul.
User avatar
Aloro
Team Member; Retired with Honors
 
Posts: 12810
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End

PostAuthor: Titanium Dragon » Sat Dec 13, 2003 5:08 am

Well, this is actually in the OnPlayerDying script as part of a bleeding script - I would imagine Avlis uses something similar, though my bet would be they took what I'm putting into this script into the OnPlayerDying and OnPlayerDeath scripts instead. I'm not sure which would be more efficient.

Anyway... that line looks much like mine, but without assigning a unique tag to the corpse, which actually is probably unnecessary as the name of the player whose corpse it is is in a variable on the corpse anyway.

Hmm... *changes the script and sees if it fixes it*

As an aside, I haven't added in the stripping code yet - I kinda wanted to get the corpse to spawn before I did that.
User avatar
Titanium Dragon
Sage
 
Posts: 2917
Joined: Sun Apr 27, 2003 5:18 pm
Location: Corvallis, OR (GMT - 7)


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], Google [Bot], loki70, silverfields2