Hi all,
I'm new to scripting and I'm struggling with a script I'm making for BG EE.
The idea of the script is to clear Imoen's proficiencies and give her 2 new random allocations. These 2 must be different of eachother, and so the script will generate a new allocation of there is a collission. This is my test script:
// Clear default proficiencies
IF
Exists("Imoen") // Imoen
Global("JP#IMOEN_CLEAR_PROF","GLOBAL",0)
THEN
RESPONSE #100
ChangeStat("Imoen",PROFICIENCYSHORTSWORD,0,SET)
ChangeStat("Imoen",PROFICIENCYSHORTBOW,0,SET)
SetGlobal("JP#IMOEN_CLEAR_PROF","GLOBAL",1)
END
// Generate random proficiency
IF
Exists("Imoen") // Imoen
Global("JP#IMOEN_CLEAR_PROF","GLOBAL",1)
Global("JP#IMOEN_PROF","GLOBAL",0)
THEN
RESPONSE #100
SetGlobal("JP#IMOEN_PROF","GLOBAL",90) // Long sword
RESPONSE #100
SetGlobal("JP#IMOEN_PROF","GLOBAL",91) // Short sword
END
// Apply random proficiency if not yet chosen
IF
Exists("Imoen") // Imoen
Global("JP#IMOEN_PROF","GLOBAL",90)
CheckStatLT("Imoen",1,PROFICIENCYLONGSWORD) // Long sword
GlobalLT("JP#IMOEN_PROF_DONE","GLOBAL",2)
THEN
RESPONSE #100
ChangeStat("Imoen",PROFICIENCYLONGSWORD,1,ADD) // Long sword
IncrementGlobal("JP#IMOEN_PROF_DONE","GLOBAL",1)
SetGlobal("JP#IMOEN_PROF","GLOBAL",0)
END
IF
Exists("Imoen") // Imoen
Global("JP#IMOEN_PROF","GLOBAL",91)
CheckStatLT("Imoen",1,PROFICIENCYSHORTSWORD) // Short sword
GlobalLT("JP#IMOEN_PROF_DONE","GLOBAL",2)
THEN
RESPONSE #100
ChangeStat("Imoen",PROFICIENCYSHORTSWORD,1,ADD) // Short sword
IncrementGlobal("JP#IMOEN_PROF_DONE","GLOBAL",1)
SetGlobal("JP#IMOEN_PROF","GLOBAL",0)
END
// New random proficiency if already used
IF
Exists("Imoen") // Imoen
Global("JP#IMOEN_PROF","GLOBAL",90)
!CheckStatLT("Imoen",1,PROFICIENCYLONGSWORD) // Long sword
GlobalLT("JP#IMOEN_PROF_DONE","GLOBAL",2)
THEN
RESPONSE #100
SetGlobal("JP#IMOEN_PROF","GLOBAL",0)
END
IF
Exists("Imoen") // Imoen
Global("JP#IMOEN_PROF","GLOBAL",91)
!CheckStatLT("Imoen",1,PROFICIENCYSHORTSWORD) // Short sword
GlobalLT("JP#IMOEN_PROF_DONE","GLOBAL",2)
THEN
RESPONSE #100
SetGlobal("JP#IMOEN_PROF","GLOBAL",0)
END
// Clean up
IF
Exists("Imoen") // Imoen
Global("JP#IMOEN_PROF_DONE","GLOBAL",2)
THEN
RESPONSE #100
SetGlobal("JP#IMOEN_PROF_DONE","GLOBAL",99)
DisplayString(Myself,48307) // Squeak!
DestroySelf()
END
The result should be that Imoen has one pip in long swords and one in short swords.
When executed in game, I see the Squeak message, all the variables are also set, but Imoen still has the default shortsword and short bow proficiencies.
Anybody that can help clarify why this is?