Posted by: Erg
« on: September 07, 2014, 03:13:49 PM »I've got permission to use for Finch the same Dream Timer of BG1 NPC Project. I will upload a new beta shortly
Baldur's Gate Unfinished Business sees the light of day! More info available on the BG1UB site.
// R_2_E_F this one manually because SOMEBODY (KULYOK) CAN'T APPEND PROPERLY TO THE 2DA
but all this doesn't matter to this codeblock, because if the NPC is installed, the biography would have already run.
IF
Global("Condition","GLOBAL",1)
Global("Biography","GLOBAL",0)
THEN
RESPONSE #100
SetGlobal("Biography","GLOBAL",1)
SetPlayerSound(Myself,@999,EXISTANCE5)
END
(Hey- cool idea. Hard to implement in terms of writing and heavy additions, but a dynamic biogtraphy using the stringfixer code to reset just that section of the soundset to a new cumulative Biography? wow.... cool. Too much work for somethig most folks ignore.)
COPY_EXISTING_REGEXP GLOB ~^.*\.cre$~ ~override~
READ_ASCII 0x280 deathvariable
READ_BYTE 0x280 check
READ_ASCII 0x248 script
READ_BYTE 0x27b align
READ_LONG 0x1cc biography
SPRINT s_r ~%SOURCE_RES%~
PATCH_IF FILE_CONTAINS_EVALUATED (~override/pdialog.2da~ ~^%deathvariable%[ \t]~) AND // if it's an NPC
check != 0 AND NOT (("%biography%" > 2147483646) OR ("%biography%" < 1)) BEGIN // and the DV is nonempty
SPRINT ~pdialogue~ ~void_this_is_void~ // useful to catch missing *p file from the 2da
// read all pre-read lines in pdialog and find the one with this DV. find out the SoA *p dialogue
// (the TOB *P dialogue doesn't matter).
FOR (i = 1; i < _#_#_#pdialog; i+=1) BEGIN // skip the first line, AKA the one with the headers
READ_2DA_ENTRY_FORMER ~_#_#_#pdialog~ i 0 thisline
PATCH_IF !(~%thisline%~ STRING_COMPARE_CASE ~%deathvariable%~) BEGIN
READ_2DA_ENTRY_FORMER ~_#_#_#pdialog~ i 1 pdialogue
// R_2_E_F this one manually because SOMEBODY (KULYOK) CAN'T APPEND PROPERLY TO THE 2DA
//READ_2DA_ENTRY_FORMER ~_#_#_#pdialog~ i 7 tobscript
SPRINT tobscript ~_#_#_#pdialog_%i%_7~
SPRINT ~tobscript~ EVALUATE_BUFFER ~%%tobscript%%~
SPRINT tobpdial ~_#_#_#pdialog_%i%_4~
SPRINT ~tobpdial~ EVALUATE_BUFFER ~%%tobpdial%%~
// PATCH_PRINT ~%tobscript%~
END
END
PATCH_IF (NOT FILE_CONTAINS_EVALUATED (~virtue/donescript~ ~^%script% -~)) BEGIN
//I didn't already deal with this script
// PATCH_PRINT ~%s_r% SoA script~
INNER_ACTION BEGIN
APPEND_OUTER ~virtue/donescript~ ~%script% -~ // add this to the log!
COPY - ~virtue/bg2/npcs/ET_GENER.BAF~ ~virtue/temp/this_et.baf~ // prepare a virtual copy of the generic script
REPLACE_TEXTUALLY ~___NPC___~ ~%deathvariable%~ // ... which references our NPC DV.
EXTEND_TOP ~%script%.bcs~ ~virtue/temp/this_et.baf~ // and append it to the current NPC script
END
END
Ah. Whoops. "Ribald.bcs" wasn't in the picture. Now, how to get these filenames from pdialog.2da...Oh.
COPY_EXISTING_REGEXP GLOB ~.*[dD]\.bcs~ ~override~You're matching way more than just dream scripts there--anything ending in D. Read the script filenames from pdialog.2da.