NiGHTMARE Posted September 5, 2005 Share Posted September 5, 2005 I'm trying to create three versions of original files in the override, one set with the normal file name, one set with NM appended to the beginning, and another with NM appended to the end. Obviously I could just do COPY_EXISTING for each of the files I want (all bastard swords), but I'm hoping there's a more efficient, other-mod-compatible method. I've come up with the following (based on G3 Tweaks code), but I'm unable to test it right now, so I'd appreciate input from a WeiDu guru . Will it work, and/or is there a more efficient method? COPY_EXISTING_REGEXP GLOB ~.+\.itm$~ ~override~ // PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN // protects against invalid files READ_ASCII 0x22 "anim" (2) READ_BYTE 0x31 "prof" PATCH_IF ("%prof%" = 89 AND (("%anim%" STRING_COMPARE_CASE "s1" = 0))) BEGIN // If item is a bastard sword COPY_EXISTING ~%SOURCE_FILE%~ ~NM%SOURE_FILE%/OVERRIDE~ COPY_EXISTING ~%SOURCE_FILE%~ ~%SOURE_FILE%NM/OVERRIDE~ // Insert more code here END END BUT_ONLY_IF_IT_CHANGES Link to comment
CamDawg Posted September 5, 2005 Share Posted September 5, 2005 Almost. COPY_EXISTING can not be nested in a PATCH_IF, as it's a top-level action. You need to use an INNER_ACTION in there somewhere--it basically pauses the C_E_R and lets you perform actions such as C_E in the meantime. Link to comment
NiGHTMARE Posted September 5, 2005 Author Share Posted September 5, 2005 Excellent, thanks . Link to comment
NiGHTMARE Posted September 5, 2005 Author Share Posted September 5, 2005 This is the completed code, barring any errors. Again it hasn't been tested yet, I need to do a re-install first . COPY_EXISTING_REGEXP GLOB ~.+\.itm$~ ~override~ // PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN // protects against invalid files READ_ASCII 0x22 "anim" (2) READ_BYTE 0x31 "prof" PATCH_IF ("%prof%" = 89 AND (("%anim%" STRING_COMPARE_CASE "s1" = 0))) BEGIN // If item is a bastard sword INNER_ACTION BEGIN COPY_EXISTING ~%SOURCE_FILE%~ ~NM%SOURE_FILE%/OVERRIDE~ // zero lore one-handed clones COPY_EXISTING ~%SOURCE_FILE%~ ~%SOURE_FILE%NM/OVERRIDE~ // zero lore two-handed clones READ_LONG 0x64 "abil_off" READ_SHORT 0x68 "abil_num" WRITE_SHORT 0x68 ("%abil_num%" + 1) READ_LONG 0x6a "fx_off" WRITE_LONG 0x6a ("%fx_off%" + 0x38) READ_SHORT 0x70 "fx_num" READ_SHORT ("%abil_off%" + 0x1e + (("%abil_num%" - 1) * 0x38)) "last_fx_num" READ_SHORT ("%abil_off%" + 0x20 + (("%abil_num%" - 1) * 0x38)) "last_fx_idx" SET "new_fx" = ("%last_fx_idx%" + "%last_fx_num%") PATCH_IF (~%DEST_RES%~ STRING_COMPARE_CASE ~%SOURCE_RES%~ != 0) BEGIN // if not the "dummy" version WRITE_SHORT 0x42 0 // zero lore for new copies END PATCH_IF (~%DEST_RES%~ STRING_MATCHES_REGEXP ~[iI][kK]......~ = 0) BEGIN // if two-handed version READ_BYTE 0x18 "flags" WRITE_BYTE 0x18 ("%flags%" BOR 0b00000010) // add two-handed flag WRITE_ASCII 0x22 ~S2~ // paperdoll animation FOR (loops = 0; loops < abil_num; loops = loops + 1) BEGIN READ_SHORT ("%abil_off%" + ("%loops%" * 0x38)) "type" PATCH_IF ("%type%" = 1) BEGIN WRITE_SHORT ("%abil_off%" + 0x12 + ("%loops%" * 0x38)) 4 // Speed factor WRITE_SHORT ("%abil_off%" + 0x16 + ("%loops%" * 0x38)) 6 // Dice size WRITE_SHORT ("%abil_off%" + 0x18 + ("%loops%" * 0x38)) 2 // # Dice WRITE_SHORT ("%abil_off%" + 0x2c + ("%loops%" * 0x38)) 60 // overhand attacks WRITE_SHORT ("%abil_off%" + 0x2e + ("%loops%" * 0x38)) 40 // slashing attacks WRITE_SHORT ("%abil_off%" + 0x30 + ("%loops%" * 0x38)) 0 // thrusting attacks END END END ELSE BEGIN // if one-handed version WRITE_BYTE 0x26 9 // Required strength END INSERT_BYTES ("%fx_off%" + ("%new_fx%" * 0x30)) 0x30 // new effect WRITE_SHORT ("%fx_off%" + ("%new_fx%" * 0x30)) 122 // create inventory item WRITE_BYTE ("%fx_off%" + 0x02 + ("%new_fx%" * 0x30)) 1 // target: self WRITE_BYTE ("%fx_off%" + 0x0c + ("%new_fx%" * 0x30)) 1 // instant/permanent till death WRITE_BYTE ("%fx_off%" + 0x12 + ("%new_fx%" * 0x30)) 100 // probability PATCH_IF (~%DEST_RES%~ STRING_MATCHES_REGEXP ~[nN][mM]......~ = 0) BEGIN // if two-handed version WRITE_EVALUATED_ASCII ("%fx_off%" + 0x14 + ("%new_fx%" * 0x30)) ~%SOURCE_RES%NM~ END ELSE BEGIN // if one-handed version WRITE_EVALUATED_ASCII ("%fx_off%" + 0x14 + ("%new_fx%" * 0x30)) ~NM%SOURCE_RES%~ END INSERT_BYTES ("%fx_off%" ) 0x38 // new ability WRITE_BYTE ("%fx_off%" ) 3 // magical WRITE_BYTE ("%fx_off%" + 0x01) 1 // ID to use WRITE_SHORT ("%fx_off%" + 0x02) 3 // in item slots PATCH_IF (~%DEST_RES%~ STRING_MATCHES_REGEXP ~[nN][mM]......~ = 0) BEGIN // if two-handed version WRITE_ASCII ("%fx_off%" + 0x04) ~ISW1H01~ END ELSE BEGIN // if one-handed version WRITE_ASCII ("%fx_off%" + 0x04) ~ISW2H01~ END WRITE_SHORT ("%fx_off%" + 0x0c) 5 // target: caster WRITE_SHORT ("%fx_off%" + 0x0e) 1 // range: 1 WRITE_SHORT ("%fx_off%" + 0x1e) 1 // num effects: 1 WRITE_SHORT ("%fx_off%" + 0x20) ("%new_fx%") // fx index WRITE_SHORT ("%fx_off%" + 0x22) 1 // num charges: 1 WRITE_BYTE ("%fx_off%" + 0x24) 1 // vanishes when drained WRITE_SHORT ("%fx_off%" + 0x2a) 1 // projectile: none END END END BUT_ONLY_IF_IT_CHANGES If you can't tell, this is supposed to make bastard swords equippable in either one or two hands, and adjust their stats (based on pnp sources) accordingly. Most of the code was adapted from the "Two-Handed Katanas" component of G3 Tweaks, but I figured there was a slightly better way of doing it . I then borrowed a bit of code from "Weapon Animation Tweaks", and tried to fit it all together . Link to comment
CamDawg Posted September 6, 2005 Share Posted September 6, 2005 One of the reasons why we never generalized the 2H weapon components is because file names of greater than 6 characters breaks the sw1h01, iksw1h01, sw1h01ik scheme. Cutting off letters quickly runs into the potential problem of items with a similar name. One possible workaround I had considered was using either a static count, i.e. just start naming the new swords cd000001.itm, cd000002.itm, and just treat them as the come. This runs into problems if the mod order is changed, as cd000001 may no longer be the same item if a mod is added/removed in the middle of a game. Another possible solution would be a straight character substitution, i.e. change every "a" for an "!" or somesuch. Using a character not used by the engine reduces the odds of duplication, but there's not enough to ensure uniqueness. Tutu's convention of prefacing item names with a character may also work, if done correctly. Link to comment
NiGHTMARE Posted September 6, 2005 Author Share Posted September 6, 2005 Perhaps a combination of the replacing the first two characters with the modder's personal prefix, and a character substitution for the last character (to differentiate between the one- and two-handed versions)... Link to comment
the bigg Posted September 6, 2005 Share Posted September 6, 2005 In the auto-replicating EFFs code I developed for RtW, I prefaced all EFF file name I had to substitute with __, cutting off starting characters to stay in the 8 char count (to do this, SPRINT newfilename ~__%SOURCE_REF%~ and then patch the newfilename in a INNER_PATCH, APPEND the old and new file name in an apposite file containing the list, and finally load the list, read it and make the copies. Example: 12345678 -> __345678 1234567 -> __234567 123456 -> __123456 For the real release of RtW (eh eh ) I'll also add code to make sure there are no duplicates (so 123456 and 1123456, which would have the same __123456 new file name, one would become ___23456. If you want, I can send you prepared code for all of this - just PM me (preferably on SHS, but I'm not picky ) Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.