What is it with Wait(), FadeToColor() and LeaveAreaLUA()?
chimeric
Member Posts: 1,163
I'm using the last of these actions to move creatures around. FadeToColor starts first to cover it up, but with the LUA the blackness lasts 10-15 seconds, even without a Wait(). In fact, I removed Wait() to shorten the time a little, and it's still too long. The game action has resumed, FadeFromColor was written to go off quickly, now characters are talking, music is playing, but all is black. This is similar to the problems I'm having with AdvanceTime() - either in combination with FadeToBlack or by itself it invokes a long blackness. Has anyone else noticed this?
0
Comments
The problem with a long black-out happens both for LeaveAreaLUA and MoveGlobal, which I began to use instead. I thought SetCursorState was to blame, because the actions all happened in the pseudo-cutscene mode, but I have since eliminated it.
Here is the script. The idea is: at the end of the reply line the party roughs up the NPC - file name KARQUE_#, script name KARQUE, and drags him outside. There is another, recent problem with it, for some reason the script fails to teleport (move) creatures, including "Karque" who is made Global. I gave a Wait(1) for that command to be processed, no difference. The teleport used to work in some combination, Karque was whisked away together with the party. But now none of them go. When the saved game is opened in an editor, the list of global NPC includes *ARQUE_#.
The "BOUNCE_#" spell knocks the target unconscious (so not processing scripts). I don't know whether this matters for MoveGlobal, and it makes no difference whether I apply the spell before.
Here are the two scripts, both are problematic. The first one produces a long blackness but no one teleports anywhere. The second one has no Wait(), so it is quick, and teleports them all - somewhere, the current area grays out, but the creatures all become unclickable. The coordinates of their destination are correct, I just checked them. "AR4900" is the Nashkel Fair and the [x.y] value is in open, clear spot.
1.
THEN REPLY ~*Tackle and pin.*~ DO ~FadeToColor([0.0],0) AddexperienceParty(150) SetGlobal("KARQUE_RESCUED","GLOBAL",1) ActionOverride("KARQUE",MakeGlobal()) Wait(1) MoveGlobal("AR4900","KARQUE",[1750.3030]) ApplySpellRES("BOUNCE_#","KARQUE") MoveGlobal("AR4900",Player1,[1750.3130]) MoveGlobal("AR4900",Player2,[1750.3130]) MoveGlobal("AR4900",Player3,[1750.3130]) MoveGlobal("AR4900",Player4,[1750.3130]) MoveGlobal("AR4900",Player5,[1750.3130]) MoveGlobal("AR4900",Player6,[1750.3130]) FadeFromColor([30.0],0) ~ EXIT
2.
THEN REPLY ~*Suddenly grab him and drag him out of the tent.*~ DO ~FadeToColor([0.0],0) AddexperienceParty(150) SetGlobal("KARQUE_RESCUED","GLOBAL",1) ActionOverride("KARQUE",MakeGlobal()) VerbalConstant("KARQUE",DAMAGE) ApplySpellRES("BOUNCE_#","KARQUE") MoveGlobal("AR4900","KARQUE",[1750.3030]) MoveGlobal("AR4900",Player1,[1750.3130]) MoveGlobal("AR4900",Player2,[1750.3130]) MoveGlobal("AR4900",Player3,[1750.3130]) MoveGlobal("AR4900",Player4,[1750.3130]) MoveGlobal("AR4900",Player5,[1750.3130]) MoveGlobal("AR4900",Player6,[1750.3130]) FadeFromColor([30.0],0) ~ EXIT
P.S. When I changed the code to CutSceneId("KARQUE"), hoping Player1 in the Object field there was the reason why the game perceived the spell as cast by the party, there was a long blackness, and when it finally lifted, everyone was in their old places. The cutscene mode wouldn't end, too. I had to shut down the game with Task Manager.
P.P.S. After this, Balquo, I tried to put the code, minus the cutscene bit, in the area file. The reply line now just sets the global. But I had to do a lot of tweaking with Wait() in-between and after MakeGlobal and the moving actions. The long blackness is obviously some kind of bug that can't be eradicated. Meanwhile I learned that AdvanceTime in the middle of a script always or very easily breaks the chain.
And, as might have been expected, any actions in an area script written to happen after all of the actors are teleported to another area, fail. This includes FadeFromColor, and giving back the inteface, too. The actors are in another area by that point.
My next idea was to put the actions in the script of the creature itself, but the catch there is that it applies unconsciousness to itself, hence can't process the rest...
It was quite a special combination of teleports, a knockout and a pseudo cutscene. In the end I put it in baldur.bcs.
Hostility - that really depends on what scripts he has. It you only need to prevent them from running for a while, then adding something like this to the top of override script should be enough
Global("block_my_scripts","locals",1)
THEN
RESPONSE #100
NoAction()
END
Anyway, no biggie. I really wish I could use AdvanceTime() in the middle of a script, though.