Help - Search - Members - Calendar
Full Version: Global Not Setting
The Black Wyrm's Lair - Forums > Mod development resources & discussion > Modder's Workshop
Sir_Carnifex
I'm having a problem with a global variable not setting properly. This dialogue works fine, but I can't get the next in the series to occur unless I manually set it. Yet, you'd think that if it weren't being changed, that the initial dialogue would repeat over and over, but it doesn't.

Here's the code:

CODE
APPEND BKORGAN
IF ~InParty("CXHalbo")
See("CXHalbo")
!Dead("CXHalbo")
!StateCheck("CXHalbo",STATE_SLEEPING)
Global("KorganHalbo1","GLOBAL",0)~ THEN BEGIN KorganHalboTalkDwarf1
SAY ~Blah Blah.~
=
~Blah Blah.~
IF ~~ THEN DO ~SetGlobal("KorganHalbo1","GLOBAL",1)~ EXTERN BCXHALBO KorganHalboTalkDwarf1.1
END
END



The second question is:

How do I go about setting a character's state to intoxicated? I couldn't find any specific state for that. The only thing I could find was the wish spell.
Bookwyrme
One way to check to see if it is or is not setting is to use CLUAConsole:GetGlobal("KorganHalbo1","GLOBAL")

That will tell you if it's set.

I suggest also checking the conditions for the next talk firing to make sure that you have typed the Global the exact same way--typos, I report from experience, are fairly easy. If that doesn't work, maybe you could also post the triggering conditions for the next talk for people to see.
Sir_Carnifex
Thanks, I'll check to see if it sets. I didn't know about that GetGlobal thing.

And believe me when I say I know ALL about typos! I am pretty sure this is NOT the problem as I checked for that at least five times. I will look over it again though. Sometimes I miss obvious things. banghead.gif
Sikret
Variabes take a little bit time to be set. If you set a variable in a dialogue line which immediately transfers you to another dialogue block which checks that particular variable, the variable will not be set in such a short priod of time. There are several possible workaround for this problem depending on the situation.
Moongaze
"The next in the series" being the next part of the same banter, or an entirely new banter block that needs to fire after the current one being finished? In the latter case, I tend not to use APPEND and EXTERN if it only involves my NPC and a Bioware NPC... and I'd set a timer if I don't want the internal banter engine to randomly choose when to fire the follow-up to the previous dialogue.
Tervadh
QUOTE(Sir_Carnifex @ Jun 22 2008, 12:05 AM) *
The second question is:

How do I go about setting a character's state to intoxicated? I couldn't find any specific state for that. The only thing I could find was the wish spell.
It's a stat (stats.ids) not a state (state.ids). So you can do a StatCheck and then apply a Drunkenness modifier (opcode #94) via spell, etc.
Sir_Carnifex
QUOTE(Tervadh @ Jun 22 2008, 09:41 AM) *
QUOTE(Sir_Carnifex @ Jun 22 2008, 12:05 AM) *
The second question is:

How do I go about setting a character's state to intoxicated? I couldn't find any specific state for that. The only thing I could find was the wish spell.
It's a stat (stats.ids) not a state (state.ids). So you can do a StatCheck and then apply a Drunkenness modifier (opcode #94) via spell, etc.
I'll take a look and see what I can do. Thanks

About that variable not triggering, I solved it. Even though Weidu accepted my method of using the chain style in the APPEND to have Korgan have two lines before setting the variable, the game didn't like that. I had to put the variable after the first line, then GOTO another APPEND of Korgan's banter file. It works fine now.

Just for a visual, the edited version:

CODE
APPEND BKORGAN
IF ~InParty("CXHalbo")
See("CXHalbo")
!Dead("CXHalbo")
!StateCheck("CXHalbo",STATE_SLEEPING)
Global("KorganHalbo1","GLOBAL",0)~ THEN BEGIN KorganHalboTalkDwarf1
SAY ~Blah Blah.~
IF ~~ THEN DO ~SetGlobal("KorganHalbo1","GLOBAL",1)~ GOTO KorganHalboTalkDwarf1.01
END
END

