Skip to content

What is it with Wait(), FadeToColor() and LeaveAreaLUA()?

chimericchimeric 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?

Comments

  • BalquoBalquo Member, Developer Posts: 2,746
    Paste the script and I'll take a look.
  • chimericchimeric Member Posts: 1,163
    edited February 2017
    I'm going to post a script action in my .d file, because that's where it's triggered - in the concluding reply of a dialogue. This may be of some importance.

    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
    Post edited by chimeric on
  • BalquoBalquo Member, Developer Posts: 2,746
    edited February 2017
    I would add this to a cutscene. So your action for each reply would be something like
    THEN REPLY ~*Suddenly grab him and drag him out of the tent.*~ DO ~ClearAllActions()
    StartCutSceneMode()
    StartCutScene("file_name") ~ EXIT
    
    And the cutscene itself:
    IF
    	True()
    THEN
    	RESPONSE #100
    		CutSceneId(Player1)
    		FadeToColor([0.0],0) 
    		AddexperienceParty(150) 
    		SetGlobal("KARQUE_RESCUED","GLOBAL",1) 
    		ActionOverride("KARQUE",MakeGlobal()) 
    		Wait(1) 
    		MoveGlobal("AR4900","KARQUE",[1750.3030]) 
    		ApplySpellRES("BOUNCE_#","KARQUE") 
    		LeaveAreaLUA("AR4900","",[1750.3130],SW)
    		ActionOverride(Player2,LeaveAreaLUA("AR4900","",[1750.3130],S))
    		ActionOverride(Player3,LeaveAreaLUA("AR4900","",[1750.3130],S))
    		ActionOverride(Player4,LeaveAreaLUA("AR4900","",[1750.3130],S))
    		ActionOverride(Player5,LeaveAreaLUA("AR4900","",[1750.3130],S))
    		ActionOverride(Player6,LeaveAreaLUA("AR4900","",[1750.3130],S))
    		FadeFromColor([30.0],0) 
    		EndCutSceneMode()
    END
    Post edited by Balquo on
  • chimericchimeric Member Posts: 1,163
    edited February 2017
    This worked for teleporting, but the Bounce spell now turns Karque hostile, and the party kills him when they all appear outside. The spell isn't flagged "Hostile," and ApplySpellRES is cast by the engine itself, not any character, so I'm not sure why that happens. Also doing it with a cutscene zooms the action unpleasantly out of the 800x600 or so resolution the game is most enjoyably played at. Anything that happens in a real cutscene has to be squinted at, which is why I only imitate them with SetCursorMode().

    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.
    Post edited by chimeric on
  • ArdanisArdanis Member Posts: 1,736
    Transitions between areas only work via dedicated StartCutscene() script with Player1 as ID. Otherwise something just randomly breaks. The zoom issue may be unfortunate, but it's a far, far lesser evil.

    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
    IF
    Global("block_my_scripts","locals",1)
    THEN
    RESPONSE #100
    NoAction()
    END
  • BalquoBalquo Member, Developer Posts: 2,746
    I would guess that Player1 is casting the spell during the cutscene since Player1 is the ID and that is why he is turning hostile. Try ActionOverride("KARQUE",ApplySpellRES("BOUNCE_#",Myself)) instead.
  • chimericchimeric Member Posts: 1,163
    I tried to make Karque the object of the Cutscene, and then I got the weird long black-out. Anyway, I don't like the zoom-out, so putting the whole thing in baldur.bcs did the job under a fake mode. At least baldur runs anywhere and always. There were a few more scripts with moving globals about, fade-outs and waits, but all run fine from the dialogue when only the party is moved. It's when a misc NPC made global has to teleport somewhere under this cover of night that weirdness happens. Of course, I have to use some length of FadeToBlack + Wait() to cover the mechanics, but any length of Wait() after the teleport and before FadeFromColor leads to a long stretch of gloom...

    Anyway, no biggie. I really wish I could use AdvanceTime() in the middle of a script, though.
Sign In or Register to comment.