Jump to content

Remove All Spells of a Certain Level


Recommended Posts

4 hours ago, subtledoctor said:

I don’t think there even are any spells in some of those categories.

Ok, I think I understand the problem now and maybe I've expressed myself poorly.

 

Quote

- one array of 1st-level cleric-only spells excluded from good casters

Taking this as an example. That's not what I'm looking for what I want is, following this example, all first-level spells that are not druid exclusive and not evil exclusive.

Examples of such spells: Command, Magic Stone, Sanctuary...

So maybe I need to invert the zeros and ones from the BAND part of the code?

Edit:

Changing to:

	PATCH_IF (alignment BAND 0b11111011 = 0b11111011) BEGIN
	PATCH_IF (class     BAND 0b01111111 = 0b01111111) BEGIN

Also doesn't work...

Edit2:

Made a new test using BOR

PATCH_IF (alignment BOR 0b00000100 = 0b00000100) BEGIN
PATCH_IF (class     BOR 0b10000000 = 0b10000000) BEGIN

Doing this the spells appear in the spellbook but too many spells, as you can see in the image attached - Change Chicken, Dark Gift, Chromatic Orb (twice), Repulse X, two versions of Entangle and Bless, Spirit Ward, a nameless spell with a Detect Evil icon, etc.

Baldr000.png

But that's definitely some progress, no doubt.

Anyone with an insight of what I may be doing wrong?

Thanks. 

Edited by Raduziel
Link to comment
3 hours ago, Raduziel said:

Ok, I think I understand the problem now and maybe I've expressed myself poorly.

You expressed yourself fine, you only wrote the code poorly! :laugh:

3 hours ago, Raduziel said:

Change Chicken, Dark Gift, Chromatic Orb (twice), Repulse X, two versions of Entangle and Bless, Spirit Ward, a nameless spell with a Detect Evil icon, etc.

I don't know what the heck "Change Chicken" is, but if you are adding spells, and you want it to match what the engine will automatically add at the next level-up (hint, hint), then you need to limit the spells to those with the SPPR prefix - could maybe do something like:

SNPRINT 4 ~%SOURCE_RES%~ source_prefix
PATCH_IF (~%source_prefix%~ STRING_EQUAL_CASE ~sppr~) BEGIN

... and, you need to make sure that the spells are not in hidespl.2da:

PATCH_IF !(FILE_CONTAINS_EVALUATED (~hidespl.2da~ ~%SOURCE_RES%~)) BEGIN

 

3 hours ago, Raduziel said:

what I want is, following this example, all first-level spells that are not druid exclusive and not evil exclusive.

You were close.  You need to switch to BOR and switch the 1s and 0s.  Try this:

COPY_EXISTING_REGEXP ~^.+\.spl$~ ~override~
 PATCH_IF %SOURCE_SIZE% > 0x71 BEGIN
  READ_SHORT 0x1c type
  READ_LONG  0x34 level
  READ_BYTE  0x1e good_evil
  READ_BYTE  0x21 cleric_druid
   PATCH_IF (type = 2) BEGIN // priest
    SNPRINT 4 ~%SOURCE_RES%~ source_prefix
    PATCH_IF (~%source_prefix%~ STRING_EQUAL_CASE ~sppr~) BEGIN
     PATCH_IF !(FILE_CONTAINS_EVALUATED (~hidespl.2da~ ~%SOURCE_RES%~)) BEGIN
      PATCH_IF (good_evil BOR 0b11111011 = 0b11111011) BEGIN // not exclude good
       PATCH_IF (cleric_druid BOR 0b10111111 = 0b10111111) BEGIN // not exclude cleric
        SPRINT $divine_valid_good_cleric(~%SOURCE_RES%~) ~%level%~
       END
      END
     END
    END
   END
  END
 END
BUT_ONLY

COPY_EXISTING_REGEXP ~whomever.cre~ ~override~
 PHP_EACH divine_valid_good_cleric AS spl => lvl BEGIN
  PATCH_IF (lvl = 1) BEGIN
   ADD_KNOWN_SPELL ~%spl%~ #0 ~priest~
  END
  PATCH_IF (lvl = 2) BEGIN
   ADD_KNOWN_SPELL ~%spl%~ #1 ~priest~
  END
 END
IF_EXISTS BUT_ONLY

 

Edited by subtledoctor
Link to comment

Ok, now for some reason the NPC's class is not being changed (from Fighter to Cleric).

I appreciate the effort but I'll give up for now and keep the original coding - it ignores mod-added spells but works as intended with both unmodded and DoF.

Special thanks to @subtledoctor for sharing so much of his time.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...