Aller au contenu

Photo

Need help with on death events.


  • Veuillez vous connecter pour répondre
44 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I have a particular area in my module that requires a special script for the on death event.  As long as you are posessing your owned character when the party is killed, everything works fine.  If you are posessing a companion when the whole party is killed then the normal death screen fires.  Also, I have placed lots of debug messages in the companion on death script and the player on death script and these messages fire fine unless you are posessing a companion when the party is killed, in which case no messages are displayed. 

It almost looks like another script is firing when I am killed while posessing a companion.  Does anyone know of other events that may be firing.  I have the CompanionOnDeath in the companion properties as well as the PlayerOnDeath and PlayerOnDying events in the module properties covered. 

I'm completely stumped at this point.

#2
kevL

kevL
  • Members
  • 4 052 messages
hey Matt,

are ya familiar with SetOwnersControlledCompanion( ), by chance? It can be used to push the player control back onto his/her OwnedPC quite easily. I've solved quite a few wtf moments by using it at the top of a script, so that the bulk of that code runs while player is controlling the main PC.


i'm curious what happens if, first thing in the Companion OnDeath scripts, you put say

object oPC = SetOwnersControlledCompanion(OBJECT_SELF)
;


- make sense, as a test??? I'm thinking that if you can rig things like this before the deathGUI ( or whatever ) is called it might sort out, (or does the problem seem to occur *before* even the CompOnDeath fires ..)

- uhh, i guess it might also depend on whether player is controlling a dead companion when the last party member dies - just lying there, watching as it were - but then, with SetOwnersControlledCompanion( ) ye could theoretically ping-pong control to a still-living character

#3
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Hi Kev. Thanks for the advice. I tried it and it didn't seem to work, though.

#4
kevL

kevL
  • Members
  • 4 052 messages
is the issue that, the OnDeath/OnDying scripts aren't even firing when controlling a companion??

got me there ....

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
That's what it looks like. I just can't figure out what script or what event may be firing. I can't get any debug messages to show up from any of my death scripts.

#6
kevL

kevL
  • Members
  • 4 052 messages

As long as you are posessing your owned character when the party is killed, everything works fine. If you are posessing a companion when the whole party is killed then the normal death screen fires.

... but you don't want the normal death screen, right

I have a particular area in my module that requires a special script for the on death event.

may i ask how, are you changing from one (assumedly defaultish) deathscript to your special deathscript(s)


If you really think some other script is firing, try the "logrunscript" console command that SlowDive mentioned a link to ( need logging enabled in nwn2player.ini )

#7
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
"may i ask how, are you changing from one (assumedly defaultish) deathscript to your special deathscript(s)"

In the module OnPlayerDeath and OnPlayerDying events, I have substituted by own script. On the OnDeath event on the properties tab of each of my companions, I have substituted my own script.

"... but you don't want the normal death screen, right"

Yes, that is correct. In one area, I want an automatic respawn to a certain location.

"If you really think some other script is firing, try the "logrunscript" console command that SlowDive mentioned a link to ( need logging enabled in nwn2player.ini ) "

Fantastic suggestion! I just saw slowdive's post myself. This, I think, is what I needed. Thanks!

#8
kevL

kevL
  • Members
  • 4 052 messages

In the module OnPlayerDeath and OnPlayerDying events, I have substituted by own script. On the OnDeath event on the properties tab of each of my companions, I have substituted my own script.

okay, thought they might be changing on-the-fly ( & i might be crazy )

Yes, that is correct. In one area, I want an automatic respawn to a certain location.

so at its core, your deathscripts just check for this specific area and do a special respawn ...

... for player OnDeath and companion OnDeath - why onDying, doesn't this just shunt into OnDeath (after -10 hp. or whtver) anyway. But Okay, it also refuses to fire if controlling a companion .....?


- curious what turns up, i had to hunt through a bunch of heartbeats & perceptions

#9
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
On Dying just to cover all the bases. If the two fire simultaneously (on death and on dying, the on dying fires first.)

#10
kevL

kevL
  • Members
  • 4 052 messages
any luck ( ie anything decipherable ) w/ LogRunScript yet?

#11
Dann-J

Dann-J
  • Members
  • 3 161 messages
I've frequently used module-wide OnPlayerDeath/Dying custom scripts without any problems, but I've never been brave enough to mess with the OnDeath creature/companion scripts. I'd suggesting looking at the latter.

#12
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
No luck yet. Still trying to get my log file to generate information.

#13
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Still trying to figure out the log file and how it relates to my scripts.  Not seeing all my death scripts where I would expect even when things are working.  Clearly dont' fully understand log file.

Modifié par M. Rieder, 15 mars 2012 - 11:45 .


#14
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
...doesn't help that 5 seconds of gameplay generates several hundred lines...

#15
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
You're the man, KevL!

I re-tried the SetOwnersControlledCompanion() command except this time I put it in the PC on death and used this:

SetOwnersControlledCompanion(GetFirstPC(FALSE),GetFirstPC());


