Andyr Posted May 23, 2004 Share Posted May 23, 2004 Cam/Idobek probably will know the answer to this: So, I am editing the Amnish Soldiers in BGII. There are about a dozen different .CRE files to be done, and the creatures have a couple of different names (Amnish Soldier, Amnish Guard etc...) and slightly different stats. So I could patch each one individually, but is there an easier way? I was thinking I could use COPY_EXISTING_REGEXP, READ/WRITE combinations to change the stats based on the differing originals, and then a series of name checks so I copy over only the creatures I am interested in. But I'd want to be able to specify a list of creature names. So in pseudocode: C_E_R ~*.CRE~ ~override~ READ someplace something WRITE someplace someotherthing IF_EVAL OR(somenumber) nameoffset Amnish Guard strref nameoffset Amnish Soldier strref etc... END Is this possible? i.e. can I specify several conditions to do the patching by, only one of which needs to be fulfilled? Alternatively is it possible to search for the fragment Amnish inside a string, and apply the patch only to files where this occurs in the name? Yes, I am too lazy to patch the files individually if I can avoid it. Link to comment
CamDawg Posted May 23, 2004 Share Posted May 23, 2004 Well, yes and no. The first piece of good news is that C_E can take multiple files, so you could use C_E ~source1~ ~override/dest1~ ~source2~ ~override/dest2~ ~source3~ ~override/dest3~ (patching) Using a REGEXP is, of course, another method. WeiDU does not have the capability of examining the contents of strings, but you could use STRREFs as one method. Do a search for the strings you want in dialog.tlk, and then use READ on the name field, trying to match the STRREF is one option. IF_EVAL, according to Wes, is "hacky" so it should be avoided. IF_EVAL also refers to the entire C_E function, so you can't use it unless you break the conditions into seperate patches--which you don't want to do. IF_EVAL has been essentially repaced by WHILE and BUT_ONLY_IF_IT_CHANGES (Idobek has written tutorials on both, BTW). In pseudo-code, you would structure it something like this: C_E_R GLOB ~*.CRE~ ~override~ READ (Name STRREF) SET "patch1" = 0 SET "patch2" = 0 SET "patch3" = 0 WHILE (Name STRREF = Amnish Soldier AND "%patch1%" = 0) BEGIN (patching for Amnish Soldier) SET "patch1" = 1 END WHILE (Name STRREF = Amnish Sarge AND "%patch2%" = 0) BEGIN (patches for Amnish Sarge) SET "patch2" = 1 END WHILE ((Name STRREF = Amnish Sarge OR Name STRREF = Amnish Soldier) AND "%patch3%" = 0)) BEGIN (patches for both) SET "patch3" = 1 BUT_ONLY_IF_IT_CHANGES In general, you'll want all of your READs (and SETs) before you start WHILE looping. It's also easy to get stuck in an infinite loop with WHILE, so that's why I'm using the patch1 and patch2 variables. Otherwise, every time the WHILE loop gets evaluated, the STRREF is still true, and it's trapped in an infinite loop. Finally, tack on BUT_ONLY_IF_IT_CHANGES. If you don't, WeiDU will copy everything matched by the REGEXP into the override, which in this case means every CRE in the game gets copied. WHILE loops can also be nested inside one another, which leads to additional functionality. One other note, BUT_ONLY_IF_IT_CHANGES has a bug in the current WeiDU (v155) if used in conjunction with INSERT and DELETE_BYTEs. I patch all of the armor in the game with a single REGEXP in G3 Tweaks using WHILE loops for the various armor types. It is, I think, the single longest C_E_R I've ever written, but it essentially uses the method above. It's long and ugly, but you shold be able to get the gist of it. Link to comment
Andyr Posted May 23, 2004 Author Share Posted May 23, 2004 Thanks, I might just use the multiple C_E then. Any thoughts on searching inside strings for the sequence 'Amnish'? I have since thought of a better way to patch (search for the Amnish Soldier animation instead of names), but am curious as to whether looking inside strings can be done. Link to comment
Idobek Posted May 23, 2004 Share Posted May 23, 2004 Any thoughts on searching inside strings for the sequence 'Amnish'? I have since thought of a better way to patch (search for the Amnish Soldier animation instead of names), but am curious as to whether looking inside strings can be done. Not with WeiDU. Link to comment
Andyr Posted May 23, 2004 Author Share Posted May 23, 2004 Ah well. Thanks anyway! I'll use one of the other methods. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.