Jump to content
CamDawg

Toss your semi-useful WeiDU macros here

Recommended Posts

@Ardanis

Could you have a look at the following piece of code? It seems there's a problem with your ADD_SPELL_HEADER/FJ_SPL_ITM_REINDEX....

Spoiler

CREATE    "SPL"    "GTPENAL"
    WRITE_LONG 0x018 (BIT14 | BIT25)  // Castable when Silenced, Ignore Dead/Wild Magic
    WRITE_SHORT 0x01c 4               // Innate ability
    WRITE_LONG 0x034 1                 // Spell level

    LPF ADD_SPELL_HEADER
    INT_VAR
        type = 1         // Melee
        location = 4      // Ability
        target = 1         // Living Actor
        range = 1
        required_level = 1
        projectile = 1       // NONE
    END

 

This is the error:

Spoiler

ERROR: cannot convert hs or %hs% to an integer
Stopping installation because of error.
Stopping installation because of error.
Stopping installation because of error.
Stopping installation because of error.
Stopping installation because of error.

ERROR Installing [Revised Items ---> BG:EE], rolling back to previous state
[Item_Tweaks/backup/0/UNSETSTR.0] SET_STRING uninstall info not found
Will uninstall   0 files for [ITEM_TWEAKS/ITEM_TWEAKS.TP2] component 0.
Uninstalled      0 files for [ITEM_TWEAKS/ITEM_TWEAKS.TP2] component 0.
Unable to Unlink [Item_Tweaks/backup/0/READLN.0]: Unix.Unix_error(Unix.ENOENT, "unlink", "Item_Tweaks/backup/0/READLN.0")
Unable to Unlink [Item_Tweaks/backup/0/READLN.0.TEXT]: Unix.Unix_error(Unix.ENOENT, "unlink", "Item_Tweaks/backup/0/READLN.0.TEXT")
ERROR: Not_found

 

 

Edited by Luke

Share this post


Link to post

The function checks file's extension to determine its type (spl or itm), and CREATE action doesn't seem to provide one.This works

CREATE    "SPL"    "GTPENAL"
    WRITE_LONG 0x018 (BIT14 | BIT25)  // Castable when Silenced, Ignore Dead/Wild Magic
    WRITE_SHORT 0x01c 4               // Innate ability
    WRITE_LONG 0x034 1                 // Spell level

COPY_EXISTING "GTPENAL.SPL" override
    LPF ADD_SPELL_HEADER
    INT_VAR
        type = 1         // Melee
        location = 4      // Ability
        target = 1         // Living Actor
        range = 1
        required_level = 1
        projectile = 1       // NONE
    END

 

Share this post


Link to post
On 1/15/2019 at 2:12 PM, Ardanis said:

The function checks file's extension to determine its type (spl or itm), and CREATE action doesn't seem to provide one.This works


CREATE    "SPL"    "GTPENAL"
    WRITE_LONG 0x018 (BIT14 | BIT25)  // Castable when Silenced, Ignore Dead/Wild Magic
    WRITE_SHORT 0x01c 4               // Innate ability
    WRITE_LONG 0x034 1                 // Spell level

COPY_EXISTING "GTPENAL.SPL" override
    LPF ADD_SPELL_HEADER
    INT_VAR
        type = 1         // Melee
        location = 4      // Ability
        target = 1         // Living Actor
        range = 1
        required_level = 1
        projectile = 1       // NONE
    END

 

Wow that's good to know.  I've had to avoid CREATE for like a year because I didn't realize why FJ_SPL_ITM_REINDEX kept throwing errors. @Aquadrizzt if you're around these parts, might want to update QDMulti v0.3 with this adjustment.

Edited by subtledoctor

Share this post


Link to post

@subtledoctor

Yep, CREATE is so handy, there's no need to create in advance your files with NearInfinity......

Thanks @Ardanis by the way

Edited by Luke

Share this post


Link to post

Strictly speaking, if you create them from scratch then you don't need FJ_SPL_ITM_REINDEX in the first place, it's just a safeguard against non-standard structuring in some files - just comment it out in your code.

Share this post


Link to post
1 hour ago, Ardanis said:

Strictly speaking, if you create them from scratch then you don't need FJ_SPL_ITM_REINDEX in the first place, it's just a safeguard against non-standard structuring in some files - just comment it out in your code.

But... that's called in the ADD_SPELL_HEADER function... no?   I always had errors when trying to add spell headers to new, headerless spells.  E.g. this code would tend to flake out on me at line 285.

Share this post


Link to post

