deratiseur Posted September 27 Posted September 27 (edited) I need a weidu code please. I need something that lists all level 3 NON-druidic cleric spells and renames them (SPPR301.spl -> pxath301.spl) and makes them level 1 then adds them to the pxathrv3.spl spell with effect #171 The end result would be a pxathrv3.spl spell that gives all level 3 cleric spells as level 1 spells. I could do it by copying spells one by one, but I need this code to identify all spells, including those from iWDEEE or added by mods. Edited September 27 by deratiseur Quote
lynx Posted September 27 Posted September 27 Whether a priest spell is usable by druids and the like is something you can check by reading bit 31 of exclusion flags in the header of SPL files. https://gibberlings3.github.io/iesdp/file_formats/ie_formats/spl_v1.htm#Exclusion_Flags Quote
deratiseur Posted September 27 Author Posted September 27 I'm unable to write this code, even knowing that. Quote
argent77 Posted September 27 Posted September 27 (edited) It helps greatly to split a problem into several smaller parts which can then be coded more easily. For collecting all available spells I can think of two strategies: 1) Loop through all level 3 priest spells (SPPR301.SPL ... SPPR349.SPL) and check if the spells exist. 2) Look up entries in SPELL.IDS to determine available spells. If they meet your criteria then patch the spells and store their resource names in an array for later when you add them as op171 entries to your meta spell. Including kit-specific spells in the list is also possible but more difficult. You would have to scan the CLAB tables of all cleric kits and check the GA_xxx entries for valid cleric spells. The CLAB tables can be looked up in KITLIST.2DA. Edited September 27 by argent77 Quote
Jarno Mikkola Posted September 27 Posted September 27 (edited) 29 minutes ago, argent77 said: It helps greatly to split a problem into several smaller parts which can then be coded more easily. For collecting all available spells I can think of two strategies: 1) Loop through all level 3 priest spells (SPPR301.SPL ... SPPR349.SPL) and check if the spells exist. 2) Look up entries in SPELL.IDS to determine available spells. If they meet your criteria then patch the spells and store their resource names in an array for later when you add them as op171 entries to your meta spell. Including kit-specific spells in the list is also possible but more difficult. You would have to scan the CLAB tables of all cleric kits and check the GA_xxx entries for valid cleric spells. The CLAB tables can be looked up in KITLIST.2DA. And one cannot just ... why ? COPY_EXISTING_REGEXP GLOB ~^.+\.spl$~ ~modfolder~ PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN // protects against invalid files READ_SHORT 0x1c "spl_type" READ_LONG 0x34 ~spell_level~ ... PATCH_IF ("%spl_type%" = "2") BEGIN PATCH_IF ("%spell_level%" = "3") BEGIN etc etc etc COPY ~modfolder~ rename or whatwhave you... .. I too am not able to, but let's try to start ... there plenty of people here that sure know what to do at one step or another, so ... and deratiseur asked code, so giving explanation of the problem without any code is not likely what was requested. Edited September 27 by Jarno Mikkola Quote
WanderingScholar Posted September 27 Posted September 27 (edited) 3 hours ago, deratiseur said: I'm unable to write this code, even knowing that. This should get you close to what you're trying to do but there are some problems. One, is that I'm using the prefix PX# to rename the new level 1 spells. Now most if not all of their names will be over 8 characters, which I believe is not allowed when it comes to filling in the new resources. Someone else more skilled than me like @argent77 might be able to figure out how to produce the naming scheme you want. Another thing is that the PATCH_IF line is probably too indiscriminate. It's adding spells from traps and the like despite them being level 3 priest spells, which you probably don't want. You'll have to mess with it. Spoiler // This will create the new level 1 spells. COPY_EXISTING_REGEXP GLOB ~.*\.spl$~ ~override~ READ_SHORT 0x1c spell_type READ_LONG 0x34 spell_level READ_LONG 0x1e exclusion_flags PATCH_IF (spell_type == 2) AND (spell_level == 3) AND ((exclusion_flags & 0x40000000) == 0) BEGIN // You can be more discriminant by adding AND's SPRINT new_resref ~PX#%SOURCE_RES%~ // Check if the new file already exists PATCH_IF NOT FILE_EXISTS_IN_GAME ~%new_resref%.SPL~ BEGIN INNER_ACTION BEGIN COPY_EXISTING ~%SOURCE_FILE%~ ~override/%new_resref%.SPL~ WRITE_LONG 0x34 1 // Set spell level to 1 BUT_ONLY END END END BUT_ONLY Spoiler // This puts all the info into an array then uses a FOR loop to patch the effects into your spell OUTER_SET spell_count = 0 OUTER_SPRINT $spell_array("") "" COPY_EXISTING_REGEXP GLOB ~^PX#.+\.spl$~ ~override~ PATCH_IF (SOURCE_SIZE > 0x71) BEGIN // Ensure it's a valid spell file READ_ASCII 0x3a source_res (8) NULL TEXT_SPRINT $spell_array("%spell_count%") ~%SOURCE_RES%~ SET spell_count += 1 END BUT_ONLY COPY_EXISTING ~pxathrv3.spl~ ~override~ FOR (i = 0; i < spell_count; ++i) BEGIN LPF ADD_SPELL_EFFECT INT_VAR opcode = 171 target = 1 timing = 1 STR_VAR resource = EVAL $spell_array("%i%") END END BUT_ONLY I'm still a WeiDU noob but hopefully this helps a bit. Edited September 27 by WanderingScholar Quote
deratiseur Posted September 28 Author Posted September 28 Ok, thank you for this code, it works very well (too well, it added OHDXDIS, SPPR350, SPPR982 and all the SPRAxxx, but no problem, I can have them managed by another ready-made spell). I've just replaced "PX#" with "1", so the spells become 1SPPRxxx. I'd do it for several levels and for example for level 4 it would become 4SPPRxxx. Quote
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.