Jump to content

Variable timers: tp2


Kulyok

Recommended Posts

So! We at BG1 NPC Project are recoding the romances *yet again*, this time it is me doing this, and since I can't tell whether my way is the optimal one, I would like my "elder comrades" ;) - cmorgan and Nythrun, notably - to take a look at this piece of code and to tell me whether there's a better way to do this, which I really hope there is. I am posting it here, instead of BG1 NPC Workroom, because other mods may benefit from this in the end: Gavin NPC or Darian NPC, for one.

 

(I'd just like to mention that the code I post here is all tested and workable, it's just whether it is the best way or not, I really can't know).

 

(BACKSTORY)

Here is the task: we want every player to be able to choose his or her own speed to play the romance with. 15, 30, 45, 60 or 90 minutes.

 

The technical side: All timers are now being set in the dialogue file(if you want to know why, look here ), and instead of providing five different dialogue files, I've just written it like this in my .d file(that's Xan romance, by the way):

IF WEIGHT #-2
~Global("X#XALoveTalk","GLOBAL",18)~ THEN BEGIN XanLoveTalk9
SAY @240
++ @241 DO ~IncrementGlobal("X#XALoveTalk","GLOBAL",1) RealSetGlobalTimer("X#XALoveTalkTime","GLOBAL",%XAROM_TIMER%) SetGlobal("X#XaRomCheck","GLOBAL",0)~ + X#XALT9.1

(/BACKSTORY)

 

Now, tp2. This is where it gets ugly, because there are two steps to make:

 

1) Compile not-timer-dependant romance files: all scripts, .mos dreams, sound files, etc.

2) Provide five different subcomponents for each variable timer, where %XAROM_TIMER% gets replaced with 900, 1800, 2700, 3600.

 

cmorgan did mention a scary word "EVALUATE_BUFFER", but, since I've no idea what this is, and Weidu readme mentions it is only for .baf/.bcs files, here's what I've come up with. Basically, it's reworked BG1 NPC code:

 

