Jump to content


Photo

Restcheck: Coding to make your mod's rest scenes yield to those in


  • Please log in to reply
7 replies to this topic

#1 BCaesar

BCaesar
  • Member
  • 56 posts

Posted 31 March 2017 - 07:51 PM

Rest Check, version 1.01, and RestCheck for Mods version 1.03

Created by BCaesar

Update: Added "RestCheck For Mods", additional coding that will allow your rest scenes to yield to those from a list of other mods. That attachment is in post #3. The two attachments to post #1 are unchanged.


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:
Two mods that I know of:

All Things Mazzy, Playable Clara

Corthala Romantique



How to help Test RestCheck:
You can download restcheck as a stand-alone mod (instead of adding it to a mod) and test restcheck with the restcheck tool (included).

So far RestCheck has been tested and is confirmed to work with:
1) The first three Imoen/Jon dreams in Baldur's Gate II.

It still needs to be tested with the two later dreams and with the romance rest scenes from BG2:EE. What it should do if it's working on that rest is the restchecktool will say, "!!!Restcheck is preventing a rest scene from your mod triggering this rest." If you find that it is not working or there are some bugs you can post about them in the RestCheck thread or e-mail me at caesarbran@gmx.com
 

And for my own ease-of-use here's the link to the Restcheck thread on the Beamdog Forum.

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:

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

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

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).

Attached Files


Edited by BCaesar, 06 July 2018 - 01:43 PM.

Mod: All Things Mazzy (banters, romance, expanded friendship and more)

Tutorial/Coding: Rest Check (coding for anyone to make their Mod's rest scenes yield to those from BG2:EE and additional coding to make them yield to those from a list of other mods as well.


#2 BCaesar

BCaesar
  • Member
  • 56 posts

Posted 31 March 2017 - 07:58 PM

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 which just sets 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.


Mod: All Things Mazzy (banters, romance, expanded friendship and more)

Tutorial/Coding: Rest Check (coding for anyone to make their Mod's rest scenes yield to those from BG2:EE and additional coding to make them yield to those from a list of other mods as well.


#3 BCaesar

BCaesar
  • Member
  • 56 posts

Posted 31 March 2017 - 08:00 PM

Lastly, the third attachment: Restcheck for Mods 1.03 is additional coding to make your mod's rest scenes not trigger at the same time as any of the following mods:

1) Keldorn, Edwin, and Nalia romances (I'm not looking up the links, but they're easy to find).
2) Mazzy Friendship: http://www.spellhold...mazzyfriendship
3) Viconia Friendship: http://www.spellhold....net/ie/viconia
4) NPC IEP Banters: http://www.spellhold...s.net/ie/npciep
5) Haer'Dalis Romance: http://www.spellhold...aerdalisromance
6) Sarevok Romance: http://www.spellhold.../sarevokromance
7) Imoen Romance: http://www.imoen.blindmonkey.org/

8 ) Yoshimo Romance: http://www.baldursga....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.

Attached Files


Edited by BCaesar, 06 July 2018 - 01:43 PM.

Mod: All Things Mazzy (banters, romance, expanded friendship and more)

Tutorial/Coding: Rest Check (coding for anyone to make their Mod's rest scenes yield to those from BG2:EE and additional coding to make them yield to those from a list of other mods as well.


#4 jastey

jastey
  • Staff
  • 1178 posts

Posted 22 May 2017 - 11:30 PM

berelinde wrote a tutorial how to prevent other rest dialogues to trigger after one in your mod. It's by replacing the normal RestParty() with a spelled-out rest cutscene using Rest() for all party members which prevents rest dialogues to trigger. It can be found here.



#5 jastey

jastey
  • Staff
  • 1178 posts

Posted 31 March 2018 - 05:10 AM

Hi BCaesar, just to let you know: Corthala Romantique (Valygar Romance) (currently in testing - again) is using rest Check, too. Thank you again for providing this and sparing me a lot of work!

#6 BCaesar

BCaesar
  • Member
  • 56 posts

Posted 06 July 2018 - 12:14 PM

Hi BCaesar, just to let you know: Corthala Romantique (Valygar Romance) (currently in testing - again) is using rest Check, too. Thank you again for providing this and sparing me a lot of work!

 

Glad I could help. I've basically been gone for a year (life and all that), so it's nice to see the work I put in go to some use.

 

Plus my partner in our Mazzy mod got so tired of me not having free time that she learned to code and she's good enough now that she's updating it and doing the coding part so that's being updated again.


Edited by BCaesar, 06 July 2018 - 01:23 PM.

Mod: All Things Mazzy (banters, romance, expanded friendship and more)

Tutorial/Coding: Rest Check (coding for anyone to make their Mod's rest scenes yield to those from BG2:EE and additional coding to make them yield to those from a list of other mods as well.


#7 BCaesar

BCaesar
  • Member
  • 56 posts

Posted 06 July 2018 - 01:06 PM

Hi BCaesar, just to let you know: Corthala Romantique (Valygar Romance) (currently in testing - again) is using rest Check, too. Thank you again for providing this and sparing me a lot of work!

 

Just letting you know I added my "Rest Check for Mod Scenes" coding. It's attached to post #3 and will make your mod yield to the rest scenes of all the other mods listed.


Mod: All Things Mazzy (banters, romance, expanded friendship and more)

Tutorial/Coding: Rest Check (coding for anyone to make their Mod's rest scenes yield to those from BG2:EE and additional coding to make them yield to those from a list of other mods as well.


#8 jastey

jastey
  • Staff
  • 1178 posts

Posted 06 July 2018 - 02:59 PM

BCaesar: nice to see you back! And good tactic of getting your partner to code!..

One question: If one mod yields to all other mods, how do you make sure the rest scenes are "equally distributed" between mods and not one mod kind of never triggers its rest scenes? I'd be kind of nervous that "my" mod's rest scenes won't have a chance to trigger.