kreso Posted January 3, 2016 Share Posted January 3, 2016 I need some help. What I want to do is find all items/spells that use a specific opcode (example, apr modifier) and patch *only* those. What command do I use to select them (If I find opcode 1 then do.....). In Weidu language, this would be written how? If I don't; installer works fine but displays "warning:no effects added to chan09.itm" etc.; basically it goes through all items - and I want it to work only if a specific opcode is found. Link to comment
Jarno Mikkola Posted January 3, 2016 Share Posted January 3, 2016 Here's a patch for mage and innate spells that use opcode 12 with elemental damage to make all of them go through the magic resistance, you can try to use that to what ever you are after: COPY_EXISTING_REGEXP GLOB ~.*\.spl~ ~override~ READ_LONG 0x64 ~ab_off~ READ_SHORT 0x68 ~ab_num~ READ_LONG 0x6a ~ef_off~ FOR (i=0;i<ab_num;i+=1) BEGIN READ_SHORT (ab_off+i*0x28 + 0x000c) ~type~ PATCH_IF ~type~=1 OR ~type~=4 THEN BEGIN READ_SHORT (ab_off+i*0x28+0x00) ~opcode~ READ_SHORT (ab_off+i*0x28+0x08) ~damage~ PATCH_IF ~opcode=12~ THEN BEGIN READ_SHORT (ab_off+i*0x28+0x1e) ~ef_num~ READ_SHORT (ab_off+i*0x28+0x20) ~ef_ind~ PATCH_IF ~damage~=65536 OR ~damage~=65537 OR ~damage~=65538 OR ~damage~=65539 OR ~damage~=131072 OR ~damage~=131073 OR ~damage~=131074 OR ~damage~=131075 OR ~damage~=262144 OR ~damage~=262145 OR ~damage~=262146 OR ~damage~=262147 OR ~damage~=524288 OR ~damage~=524289 OR ~damage~=524290 OR ~damage~=524291 OR ~damage~=2097152 OR ~damage~=2097153 OR ~damage~=2097154 OR ~damage~=2097156 THEN BEGIN FOR (k=0;k<ef_num;k+=1) BEGIN WRITE_BYTE (ef_off+(k+ef_ind)*0x30 + 0x000d) 2 END END END END END It would of course help if you said what ever it is that you are after. Link to comment
Jarno Mikkola Posted January 3, 2016 Share Posted January 3, 2016 (If I find opcode 1 then do.....). In Weidu language, this would be written how?So the above would be: COPY_EXISTING_REGEXP GLOB ~.*\.spl~ ~override~ //Get every .spl file READ_LONG 0x64 ~ab_off~ //read needed offset READ_SHORT 0x68 ~ab_num~ //read offset READ_LONG 0x6a ~ef_off~ //read offset FOR (i=0;i<ab_num;i+=1) BEGIN //we set up a function variable so we can see all the 'effect' READ_SHORT (ab_off+i*0x28+0x00) ~opcode~ //and here we use that variable in this function to read the opcode PATCH_IF ~opcode=1~ THEN BEGIN //and if the opcode is the read, aka = 1, we apply the patch that begins from this point Link to comment
kreso Posted January 16, 2016 Author Share Posted January 16, 2016 Tnx Jarno, but that didn't really work. Code works but nothing gets changed. Anyhow, I've made this work, but still have one issue. After I do the CLONE_EFFECT command it's executed more than once for each spell and item which gets it. Example - I want Flail of Ages to remove Haste. This I do via REGEXP to get all of the items which have a slowing effect to match probabilities; but when looking at the item in NI I see no less than 4(!) "Remove effects by type" (221) opcodes.. They're all the same, pointing at the same resource. Why does this happen and how can I prevent it? If I add this effect to a specific spell/item manually; it works as it should (only one 221 is added). Link to comment
Jarno Mikkola Posted January 16, 2016 Share Posted January 16, 2016 I need to see your code... Link to comment
kreso Posted January 17, 2016 Author Share Posted January 17, 2016 COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ PATCH_IF (SOURCE_SIZE > 0x71) BEGIN READ_LONG 0x64 ab_off READ_SHORT 0x68 ab_num READ_LONG 0x6a ef_off FOR (i=0;i<ab_num;i+=1) BEGIN READ_SHORT (ab_off+i*0x38+0x1e) ef_num READ_SHORT (ab_off+i*0x38+0x20) ef_ind FOR (k=0;k<ef_num;k+=1) BEGIN READ_SHORT (ef_off+(ef_ind+k)*0x30) opcode PATCH_IF opcode=40 BEGIN LPF CLONE_EFFECT INT_VAR match_opcode = 40 multi_match = 1 opcode = 221 timing = 1 parameter1 = 9 savingthrow = 0 parameter2 = EVALUATE_BUFFER %sectype_k1#Haste% insert_point = 1 END END END END END BUT_ONLY Link to comment
Jarno Mikkola Posted January 17, 2016 Share Posted January 17, 2016 You have multiple opcodes in use, you approve one and they all get clones... There's a way to go around this, I just need to study it somewhat more. Aka hopefully tomorrow I have something. Link to comment
kreso Posted January 17, 2016 Author Share Posted January 17, 2016 Well, it does work properly, but I tought that BUT_ONLY would prevent this from happening. Link to comment
Jarno Mikkola Posted January 17, 2016 Share Posted January 17, 2016 Well, it does work properly, but I tought that BUT_ONLY would prevent this from happening.It guarantees that the COPY happens only when the file gets a change. Link to comment
kreso Posted January 17, 2016 Author Share Posted January 17, 2016 Bleh. I should probably add something just below PATCH_IF. In English: Patch if found opcode 58 patch if I haven't already patched. Link to comment
Wisp Posted January 17, 2016 Share Posted January 17, 2016 My eyes! What are you doing?! (The reason you are getting multiple clones is because you are inserting the new effect before your opcode 40, which moves opcode 40 up, where it is read again, a new clone is inserted and so on until the code has looped ef_num times.) I'll add something to CLONE_EFFECT to make this sort of dragnet cloning possible without the warning. Link to comment
Jarno Mikkola Posted January 17, 2016 Share Posted January 17, 2016 My eyes! What are you doing?! (The reason you are getting multiple clones is because you are inserting the new effect before your opcode 40, which moves opcode 40 up, where it is read again, a new clone is inserted and so on until the code has looped ef_num times.) I'll add something to CLONE_EFFECT to make this sort of dragnet cloning possible without the warning. Would there been use for the MODDER flag ? Never used it. Link to comment
kreso Posted January 18, 2016 Author Share Posted January 18, 2016 (The reason you are getting multiple clones is because you are inserting the new effect before your opcode 40, which moves opcode 40 up, where it is read again, a new clone is inserted and so on until the code has looped ef_num times.) Can it be changed, and if, how? I tried insert command, but that doesn't seem to do anything. Or should I just live with the code that prints warnings? Link to comment
Jarno Mikkola Posted January 18, 2016 Share Posted January 18, 2016 Can it be changed, and if, how? You need to set the code so that it inserts just one added effect per each opcode 40... the fact that you make the leap from the reading bits to the LPF CLONE_EFFECT is the one that leads to this erroneous way. I have no idea how to do it with LPF CLONE... but it can be done with the reading bits, adding bits (INSERT_BYTES) and then editing them. I have this in spells: BEGIN ~Faster Casting with just 3 second delay~ COPY_EXISTING_REGEXP GLOB ~^.+\.spl$~ ~override~ PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN // protects against invalid files READ_LONG 0x64 "abil_off" READ_SHORT 0x68 "abil_num" READ_LONG 0x6a "fx_off" READ_SHORT 0x70 "fx_num" SET ~loops~ = 0 SET ~delta~ = 0 WHILE (~loops~ < ~abil_num~) BEGIN READ_SHORT (abil_off + 0x1e + (0x28 * loops)) ~abil_fx_num~ READ_SHORT (abil_off + 0x20 + (0x28 * loops)) ~abil_fx_idx~ //from here in spells SET ~abil_fx_idx~ = (abil_fx_idx + delta) WRITE_SHORT (~abil_off~ + 0x20 + (0x28 * loops)) ~abil_fx_idx~ INSERT_BYTES (~fx_off~ + ((~abil_fx_idx~) * 0x30)) 0x30 // New effect WRITE_SHORT (~fx_off~ + ((~abil_fx_idx~) * 0x30)) 146 // Casts another effect to target res spell which is 188 opcode aka Restores Spell Casting //ability 1 WRITE_BYTE (~fx_off~ + 0x02 + ((~abil_fx_idx~) * 0x30)) 1 // 1= Target Self, 7 = Self, ignores game pause WRITE_LONG (~fx_off~ + 0x04 + ((~abil_fx_idx~) * 0x30)) 1 // Parameter 1 = 1 casting level WRITE_BYTE (~fx_off~ + 0x08 + ((~abil_fx_idx~) * 0x30)) 1 // Parameter 2 = 0 aka normal casting, 1 = instant effect without graphics WRITE_BYTE (~fx_off~ + 0x0c + ((~abil_fx_idx~) * 0x30)) 3 // Delayed WRITE_BYTE (~fx_off~ + 0x0e+ ((~abil_fx_idx~) * 0x30)) 3 // Delay amount WRITE_ASCII (~fx_off~ + 0x14 + ((~abil_fx_idx~) * 0x30)) ~ij#fast~ WRITE_BYTE (fx_off + 0x12 + ((abil_fx_idx) * 0x30)) 100 // Probability WRITE_BYTE (fx_off + 0x0d + ((abil_fx_idx) * 0x30)) 3 // Dispel/Bypass SET ~delta1~ = 1 SET ~delta~ = (delta + delta1) WRITE_SHORT (abil_off + 0x1e + (0x28 * loops)) (abil_fx_num + delta1) SET ~loops~ = (loops + 1) //to here in spells END END BUT_ONLY COPY ~Fastercasting/ij#fast.spl~ ~override~ So I have to edit that or the iiSpell Restoration mods, and make it so that it does the same kind of insertion, but in this case with opcode 221 instead of 146 or 261 ... and different condition, the PATCH_IF opcode=40 BEGIN, and of course to items instead spells. Link to comment
Mike1072 Posted January 18, 2016 Share Posted January 18, 2016 Do you really need to be looping at all? If all you are trying to do is clone each effect that uses opcode 40, you can accomplish that just with CLONE_EFFECT. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.