It worked like a charm!

Mokah was having trouble with this too. I'm going to PM her... I'll give you the cred. Thanks again! I love it when scripts work!

#16
kevL

kevL
  • Members
  • 4 052 messages
i tell ya, Matt

i'd like to stand on a rooftop and yell


SetOwnersControlledCompanion()

!






(now, Pain might have some issues with that GetFirstPC bit .. so do i, btw hehe, but that's a tricky line ya got there :)

#17
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Oh god! Don't tell pain that I used GetFirstPC()! :)

The problem is that object identification for the death script when you are controlling a compaion is so bonkers that it's hard to tell what is what. I'm not sure who ObjectSelf is in this case and when I try to use GetLastPlayerDied() it seems to behave oddly. I had to use GetFirstPC() because that was the only identifier that resulted in proper behavior.

A better coder could no doubt make it happen more properly but that's not me. I'm just glad the whole messy affair works.

For TWAIII I am going to use the standard SOZ deathscripts and that is it. Nothing fancy.

#18
kevL

kevL
  • Members
  • 4 052 messages
been thinking about this,

my guess, that the module OnPlayerDeath script fires when a PlayerControlled (PC ..) object coroaks


- cant think up a suitable replacement for GFPC either. you could use a debug like,

string sObjectSelf = GetName(OBJECT_SELF);
SendMessageToPC(GetFirstPC(FALSE), "name_of_script, run by : " + sObjectSelf);

in the OnDeath scripts ... but bonkers is bonkers, *shurg~

#19
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Isn't there some sort of get-party-leader or get-faction-leader function?

#20
kevL

kevL
  • Members
  • 4 052 messages
yes, SetOwnersControlledCompanion( ;)

it has the (unfortunate, though compatible w/ the engine) side effect of transferring player-control to a (possibly other) object.


GetFactionLeader( ) returns, in my SP tests, the player-controlled character, so no luff there.

GetOwnedCharacter( ) is prolly what you're thinking of, and likely an excellent candidate to replace GetFirstPC( ) above,


SetOwnersControlledCompanion(OBJECT_SELF);

is another way of saying:

SetOwnersControlledCompanion(OBJECT_SELF, GetOwnedCharacter(OBJECT_SELF));



*it might work! ( maintain Multi-Player compatibility ) The OBJECT_SELF might still present a bork; it seems like it should be GetLastPlayerDied( ) ... but M.R. says that heads south too :\\

Since the engine seems to be running the module OnPlayerDeath script when controlling a companion ( in addition to the companion OnDeath script ? ), what it defines as OBJECT_SELF and/or GetLastPlayerDied( ) could be either the PC proper or the companion ....... (don't forget familiars also, and SoZ PlayerCreated) - that's why i head straight for SetOwnersControlledCompanion as it seems to bypass all this confusion,

Modifié par kevL, 16 mars 2012 - 07:34 .


#21
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Here's the problem I ran into:

I can't get the owned character of the faction leader because there is no proper way to identify the object when the companion is owned in the death script. OJBECT_SELF does not seem to work nor does GetLastPlayerDied(). Without an object to be the argument for GetFactionLeader() you have nothing to work with that I can think of. There is probably something but I don't know what it is.

It gets even wierder: I had a conditional that was met when I am posessing my owned PC but not when I'm posessing the compaion. The condition is a simple boolean swich on a global integer, but for some reason whether I was posessing my compaion or owned character, it seemed to make a difference. That's why I had to switch control in the first place.

#22
M. Rieder

M. Rieder
  • Members
  • 2 530 messages

kevL wrote...

been thinking about this,

my guess, that the module OnPlayerDeath script fires when a PlayerControlled (PC ..) object coroaks


- cant think up a suitable replacement for GFPC either. you could use a debug like,

string sObjectSelf = GetName(OBJECT_SELF);
SendMessageToPC(GetFirstPC(FALSE), "name_of_script, run by : " + sObjectSelf);

in the OnDeath scripts ... but bonkers is bonkers, *shurg~




This is a great test to run and I think this is the right direction.  I tried many different versions of this using FloatingTextStringOnCreature(), SendMessageToPC(), SetNoticeText(), but none of the messages ever showed up.  I'm sort of lazy and now that it works, I'm not going to mess with it anymore.  I'm looking at releasing, possibly this weekend if the rest of my final play-through goes well. 

#23
kevL

kevL
  • Members
  • 4 052 messages
tl;dr : o_O

sounds solid, that's what really matters

#24
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
update:

I take back everything. The fix I proposed didn't fix it, it just made it look fixed in my test run. I have since fixed it, but a different way. Apparently my script is still running (the custom death one) so as a part of it, I removed the death screen and all is well. It doesn't work as planned and the issue of weird death behavior when controlling companions is not fixed, however.

#25
kevL

kevL
  • Members
  • 4 052 messages
hm, could you link/Post the OnDeath scripts - would like to try & find out where the anomaly is.