Skip to content

Restcheck (code for mod rest scene compatibility with BG2:EE and other mods). Version 1.07

BCaesarBCaesar Member Posts: 453
edited June 2020 in BGII:EE Mods
Full Rest Check version 1.08
Update: One bug fix. In the ToB Imoen romance mod I had forgotten to copy over a Global("ImoenRomanceActive","GLOBAL",2) into restcheck. That's fixed now (it wouldn't have affected anything in the IR-Romance, but it was breaking my mod which used the restcheck code).

What this is:
Rest Check is code to prevent the rest scenes in your mod from triggering at the same time as the dreams and rest scenes in Baldur's Gate II - Enhanced Edition. It will stop any of your rest scenes from triggering before another one does, and for two turns (minutes) of real-time afterward.

The Rest Check Tool is code that triggers a dialogue every time you rest which checks whether or not restcheck is working.

How to add rest check to a mod you have created:
1) Open the restcheck tp2 file (I'm assuming with Notepad++). Copy and paste the contents into your own mod tp2 file, anywhere after BEGIN. If you want to use the restcheck tool then open that tp2 file and copy/paste that on the bottom of your mod tp2 file. Then use Find... (Under Search, or CTRL+F), go to the 'Replace' tab. Find what: ModFolderName and replace it with whatever the actual name of your mod folder is.

2) Copy the restcheck folder and paste it in your mod folder. Do the same with the restchecktool folder if you want to use that as well.

3) Add the following trigger to your mod's rest scenes:
Global("_rc_restcheck","GLOBAL",0)
You do not need to change the prefix.

4) You're done. Now your mod scenes will not trigger on the same rest as any of the in-game dreams or romance rest scenes in Baldur's Gate II - Enhanced Edition.

5) If you added the restchecktool to your mod as well then that will have a separate install option when your mod installs. It's only used for testing purposes. You don't need it for restcheck to work (only to verify that it is working).

Mods using restcheck:
I know of two so far:
Playable Clara and All things Mazzy
Corthala Romantique


Thank you.
-BCaesar

P.S.

Here's an example of the coding from restcheck, so you can see how it works. This is for the very first dream in Baldur's Gate SoA:


So what this does is if all the conditions for this dream are met (meaning it will happen the next time you rest) then it sets Global("_rc_restcheck","GLOBAL",1). On your rest scenes you add the condition trigger: Global("_rc_restcheck","GLOBAL",0), so your scenes will yield to those already in game.

Once the first Imoen dream starts (or any other scene) RestCheck sets Global("_rc_restcheck","GLOBAL",2), meaning that your dreams still will not trigger. Then this coding takes over: //Rest check timer. IF Global("_rc_restcheck","GLOBAL",2) THEN RESPONSE #100 SetGlobal("_rc_restcheck","GLOBAL",3) RealSetGlobalTimer("_rc_restchecktimer1","GLOBAL",TWO_TURNS) END IF RealGlobalTimerExpired("_rc_restchecktimer1","GLOBAL") Global("_rc_restcheck","GLOBAL",3) THEN RESPONSE #100 SetGlobal("_rc_restcheck","GLOBAL",0) END </pre>

So once the dream starts and Global("_rc_restcheck","GLOBAL",2) is set then a 2 minute timer (real-time) starts. As long as that timer is running your rest scenes will still yield. This prevents your scene from occuring right after the Imoen dream finishes. After the 2 minutes Rest Check resets Global("_rc_restcheck","GLOBAL",0) meaning your rest scene is able to happen the next time you rest.