APPEND BKORGAN
IF ~~ THEN BEGIN KorganHalboTalkDwarf1.01
SAY ~Blah Blah.~
IF ~~ THEN EXTERN BCXHALBO KorganHalboTalkDwarf1.1
END
END



Off the subject here but... While working with Korgan, I noticed that he's always repeating his first second* PC dialogue like the variable isn't setting there. Is this a bug that came with the game, or did I somehow mess something up?

*EDIT

Another Edit. I forgot to answer Moongaze. Sorry 'bout that!

QUOTE(Moongaze)
"The next in the series" being the next part of the same banter, or an entirely new banter block that needs to fire after the current one being finished? In the latter case, I tend not to use APPEND and EXTERN if it only involves my NPC and a Bioware NPC... and I'd set a timer if I don't want the internal banter engine to randomly choose when to fire the follow-up to the previous dialogue.

It's a new banter block. I do use APPEND and EXTERN because of the complicated nature of what I'm doing. Well, it's complicated for me anyway! Maybe once I get more experience, I'll learn simpler ways to do these things. For now, go with what works. smile.gif

Oh, and the second dialogue uses the J.DLG, so the banter timer doesn't come into play.
Bookwyrme
CHAIN rules.
Moongaze
QUOTE(Sir_Carnifex @ Jun 23 2008, 12:43 AM) *
Another Edit. I forgot to answer Moongaze. Sorry 'bout that!

QUOTE(Moongaze)
"The next in the series" being the next part of the same banter, or an entirely new banter block that needs to fire after the current one being finished? In the latter case, I tend not to use APPEND and EXTERN if it only involves my NPC and a Bioware NPC... and I'd set a timer if I don't want the internal banter engine to randomly choose when to fire the follow-up to the previous dialogue.

It's a new banter block. I do use APPEND and EXTERN because of the complicated nature of what I'm doing. Well, it's complicated for me anyway! Maybe once I get more experience, I'll learn simpler ways to do these things. For now, go with what works. smile.gif

Oh, and the second dialogue uses the J.DLG, so the banter timer doesn't come into play.


Egh, you're already better at this than I am, I see.
Sorry I could not be of any help.
Sir_Carnifex
QUOTE(Tervadh @ Jun 22 2008, 09:41 AM) *
QUOTE(Sir_Carnifex @ Jun 22 2008, 12:05 AM) *
The second question is:

How do I go about setting a character's state to intoxicated? I couldn't find any specific state for that. The only thing I could find was the wish spell.
It's a stat (stats.ids) not a state (state.ids). So you can do a StatCheck and then apply a Drunkenness modifier (opcode #94) via spell, etc.

Alright, back to the intoxication thing. I have to admit that when I look at this explanation, then the stats, then the set spell, then the opcodes, I'm sure if anyone were looking at me, he'd see question marks floating above my head. So would it be too much to ask for a demonstration of HOW to use these to set a character to be drunk after a dialogue? Thanks!
Bookwyrme
I wouldn't mind seeing a demonstration myself smile.gif
kulyok
Look at Xan's code: there's an intoxication stat in his script; it's easy enough. Search O#XanS.baf in Xan/Scripts.
Sir_Carnifex
Alright, I may be wrong, but it looks like that script only checks to see if the player is intoxicated. If it checks out, then it initiates the dialogue. I'm trying to do something a little different. Namely, have a character who is NOT drunk get set to intoxicated AFTER a dialogue. I don't see any SetStat action, so I assume that I have to do something with all that gibberish Tervadh mentioned.

Me after looking at it ---> wacko.gif
Daulmakan
Can't you do a SetStat for it after the dialog? Or enforcing a spell with the drunkness effect/opcode?

QUOTE
#94 (0x05E) Stat: Drunkenness Modifier [94]Parameter #1: Statistic Modifier
Parameter #2: Type
Description:
Applies the modifier value specified by the 'Statistic Modifier' field in the style specified by the 'Type' field.

