subtledoctor Posted January 9, 2020 Posted January 9, 2020 I'm trying to figure out how to represent this. Bear with me, I'll explain the whole circumstance. I have a mana/points-based spellcasting system set up. It uses 7 bits of a proficiency stat to measure the number of points you have, and uses opcode 233 to adjust the number as needed. Instances of spells are actually innate abilities, and the number of mana points you have is how many times a 171 effect is applied giving you the abilities. So, at 7th level at the start of SoD/BG2, you have 21 points (which is bits 5, 3, and 1 of the stat). You cast a 3rd-level spell; it applies opcode 233 to reduce your stat value by 3 to 18 (bits 5 and 2). All of your known spells (the innate abilities) are removed, then some subspells are cast using opcode 326 to check the stat, using relation 7 (binary greater or equal) in SPLPROT.2da the subspell sees you have bit 2 in the stat, so it adds your known spells 2 times the subspell sees you have bit 5 in the stat, so it adds your known spells 16 times you end up with 18 instances of your spells, representing your 18 remaining mana points. In steps 4 and 5, each instance of adding each known spell occurs via a subspell with opcode 171. I want to make sure that those subspells will be blocked if you don't have enough mana points to cast a spell of a level higher than your point total. I.e. if you only have 4 mana points left, then all opcode 171 subspells for spells of level 5 and higher should be blocked. So far so easy. (Right?) My issue is, all known spells are re-added every time you cast one, even if a spell is of a higher level than your remaining mana points. If I have 3 points, and cast Blur, I should only get my 1st-level spells added again. To do this I have added opcode 318 effects to an item, referencing a line in SPLPROT.2da with relation 2 (numerical less than), so that the player will be immune to a 171 subspell for a spell of level x if the player's stat is less than x. But, it doesn't work. No matter how low the stat value, I still get spells of every level. I get the correct number of spells - if I have one mana point left, I will only get one instance of them. So the "binary greater or equal" relation is working just fine. Do I need to use a binary relation value? I vaguely recall having problems with relation 11, that "binary less than" doesn't actually work as expected; e.g. "binary less than 3" will return true if the value is 4. Or something. Anyway, if anyone has some thoughts I'd appreciate it. This is a small but important part of the mod, and the result is going to be very cool. Quote
Mike1072 Posted January 9, 2020 Posted January 9, 2020 Here's a combination of my understanding of your steps 3 through 5 mixed with some suggestions. I have no experience with using these opcodes, just operating based on the descriptions in the IESDP. To add the appropriate spells, you have 7 different 326 effects, each comparing a different bit of the stat and casting a spell that adds all spells the appropriate number of times: if bit 0 of stat is set, cast spell "add1x" if bit 1 of stat is set, cast spell "add2x" if bit 2 of stat is set, cast spell "add4x" if bit 3 of stat is set, cast spell "add8x" if bit 4 of stat is set, cast spell "add16x" if bit 5 of stat is set, cast spell "add32x" if bit 6 of stat is set, cast spell "add64x" Then those spells cast subspells for each level. "add1x" casts: "addlvl1" "addlvl2" "addlvl3" "addlvl4" "addlvl5" "addlvl6" "addlvl7" "addlvl8" "addlvl9" "add2x" casts "add1x" twice "add4x" casts "add1x" four times "add8x" casts "add1x" eight times "add16x" casts "add1x" sixteen times "add32x" casts "add1x" thirty-two times "add64x" casts "add1x" sixty-four times When the player has 1 spell point remaining, you want "addlvl1" to be applied and none of the other "addlvlX" subspells, so you're trying to apply an immunity to "addlvl2", etc. It sounds like you're using the correct relation, so I don't know why that isn't working. Instead of applying immunity to those subspells, you could try changing "add1x" so it conditionally casts the subspells, using opcode 318 to only cast when the stat is greater or equal (relation 4) to the spell level. New "add1x": if stat >= 1, cast spell "addlvl1" if stat >= 2, cast spell "addlvl2" if stat >= 3, cast spell "addlvl3" if stat >= 4, cast spell "addlvl4" if stat >= 5, cast spell "addlvl5" if stat >= 6, cast spell "addlvl6" if stat >= 7, cast spell "addlvl7" if stat >= 8, cast spell "addlvl8" if stat >= 9, cast spell "addlvl9" Quote
kjeron Posted January 9, 2020 Posted January 9, 2020 (edited) 1 hour ago, subtledoctor said: So far so easy. (Right?) My issue is, all known spells are re-added every time you cast one, even if a spell is of a higher level than your remaining mana points. If I have 3 points, and cast Blur, I should only get my 1st-level spells added again. To do this I have added opcode 318 effects to an item, referencing a line in SPLPROT.2da with relation 2 (numerical less than), so that the player will be immune to a 171 subspell for a spell of level x if the player's stat is less than x. Why are the 318 effects on an item, or what is the purpose of that item? Edited January 9, 2020 by kjeron Quote
subtledoctor Posted January 9, 2020 Author Posted January 9, 2020 (edited) Only because I tried applying them with timing 9 (via both clab and in-game spell) and it didn't work. I didn’t even see the effects on the .CRE in the savegame (which was weird - but evidently not the problem). Using an item is just a way to control for failure to apply the 318 effects by other means. Edited January 9, 2020 by subtledoctor Quote
kjeron Posted January 9, 2020 Posted January 9, 2020 op318 only checks it's splprot conditions once, when it is applied. It's not a passive on/off check throughout it's duration. Quote
subtledoctor Posted January 9, 2020 Author Posted January 9, 2020 Huh. Didn’t realize that. Maybe I can squeeze it into the spell-adding spells, then. Failing that, I suppose I could split up the spell levels. That would entail tracking the number of mana points in 9 stats (well, 9 bytes) instead of 1... kind of silly to track 9 copies of a single number, but it could work. Quote
subtledoctor Posted January 9, 2020 Author Posted January 9, 2020 For anyone feeling adventurous here is a preview version of the new system in action. 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.