I've made a nice GUI as an alternative to the native crafting systems. It's working fine and dandy (crafting is actually fun now). Here's the thing:
When I open the GUI with a character other then my main character, some of the script functions called by my GUI affect the controlled character while others affect the main character regardless of who is using the GUI (tested in the OC and SoZ).
Basically, I have one big script which does all the scripting functions for my GUI, each function is called indivdually by a switch. It looks a bit like this:
object oPC = GetFirstPC(FALSE);
blah
blah
switch (nCommand)
case 1: blah
case 2: blah
etc...
where each case is a different function that my GUI needs to do.
The following functions work correctly on the currently controlled character:
CreateItemOnObject
CloseGUIScreen
GetSpellKnown
GetHasFeat
The following functions seem to target the main character regardless of who is being controlled:
GetclassByPosition
GetLevelByclass
TakeGoldFromCreature
ApplyEffectToObject
GetFirstItemInInventory
GetNextItemInInventory
And here's the real mystery: object oPC is defined only once in the whole script. Passing oPC in that script produces different targets depending on what function I use.
I've tried using OBJECT_SELF and GetControlledCharacter instead to no avail.
What the heck?
My GUI doesn't know who I am!
Débuté par
CrawBird
, juin 04 2011 12:23
#1
Posté 04 juin 2011 - 12:23
#2
Posté 04 juin 2011 - 01:32
First you should never avoid using GetFirstPC unless you are intending to loop all PCs (in a MP setting)
GetControlledCharacter is the function you need to be using to affect the character currently being possessed.
GetOwnedCharacter is what you need to use to get your original PC, when possessing a companion.
Scenario: When controlling your main character and invoking a gui callback script:
OBJECT_SELF = your original PC created at character creation
GetControlledCharacter(OBJECT_SELF) the character currently being possessed (in this case your original PC)
GetOwnedCharacter(OBJECT_SELF) your original character created at character creation
When possessing a character and invoking a gui callback
OBJECT_SELF = your original PC created at character creation
GetControlledCharacter(OBJECT_SELF) the character currently being possessed (in this case the one your possessing)
GetOwnedCharacter(OBJECT_SELF) your original character created at character creation
We'd really need to see your entire script to be able to help you further.
GetControlledCharacter is the function you need to be using to affect the character currently being possessed.
GetOwnedCharacter is what you need to use to get your original PC, when possessing a companion.
Scenario: When controlling your main character and invoking a gui callback script:
OBJECT_SELF = your original PC created at character creation
GetControlledCharacter(OBJECT_SELF) the character currently being possessed (in this case your original PC)
GetOwnedCharacter(OBJECT_SELF) your original character created at character creation
When possessing a character and invoking a gui callback
OBJECT_SELF = your original PC created at character creation
GetControlledCharacter(OBJECT_SELF) the character currently being possessed (in this case the one your possessing)
GetOwnedCharacter(OBJECT_SELF) your original character created at character creation
We'd really need to see your entire script to be able to help you further.
#3
Posté 04 juin 2011 - 02:41
I have tried
My script is long but, if there are people willing to help, I'm certainly willing to post.
What's the best way to post this? Is there any way to post those scolling text boxes like on the old site? I'm not convinced that the BBCode [code*] or [quote*] tags are going to do a lot of good with something this long.
Meanwhile, I'll try storing my character as a gobal or something and calling up that global in all the functions that are going rogue on me.
Thanks for responding 34.
GetControlledCharacter(OBJECT_SELF)already with no variation in the results. I'll switch to using that by default just in case I actually decide to distribute my work for once.
My script is long but, if there are people willing to help, I'm certainly willing to post.
What's the best way to post this? Is there any way to post those scolling text boxes like on the old site? I'm not convinced that the BBCode [code*] or [quote*] tags are going to do a lot of good with something this long.
Meanwhile, I'll try storing my character as a gobal or something and calling up that global in all the functions that are going rogue on me.
Thanks for responding 34.
#4
Posté 04 juin 2011 - 04:48
[quote]CrawBird wrote...
My script is long but, if there are people willing to help, I'm certainly willing to post.
What's the best way to post this? Is there any way to post those scolling text boxes like on the old site? I'm not convinced that the BBCode [code*] or [quote*] tags are going to do a lot of good with something this long.
[/quote]
I recommend PasteBin. Then you post the link here.
My script is long but, if there are people willing to help, I'm certainly willing to post.
What's the best way to post this? Is there any way to post those scolling text boxes like on the old site? I'm not convinced that the BBCode [code*] or [quote*] tags are going to do a lot of good with something this long.
[/quote]
I recommend PasteBin. Then you post the link here.
#5
Posté 04 juin 2011 - 05:34
I'll check PasteBin soon but I have to turn off my computer shortly so I'll just dump my latest findings.
I made a test script that is fired by the GUI during OnAdd and says this:
Line 1: Should return class # for first class
Line 2: Should return level of class 1
Line 3: Should also return level of class 1
When I open the GUI with my main character, I get:
8 <-- first class rogue
9 <-- correct levels in rogue
9 <-- correct levels in rogue
When I open the GUI with a controlled companion, I get:
39 <-- first class warlock
0 <-- !?!
22 <-- correct levels in warlock
Many of the problems that I've been having are all using script that utilizes
This actually solved most of the problems that I've been having. I'm successfully using work arounds with the
This line still always hits the main character for some reason.
Head scratcher, eh?
I made a test script that is fired by the GUI during OnAdd and says this:
SendMessageToPC(GetControlledCharacter(OBJECT_SELF), IntToString(GetclassByPosition(1, GetControlledCharacter(OBJECT_SELF))));
SendMessageToPC(GetControlledCharacter(OBJECT_SELF), IntToString(GetLevelByclass(GetclassByPosition(1, GetControlledCharacter(OBJECT_SELF)))));
SendMessageToPC(GetControlledCharacter(OBJECT_SELF), IntToString(GetLevelByPosition(1, GetControlledCharacter(OBJECT_SELF))));
Line 1: Should return class # for first class
Line 2: Should return level of class 1
Line 3: Should also return level of class 1
When I open the GUI with my main character, I get:
8 <-- first class rogue
9 <-- correct levels in rogue
9 <-- correct levels in rogue
When I open the GUI with a controlled companion, I get:
39 <-- first class warlock
0 <-- !?!
22 <-- correct levels in warlock
Many of the problems that I've been having are all using script that utilizes
GetLevelByclass.It seems to me that
GetLevelByclassdoes not work with controlled characters and grabs OBJECT_SELF instead for some reason. It would explain the results of the above experiment (my rogue has 0 levels in warlock afterall).
This actually solved most of the problems that I've been having. I'm successfully using work arounds with the
GetclassByPositionfunction. The problems I have with some other functions I'm starting to think are unrelated with one exception:
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_CRAFT_SELF), GetControlledCharacter(OBJECT_SELF));
This line still always hits the main character for some reason.
Head scratcher, eh?





Retour en haut