Same issue as Luke's - it's trying to run reindex, and it fails without file extension. Frankly, those functions have been written well before CREATE (in fact, the library file they're from has its own CREATE_SPELL function), so this is a new conflict... but if you only need header additions to new files, then you can just comment the reindex out at line 84.

Edited by Ardanis

Share this post


Link to post

This function automatically updates the descriptions of the anti-defense spells (Ruby Ray, Breach et al) to reflect the actual spells that they affect (which, on a modded environment, might be very different from the vanilla list - not that the vanilla list is completely accurate anyway). The algorithm is a little heuristic but should be pretty robust. You need to supply one short string.

EDIT: this uses slightly more of SCS's function environment than I'd realized at first glance. I'll embed it in v32; if anyone wants to use it, talk to me about how to extract it.

 

Share this post


Link to post
Posted (edited)

ADD_SPELL_EX - Action function similar to WeiDU ADD_SPELL (adding a spell of type and level into spell.ids, in the first empty slot possible), but more flexible:

https://github.com/K4thos/IE-code-repository/blob/master/add_spell_ex.tpa

-----------

Also my older REPLACE_MULTILINE function now supports regexp variables in output string, which works in a similar way to REPLACE_EVALUATE (see the 200 MATCHi variables explanation in weidu documentation.)

Edited by K4thos

Share this post


Link to post
Posted (edited)

APPEND_TO_IDS - Action function for appending into IDS file at the first free index slot within given index range.
The action can return numerical reference of the appended entry or existing index if symbolic name already exists within the file.

Example usage:

LAF APPEND_TO_IDS INT_VAR min = 400 max = 65535 STR_VAR file = ~STATS.IDS~ name = ~SYMBOLIC_NAME~ RET index END

https://github.com/K4thos/IE-code-repository/blob/master/append_to_ids.tpa

Edited by K4thos

Share this post


Link to post
Posted (edited)

COMPILE_LUA - Action function that lets you compile BAF and D files containing Bubb's EEex Lua functions (EEex_Lua, EEex_LuaTrigger)
The function converts easy to read multiline Lua code into a single line syntax supported by weidu

Example usage:

LAF COMPILE_LUA STR_VAR path = ~someDir/someFile.baf~ END
LAF COMPILE_LUA STR_VAR path = ~someDir~ END

https://github.com/K4thos/IE-code-repository/blob/master/compile_lua.tpa

edit: feel free to merge this post with previous one.

Edited by K4thos

Share this post


Link to post
Posted (edited)

This one is like spell_to_innate, but allows for a few more options (including changing spell types from any kind to any other kind).  A lot of the text options are English only, but those can be traified to support other languages.  Also, it won't replace any sphere text in spells with custom sphere names, but those could easily be added.  


 

Spoiler

DEFINE_PATCH_FUNCTION ALTER_SPELL_TYPE
  INT_VAR   spell_type        = "-1" //Special: (0); Wizard: (1); Cleric: (2); Psionic: (3); Innate: (4); Song: (5)
            spell_level       = "-1"
            location          = "-1" //none: (0); spell: (2); innate (4) - ONLY Necessary if other than specified by Spell type (otherwise location automatically changed)
            school          = "-1" //school: 0 = None; 1 = abjuration; 2 = conjuration; 3= divination; 4 = enchantment; 5 = illusion; 6 = invoker; 7 = necromancer; 8 = transmuter; 9 = trueclass mage; 10 = wild mage only
            opposition_school = "-1" //opposition school: 0 = None; 1 = abjuration; 2 = conjuration; 3= divination; 4 = enchantment; 5 = illusion; 6 = invoker; 7 = necromancer; 8 = transmuter; 9 = trueclass mage; 10 = wild mage only
         prohibited_alignment = "-1" //or prohibited alignment: 1 = exclude chaotic; 2 = evil; 3 = good; 4 = ethical neutral; 5 = lawful 6 = moral neutral
            casting_graphics  = "-1" //school: 0 = None; 1 = abjuration; 2 = conjuration; 3= divination; 4 = enchantment; 5 = illusion; 6 = invoker; 7 = necromancer; 8 = transmuter; 9 = black sparks
            cleric_druid_only = "-1" //0 = no restrictions; 1 = cleric/Pal exclusive (priest spells); 2 = druid/Ran exclusive (priest spells); 3 = prohibit all
            wild_mage         = "-1" //0 = Wildmage restricted (wm can't cast); 1 = Wildmage can cast (mage spells)
            sec_type          = "-1" //0 = none; 1 = Spell Protection; 2 = Specific Protections; 3 = Illusonary Protections; 4 = Magic Attack; 5 = Divination Attack; 6 = Conjuration; 7 = Combat Protections; 8 = Contingency; 9 = Battleground; 10 = Offensive Damage; 11 = Disabling; 12 = Combination; 13 = Non-Combat; 14 = Dorn's Sword
            failure           = "-1" // 0 = Failure NOT possible; 1 = Failure possible (other values not accepted)
            indoors           = "-1" // 0 = cannot be cast indoors; 1 = can cast indoors (other values not accepted)
            surge             = "-1" // 0 = wildsurge not possible; 1 = wildsurge possible (other values not accepted)
            los               = "-1" // 0 = Line of Sight required; 1 = no LOS required (other values not accepted)
            combat            = "-1" // 0 = cannot be cast in combat; 1 = CAN be cast in combat (other values not accepted)
            hostile           = "-1" // 0 = not hostile spell; 1 = Hostile (other values not accepted) !
            spotting          = "-1" // 0 = no spotting(?); 1 = spotting (other values not accepted)
            target_invisible  = "-1" // 0 = cannot target invisible; 1 = can target invisibile (other values not accepted)
            silence           = "-1" // 0 = cannot cast when silenced; 1 = can cast when silenced (other values not accepted)
  STR_VAR   level_text        = "SAME"  //Only accepts values of 1-10, "Quest", "Cantrip" or "Orison"--Changes "Level: x" in spell description to "Level: y" where y is the value added TEST!!!
         school_text          = "SAME"  //Only necessary for user created schools
          sphere_text          = "SAME"  //Name of sphere
        c_icon            = "NO"  //"SAME" = %SOURCE_RES%C, "ADD" = %spell_res%C, else Exact name given of C icon

BEGIN
  READ_LONG  0x64 abil_off ELSE 0
  READ_SHORT 0x68 abil_num ELSE 0
  READ_ASCII (abil_off + 0x04) bam (8) // reads the bam filename from ability

// Handle spell_type if specified
PATCH_IF (spell_type >= 0) //types: innate(4)
  BEGIN
    WRITE_SHORT 0x1C spell_type
  PATCH_IF (location < 0) BEGIN
    PATCH_IF (spell_type = 0) OR ((spell_type = 2) OR (spell_type = 4)) BEGIN
      FOR (index = 0 ; index < abil_num ; ++index) BEGIN
        WRITE_SHORT (abil_off + 0x02 + (0x28 * index)) spell_type
      END
    END ELSE BEGIN
      FOR (index = 0 ; index < abil_num ; ++index) BEGIN
        WRITE_SHORT (abil_off + 0x02 + (0x28 * index)) 0
      END
    END
  END
END
  
  // Handle spell level if specified
PATCH_IF (spell_level > 0)
  BEGIN
    WRITE_LONG  0x34 spell_level
  END
// Handle location if specified
PATCH_IF (location >= 0) BEGIN
  FOR (index = 0 ; index < abil_num ; ++index) BEGIN
    WRITE_SHORT (abil_off + 0x02 + (0x28 * index)) location
  END
END

// Handle opp school if specified (mage only)
PATCH_IF (opposition_school >= 0) BEGIN
  PATCH_IF (opposition_school = 0) BEGIN
   WRITE_LONG 0x001e 0x0000 //General spells, exclude nobody
  END
  PATCH_IF (opposition_school = 1) BEGIN
   WRITE_LONG 0x001e 0x0040 //General spells, exclude abjuration
  END
  PATCH_IF (opposition_school = 2) BEGIN
   WRITE_LONG 0x001e 0x0080 //General spells, exclude conjuration
  END
  PATCH_IF (opposition_school = 3) BEGIN
   WRITE_LONG 0x001e 0x0100 //General spells, exclude divination
  END
  PATCH_IF (opposition_school = 4) BEGIN
   WRITE_LONG 0x001e 0x0200 //General spells, exclude enchanter
  END
  PATCH_IF (opposition_school = 5) BEGIN
   WRITE_LONG 0x001e 0x0400 //General spells, exclude illusion
  END
  PATCH_IF (opposition_school = 6) BEGIN
   WRITE_LONG 0x001e 0x0800 //General spells, exclude invoker
  END
  PATCH_IF (opposition_school = 7) BEGIN
   WRITE_LONG 0x001e 0x1000 //General spells, exclude necro
  END
  PATCH_IF (opposition_school = 8) BEGIN
   WRITE_LONG 0x001e 0x2000 //General spells, exclude transmutation
  END
  PATCH_IF (opposition_school = 9) BEGIN
   WRITE_LONG 0x001e 0x4000 //General spells, exclude trueclass mage
  END
  PATCH_IF (opposition_school = 10) BEGIN
   WRITE_LONG 0x001e 0x7fc0 //General spells, wildmage only
  END
END
//prohibited_alignment if specified (priest only)
PATCH_IF (prohibited_alignment > 0) BEGIN
  PATCH_IF (prohibited_alignment = 1) BEGIN
   WRITE_LONG 0x001e 0x0001 //exclude chaotic
  END
  PATCH_IF (prohibited_alignment = 2) BEGIN
   WRITE_LONG 0x001e 0x0002 //exclude evil
  END
  PATCH_IF (prohibited_alignment = 3) BEGIN
   WRITE_LONG 0x001e 0x0004 //exclude good
  END
  PATCH_IF (prohibited_alignment = 4) BEGIN
   WRITE_LONG 0x001e 0x0020 //exclude ethical neutral
  END
  PATCH_IF (prohibited_alignment = 5) BEGIN
   WRITE_LONG 0x001e 0x0010 //exclude lawful
  END
  PATCH_IF (prohibited_alignment = 6) BEGIN
   WRITE_LONG 0x001e 0x0008 //exclude moral neutral
  END
END 


PATCH_IF (school >= 0) BEGIN
  PATCH_IF (school = 0) BEGIN
   WRITE_BYTE 0x0025 0x01 // None
  END
  PATCH_IF (school = 1) BEGIN
   WRITE_BYTE 0x0025 0x01 // Abjuration
  READ_LONG 0x50 "valid"
  PATCH_IF (%valid% >= 0) BEGIN // verify desc is valid
  READ_STRREF 0x50 ~desc~
    INNER_PATCH_SAVE new_desc ~%desc%~ BEGIN //CHECK SPELLS: Wraithform, MMM, Fireshield
    REPLACE_TEXTUALLY ~Abjuration~ ~Abjuration~        //replacing old with new 
    REPLACE_TEXTUALLY ~Conjuration~ ~Abjuration~        //replacing old with new 
    REPLACE_TEXTUALLY ~Conjuration/Summoning~ ~Abjuration~        //replacing old with new 
    REPLACE_TEXTUALLY ~Alteration~ ~Abjuration~        //replacing old with new 
    REPLACE_TEXTUALLY ~Evocation~ ~Abjuration~        //replacing old with new 
    REPLACE_TEXTUALLY ~Necromancy~ ~Abjuration~        //replacing old with new 
    REPLACE_TEXTUALLY ~Enchantment/Charm~ ~Abjuration~        //replacing old with new 
    REPLACE_TEXTUALLY ~Illusion/Phantasm~ ~Abjuration~        //replacing old with new 
    REPLACE_TEXTUALLY ~(Divination)~ ~(Abjuration)~        //replacing old with new
    REPLACE_TEXTUALLY ~School: Divination~ ~School: Abjuration~        //replacing old with new
    END       //
  SAY_EVALUATED 0x50 ~%new_desc%~
  END  // end text change
  END
  PATCH_IF (school = 2) BEGIN
   WRITE_BYTE 0x0025 0x02 // Conjuration
  READ_LONG 0x50 "valid"
  PATCH_IF (%valid% >= 0) BEGIN // verify desc is valid
  READ_STRREF 0x50 ~desc~
    INNER_PATCH_SAVE new_desc ~%desc%~ BEGIN //CHECK SPELLS: Wraithform, MMM, Fireshield
    REPLACE_TEXTUALLY ~Abjuration~ ~Conjuration~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration~ ~Conjuration~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration/Summoning~ ~Conjuration/Summoning~        //replacing old with new
    REPLACE_TEXTUALLY ~Alteration~ ~Conjuration~        //replacing old with new
    REPLACE_TEXTUALLY ~Evocation~ ~Conjuration~        //replacing old with new
    REPLACE_TEXTUALLY ~Necromancy~ ~Conjuration~        //replacing old with new
    REPLACE_TEXTUALLY ~Enchantment/Charm~ ~Conjuration~        //replacing old with new
    REPLACE_TEXTUALLY ~Illusion/Phantasm~ ~Conjuration~        //replacing old with new
    REPLACE_TEXTUALLY ~(Divination)~ ~(Conjuration)~        //replacing old with new
    REPLACE_TEXTUALLY ~School: Divination~ ~School: Conjuration~        //replacing old with new
    END
    //
  SAY_EVALUATED 0x50 ~%new_desc%~
  END  // end text change
  END
  PATCH_IF (school = 3) BEGIN
   WRITE_BYTE 0x0025 0x03 // (Divination)
  READ_LONG 0x50 "valid"
  PATCH_IF (%valid% >= 0) BEGIN // verify desc is valid
  READ_STRREF 0x50 ~desc~
    INNER_PATCH_SAVE new_desc ~%desc%~ BEGIN //CHECK SPELLS: Wraithform, MMM, Fireshield
    REPLACE_TEXTUALLY ~Abjuration~ ~Divination~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration~ ~Divination~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration/Summoning~ ~Divination~        //replacing old with new
    REPLACE_TEXTUALLY ~Alteration~ ~Divination~        //replacing old with new
    REPLACE_TEXTUALLY ~Evocation~ ~Divination~        //replacing old with new
    REPLACE_TEXTUALLY ~Necromancy~ ~Divination~        //replacing old with new
    REPLACE_TEXTUALLY ~Enchantment/Charm~ ~Divination~        //replacing old with new
    REPLACE_TEXTUALLY ~Illusion/Phantasm~ ~Divination~        //replacing old with new
    END
    //
  SAY_EVALUATED 0x50 ~%new_desc%~
  END  // end text change
  END
  PATCH_IF (school = 4) BEGIN
   WRITE_BYTE 0x0025 0x04 // Enchanter
  READ_LONG 0x50 "valid"
  PATCH_IF (%valid% >= 0) BEGIN // verify desc is valid
  READ_STRREF 0x50 ~desc~
    INNER_PATCH_SAVE new_desc ~%desc%~ BEGIN //CHECK SPELLS: Wraithform, MMM, Fireshield
    REPLACE_TEXTUALLY ~Abjuration~ ~Enchantment/Charm~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration~ ~Enchantment/Charm~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration/Summoning~ ~Enchantment/Charm~        //replacing old with new
    REPLACE_TEXTUALLY ~Alteration~ ~Enchantment/Charm~        //replacing old with new
    REPLACE_TEXTUALLY ~Evocation~ ~Enchantment/Charm~        //replacing old with new
    REPLACE_TEXTUALLY ~Necromancy~ ~Enchantment/Charm~        //replacing old with new
    REPLACE_TEXTUALLY ~Enchantment/Charm~ ~Enchantment/Charm~        //replacing old with new
    REPLACE_TEXTUALLY ~Illusion/Phantasm~ ~Enchantment/Charm~        //replacing old with new
    REPLACE_TEXTUALLY ~(Divination)~ ~(Enchantment/Charm)~        //replacing old with new
    REPLACE_TEXTUALLY ~School: Divination~ ~School: Enchantment/Charm~        //replacing old with new
    END
  SAY_EVALUATED 0x50 ~%new_desc%~   //
  END  // end text change
  END
  PATCH_IF (school = 5) BEGIN
   WRITE_BYTE 0x0025 0x05 // Illusion
  READ_LONG 0x50 "valid"
  PATCH_IF (%valid% >= 0) BEGIN // verify desc is valid
  READ_STRREF 0x50 ~desc~
    INNER_PATCH_SAVE new_desc ~%desc%~ BEGIN //CHECK SPELLS: Wraithform, MMM, Fireshield
    REPLACE_TEXTUALLY ~Abjuration~ ~Illusion/Phantasm~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration~ ~Illusion/Phantasm~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration/Summoning~ ~Illusion/Phantasm~        //replacing old with new
    REPLACE_TEXTUALLY ~Alteration~ ~Illusion/Phantasm~        //replacing old with new
    REPLACE_TEXTUALLY ~Evocation~ ~Illusion/Phantasm~        //replacing old with new
    REPLACE_TEXTUALLY ~Necromancy~ ~Illusion/Phantasm~        //replacing old with new
    REPLACE_TEXTUALLY ~Enchantment/Charm~ ~Illusion/Phantasm~        //replacing old with new
    REPLACE_TEXTUALLY ~Illusion/Phantasm~ ~Illusion/Phantasm~        //replacing old with new
    REPLACE_TEXTUALLY ~(Divination)~ ~(Illusion/Phantasm)~        //replacing old with new
    REPLACE_TEXTUALLY ~School: Divination~ ~School: Illusion/Phantasm~        //replacing old with new
    END
  SAY_EVALUATED 0x50 ~%new_desc%~   //
  END  // end text change
  END
  PATCH_IF (school = 6) BEGIN
   WRITE_BYTE 0x0025 0x06 // Invoker
  READ_LONG 0x50 "valid"
  PATCH_IF (%valid% >= 0) BEGIN // verify desc is valid
  READ_STRREF 0x50 ~desc~
    INNER_PATCH_SAVE new_desc ~%desc%~ BEGIN //CHECK SPELLS: Wraithform, MMM, Fireshield
    REPLACE_TEXTUALLY ~Abjuration~ ~Evocation~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration~ ~Evocation~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration/Summoning~ ~Evocation~        //replacing old with new
    REPLACE_TEXTUALLY ~Alteration~ ~Evocation~        //replacing old with new
    REPLACE_TEXTUALLY ~Evocation~ ~Evocation~        //replacing old with new
    REPLACE_TEXTUALLY ~Necromancy~ ~Evocation~        //replacing old with new
    REPLACE_TEXTUALLY ~Enchantment/Charm~ ~Evocation~        //replacing old with new
    REPLACE_TEXTUALLY ~Illusion/Phantasm~ ~Evocation~        //replacing old with new
    REPLACE_TEXTUALLY ~(Divination)~ ~(Evocation)~        //replacing old with new
    REPLACE_TEXTUALLY ~School: Divination~ ~School: Evocation~        //replacing old with new
    END
  SAY_EVALUATED 0x50 ~%new_desc%~    //
  END  // end text change
  END
  PATCH_IF (school = 7) BEGIN
   WRITE_BYTE 0x0025 0x07 // Necro
  READ_LONG 0x50 "valid"
  PATCH_IF (%valid% >= 0) BEGIN // verify desc is valid
  READ_STRREF 0x50 ~desc~
    INNER_PATCH_SAVE new_desc ~%desc%~ BEGIN //CHECK SPELLS: Wraithform, MMM, Fireshield
    REPLACE_TEXTUALLY ~Abjuration~ ~Necromancy~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration~ ~Necromancy~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration/Summoning~ ~Necromancy~        //replacing old with new
    REPLACE_TEXTUALLY ~Alteration~ ~Necromancy~        //replacing old with new
    REPLACE_TEXTUALLY ~Evocation~ ~Necromancy~        //replacing old with new
    REPLACE_TEXTUALLY ~Necromancy~ ~Necromancy~        //replacing old with new
    REPLACE_TEXTUALLY ~Enchantment/Charm~ ~Necromancy~        //replacing old with new
    REPLACE_TEXTUALLY ~Illusion/Phantasm~ ~Necromancy~        //replacing old with new
    REPLACE_TEXTUALLY ~(Divination)~ ~(Necromancy)~        //replacing old with new
    REPLACE_TEXTUALLY ~School: Divination~ ~School: Necromancy~        //replacing old with new
    END
  SAY_EVALUATED 0x50 ~%new_desc%~      //
  END  // end text change
  END
  PATCH_IF (school = 8) BEGIN
   WRITE_BYTE 0x0025 0x08 // Transmutation
  READ_LONG 0x50 "valid"
  PATCH_IF (%valid% >= 0) BEGIN // verify desc is valid
  READ_STRREF 0x50 ~desc~
    INNER_PATCH_SAVE new_desc ~%desc%~ BEGIN //CHECK SPELLS: Wraithform, MMM, Fireshield
    REPLACE_TEXTUALLY ~Abjuration~ ~Alteration~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration~ ~Alteration~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration/Summoning~ ~Alteration~        //replacing old with new
    REPLACE_TEXTUALLY ~Alteration~ ~Alteration~        //replacing old with new
    REPLACE_TEXTUALLY ~Evocation~ ~Alteration~        //replacing old with new
    REPLACE_TEXTUALLY ~Necromancy~ ~Alteration~        //replacing old with new
    REPLACE_TEXTUALLY ~Enchantment/Charm~ ~Alteration~        //replacing old with new
    REPLACE_TEXTUALLY ~Illusion/Phantasm~ ~Alteration~        //replacing old with new
    REPLACE_TEXTUALLY ~(Divination)~ ~(Alteration)~        //replacing old with new
    REPLACE_TEXTUALLY ~School: Divination~ ~School: Alteration~        //replacing old with new
    END
  SAY_EVALUATED 0x50 ~%new_desc%~     //
  END  // end text change
  END
  PATCH_IF (school = 9) BEGIN
   WRITE_BYTE 0x0025 0x09 // Generalist(?)
  END
END

PATCH_IF (cleric_druid_only >= 0) BEGIN
  PATCH_IF (cleric_druid_only = 0) BEGIN
      READ_BYTE    0x21 none //
      WRITE_BYTE   0x21 (none BAND 0b00000000)  // reset
  END
  PATCH_IF (cleric_druid_only = 1) BEGIN
      READ_BYTE    0x21 none //
      WRITE_BYTE   0x21 (none BAND 0b00000000)  // reset
      READ_BYTE    0x21 cleric //
      WRITE_BYTE   0x21 (cleric BOR 0b10000000)  // set to cleric
  END
  PATCH_IF (cleric_druid_only = 2) BEGIN
      READ_BYTE    0x21 none //
      WRITE_BYTE   0x21 (none BAND 0b00000000)  // reset
      READ_BYTE    0x21 druid //
      WRITE_BYTE   0x21 (druid BOR 0b01000000)  // set to druid
  END
  PATCH_IF (cleric_druid_only = 3) BEGIN
      READ_BYTE    0x21 none //
      WRITE_BYTE   0x21 (none BAND 0b00000000)  // reset
      READ_BYTE    0x21 no_wild //
      WRITE_BYTE   0x21 (no_wild BOR 0b11000000)  // Restrict everybody
  END
END
//wild_mage if specified
PATCH_IF (wild_mage >= 0) BEGIN
  PATCH_IF (wild_mage = 0) BEGIN  //Wildmage Can't cast
      READ_BYTE    0x21 none //
      WRITE_BYTE   0x21 (none BAND 0b00000000)  // reset
      READ_BYTE    0x21 no_wild //
      WRITE_BYTE   0x21 (no_wild BOR 0b11000000)  // Restrict wildmage
  END
  PATCH_IF (wild_mage = 1) BEGIN //wildmage Can cast
      READ_BYTE    0x21 none //
      WRITE_BYTE   0x21 (none BAND 0b00000000)  // wildmage enabled
  END
END
//casting graphics if specified
PATCH_IF (casting_graphics >= 0) BEGIN
  PATCH_IF (casting_graphics = 0) BEGIN
   WRITE_SHORT 0x0022 00 // c.graphics -schooless
  END
  PATCH_IF (casting_graphics = 1) BEGIN
   WRITE_SHORT 0x0022 12 // c.graphics -abjuration
  END
  PATCH_IF (casting_graphics = 2) BEGIN
   WRITE_SHORT 0x0022 14 // c.graphics -conjuration
  END
  PATCH_IF (casting_graphics = 3) BEGIN
   WRITE_SHORT 0x0022 16 // c.graphics -divination
  END
  PATCH_IF (casting_graphics = 4) BEGIN
   WRITE_SHORT 0x0022 11 // c.graphics -enchantment
  END
  PATCH_IF (casting_graphics = 5) BEGIN
   WRITE_SHORT 0x0022 13 // c.graphics -illusion
  END
  PATCH_IF (casting_graphics = 6) BEGIN
   WRITE_SHORT 0x0022 15 // c.graphics -invoker
  END
  PATCH_IF (casting_graphics = 7) BEGIN
   WRITE_SHORT 0x0022 09 // c.graphics -necromancy
  END
  PATCH_IF (casting_graphics = 8) BEGIN
   WRITE_SHORT 0x0022 10 // c.graphics -alteration
  END
  PATCH_IF (casting_graphics = 9) BEGIN
   WRITE_SHORT 0x0022 18 // c.graphics -black sparks
  END
END
// Handle sec school if specified
PATCH_IF (sec_type >= 0) BEGIN
  PATCH_IF (sec_type = 0) BEGIN
   WRITE_LONG 0x0027 0x0000 //None
  END
  PATCH_IF (sec_type = 1) BEGIN
   WRITE_LONG 0x0027 0x01 //Spell Protection
  END
  PATCH_IF (sec_type = 2) BEGIN
   WRITE_LONG 0x0027 0x02 //-SPECIFICPROTECTIONS
  END
  PATCH_IF (sec_type = 3) BEGIN
   WRITE_LONG 0x0027 0x03 //-ILLUSIONARYPROTECTIONS
  END
  PATCH_IF (sec_type = 4) BEGIN
   WRITE_LONG 0x0027 0x04 //-MAGICATTACK
  END
  PATCH_IF (sec_type = 5) BEGIN
   WRITE_LONG 0x0027 0x05 //DIVINATIONATTACK
  END
  PATCH_IF (sec_type = 6) BEGIN
   WRITE_LONG 0x0027 0x06 //CONJURATION
  END
  PATCH_IF (sec_type = 7) BEGIN
   WRITE_LONG 0x0027 0x07 //0x07-COMBATPROTECTIONS
  END
  PATCH_IF (sec_type = 8) BEGIN
   WRITE_LONG 0x0027 0x08 //0x08-CONTINGENCY
  END
  PATCH_IF (sec_type = 9) BEGIN
   WRITE_LONG 0x0027 0x09 //0x09-BATTLEGROUND
  END
  PATCH_IF (sec_type = 10) BEGIN
   WRITE_LONG 0x0027 0x0a //-OFFENSIVEDAMAGE
  END
  PATCH_IF (sec_type = 11) BEGIN
   WRITE_LONG 0x0027 0x0b //0x0b-DISABLING
  END
  PATCH_IF (sec_type = 12) BEGIN
   WRITE_LONG 0x0027 0x0c //0x0c-COMBINATION
  END
  PATCH_IF (sec_type = 13) BEGIN
   WRITE_LONG 0x0027 0x0d //0x0d-NON-COMBAT
  END
  PATCH_IF (sec_type = 14) BEGIN
   WRITE_LONG 0x0027 0x0e //0x0e-DORNS_SWORD
  END
END

//Handle hostile if specified
PATCH_IF (hostile = 0) BEGIN
      READ_BYTE    0x19 no_hos //
      WRITE_BYTE   0x19 (no_hos BAND 0b11111011)  //
END
PATCH_IF (hostile = 1) BEGIN
      READ_BYTE    0x19 hos //
      WRITE_BYTE   0x19 (hos BOR 0b00000100)  //
END
// Handle failure if specified
PATCH_IF (failure = 0) BEGIN
   WRITE_LONG 0x0018 (THIS | 0x4000)       //No failure
END
PATCH_IF (failure = 1) BEGIN
      READ_BYTE    0x19 no_fail //
      WRITE_BYTE   0x19 (no_fail BAND 0b10111111)  // not no fail
END

// Handle indoors if specified
PATCH_IF (indoors = 0) BEGIN
   WRITE_LONG 0x0018 (THIS | 0x2000)       //Not indoors
END
PATCH_IF (indoors = 1) BEGIN
      READ_BYTE    0x19 inside //
      WRITE_BYTE   0x19 (inside BAND 0b11011111)  // Can be cast indoors
END

// Handle surge if specified
PATCH_IF (surge = 0) BEGIN
   WRITE_LONG 0x0018 (THIS | 0x8000)       //No wildsurge
END
PATCH_IF (surge = 1) BEGIN
      READ_BYTE    0x19 no_surge //
      WRITE_BYTE   0x19 (no_surge BAND 0b01111111)  // not no surge
END

// Handle spotting if specified
PATCH_IF (spotting = 0) BEGIN
      READ_BYTE    0x19 spot //
      WRITE_BYTE   0x19 (spot BAND 0b11101111)  // not spot
END
PATCH_IF (spotting = 1) BEGIN
   WRITE_LONG 0x0018 (THIS | 0x1000)       //allow spotting?
END

//Handle LOS if specified
PATCH_IF (los = 0) BEGIN
      READ_BYTE    0x19 see //
      WRITE_BYTE   0x19 (see BAND 0b11110111)  // LOS required
END
PATCH_IF (los = 1) BEGIN
      READ_BYTE    0x19 see //
      WRITE_BYTE   0x19 (see BOR 0b00001000)  //  los not required
END

// Handle combat if specified
PATCH_IF (combat = 0) BEGIN
    READ_BYTE     0x001a fail //reads the byte
    WRITE_BYTE    0x001a (fail BOR 0b00000001)  // CANNOT cast in combat
END 
PATCH_IF (combat = 1) BEGIN
    READ_BYTE     0x001a fail //reads the byte
    WRITE_BYTE    0x001a (fail BAND 0b11111110)  // CAN cast in combat
END
//target_invisible if specified
PATCH_IF (target_invisible = 0) BEGIN
    READ_BYTE     0x001b invis //reads the byte
    WRITE_BYTE    0x001b (invis BAND 0b11111110)  // CANNOT target invis
END
PATCH_IF (target_invisible = 1) BEGIN
    READ_BYTE     0x001b invis //reads the byte
    WRITE_BYTE    0x001b (invis BOR 0b00000001)  // CAN target invis
END

//silence if specified
PATCH_IF (silence = 0) BEGIN
    READ_BYTE     0x001b speak //reads the byte
    WRITE_BYTE    0x001b (speak BAND 0b11111101)  // CANNOT cast silenced
END
PATCH_IF (silence = 1) BEGIN
    READ_BYTE     0x001b speak //reads the byte
    WRITE_BYTE    0x001b (speak BOR 0b00000010)  // CAN cast silenced
END

//level text if specified
PATCH_IF ("%level_text%" STRING_COMPARE_CASE "SAME" != 0) BEGIN //
  
//lev x to lev y
  READ_LONG 0x50 "valid"
  PATCH_IF (%valid% >= 0) BEGIN // verify desc is valid
  READ_STRREF 0x50 ~desc~
    INNER_PATCH_SAVE new_desc ~%desc%~ BEGIN
    REPLACE_TEXTUALLY ~Level: Cantrip~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: Orison~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: 1~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: 2~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: 3~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: 4~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: 5~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: 6~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: 7~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: 8~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: 9~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: 10~ ~Level: %level_text%~        //replacing old with new 
    REPLACE_TEXTUALLY ~Level: Quest~ ~Level: %level_text%~        //replacing old with new
    END
  SAY_EVALUATED 0x50 ~%new_desc%~
  END  // 

END //end lev text

//level school if specified
PATCH_IF ("%school_text%" STRING_COMPARE_CASE "SAME" != 0) BEGIN //
  READ_LONG 0x50 "valid"
  PATCH_IF (%valid% >= 0) BEGIN // verify desc is valid
  READ_STRREF 0x50 ~desc~
    INNER_PATCH_SAVE new_desc ~%desc%~ BEGIN
    REPLACE_TEXTUALLY ~Abjuration~ ~%school_text%~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration~ ~%school_text%~        //replacing old with new
    REPLACE_TEXTUALLY ~Conjuration/Summoning~ ~%school_text%~        //replacing old with new
    REPLACE_TEXTUALLY ~Alteration~ ~%school_text%~        //replacing old with new
    REPLACE_TEXTUALLY ~Evocation~ ~%school_text%~        //replacing old with new
    REPLACE_TEXTUALLY ~Necromancy~ ~%school_text%~        //replacing old with new
    REPLACE_TEXTUALLY ~Enchantment/Charm~ ~%school_text%~        //replacing old with new
    REPLACE_TEXTUALLY ~Illusion/Phantasm~ ~%school_text%~        //replacing old with new
    REPLACE_TEXTUALLY ~(Divination)~ ~(%school_text%)~        //replacing old with new
    REPLACE_TEXTUALLY ~School: Divination~ ~School: %school_text%~        //replacing old with new
    END
  SAY_EVALUATED 0x50 ~%new_desc%~
  END  //
END//End school_text text

//level school if specified
PATCH_IF ("%sphere_text%" STRING_COMPARE_CASE "SAME" != 0) BEGIN //
  READ_LONG 0x50 "valid"
  PATCH_IF (%valid% >= 0) BEGIN // verify desc is valid
  READ_STRREF 0x50 ~desc~
    INNER_PATCH_SAVE new_desc ~%desc%~ BEGIN
      REPLACE_TEXTUALLY ~Sphere: Affliction~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Air~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: All~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Animal~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Animal, Summoning~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Benediction~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Chaos~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Charm~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Charm, Combat, Law~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Charm, Creation~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Charm, Law~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Charm, Protection~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Combat~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Combat, Necromantic~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Combat, Plant~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Combat, Summoning~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Creation~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Death~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Deception~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Destruction~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Divination~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Dread~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Earth~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Elemental~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Elemental (Air)~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Elemental Air~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Elemental (Earth)~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Elemental (Earth), Summoning~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Elemental Earth~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Elemental (Fire)~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Elemental (Fire), Summoning~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Elemental Fire~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Elemental (Water)~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Elemental Water~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Exploration~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Fire~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Guardian~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Guardian, Creation~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Healing~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Knowledge~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Law~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Life~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Light~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Magic~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Necromantic~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Necromantic, Protection~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Numbers~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Perdition~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Plant~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Protection~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Protection, Elemental (Fire)~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Protection, Plant~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Protection, Sun~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Protection, Weather~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Shadow~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Summoning~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Sun~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Thought~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Travelers~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Universal~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Vigor~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: War~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Wards~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Wards, Elemental (Air)~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Water~ ~Sphere: %sphere_text%~        //replacing old with new
      REPLACE_TEXTUALLY ~Sphere: Weather~ ~Sphere: %sphere_text%~        //replacing old with new
//missing sphere info
      REPLACE_TEXTUALLY ~1
Range~ ~1
Sphere: %sphere_text%
Range~        //replacing old with new
      REPLACE_TEXTUALLY ~2
Range~ ~2
Sphere: %sphere_text%
Range~        //replacing old with new
      REPLACE_TEXTUALLY ~3
Range~ ~3
Sphere: %sphere_text%
Range~        //replacing old with new
      REPLACE_TEXTUALLY ~4
Range~ ~4
Sphere: %sphere_text%
Range~        //replacing old with new
      REPLACE_TEXTUALLY ~5
Range~ ~5
Sphere: %sphere_text%
Range~        //replacing old with new
      REPLACE_TEXTUALLY ~6
Range~ ~6
Sphere: %sphere_text%
Range~        //replacing old with new
      REPLACE_TEXTUALLY ~7
Range~ ~7
Sphere: %sphere_text%
Range~        //replacing old with new
      REPLACE_TEXTUALLY ~8
Range~ ~8
Sphere: %sphere_text%
Range~        //replacing old with new
      REPLACE_TEXTUALLY ~9
Range~ ~9
Sphere: %sphere_text%
Range~        //replacing old with new
      REPLACE_TEXTUALLY ~Quest
Range~ ~Quest
Sphere: %sphere_text%
Range~        //replacing old with new
      REPLACE_TEXTUALLY ~Orison
Range~ ~Orison
Sphere: %sphere_text%
Range~        //replacing old with new
      REPLACE_TEXTUALLY ~Cantrip
Range~ ~Cantrip
Sphere: %sphere_text%
Range~        //replacing old with new
END
  SAY_EVALUATED 0x50 ~%new_desc%~
  END  //
END//End school_text text

//c_icon if specified
PATCH_IF ("%c_icon%" STRING_COMPARE_CASE "NO" != 0) BEGIN //
 PATCH_IF ("%c_icon%" STRING_COMPARE_CASE "SAME" = 0) BEGIN //
  WRITE_EVALUATED_ASCII 0x003a ~%SOURCE_RES%C~
 END  
 ELSE PATCH_IF ("%c_icon%" STRING_COMPARE_CASE "ADD" = 0) BEGIN
  WRITE_EVALUATED_ASCII 0x003a ~%spell_res%C~
 END
 ELSE
 BEGIN
  WRITE_EVALUATED_ASCII 0x003a ~%c_icon%~
 END
END//End c_icon

END

 

 

 

 

Sample uses:

 

Spoiler

 

 

Changes Grease to an innate that cannot be cast indoors, but can be cast while silenced


COPY_EXISTING ~SPWI101.SPL~ ~override/B_TEST.SPL~
       LPF  ALTER_SPELL_TYPE
          INT_VAR   spell_type = 4 //Special: (0); Wizard: (1); Cleric: (2); Psionic: (3); Innate: (4); Song: (5)
                    indoors    = 0 // 0 = cannot be cast indoors; 1 = can cast not indoors (other values not accepted)
                    silence    = 1 // 0 = cannot cast when silenced; 1 = can cast when silenced (other values not accepted)
          STR_VAR
          END

Adds that spell as a druid/ranger exclusive in the FOOEY sphere


ADD_SPELL ~override/B_TEST.SPL~ 1 1 ~TEST~ //
  LPF ALTER_SPELL_TYPE
   INT_VAR          spell_type = 2 //Special: (0); Wizard: (1); Cleric: (2); Psionic: (3); Innate: (4); Song: (5)
                    indoors    = 1 // 0 = cannot be cast indoors; 1 = can cast indoors (other values not accepted)
                    silence    = 0 // 0 = cannot cast when silenced; 1 = can cast when silenced (other values not accepted)
                    cleric_druid_only = 2 //0 = no restrictions; 1 = cleric/Pal exclusive (priest spells); 2 = druid/Ran exclusive (priest spells); 3 = prohibit all
   STR_VAR          sphere_text = "FOOEY"
  END      //

 

adding "C" icon to the above spell


LAF RES_NUM_OF_SPELL_NAME
  STR_VAR spell_name = ~TEST~
  RET spell_res
END



COPY ~-path/bam.bam~  ~override/%spell_res%C.bam~

COPY_EXISTING ~%spell_res%.spl~ ~override~
  LPF ALTER_SPELL_TYPE
   INT_VAR
   STR_VAR  c_icon   = "ADD"
  END      //

 

 

 

 

This one is a lot smaller.  It just adds additional prohibitions (i.e. school or alignment) to a given spell:


 

Spoiler

 


DEFINE_PATCH_FUNCTION SECOND_OPP
  INT_VAR   generalist        = "-1" //1 = Prohibit Generalist (too)(NO OTHER VALUES ACCEPTED) TEST
            abjuration        = "-1" //1 = Prohibit Abjuration (too)(NO OTHER VALUES ACCEPTED) TEST
            conjuration       = "-1" //1 = Prohibit Conjuration (too)(NO OTHER VALUES ACCEPTED) TEST
            divination        = "-1" //1 = Prohibit Divination (too)(NO OTHER VALUES ACCEPTED) TEST
            enchantment       = "-1" //1 = Prohibit Enchantment (too)(NO OTHER VALUES ACCEPTED) TEST
            illusionist       = "-1" //1 = Prohibit Illusion (too)(NO OTHER VALUES ACCEPTED) TEST
            invocation        = "-1" //1 = Prohibit Invocation (too)(NO OTHER VALUES ACCEPTED) TEST
            necromancy        = "-1" //1 = Prohibit Necromancy (too)(NO OTHER VALUES ACCEPTED) TEST
            alteration        = "-1" //1 = Prohibit Transmutation (too)(NO OTHER VALUES ACCEPTED) TEST
            chaos             = "-1" //1 = Prohibit Chaotic priests (too)(NO OTHER VALUES ACCEPTED) TEST
            evil              = "-1" //1 = Prohibit Evil priests (too)(NO OTHER VALUES ACCEPTED) TEST
            good              = "-1" //1 = Prohibit Good priests (too)(NO OTHER VALUES ACCEPTED) TEST
            geneutral         = "-1" //1 = Prohibit moral neutral priests (too)(NO OTHER VALUES ACCEPTED) TEST
            law               = "-1" //1 = Prohibit Lawful priests (too)(NO OTHER VALUES ACCEPTED) TEST
            lcneutral         = "-1" //1 = Prohibit Morally neutral priests (too)(NO OTHER VALUES ACCEPTED) TEST
  STR_VAR   
  
  BEGIN

//Additional restricted schools if specified
PATCH_IF (generalist = 1) BEGIN //Adds Generalist restriction to spell
    READ_BYTE     0x001f general //reads the byte
    WRITE_BYTE    0x001f (general BOR 0b01000000)  //
END
PATCH_IF (abjuration = 1) BEGIN //Adds abjuration restriction to spell
    READ_BYTE     0x001e abj //reads the byte
    WRITE_BYTE    0x001e (abj BOR 0b01000000)  //
END
PATCH_IF (conjuration = 1) BEGIN //Adds conjuration restriction to spell
    READ_BYTE     0x001e conj //reads the byte
    WRITE_BYTE    0x001e (conj BOR 0b10000000)  //
END
PATCH_IF (divination = 1) BEGIN //Adds divination restriction to spell
    READ_BYTE     0x001f div //reads the byte
    WRITE_BYTE    0x001f (div BOR 0b00000001)  //
END
PATCH_IF (enchantment = 1) BEGIN //Adds enchantment restriction to spell
    READ_BYTE     0x001f enc //reads the byte
    WRITE_BYTE    0x001f (enc BOR 0b00000010)  //
END
PATCH_IF (illusionist = 1) BEGIN //Adds illusionist restriction to spell
    READ_BYTE     0x001f enc //reads the byte
    WRITE_BYTE    0x001f (enc BOR 0b00000100)  //
END
PATCH_IF (invocation = 1) BEGIN //Adds invocation restriction to spell
    READ_BYTE     0x001f inv //reads the byte
    WRITE_BYTE    0x001f (inv BOR 0b00001000)  //
END
PATCH_IF (necromancy = 1) BEGIN //Adds necromancy restriction to spell
    READ_BYTE     0x001f nec //reads the byte
    WRITE_BYTE    0x001f (nec BOR 0b00010000)  //
END
PATCH_IF (alteration = 1) BEGIN //Adds alteration restriction to spell
    READ_BYTE     0x001f alt //reads the byte
    WRITE_BYTE    0x001f (alt BOR 0b00100000)  //
END
PATCH_IF (chaos = 1) BEGIN //Adds chaos restriction to spell
    READ_BYTE     0x001e cha //reads the byte
    WRITE_BYTE    0x001e (cha BOR 0b00000001)  //
END
PATCH_IF (evil = 1) BEGIN //Adds evil restriction to spell
    READ_BYTE     0x001e evi //reads the byte
    WRITE_BYTE    0x001e (evi BOR 0b00000010)  //
END
PATCH_IF (good = 1) BEGIN //Adds good restriction to spell
    READ_BYTE     0x001e god //reads the byte
    WRITE_BYTE    0x001e (god BOR 0b00000100)  //
END
PATCH_IF (geneutral = 1) BEGIN //Adds neutral moral restriction to spell
    READ_BYTE     0x001e nmor //reads the byte
    WRITE_BYTE    0x001e (nmor BOR 0b00001000)  //
END
PATCH_IF (law = 1) BEGIN //Adds law restriction to spell
    READ_BYTE     0x001e lw //reads the byte
    WRITE_BYTE    0x001e (lw BOR 0b00010000)  //
END
PATCH_IF (lcneutral = 1) BEGIN //Adds neutral ethical restriction to spell
    READ_BYTE     0x001e neth //reads the byte
    WRITE_BYTE    0x001e (neth BOR 0b00100000)  //
END

  END

 

 

 

 

 

Edited by Grammarsalad
Quick and sneaky update as well as a sample use

Share this post


Link to post
Posted (edited)

EXECUTE_LUA - Action and patch functions used for executing Lua code and retrieving the outcome back into WeiDU

Example usage:

LPF EXECUTE_LUA STR_VAR lua = ~3 / 2~ RET return END
LPF EXECUTE_LUA INT_VAR seed = 1 STR_VAR lua = ~math.random(1, 100) / 100~ RET return seed END
LPF EXECUTE_LUA INT_VAR seed = seed STR_VAR lua = EVAL ~loadfile "%MOD_FOLDER%/someFile.lua"~ RET return seed END

https://github.com/K4thos/IE-code-repository/blob/master/execute_lua.tpa

Here you can find compiled Lua executable for Windows, Linux and Mac OS: https://github.com/K4thos/EET/tree/master/EET/bin

Edited by K4thos

Share this post


Link to post
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...