jastey Posted July 25, 2017 Share Posted July 25, 2017 This is from Jarl's Adventure Pack. I have two questions regarding this. First: Does this do what I think, namely read the string ref of a journal entry for later use? If yes, this means this could be used in a mod to grab the correct journal strings for a successful EraseJournalEntry() across platforms? Second: Is this syntax fail-proof, or does it read gibberish if another mod altered the dialogue it tries to read from by adding a reply option or whatever? If yes, could it be coded so it is compatible? (If yes, would someone please provide it, preferably with some comments, as there are other instances and I don't know what the numbers in brackets mean?) COPY_EXISTING ~HUSAM.DLG~ ~override~ READ_SHORT 0xc "JA#OFF_STT" READ_SHORT 0x14 "JA#OFF_RES" READ_SHORT ("%JA#OFF_STT%" + (0x10 * 6) + 0x4) "JA#INDEX" READ_LONG ("%JA#OFF_RES%" + (0x20 * ("JA#INDEX" + 0)) + 0x8) "ja#entry01" GET_STRREF %ja#entry01% "husam1" Link to comment
argent77 Posted July 25, 2017 Share Posted July 25, 2017 Yes, this code reads a specific journal strref from a DLG file. However, it is not foolproof. The code doesn't check state and response indices against number of available entries. It doesn't even check the response flags to see if there is a valid journal entry available. I would code it as WeiDU function if there are several instances where to fetch a journal strref: DEFINE_PATCH_FUNCTION READ_JOURNAL_STRREF INT_VAR // either use these two parameters if response index should be determined from a state index state = "-1" // state index stateResponse = 0 // relative response index (e.g. 0 for first response associated with the state, 1 for second response, and so on...) // or use this parameter instead to specify response index directly response = "-1" // (absolute) response index RET strref // returned string reference, or -1 if not available BEGIN SET strref = "-1" // determine response index from dialogue state if specified PATCH_IF (state >= 0) BEGIN READ_LONG 0x08 numStates PATCH_IF (state < numStates) BEGIN READ_LONG 0x0c ofsStates SET ofs = ofsStates + (state * 0x10) // calculate offset to specified state READ_LONG (ofs + 4) firstResponse READ_LONG (ofs + 8) numStateResponses PATCH_IF (stateResponse >= 0 && stateResponse < numStateResponses) BEGIN SET response = firstResponse + stateResponse // calculate absolute response index (processed below) END END END // deal with dialogue response index directly PATCH_IF (response >= 0) BEGIN READ_LONG 0x10 numResponses PATCH_IF (response < numResponses) BEGIN READ_LONG 0x14 ofsResponses SET ofs = ofsResponses + (response * 0x20) READ_LONG ofs flags PATCH_IF (flags & BIT4) BEGIN // response flags bit 4 indicates available journal entry READ_LONG (ofs + 8) strref END END END END To get the same string reference as in Jarl's code: COPY_EXISTING ~husam.dlg~ ~override~ // get journal entry from first response associated with dialogue state 6 LPF READ_JOURNAL_STRREF INT_VAR state = 6 RET strref END // just for debugging purposes: fetch journal text from strref and output it in console GET_STRREF strref journalText PATCH_PRINT ~Journal entry #%strref%: %journalText%~ BUT_ONLY Link to comment
jastey Posted July 25, 2017 Author Share Posted July 25, 2017 This is very cool. This is what I need to EraseJournalEntry() across platforms without hassling translators for exact matching strings. Thank you very much! Link to comment
jastey Posted July 26, 2017 Author Share Posted July 26, 2017 // get journal entry from first response associated with dialogue state 6 argent77, what would I have to do to get a journal entry from another reply option but the first one? What does the "-1" in the definition mean? Would I have to define more values for state and stateResponse for different uses of the function? How would I use the strrefs it gives me back. Say I want to erase several journal entries of one quest. I use the function in the tp2 to get the strrefs, and then I can use it in teh next .d file (with #%strref%)? Is there a way to read more than one strref and give it a unique name, maybe, so I can ference to more than one in one go? Thank you in advance for answering questions (that are clear to you...) Link to comment
argent77 Posted July 26, 2017 Share Posted July 26, 2017 argent77, what would I have to do to get a journal entry from another reply option but the first one? What does the "-1" in the definition mean? Would I have to define more values for state and stateResponse for different uses of the function? You would have to set "stateResponse" as well (e.g. to 1 if you want to target the second reply of a state). LPF READ_JOURNAL_STRREF INT_VAR state = 6 stateResponse = 1 RET strref END "stateResponse" is set to 0 by default. That's why you don't have to specify it in the function call if you want to return the journal entry from the first response of a state. -1 is just used as a marker internally, so that you have the choice to fetch a journal entry either from a response relative to a state index or from an absoute response index directly. For example, HUSAM.DLG, first response of state index 6 is stored as absolute response index 9 in the DLG file, so either of the following function calls would fetch the same journal strref: LPF READ_JOURNAL_STRREF INT_VAR state = 6 // stateResponse is set to 0 by default RET strref END LPF READ_JOURNAL_STRREF INT_VAR response = 9 RET strref END How would I use the strrefs it gives me back. Say I want to erase several journal entries of one quest. I use the function in the tp2 to get the strrefs, and then I can use it in teh next .d file (with #%strref%)? Is there a way to read more than one strref and give it a unique name, maybe, so I can ference to more than one in one go? Do you plan to erase them via EraseJournalEntry()? In this case it should be enough to specify the strref as argument of the script action: ~EraseJournalEntry(%strref%)~ The content of "strref" is a simple numeric value. You can assign it to another variable with SET (e.g. SET myUniqueVar = strref). Link to comment
jastey Posted July 26, 2017 Author Share Posted July 26, 2017 That made it clear. Thank you very much! I implemented it and it's working like a charm. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.