Need help with on death events.
#1
Posté 14 mars 2012 - 11:21
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
Posté 15 mars 2012 - 12:10
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
Posté 15 mars 2012 - 12:34
#4
Posté 15 mars 2012 - 12:37
got me there ....
#5
Posté 15 mars 2012 - 12:55
#6
Posté 15 mars 2012 - 01:32
... but you don't want the normal death screen, rightAs 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.
may i ask how, are you changing from one (assumedly defaultish) deathscript to your special deathscript(s)I have a particular area in my module that requires a special script for the on death event.
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
Posté 15 mars 2012 - 04:52
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
Posté 15 mars 2012 - 06:13
okay, thought they might be changing on-the-fly ( & i might be crazy )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.
so at its core, your deathscripts just check for this specific area and do a special respawn ...Yes, that is correct. In one area, I want an automatic respawn to a certain location.
... 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
Posté 15 mars 2012 - 07:56
#10
Posté 15 mars 2012 - 09:45
#11
Posté 15 mars 2012 - 10:53
#12
Posté 15 mars 2012 - 11:09
#13
Posté 15 mars 2012 - 11:34
Modifié par M. Rieder, 15 mars 2012 - 11:45 .
#14
Posté 15 mars 2012 - 11:46
#15
Posté 15 mars 2012 - 11:51
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
Posté 16 mars 2012 - 12:03
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
Posté 16 mars 2012 - 04:58
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
Posté 16 mars 2012 - 05:50
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
Posté 16 mars 2012 - 06:34
#20
Posté 16 mars 2012 - 07:14
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
Posté 16 mars 2012 - 09:35
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
Posté 16 mars 2012 - 09:38
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
Posté 16 mars 2012 - 09:55
sounds solid, that's what really matters
#24
Posté 17 mars 2012 - 02:03
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
Posté 17 mars 2012 - 03:56





Retour en haut






