1. Adding a new projectileI would like to see in some shape or form some sample code that I could work off of:
1.) ADD_PROJECTILE (the easy part)
2.) Patching spells and items (still the easy part)
3.) Patching effects within spells that use projectile entries (ie physical mirror).
4.) Patching projectiles that use other projectiles (yes, there are some).
ADD_PROJECTILE ~mymod/pros/PSHAMMA.pro~ //Green Thrown Hammer2. Patching an item to use the new projectile (spell would be similar)
ACTION_IF FILE_EXISTS_IN_GAME ~aegis.itm~ THEN BEGIN //Aegis-Fang +3 COPY_EXISTING ~aegis.itm~ ~override~ PATCH_IF SOURCE_SIZE > 0x71 BEGIN READ_LONG 0x64 hf //Extended header offset READ_SHORT 0x68 hc //Extended header count FOR (i = 0; i < hc; i += 1) BEGIN //Cycle through headers READ_BYTE (0x38 * i + hf) pt //Attack type PATCH_IF pt = 2 BEGIN WRITE_ASCII (0x38 * i + hf + 4) ~T-AEGIST~ #8 //Use icon 1 (ranged) WRITE_SHORT (0x38 * i + hf + 0x2a) ~%PSHAMMA%~ //Projectile animation END ELSE PATCH_IF pt = 1 BEGIN WRITE_ASCII (0x38 * i + hf + 4) ~T-AEGISI~ #8 //Use icon 2 (melee) WRITE_SHORT (0x38 * i + hf + 0x2a) 1 //Projectile animation (none) END END END BUT_ONLY_IF_IT_CHANGES END3. Patching effects within spells that use projectiles
ADD_PROJECTILE ~mymod/pros/NEWAROW1.pro~ //New Arrow projectile 1 ADD_PROJECTILE ~mymod/pros/NEWAROW2.pro~ //New Arrow projectile 2 COPY_EXISTING ~sppr613.spl~ ~override~ //Physical Mirror PATCH_IF SOURCE_SIZE > 0x71 BEGIN READ_LONG 0x64 hf //Extended header offset READ_SHORT 0x68 hc //Extended header count READ_LONG 0x6a fb //Feature block offset hd = 0 FOR (i1 = 0; i1 < hc; i1 += 1) BEGIN //Cycle through extended headers READ_SHORT (hf + 0x1e + (0x28 * i1)) fc //Feature count READ_SHORT (hf + 0x20 + (0x28 * i1)) fs //Feature offset //Example 1: change an existing effect with a projectile FOR (i2 = fs; i2 < (fs + fc); i2 += 1) BEGIN //Cycle through ability effects READ_SHORT (0x30 * i2 + fb) pc //Opcode READ_LONG (0x30 * i2 + fb + 8) p2 //Parameter 2 PATCH_IF (pc = 197) AND (p2 = 1) BEGIN //If "Bounce Projectile" and "Arrow" WRITE_LONG (fb + 0x30 * i2 + 8) ~%NEWAROW%~ //New Arrow projectile 1 END END //Example 2: add a new effect with a projectile PATCH_IF (i1 = (hd - 1)) OR (hd = 0) BEGIN //hd=1 means i1=0 INSERT_BYTES (fb + (0x30 * (fc + fs))) 0x30 WRITE_SHORT (fb + (0x30 * (fc + fs))) 197 //Opcode (Bounce Projectile) WRITE_BYTE (fb + 2 + (0x30 * (fc + fs))) 1 //Target (Self) WRITE_BYTE (fb + 3 + (0x30 * (fc + fs))) 6 //Power WRITE_LONG (fb + 8 + (0x30 * (fc + fs))) ~%NEWAROW2%~ //Parameter 2 WRITE_BYTE (fb + 0xd + (0x30 * (fc + fs))) 3 //Dispellability WRITE_BYTE (fb + 0xe + (0x30 * (fc + fs))) 54 //Duration WRITE_BYTE (fb + 0x12 + (0x30 * (fc + fs))) 100 //Probability 1 fc += 1 //Increment feature count hd += 1 //Increment header WRITE_SHORT (hf + 0x1e + (0x28 * i1)) fc //Update feature count FOR (i2 = 0; i2 < hc; i2 += 1) BEGIN //Update 1st effect indices READ_SHORT (hf + i2 * 0x28 + 0x20) fx //1st effect index PATCH_IF (fx > i1) BEGIN //If ability after current effect WRITE_SHORT (hf + i2 * 0x28 + 0x20) (fx + 1) //Increase 1st effect i1 by 1 END END END END END BUT_ONLY_IF_IT_CHANGES4. Patch a projectile within a projectile
ADD_PROJECTILE ~mymod/pros/NEWDART.pro~ //New Dart projectile COPY_EXISTING ~traptime.pro~ ~override~ PATCH_IF SOURCE_SIZE > 0x2ff BEGIN //Needs the area effect structure READ_SHORT 0x21a xj //Explosion projectile PATCH_IF xj = 32 BEGIN //If old Dart projectile WRITE_SHORT 0x21a ~%NEWDART%~ //New Dart projectile END END BUT_ONLY_IF_IT_CHANGESI cobbled this all together rather quickly from existing code and guesswork, so I can't guarantee it all works, but it should give you examples at least.
You could move a lot of the code above to macros and then patch spells en masse using COPY_EXISTING_REGEXP (which I think you already do with SpellPack). I do something similar in a couple different mods.The best thing, really would be writing some sort of function that assigns a new projectile value based off an old value and making sure all projectiles, effects, spells, and items using some old value are patched to some new value.
What I am talking about is literally, patching thousands of spells with hundreds of projectiles. If I change SpellPack, then I have to change the rest of my work as well. I cannot deviate and split my work into two. This is no joke, and I am not willing to do this alone.