A variation of this coding is used for every dream and every romance rest scene in BG2:EE (and for all the Mod rest scenes in Rest Check for Mod Scenes. IF //First Imoen Dream GlobalTimerExpired("ImoenDream1","GLOBAL") Global("HadImoenDream1","GLOBAL",0) GlobalLT("Chapter","GLOBAL",4) Global("_rc_restcheck","GLOBAL",0) THEN RESPONSE #100 SetGlobal("_rc_restcheck","GLOBAL",1) END IF Global("HadImoenDream1","GLOBAL",1) Global("_rc_HadImoenDream1","GLOBAL",0) THEN RESPONSE #100 SetGlobal("_rc_HadImoenDream1","GLOBAL",1) SetGlobal("_rc_restcheck","GLOBAL",2) END </pre>
Post edited by BCaesar on

Comments

  • BCaesarBCaesar Member Posts: 453
    edited March 2017
    Also, if you have a mod with a rest-scene I highly recommend you break up the scripting so it attempts to trigger until succeeding (rather than only attempting to trigger once). For example this is my coding in korgand.baf for the Korgan-Mazzy Inn scene in All Things Mazzy:
    
    IF //Korgan and Mazzy Inn Scene Trigger	
    	InParty("Korgan")
    	InParty("Mazzy")
    	!StateCheck("Mazzy",CD_STATE_NOTVALID)
    	!StateCheck(Player1,CD_STATE_NOTVALID)
    	!StateCheck("Korgan",CD_STATE_NOTVALID)
    	OR(11)
    		AreaCheck("AR0021")        // City Gates - Crooked Crane 1st floor
    		AreaCheck("AR0313")        // Docks - Sea's Bounty 1st floor
    		AreaCheck("AR0406")        // Slums - Copper Coronet
    		AreaCheck("AR0509")        // Bridge - Five Flagons 1st floor
    		AreaCheck("AR0513")        // Bridge - Calbor's Inn 1st floor
    		AreaCheck("AR0522")        // Bridge - Five Flagons 1st floor (stronghold)
    		AreaCheck("AR0704")        // Waukeen's Promenade - Mithrest Inn
    		AreaCheck("AR0709")        // Waukeen's Promenade - Den of the Seven Vales
    		AreaCheck("AR1105")        // Umar Hills - Imnesvale Inn
    		AreaCheck("AR1602")        // Brynnlaw - Brynnlaw Inn
    		AreaCheck("AR2010")        // Trademeet - Vytori's Pub
    	Global("_BKTRM","GLOBAL",0)
    	Global("_brestcheck","GLOBAL",0)
    	Global("_bkoma","GLOBAL",6)
    THEN
    	RESPONSE #100
    		SetGlobal("_BKTRM","GLOBAL",1)
    END	
    
    So the first script is the normal script triggering the dialogue and setting a new trigger: Global("_BKTRM","GLOBAL",1)

    Then I have the script triggering the dialogue in korgan.baf (the normal file for korgan). Remember the first one is in the dream file: korgand.
    
    IF //Korgan and Mazzy Inn Scene Dialogue Trigger    
        Global("_BKTRM","GLOBAL",1)
    THEN
        RESPONSE #100
            ActionOverride(Player1,SetDialog("Player1"))
            StartDialogNoSet(Player1)
    END      
    
    This way the dream file (korgand) only sets the trigger and then the normal file (korgan) keeps trying to start dialogue until it works (instead of trying only once). It seems to work much more reliably.
    Post edited by BCaesar on
  • BCaesarBCaesar Member Posts: 453
    edited July 2019
    Post deleted.
    Post edited by BCaesar on
  • BCaesarBCaesar Member Posts: 453
    edited July 2019
    The current version of restcheck also has coding that prevents your rest scene from happening on the same rest as scenes from any of the following mods. However if are the designer of one of those mods and put restcheck into that mod you have to remove the parts that go to your mod or it will create a feedback loop that will make nothing ever trigger (so for example if you made Mazzy Friendship and put restcheck into Mazzy Friendship you'd have to remove the part of the coding that triggers on Mazzy Friendship's rest scenes.)

    1) Keldorn, Edwin, and Nalia romances (I'm not looking up the links, but they're easy to find).
    2) Mazzy Friendship: http://www.spellholdstudios.net/ie/mazzyfriendship
    3) NPC IEP Banters: http://www.spellholdstudios.net/ie/npciep
    4) Haer'Dalis Romance: http://www.spellholdstudios.net/ie/haerdalisromance
    5) Sarevok Romance: http://www.spellholdstudios.net/ie/sarevokromance
    6) Imoen Romance: http://www.imoen.blindmonkey.org/
    7) Yoshimo Romance: http://www.baldursgatemods.com/forums/index.php?board=99.0

    Let me know if there's any problems with it. It's been a year since I last messed with it so I may have missed something making this. I do remember that you cannot use this coding in your mod if your mod is any of the ones listed above. It'll create a yielding loop where your mod yields to it's own scenes and break everything.

    I have it in my Mazzy/Playable Clara Mod and have confirmed it works with the first three Imoen dream sequences in the Imoen romance mod.
    Post edited by BCaesar on
  • BCaesarBCaesar Member Posts: 453
    BCaesar said:

    Update: Added the rest-check for mods coding.

    And then updated it because the tp2 file in 1.02 wasn't right. Should be right now.
  • BCaesarBCaesar Member Posts: 453
    Posted version 1.04. Better coding makes the restchecktool fix itself if it gets interrupted.
  • BCaesarBCaesar Member Posts: 453
    Version 1.05. A few bug fixes including a reset timer that (tested successfully) fixes some of the triggers should something break them.
  • jasteyjastey Member Posts: 2,669
    edited July 2019
    Hi, the list of mods does not match with the one in the readme.

    Also, you list Keldorn romance but all I see is a check for his romance active value for Haer'Dalis's rest talk. How is restcheck yielding to rest talks of the Keldorn romance, exactly?
  • BCaesarBCaesar Member Posts: 453
    jastey wrote: »
    Hi, the list of mods does not match with the one in the readme.

    Also, you list Keldorn romance but all I see is a check for his romance active value for Haer'Dalis's rest talk. How is restcheck yielding to rest talks of the Keldorn romance, exactly?

    Wow, I really botched that one. What's in the thread is correct. I deleted the readme. Also put the current files in. Ok should all be fixed now. This is what I get for waiting too long inbetween coding.
  • jasteyjastey Member Posts: 2,669
    I would like to repeat my question concerning the Keldorn Romance, how exactly does RestCheck Mod consider it?
  • BCaesarBCaesar Member Posts: 453
    jastey wrote: »
    I would like to repeat my question concerning the Keldorn Romance, how exactly does RestCheck Mod consider it?

    I had to do a quick change to make all the prefixes right again (they should've been _rc_ instead of _b) but anyways here's the code for the Keldorn file. It works like all the others, with it setting restcheck once the rest scene is ready to trigger, and then setting it to 2 (which starts the timer that eventually gets it back to zero) once the rest scene has already triggered.
    IF	//1st Keldorn Romance Mod SoA Rest EXTEND_BOTTOM ~keldorn.bcs~
    	InParty(Myself)
    	RealGlobalTimerExpired("B!KelTime","GLOBAL")
    	Global("B!KeldornRA","GLOBAL",1)
    	!AreaType(DUNGEON)
    	!Global("Chapter","GLOBAL",5)
    	!StateCheck(Myself,CD_STATE_NOTVALID)
    	!StateCheck(Player1,CD_STATE_NOTVALID)
    	CombatCounter(0)
    	!See([ENEMY])
    	Global("B!KelLT","GLOBAL",15)
    	Global("_rc_restcheck","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",1)
    END
    
    IF
    	Global("B!KelLT","GLOBAL",16)
    	Global("_rc_B!KelLT16","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",2)
    	SetGlobal("_rc_B!KelLT16","GLOBAL",1)
    END
    
    
    IF 	//2nd Keldorn Romance Mod SoA Rest EXTEND_BOTTOM ~keldorn.bcs~
    	InParty(Myself)
    	RealGlobalTimerExpired("B!KelTime","GLOBAL")
    	TimeOfDay(NIGHT)
    	Global("B!KeldornRA","GLOBAL",1)
    	!AreaType(DUNGEON)
    	!Global("Chapter","GLOBAL",5)
    	!StateCheck(Myself,CD_STATE_NOTVALID)
    	!StateCheck(Player1,CD_STATE_NOTVALID)
    	CombatCounter(0)
    	!See([ENEMY])
    	Global("B!KelLT","GLOBAL",67)
    	GlobalLT("Chapter","GLOBAL",8)
    	Global("_rc_restcheck","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",1)
    END
    
    IF
    	Global("B!KelLT","GLOBAL",68)
    	Global("_rc_B!KelLT68","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",2)
    	SetGlobal("_rc_B!KelLT68","GLOBAL",1)
    END
    
    
    IF	//3rd Keldorn Romance Mod SoA Rest EXTEND_BOTTOM ~keldorn.bcs~
    	InParty(Myself)
    	Global("B!KeldornRA","GLOBAL",1)
    	!AreaType(DUNGEON)
    	!Global("Chapter","GLOBAL",5)
    	!StateCheck(Myself,CD_STATE_NOTVALID)
    	!StateCheck(Player1,CD_STATE_NOTVALID)
    	CombatCounter(0)
    	!See([ENEMY])
    	Global("B!KelLT","GLOBAL",11)
    	OR(11)
    		AreaCheck("AR0021")
    		AreaCheck("AR0313")
    		AreaCheck("AR0406")
    		AreaCheck("AR0509")
    		AreaCheck("AR0513")
    		AreaCheck("AR0522")
    		AreaCheck("AR0704")
    		AreaCheck("AR0709")
    		AreaCheck("AR1105")
    		AreaCheck("AR1602")
    		AreaCheck("AR2010")
    	Global("_rc_restcheck","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",1)
    END
    
    IF
    	Global("B!KelLT","GLOBAL",12)
    	Global("_rc_B!KelLT12","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",2)
    	SetGlobal("_rc_B!KelLT12","GLOBAL",1)
    END
    	
    	
    IF	//4th Keldorn Romance Mod SoA Rest EXTEND_BOTTOM ~keldorn.bcs~
    	InParty(Myself)
    	Global("B!KeldornRA","GLOBAL",1)
    	!AreaType(DUNGEON)
    	!Global("Chapter","GLOBAL",5)
    	!StateCheck(Myself,CD_STATE_NOTVALID)
    	!StateCheck(Player1,CD_STATE_NOTVALID)
    	CombatCounter(0)
    	!See([ENEMY])
    	Global("B!KelLT","GLOBAL",53)
    	OR(11)
    		AreaCheck("AR0021")
    		AreaCheck("AR0313")
    		AreaCheck("AR0406")
    		AreaCheck("AR0509")
    		AreaCheck("AR0513")
    		AreaCheck("AR0522")
    		AreaCheck("AR0704")
    		AreaCheck("AR0709")
    		AreaCheck("AR1105")
    		AreaCheck("AR1602")
    		AreaCheck("AR2010")
    	Global("_rc_restcheck","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",1)
    END
    
    IF
    	Global("B!KelLT","GLOBAL",54)
    	Global("_rc_B!KelLT54","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",2)
    	SetGlobal("_rc_B!KelLT54","GLOBAL",1)
    END
    
    
    IF	//4th Keldorn Romance Mod SoA Rest EXTEND_BOTTOM ~keldorn.bcs~
    	InParty(Myself)
    	GlobalTimerExpired("B!KelNightTime","GLOBAL")
    	Global("B!KeldornRA","GLOBAL",1)
    	!AreaType(DUNGEON)
    	!Global("Chapter","GLOBAL",5)
    	!StateCheck(Myself,CD_STATE_NOTVALID)
    	!StateCheck(Player1,CD_STATE_NOTVALID)
    	CombatCounter(0)
    	!See([ENEMY])
    	GlobalLT("Chapter","GLOBAL",8)
    	Global("B!KelNT","GLOBAL",1)
    	Global("_rc_restcheck","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",1)
    END
    
    IF
    	Global("B!KelNT","GLOBAL",2)
    	Global("_rc_B!KelNT2","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",2)
    	SetGlobal("_rc_B!KelNT2","GLOBAL",1)
    END
    
    
    IF	//5th Keldorn Romance Mod SoA Rest EXTEND_BOTTOM ~keldorn.bcs~
    	InParty(Myself)
    	GlobalTimerExpired("B!KelNightTime","GLOBAL")
    	Global("B!KeldornRA","GLOBAL",1)
    	!AreaType(DUNGEON)
    	!Global("Chapter","GLOBAL",5)
    	!StateCheck(Myself,CD_STATE_NOTVALID)
    	!StateCheck(Player1,CD_STATE_NOTVALID)
    	CombatCounter(0)
    	!See([ENEMY])
    	GlobalLT("Chapter","GLOBAL",8)
    	Global("B!KelNT","GLOBAL",3)
    	Global("_rc_restcheck","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",1)
    END
    
    IF
    	Global("B!KelNT","GLOBAL",4)
    	Global("_rc_B!KelNT4","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",2)
    	SetGlobal("_rc_B!KelNT4","GLOBAL",1)
    END
    
    
    IF	//6th Keldorn Romance Mod SoA Rest EXTEND_BOTTOM ~keldorn.bcs~
    	InParty(Myself)
    	GlobalTimerExpired("B!KelNightTime","GLOBAL")
    	Global("B!KeldornRA","GLOBAL",1)
    	!AreaType(DUNGEON)
    	!Global("Chapter","GLOBAL",5)
    	!StateCheck(Myself,CD_STATE_NOTVALID)
    	!StateCheck(Player1,CD_STATE_NOTVALID)
    	CombatCounter(0)
    	!See([ENEMY])
    	GlobalLT("Chapter","GLOBAL",8)
    	Global("B!KelNT","GLOBAL",5)
    	Global("_rc_restcheck","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",1)
    END
    
    IF
    	Global("B!KelNT","GLOBAL",6)
    	Global("_rc_B!KelNT6","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",2)
    	SetGlobal("_rc_B!KelNT6","GLOBAL",1)
    END
    
    
    IF	//7th Keldorn Romance Mod SoA Rest EXTEND_BOTTOM ~keldorn.bcs~
    	InParty(Myself)
    	GlobalTimerExpired("B!KelNightTime","GLOBAL")
    	Global("B!KeldornRA","GLOBAL",1)
    	!AreaType(DUNGEON)
    	!Global("Chapter","GLOBAL",5)
    	!StateCheck(Myself,CD_STATE_NOTVALID)
    	!StateCheck(Player1,CD_STATE_NOTVALID)
    	CombatCounter(0)
    	!See([ENEMY])
    	GlobalLT("Chapter","GLOBAL",8)
    	Global("B!KelNT","GLOBAL",7)
    	Global("_rc_restcheck","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",1)
    END
    
    IF
    	Global("B!KelNT","GLOBAL",8)
    	Global("_rc_B!KelNT8","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",2)
    	SetGlobal("_rc_B!KelNT8","GLOBAL",1)
    END
    
    
    IF	//8th Keldorn Romance Mod SoA Rest EXTEND_BOTTOM ~keldorn.bcs~
    	InParty(Myself)
    	Global("B!KelBandage","LOCALS",1)
    	Global("B!KeldornRA","GLOBAL",1)
    	!StateCheck(Myself,CD_STATE_NOTVALID)
    	!StateCheck(Player1,CD_STATE_NOTVALID)
    	CombatCounter(0)
    	!See([ENEMY])
    	GlobalLT("Chapter","GLOBAL",8)
    	Global("_rc_restcheck","GLOBAL",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",1)
    END
    
    IF
    	Global("B!KelBandage","LOCALS",2)
    	Global("_rc_B!KelBandage2","LOCALS",0)
    THEN
    	RESPONSE #100
    	SetGlobal("_rc_restcheck","GLOBAL",2)
    	SetGlobal("_rc_B!KelBandage2","LOCALS",1)
    END
    
  • BCaesarBCaesar Member Posts: 453
    One bug fix involving me leaving a Global("ImoenRomanceActive","GLOBAL",2) out of the code to check for the ToB Imoen romance. It wouldn't have affected the Imoen Romance at all, but since my mod uses restcheck it was making my mod's rest scenes never play after Saradush was sacked if Imoen was in my party. Fixed now.
Sign In or Register to comment.