The romance itself(that's probably the boring part, feel free to skip it):

 

/* XAN ROMANCE */
BEGIN @1015 /* The BG1 NPC Project: Xan's Romance Core (teen content) */
 GROUP @1010  /* The BG1 NPC Project: Romances */
 REQUIRE_FILE ~override/X#BG1NPCCore.G3~ @1004 /* BG1 NPC Required Changes component is not installed. */
COPY ~BG1NPC/Core/X#component.xx~ ~override/X#XanRomance.G3~
/* sound */
COPY ~BG1NPC/Phase3/XAROM/Sound/X#BLANK.WAV~ ~override~

 ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
/* Script */
EXTEND_TOP ~_XAND.BCS~ ~BG1NPC/Phase3/XAROM/BAF/X#XAROD.BAF~
EXTEND_TOP ~_XAN.BCS~ ~BG1NPC/Phase3/XAROM/BAF/X#XAROM.BAF~
EXTEND_TOP ~_HARTEEL.BCS~ ~BG1NPC/Phase3/XAROM/BAF/X#XASTRE.baf~
EXTEND_TOP ~_JAHEIRA.BCS~ ~BG1NPC/Phase3/XAROM/BAF/X#XAJARE.baf~
EXTEND_TOP ~_ONTARON.BCS~ ~BG1NPC/Phase3/XAROM/BAF/X#XAMORE.baf~
EXTEND_TOP ~_TIAX.BCS~ ~BG1NPC/Phase3/XAROM/BAF/X#XATIRE.baf~
EXTEND_TOP ~_MINSC.BCS~ ~BG1NPC/Phase3/XAROM/BAF/X#XAMIRE.baf~
EXTEND_TOP ~_QUAYLE.BCS~ ~BG1NPC/Phase3/XAROM/BAF/X#XAQURE.baf~
EXTEND_TOP ~_EDWIN.BCS~ ~BG1NPC/Phase3/XAROM/BAF/X#XAEDRE.baf~
 END ELSE BEGIN /* BGT Versions */
/* Script */
EXTEND_TOP ~XAND.BCS~ ~BG1NPC/BGT/BAF/X#XAROD.BAF~
EXTEND_TOP ~XAN.BCS~ ~BG1NPC/BGT/BAF/X#XAROM.BAF~
EXTEND_TOP ~SHARTEEL.BCS~ ~BG1NPC/BGT/BAF/X#XASTRE.baf~
EXTEND_TOP ~BGJHEIRA.BCS~ ~BG1NPC/BGT/BAF/X#XAJARE.baf~
EXTEND_TOP ~MONTARON.BCS~ ~BG1NPC/BGT/BAF/X#XAMORE.baf~
EXTEND_TOP ~TIAX.BCS~ ~BG1NPC/BGT/BAF/X#XATIRE.baf~
EXTEND_TOP ~BGMINSC.BCS~ ~BG1NPC/BGT/BAF/X#XAMIRE.baf~
EXTEND_TOP ~QUAYLE.BCS~ ~BG1NPC/BGT/BAF/X#XAQURE.baf~
EXTEND_TOP ~BGEDWIN.BCS~ ~BG1NPC/BGT/BAF/X#XAEDRE.baf~
 END

 

And the timers:

 

/* Xan */
BEGIN @1040 /* Xan's Romance Speed (standard: 1 hour) */
 FORCED_SUBCOMPONENT @1097 (FILE_EXISTS_IN_GAME ~X#XanRomance.G3~)  /* Romance [Xan] */
 GROUP @1010  /* The BG1 NPC Project: Romances */
 REQUIRE_FILE ~override/X#XanRomance.G3~ @1041 /* Xan's Romance is not installed. */
 ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
/* dialogue */
COPY ~BG1NPC/Phase3/XAROM/DLG/X#XANLT1.D~ ~BG1NPC/Phase3/XAROM/DLG/X#XANLT.D~
REPLACE_TEXTUALLY EXACT_MATCH "%XAROM_TIMER%" "3600"
COMPILE ~BG1NPC/Phase3/XAROM/DLG/X#XANLT.D~
 END ELSE BEGIN /* BGT Versions */
/* dialogue */
COPY ~BG1NPC/BGT/DLG/X#XANLT.D~ ~BG1NPC/BGT/DLG/X#XANLT1.D~
REPLACE_TEXTUALLY EXACT_MATCH "%XAROM_TIMER%" "3600"
COMPILE ~BG1NPC/BGT/DLG/X#XANLT.D~ 
 END

BEGIN @1042 /* Xan's Romance Speed (45 minutes) */
 FORCED_SUBCOMPONENT @1097 (FILE_EXISTS_IN_GAME ~X#XanRomance.G3~)  /* Romance [Xan] */
 GROUP @1010  /* The BG1 NPC Project: Romances */
 REQUIRE_FILE ~override/X#XanRomance.G3~ @1041 /* Xan's Romance is not installed. */
 ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
/* dialogue */
COPY ~BG1NPC/Phase3/XAROM/DLG/X#XANLT1.D~ ~BG1NPC/Phase3/XAROM/DLG/X#XANLT.D~
REPLACE_TEXTUALLY EXACT_MATCH "%XAROM_TIMER%" "2700"
COMPILE ~BG1NPC/Phase3/XAROM/DLG/X#XANLT1.D~
 END ELSE BEGIN /* BGT Versions */
/* dialogue */
COPY ~BG1NPC/BGT/DLG/X#XANLT.D~ ~BG1NPC/BGT/DLG/X#XANLT.D~
REPLACE_TEXTUALLY EXACT_MATCH "%XAROM_TIMER%" "2700"
COMPILE ~BG1NPC/BGT/DLG/X#XANLT.D~ 
 END

 

... and three more blocks like that. (We don't have to have both XANLT.d and XANLT1.d in BG1 NPC folder, of course, only XANLT1.d: XANLT.d is created in the process).

 

So, the verdict? Should we proceed like this, or is there a better way?

Link to comment

If all of the timers are in the dialogues, you can exploit the fact that symbols are looked up in real-time. Use

 

RealSetGlobalTimer("X#XALoveTalkTime","GLOBAL",XAROM_TIMER)

 

in the .d files and then append gtimes.ids with the appropriate value:

 

APPEND ~gtimes.ids~ ~2700 XAROM_TIMER~

 

Just sub 2700 for whatever's appropriate.

Link to comment

I'd not write the variable in your dialogues as %XAROM_TIMER% if you're going to use REPLACE_TEXTUALLY to change them, just XAROM_TIMER is fine ;) The EVALUATE_BUFFER stuff would really only come in handy if you have lots of variables to replace and you don't want to write lots of REPLACE_TEXTUALLY lines.

 

You can grab gtimes entries out of the fixpack lib if you don't want to write them all out again yourself.

 

I'd do this with a single component and ACTION_READLN rather than multiple components - if you'd rather not, that's fine - and if you'd rather, I'd be happy to explain ;)

Link to comment

@berelinde: Why doesn't it surprise me? ;)

 

I am all for a single component(in fact, this was what I hoped for when I posted this thread), but I'd just like to thank Cam a lot, whether we'll be using gtimes in the end or not - his method works wonders, too. ;)

Link to comment

Okies - this will take a bit, but it's not difficult stuff: if I can pick it up, I'm sure you can also :D

 

There's a pair of .tp2 actions you'll want here, one of them involving macros, and the other being ACTION_READLN. It's not strictly necessary to use the macros, though - so we'll go through it once without them.

 

The start of the component will look much the same:

BEGIN ~Install Xan's dialogues and set the romance timer~
FORCED_SUBCOMPONENT @1097 (FILE_EXISTS_IN_GAME ~X#XanRomance.G3~)  /* Romance [Xan] */
GROUP @1010  /* The BG1 NPC Project: Romances */
REQUIRE_FILE ~override/X#XanRomance.G3~ @1041 /* Xan's Romance is not installed. */

 

You'd just point your BEGIN @ to some new string that lets people know what you're up to.

 

The part where they get to select the romance timer comes next:

PRINT ~Select the delay between Xan's dialogues from the list below:
5400 - Eighteen hours of in-game time
3600 - Twelve hours of in-game time
2700 - Nine hours of in-game time
1800 - Six hours of in-game time
900  - Three hours of in-game time
Input the number and press enter.~
ACTION_READLN ~timer~

 

Obviously, you'll want to point the PRINT command to some string in a .tra, rather than "hard coding" it into your setup-tp2. You know what PRINT does ( :( ), so the only other command there is ACTION_READLN. What this does is display a little prompt in the dos window (it's just a flashing underscore). The person installing your mod types something and presses enter - and whatever they've just entered will be stored as the variable timer (you can name this variable whatever you want ;) ).

 

Now that they've picked the timer length they want, the next thing to do is make sure that your dialogue files are using this number. Let's assume what you have written in your files is RealSetGlobalTimer("X#XALoveTalkTime","GLOBAL",XAROM_TIMER) and that you don't want to mess with EVALUATE_BUFFER (I don't blame you, that's a funky thing ;) )

ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
/* dialogue */
 COPY ~BG1NPC/Phase3/XAROM/DLG/X#XANLT1.D~ ~BG1NPC/Phase3/XAROM/DLG/X#XANLT.D~
PATCH_IF ("timer" = 3600) THEN BEGIN
  REPLACE_TEXTUALLY EXACT_MATCH "XAROM_TIMER" "3600"
END ELSE PATCH_IF ("timer" = 5400) THEN BEGIN
  REPLACE_TEXTUALLY EXACT_MATCH "XAROM_TIMER" "5400"
END ELSE PATCH_IF ("timer" = 2700) THEN BEGIN
  REPLACE_TEXTUALLY EXACT_MATCH "XAROM_TIMER" "2700"
END ELSE PATCH_IF ("timer" = 1800) THEN BEGIN
  REPLACE_TEXTUALLY EXACT_MATCH "XAROM_TIMER" "1800"
END ELSE PATCH_IF ("timer" = 900) THEN BEGIN
  REPLACE_TEXTUALLY EXACT_MATCH "XAROM_TIMER" "900"
END
 COMPILE ~BG1NPC/Phase3/XAROM/DLG/X#XANLT.D~
END ELSE BEGIN /* BGT Versions */
/* dialogue */
 COPY ~BG1NPC/BGT/DLG/X#XANLT.D~ ~BG1NPC/BGT/DLG/X#XANLT1.D~
PATCH_IF ("timer" = 3600) THEN BEGIN
  REPLACE_TEXTUALLY EXACT_MATCH "XAROM_TIMER" "3600"
END ELSE PATCH_IF ("timer" = 5400) THEN BEGIN
  REPLACE_TEXTUALLY EXACT_MATCH "XAROM_TIMER" "5400"
END ELSE PATCH_IF ("timer" = 2700) THEN BEGIN
  REPLACE_TEXTUALLY EXACT_MATCH "XAROM_TIMER" "2700"
END ELSE PATCH_IF ("timer" = 1800) THEN BEGIN
  REPLACE_TEXTUALLY EXACT_MATCH "XAROM_TIMER" "1800"
END ELSE PATCH_IF ("timer" = 900) THEN BEGIN
  REPLACE_TEXTUALLY EXACT_MATCH "XAROM_TIMER" "900"
END
 COMPILE ~BG1NPC/BGT/DLG/X#XANLT.D~
END

 

That's five options for two platforms in one component, and you can add as many or as few timing options as you like (five should be plenty, and you'll probably want to indicate which is the "default" timer.

Link to comment

There's a difficulty with this (which I bet you've already noticed): you've asked the user to input the timer they want, but they might decide to input something else (for example "3" or maybe "Xan's pomade smells nice"). If this happens, the component will fail to install (because the value you're looking for has never been set correctly). We can prevent this by putting the ACTION_READLN (remember, this is just "Give me a number or give me a letter" in WeiDU-speak) inside of a macro. I use this every time I use ACTION_READLN, and you actually won't end up with more code to write ;)

 

The code first, then I'll run through it in a bit after I eat ;) :

BEGIN @1040 /* Xan's Romance Speed (standard: 1 hour) */
FORCED_SUBCOMPONENT @1097 (FILE_EXISTS_IN_GAME ~X#XanRomance.G3~)  /* Romance [Xan] */
GROUP @1010  /* The BG1 NPC Project: Romances */
REQUIRE_FILE ~override/X#XanRomance.G3~ @1041 /* Xan's Romance is not installed. */

PRINT ~Set timer for Xan's romance~

DEFINE_ACTION_MACRO ~set_timer_for_xans_romance~ BEGIN

 PRINT ~Select the delay between Xan's dialogues from the list below:
5400 - Eighteen hours of in-game time
3600 - Twelve hours of in-game time
2700 - Nine hours of in-game time
1800 - Six hours of in-game time
900  - Three hours of in-game time
Input the number and press enter.~
 ACTION_READLN ~timer~
 ACTION_IF NOT (IS_AN_INT ~timer~) THEN BEGIN
LAUNCH_ACTION_MACRO ~set_timer_for_xans_romance~
 END ELSE BEGIN
ACTION_IF (("timer" != 900) AND ("timer" != 1800) AND ("timer" != 2700) AND ("timer" != 3600) AND ("timer" != 5400)) THEN BEGIN
  LAUNCH_ACTION_MACRO ~set_timer_for_xans_romance~
END ELSE BEGIN
  ACTION_IF ("timer" = 900) THEN BEGIN
	OUTER_SPRINT ~timer~ ~900~
  END
  ACTION_IF ("timer" = 1800) THEN BEGIN
	OUTER_SPRINT ~timer~ ~1800~
  END
  ACTION_IF ("timer" = 2700) THEN BEGIN
	OUTER_SPRINT ~timer~ ~2700~
  END
  ACTION_IF ("timer" = 3600) THEN BEGIN
	OUTER_SPRINT ~timer~ ~3600~
  END
  ACTION_IF ("timer" = 5400) THEN BEGIN
	OUTER_SPRINT ~timer~ ~5400~
  END
END
 END

END

LAUNCH_ACTION_MACRO ~set_timer_for_xans_romance~

ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
/* dialogue */
 COPY ~BG1NPC/Phase3/XAROM/DLG/X#XANLT1.D~ ~BG1NPC/Phase3/XAROM/DLG/X#XANLT.D~
REPLACE_TEXTUALLY EXACT_MATCH ~XAROM_TIMER~ ~%timer%~
 COMPILE ~BG1NPC/Phase3/XAROM/DLG/X#XANLT.D~
END ELSE BEGIN /* BGT Versions */
/* dialogue */
 COPY ~BG1NPC/BGT/DLG/X#XANLT.D~ ~BG1NPC/BGT/DLG/X#XANLT1.D~
REPLACE_TEXTUALLY EXACT_MATCH ~XAROM_TIMER~ ~%timer%~
 COMPILE ~BG1NPC/BGT/DLG/X#XANLT.D~
END

Link to comment

Oooh! That's pretty. (I regret to say it is half past midnight, so I probably should refrain from testing until tomorrow morning, but tomorrow morning I'll definitely pick it up).

 

Just one question: If all this stuff(including the macro with the timer) goes into a single component, how does the user say "N" for "No, thank you, the next component, please" or "Q"("Goodbye, don't write")? In other words, what "LAUNCH_ACTION"'s should there be, if any?

 

And - definitely - thank you very much for taking time to code all this great stuff!

Link to comment

For us at BG1 NPC, some points spring to mind.

  1. Simple is better, so the current FORCED_SUBCOMPONENT behavior can be dropped in favor of a single install. All code above is set up as it it is a forced subcomponent whose install is triggered by the user installing the earlier Xan Romance component - necessary for me when the timers were all BCS driven, but no longer needed if we now consolidate timer and dialogue into a single component.
  2. We need to make sure the values are Real Time rather than Game Time, which is still fine -- the existing gtimes entries will still work, they will just look wrong!
  3. If we continue to move towards having all possible code move towards a "multi-platform friendly single master template" (see initial attempts on the Wikki dealing with Faldorn's and Tiax's Quests) EVALUATE_BUFFER is beneficial to us. If it is flaky, then perhaps not... right now the PIDs E_B, the first component uses R_T [%]variable[%], and finally the existing Romance Timers use REPLACE_TEXTUALLY EXACT_MATCH "%BRROM_TIMER%" "900". I am ok with only going in small steps though, so we could work with either way. I would prefer to save some code - can we still use %XAROM_TIMER%, so that it is easy to eventually switch to E_B if we can work out all the details? What do we break by doing this?
  4. Nythrun is a Goddess, but she tends to give fellow human beings too much credit... I would humbly suggest that I would not trust even me to input more than one simple number, so I would only allow choices of {1,2,3,4,5} with resulting output.

So, we could try a variation: (hold on - I will be right on it...

 

/* XAN ROMANCE */
BEGIN @1015 /* The BG1 NPC Project: Xan's Romance Core (teen content) */
 GROUP @1010  /* The BG1 NPC Project: Romances */
 REQUIRE_FILE ~override/X#BG1NPCCore.G3~ @1004 /* BG1 NPC Required Changes component is not installed. */
COPY ~BG1NPC/Core/X#component.xx~ ~override/X#XanRomance.G3~
/* sound */
COPY ~BG1NPC/Phase3/XAROM/Sound/X#BLANK.WAV~ ~override~
/*  Script Extensions - Keep Separate as ENDOFBG1 is only required in BGT*/
 ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
/* Character Reactions */
   EXTEND_TOP ~_HARTEEL.bcs~   ~BG1NPC/Phase3/XAROM/BAF/X#XASTRE.baf~
EXTEND_TOP ~_JAHEIRA.bcs~ ~BG1NPC/Phase3/XAROM/BAF/X#XAJARE.baf~
EXTEND_TOP ~_ONTARON.bcs~ ~BG1NPC/Phase3/XAROM/BAF/X#XAMORE.baf~
EXTEND_TOP ~_TIAX.bcs~ ~BG1NPC/Phase3/XAROM/BAF/X#XATIRE.baf~
EXTEND_TOP ~_MINSC.bcs~ ~BG1NPC/Phase3/XAROM/BAF/X#XAMIRE.baf~
EXTEND_TOP ~_QUAYLE.bcs~ ~BG1NPC/Phase3/XAROM/BAF/X#XAQURE.baf~
EXTEND_TOP ~_EDWIN.bcs~ ~BG1NPC/Phase3/XAROM/BAF/X#XAEDRE.baf~
 END ELSE BEGIN /* BGT Versions */
/* Character Reactions */
EXTEND_TOP ~SHARTEEL.bcs~   ~BG1NPC/BGT/BAF/X#XASTRE.baf~
EXTEND_TOP ~BGJHEIRA.bcs~ ~BG1NPC/BGT/BAF/X#XAJARE.baf~
EXTEND_TOP ~MONTARON.bcs~ ~BG1NPC/BGT/BAF/X#XAMORE.baf~
EXTEND_TOP ~TIAX.bcs~ ~BG1NPC/BGT/BAF/X#XATIRE.baf~
EXTEND_TOP ~BGMINSC.bcs~ ~BG1NPC/BGT/BAF/X#XAMIRE.baf~
EXTEND_TOP ~QUAYLE.bcs~ ~BG1NPC/BGT/BAF/X#XAQURE.baf~
EXTEND_TOP ~BGEDWIN.bcs~ ~BG1NPC/BGT/BAF/X#XAEDRE.baf~
 END

 /* Xan's Dream 2DA set up Tutu/BGT */
 COPY ~BG1NPC/Phase3/XAROM/MOS/XANDREAM.MOS~ ~override~
 COPY ~BG1NPC/Phase3/XAROM/MOS/X#BLANK.2da~ ~override/XANDREAM.2da~
	 REPLACE_TEXTUALLY ~IMAGE~ ~XANDREAM~
	 REPLACE 99999 @475


/* dialogue for Tutu/BGT - NEW DIRECTORY for common template files */

PRINT ~Set timer for Xan's romance~

DEFINE_ACTION_MACRO ~set_timer_for_xans_romance~ BEGIN

 PRINT ~Select the delay between Xan's Lovetalks from the list below:

[1] 1 hour minimum real time (Default) 
[2] 45 minutes minimum real time
[3] 30 minutes minimum real  time
[4] 15 minutes minimum real time
[5] 1 hour 30 minutes minimum real time (Extended)

Input your choice and press enter.~
 ACTION_READLN ~xantimer~
 ACTION_IF NOT (IS_AN_INT ~xantimer~) THEN BEGIN
		 PRINT ~Dave? Dave, What are you doing, Dave?~
LAUNCH_ACTION_MACRO ~set_timer_for_xans_romance~
 END ELSE BEGIN
ACTION_IF (("xantimer" != 1) AND ("xantimer" != 2) AND ("xantimer" != 3) AND ("xantimer" != 4) AND ("xantimer" != 5)) THEN BEGIN
		  PRINT ~I'm sorry, please choose 1, 2 3, 4, or 5~
  LAUNCH_ACTION_MACRO ~set_timer_for_xans_romance~
END ELSE BEGIN
  ACTION_IF ("xantimer" = 2) THEN BEGIN
	OUTER_SPRINT "XAROM_TIMER" "900"
  END
  ACTION_IF ("xantimer" = 3) THEN BEGIN
	OUTER_SPRINT "XAROM_TIMER" "1800"
  END
  ACTION_IF ("xantimer" = 4) THEN BEGIN
	OUTER_SPRINT "XAROM_TIMER" "2700"
  END
  ACTION_IF ("xantimer" = 1) THEN BEGIN
	OUTER_SPRINT "XAROM_TIMER" "3600"
  END
  ACTION_IF ("xantimer" = 5) THEN BEGIN
	OUTER_SPRINT "XAROM_TIMER" "5400"
  END
END
 END

END

LAUNCH_ACTION_MACRO ~set_timer_for_xans_romance~

ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
/* dialogue */
 COPY ~BG1NPC/COM/DLG/X#XANLT_tmp.D~ ~BG1NPC/Phase3/XAROM/DLG/X#XANLT.D~
REPLACE_TEXTUALLY EXACT_MATCH ~XAROM_TIMER~ ~%XAROM_TIMER%~
 COMPILE ~BG1NPC/Phase3/XAROM/DLG/X#XANLT.D~
END ELSE BEGIN /* BGT Versions */
/* dialogue */
 COPY ~BG1NPC/COM/DLG/X#XANLT_tmp.D~ ~BG1NPC/BGT/DLG/X#XANLT.D~ 
REPLACE_TEXTUALLY EXACT_MATCH ~XAROM_TIMER~ ~%XAROM_TIMER%~
 COMPILE ~BG1NPC/BGT/DLG/X#XANLT.D~
END

 

[sIDEBAR>>>> to Nythrun; Can I do this successfully with EVALUATE_BUFFER? 'Cuse if I can, then we probably want all the timers above to be set up as variables too... because everything that does not I_C_T into an existing platform-dependent state could be reduced to one file, evaluated and then tra'd or in the case of BAF compiled/extended

 

ACTION_IF FILE_EXISTS_IN_GAME ~FW0100.are~ THEN BEGIN
OUTER_SPRINT "BGT_VAR" ""
END ELSE BEGIN
OUTER_SPRINT "BGT_VAR" "!Global("ENDOFBG","GLOBAL",2)"
END

and then put materials like

IF
%BGT_VAR%
Global("X#TiaxKicksImoen","GLOBAL",1)

and

CHAIN IF WEIGHT #-2 ~%BGT_VAR% Global("X#TiaxKicksImoen","GLOBAL",2)~ ~%TIAX_JOINED%~ X#TiaxKicksImoenStarts
~Tiaxs KICKS All!~
== ~%IMOEN_BANTER%~ IF ~InParty("%IMOEN_DV%) InMyArea("%IMOEN_DV%) !StateCheck("%IMOEN_DV%,CD_STATE_NOTVALID)~ THEN ~Ouch!!!~
END
++ ~Stop That. It's Silly.~ DO ~SetGlobal("X#TiaxKicksImoen","GLOBAL",3)~ EXIT

 

whew. didn't think I had it in me.

Link to comment

(Aside note: if someone could explain to me(and not only to me, I guess) what EVALUATE_BUFFER is, and what it does, I'll be very happy. Well... not as miserable as usual, at least. ;) )

 

Simple is better, so the current FORCED_SUBCOMPONENT behavior can be dropped in favor of a single install. All code above is set up as it it is a forced subcomponent whose install is triggered by the user installing the earlier Xan Romance component - necessary for me when the timers were all BCS driven, but no longer needed if we now consolidate timer and dialogue into a single component.

 

And note 2: for now, MACRO solution looks excellent, except that the user is forced to keep entering a number, and nothing else(n,q) will work. This is quite user-unfriendly, and I am not sure it should be implemented as it is. Is it possible to, I don't know, use something like a letter recognizer? I don't remember the exact syntax, but I think I used something like CHECKREGEXPR([^\d,n,q$])=0 at work - and I know there's something similar in .tp2 patching available, too?

 

Again, I do think it is very important for the user to be able to skip the component/to exit correctly at any given time.

 

We need to make sure the values are Real Time rather than Game Time, which is still fine -- the existing gtimes entries will still work, they will just look wrong!

If we continue to move towards having all possible code move towards a "multi-platform friendly single master template" (see initial attempts on the Wikki dealing with Faldorn's and Tiax's Quests) EVALUATE_BUFFER is beneficial to us. If it is flaky, then perhaps not... right now the PIDs E_B, the first component uses R_T [%]variable[%], and finally the existing Romance Timers use REPLACE_TEXTUALLY EXACT_MATCH "%BRROM_TIMER%" "900". I am ok with only going in small steps though, so we could work with either way. I would prefer to save some code - can we still use %XAROM_TIMER%, so that it is easy to eventually switch to E_B if we can work out all the details? What do we break by doing this?

Nythrun is a Goddess, but she tends to give fellow human beings too much credit... I would humbly suggest that I would not trust even me to input more than one simple number, so I would only allow choices of {1,2,3,4,5} with resulting output.

 

Yes, yes, and yes.

Link to comment

Also, if MACRO won't do, we might do it the ugly way: copy main romance portion for each of subcomponents, so the user will only see one component.

 

It will look ugly in .tp2, but the point is, the end user won't see it - and to him, it will look all right(and most importantly, he'll be able to access these 'n' and 'q' choices, since we'll be using SUBCOMPONENT, not FORCE_SUBCOMPONENT then).

 

I'd definitely not do it if the same thing could be achieved via ACTION_READLN, however.

Link to comment

(Right, never mind me, I see what EVALUATE_BUFFER is - I should've been reading cmorgan's posts more attentively in the first place).

 

To the Nine Hells with the letters, but could we use "0" as exit, then?

"Please choose 1, 2, 3, 4, or 5, or 0 to quit"? How will it look like?

Link to comment

In the code I tried above, the main component asks about installation. There is no SUBCOMPONENT or FORCED_SUBCOMPONENT action; it is one component, with the inclusion of user input as to what values are used in compiling. Since it is a question asked and answered, and then BAFs are compiled, we certainly *don't* want anyone exiting until the full component is installed!!!! ;) We need them to install the component, then either go back and uninstall it, or change their minds and install with a different setup. We could have a "dummy" value of say "N", that loops them back, but then we would have to figure out how to uninstall the romance materials already in place...

 

In short, it does everything we asked with no fuss. In both tp2 and user-seen materials, there is one Xan Romance. You install it, and as you install it you get to choose the timers. The whole component is uninstalled to change the timers (which it would be anyways ;) ).

 

The changes to the names of variables is because we would have duplicates of this kind of code for each romance.

 

I like it, I just need to hear Nythrun say "yep, you got it" or tell me where I messed up....

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...