Known values for 'Type' are:
0 Cumulative Modifier -> Skill = Skill + 'Statistic Modifier' value
1 Flat Value Modifier -> Skill = 'Statistic Modifier' value
2 Percentage Modifier -> Skill = (Skill * 'Statistic Modifier' value) / 100
Sir_Carnifex
I could if I knew how. First, I don't remember anything about SetStat action, nor could I find one in IESDP. I did find a ChangeStat action in IWD2 IESDP though. Is it perhaps another custom thing like CD_STATE_NOTVALID?

My main problem is that so far I've learned pretty much everything I know from actually seeing examples. Once I can see something, I can pick up how to do it (and usually remember) but explanations are a different story. You can try explaining this to me, but if I don't see it, odds are I'm going to still be confused -- which I am right now.
Sikret
The method to do it is very easy. You make a custom spell which applies the intoxication effect and then forcecast it on the creature in the dialogue file or in a script (deending on the situation).

If you want, I can do it for you. Just send me your prefix (in order to name the new spell correctly to make sure that it won't cause conflicts with other mods) and the dialogue file in which you want to apply the effect (you can send them to me via PM if you want).
Sir_Carnifex
QUOTE(Sikret @ Jun 25 2008, 01:12 AM) *
The method to do it is very easy. You make a custom spell which applies the intoxication effect and then forcecast it on the creature in the dialogue file or in a script (deending on the situation).

If you want, I can do it for you. Just send me your prefix (in order to name the new spell correctly to make sure that it won't cause conflicts with other mods) and the dialogue file in which you want to apply the effect (you can send them to me via PM if you want).

Easy is a very relative word. smile.gif

I would be very appreciative if you would do that, Sikret. I'll PM the info over later.
Tervadh
QUOTE(Sir_Carnifex @ Jun 24 2008, 05:58 PM) *
Alright, I may be wrong, but it looks like that script only checks to see if the player is intoxicated. If it checks out, then it initiates the dialogue. I'm trying to do something a little different. Namely, have a character who is NOT drunk get set to intoxicated AFTER a dialogue. I don't see any SetStat action, so I assume that I have to do something with all that gibberish Tervadh mentioned.
Eh, sorry for the late response... e-mail notifications only work half the time it seems.

What Sikret said is accurate. There is in fact already a spell to apply drunkenness in the game (spwish33) though as a wish spell I think this makes everyone drunk, so you may want your own version smile.gif. The script could be as simple as:
CODE
IF
  Global("mydrunk","GLOBAL",0)
  CheckStatLT(LastTalkedToBy(),50,INTOXICATION)
THEN
  RESPONSE #100
    SetGlobal("mydrunk","GLOBAL",1)
    ApplySpellRES("SPWISH33",LastTalkedToBy())
END
I'm sure someone's come up with something more sophisticated by now.

You can use the same opcode on an item, to make (for example) a bottle of wine that increases drunkenness when consumed.
Sir_Carnifex
QUOTE(Tervadh @ Jul 20 2008, 03:13 PM) *
Eh, sorry for the late response... e-mail notifications only work half the time it seems.

What Sikret said is accurate. There is in fact already a spell to apply drunkenness in the game (spwish33) though as a wish spell I think this makes everyone drunk, so you may want your own version smile.gif. The script could be as simple as:
CODE
IF
  Global("mydrunk","GLOBAL",0)
  CheckStatLT(LastTalkedToBy(),50,INTOXICATION)
THEN
  RESPONSE #100
    SetGlobal("mydrunk","GLOBAL",1)
    ApplySpellRES("SPWISH33",LastTalkedToBy())
END
I'm sure someone's come up with something more sophisticated by now.

You can use the same opcode on an item, to make (for example) a bottle of wine that increases drunkenness when consumed.


Thanks for the answer. Sikret made the specialized spell for me already, however, and saved me the headache. smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.