What do I have today: lots of questions and a
weidu error! Some piece of my code can't be patched in. Syntax errors are all out, though... To be honest I don't understand the error message.
This might take a while.
Copying 1 file(s) ...
ERROR: [AERBOD01.CRE] -> [override/AERBOD01.CRE] Patching Failed (COPY) (Invalid_argument("String.sub"))
ERROR Installing [Updated and Tougher Mages for BGTutu], rolling back to previous state
Will uninstall 93 files for [TUTUMAGES_SETUP.TP2] component 0.
Uninstalled 93 files for [TUTUMAGES_SETUP.TP2] component 0.
ERROR: Invalid_argument("String.sub")
PLEASE email the file TUTUMAGES_SETUP.DEBUG to gravity665@hotmail.com
Here is my code so far, intermingled with questions...
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Edit Spellbooks
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
PRINT ~This might take a while.~
COPY_EXISTING_REGEXP ~.*\.cre~ ~override~
READ_BYTE 0x234 "level" //problem with dual/multiclassed:what is level1/level2?
READ_BYTE 0x273 "class"
READ_LONG 0x2a0 "knownSpellsOffset"
READ_LONG 0x2a8 "memorizationOffset"
READ_LONG 0x2b0 "memorizedSpellsOffset"
READ_LONG 0x2b4 "numMemorizedSpells"
READ_LONG 0x244 "kit"
READ_LONG 0x2c4 "EffectsOffset"
READ_LONG 0x2bc "itemsOffset"
READ_LONG 0x2b8 "itemSlotOffset"
I want a REGEXP starting with an _ , to patch only Tutu content. I tried _.*\.cre, but
WeiDU interpretes this as a real name, not a regexp. Can I use underscores?
Also, every time you use "%someVariable%" does it use the same value you read using READ_ or does it "auto-update"? (Prolly a very stupid question:))
///////////////////////////////////////////////////////////////////////
// ADD_KNOWN_SPELL
///////////////////////////////////////////////////////////////////////
//Still not sure whether to use or not; If I use it, it
//should probably be synchronous with the memorized spells blocks
///////////////////////////////////////////////////////////////////////
//ADD_KNOWN_SPELL ~SPWI112~ #0 ~wizard~
///////////////////////////////////////////////////////////////////////
// Spell level memorization
///////////////////////////////////////////////////////////////////////
// This reads how many levels the mage has and sets a variable for every spell level
///////////////////////////////////////////////////////////////////////
SET "readLevel"=0
WHILE (("%level%"=1) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 1
SET "#spellLvl2" = 0
SET "#spellLvl3" = 0
SET "#spellLvl4" = 0 //just to be sure
SET "#spellLvl5" = 0
SET "#spellLvl6" = 0
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=2) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 2
SET "#spellLvl2" = 0
SET "#spellLvl3" = 0
SET "#spellLvl4" = 0
SET "#spellLvl5" = 0
SET "#spellLvl6" = 0
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=3) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 2
SET "#spellLvl2" = 1
SET "#spellLvl3" = 0
SET "#spellLvl4" = 0
SET "#spellLvl5" = 0
SET "#spellLvl6" = 0
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=4) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 3
SET "#spellLvl2" = 2
SET "#spellLvl3" = 0
SET "#spellLvl4" = 0
SET "#spellLvl5" = 0
SET "#spellLvl6" = 0
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=5) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 4
SET "#spellLvl2" = 2
SET "#spellLvl3" = 1
SET "#spellLvl4" = 0
SET "#spellLvl5" = 0
SET "#spellLvl6" = 0
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=6) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 4
SET "#spellLvl2" = 2
SET "#spellLvl3" = 2
SET "#spellLvl4" = 0
SET "#spellLvl5" = 0
SET "#spellLvl6" = 0
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=7) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 4
SET "#spellLvl2" = 3
SET "#spellLvl3" = 2
SET "#spellLvl4" = 1
SET "#spellLvl5" = 0
SET "#spellLvl6" = 0
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=8) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 4
SET "#spellLvl2" = 3
SET "#spellLvl3" = 3
SET "#spellLvl4" = 2
SET "#spellLvl5" = 0
SET "#spellLvl6" = 0
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=9) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 4
SET "#spellLvl2" = 3
SET "#spellLvl3" = 3
SET "#spellLvl4" = 2
SET "#spellLvl5" = 1
SET "#spellLvl6" = 0
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=10) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 4
SET "#spellLvl2" = 4
SET "#spellLvl3" = 3
SET "#spellLvl4" = 2
SET "#spellLvl5" = 2
SET "#spellLvl6" = 0
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=11) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 4
SET "#spellLvl2" = 4
SET "#spellLvl3" = 4
SET "#spellLvl4" = 3
SET "#spellLvl5" = 3
SET "#spellLvl6" = 0
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=12) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 4
SET "#spellLvl2" = 4
SET "#spellLvl3" = 4
SET "#spellLvl4" = 4
SET "#spellLvl5" = 4
SET "#spellLvl6" = 1
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=13) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 5
SET "#spellLvl2" = 5
SET "#spellLvl3" = 5
SET "#spellLvl4" = 4
SET "#spellLvl5" = 4
SET "#spellLvl6" = 2
SET "#spellLvl7" = 0
SET "readLevel"=1
END
WHILE (("%level%"=14) AND ("%readLevel%"=0))
BEGIN
SET "#spellLvl1" = 5
SET "#spellLvl2" = 5
SET "#spellLvl3" = 5
SET "#spellLvl4" = 4
SET "#spellLvl5" = 4
SET "#spellLvl6" = 2
SET "#spellLvl7" = 1
SET "readLevel"=1
END
//for specialist mages: increase numspells/lvl with 1
SET "readKit"=0
WHILE ((("%kit%"=64) OR ("%kit%"=128) OR ("%kit%"=256) OR ("%kit%"=512) OR ("%kit%"=1024) OR ("%kit%"=2048) OR ("%kit%"=4096) OR ("%kit%"=8192)) AND ("%readKit%"=0))
BEGIN
SET "#spellLvl1" = ("%#spellLvl1%" +1)
SET "#spellLvl2" = ("%#spellLvl2%" +1)
SET "#spellLvl3" = ("%#spellLvl3%" +1)
SET "#spellLvl4" = ("%#spellLvl4%" +1)
SET "#spellLvl5" = ("%#spellLvl5%" +1)
SET "#spellLvl6" = ("%#spellLvl6%" +1)
SET "#spellLvl7" = ("%#spellLvl7%" +1)
SET "readKit"=1
/***************************************************************************
*Patch #spells memorizable, #spells memorizable? and Memorized spell count. All 3 should be the same.
*If you want to check out Memorized spell count in NI, look at the offset to which Memorized Spells Offset (2b0) points,
*and add 12 (0xC) to it. Logically, this value should be equal to the #spells memorizable field.
*Mostly it is not, even in BGII. The #spells memorizable field is mostly incorrect.
***************************************************************************/
//SET "n" = 0
//WHILE ("%n%" < 8)
WRITE_SHORT ("%memorizationOffset%" + 0x72 /*+ n*0x10*/) "%#spellLvl1%"
WRITE_SHORT ("%memorizationOffset%" + 0x74) "%#spellLvl1%"
WRITE_SHORT ("%memorizationOffset%" + 0x7C) "%#spellLvl1%"
WRITE_SHORT ("%memorizationOffset%" + 0x72 + 0x10) "%#spellLvl2%"
WRITE_SHORT ("%memorizationOffset%" + 0x74 + 0x10) "%#spellLvl2%"
WRITE_SHORT ("%memorizationOffset%" + 0x7C + 0x10) "%#spellLvl2%"
WRITE_SHORT ("%memorizationOffset%" + 0x72 + 0x20) "%#spellLvl3%"
WRITE_SHORT ("%memorizationOffset%" + 0x74 + 0x20) "%#spellLvl3%"
WRITE_SHORT ("%memorizationOffset%" + 0x7C + 0x20) "%#spellLvl3%"
WRITE_SHORT ("%memorizationOffset%" + 0x72 + 0x30) "%#spellLvl4%"
WRITE_SHORT ("%memorizationOffset%" + 0x74 + 0x30) "%#spellLvl4%"
WRITE_SHORT ("%memorizationOffset%" + 0x7C + 0x30) "%#spellLvl4%"
WRITE_SHORT ("%memorizationOffset%" + 0x72 + 0x40) "%#spellLvl5%"
WRITE_SHORT ("%memorizationOffset%" + 0x74 + 0x40) "%#spellLvl5%"
WRITE_SHORT ("%memorizationOffset%" + 0x7C + 0x40) "%#spellLvl5%"
WRITE_SHORT ("%memorizationOffset%" + 0x72 + 0x50) "%#spellLvl6%"
WRITE_SHORT ("%memorizationOffset%" + 0x74 + 0x50) "%#spellLvl6%"
WRITE_SHORT ("%memorizationOffset%" + 0x7C + 0x50) "%#spellLvl6%"
WRITE_SHORT ("%memorizationOffset%" + 0x72 + 0x60) "%#spellLvl7%"
WRITE_SHORT ("%memorizationOffset%" + 0x74 + 0x60) "%#spellLvl7%"
WRITE_SHORT ("%memorizationOffset%" + 0x7C + 0x60) "%#spellLvl7%"
Is it possible to use symbolic addresses, and variables instead of constants?
This works: WRITE_SHORT ("%memorizationOffset%" + 0x72 /*+ n*0x10*/) 5
But does this?: WRITE_SHORT ("%memorizationOffset%" + 0x72 /*+ n*0x10*/) "%#spellLvl1%"
Also, I tried to combine all this code in a while loop:
SET "n" = 0
WHILE ("%n%" < 8)
WRITE_SHORT ("%memorizationOffset%" + 0x72 + "%n%"*0x10) "%#spellLvl1%"
WRITE_SHORT ("%memorizationOffset%" + 0x74 + "%n%"*0x10) "%#spellLvl1%"
WRITE_SHORT ("%memorizationOffset%" + 0x7C + "%n%"*0x10) "%#spellLvl1%"
SET "n" = "%n%" + 1
Now it is necessary that with each increment of n,
the accessed variable "%#spellLvl(n+1)%" changes, otherwise the number of lvl 1 spells would be set for all levels. Is this possible?
///////////////////////////////////////////////////////////////////////
// Memorized Spells: reserve spaces
///////////////////////////////////////////////////////////////////////
// based on total number of spells
///////////////////////////////////////////////////////////////////////
SET "totalNumMemorizedSpells" = ("%#spellLvl1%" + "%#spellLvl2%" + "%#spellLvl3%" + "%#spellLvl4%" + "%#spellLvl5%" + "%#spellLvl6%" + "%#spellLvl7%")
WHILE ("%numMemorizedSpells%" <= "%totalNumMemorizedSpells%")
BEGIN
WRITE_LONG 0x2c4 ("%EffectsOffset%" + 0x6)
WRITE_LONG 0x2bc ("%itemsOffset%" + 0x6)
WRITE_LONG 0x2b8 ("%itemSlotOffset%" + 0x6)
INSERT_BYTES ("%memorizedSpellsOffset%" + ("%numMemorizedSpells%" *0x6)) 0x06
WRITE_LONG 0x2b4 ("%numMemorizedSpells%" + 1)
END
WHILE("%numMemorizedSpells%" > "%totalNumMemorizedSpells%") //if there are more spells memorized than is allowed by the rules
BEGIN
WRITE_LONG 0x2c4 ("%EffectsOffset%" - 0x6)
WRITE_LONG 0x2bc ("%itemsOffset%" - 0x6)
WRITE_LONG 0x2b8 ("%itemSlotOffset%" - 0x6)
DELETE_BYTES ("%memorizedSpellsOffset%" + ("%numMemorizedSpells%" *0x6)) 0x06
WRITE_LONG 0x2b4 ("%numMemorizedSpells%" - 1)
END
///////////////////////////////////////////////////////////////////////
// Memorized Spells: fill in names
///////////////////////////////////////////////////////////////////////
// based on number of spells per level
// I replace spells. Without STRING_COMPARE. The "choosing algoritm" makes choices and ///fills in.
///////////////////////////////////////////////////////////////////////
SET "n1" = 0
WHILE("%n1%" <= "%#spellLvl1%"-1)
BEGIN
WRITE_ASCII ("%memorizedSpellsOffset%" + "%n1%" * 0x6) ~spwi112~
SET "n1" = "%n1%"+1
END
IF_EVAL (("%class%" = 1) OR ("%class%" = 13) OR ("%class%" = 14) OR ("%class%" = 206) OR ("%class%" = 7) OR ("%class%" = 17) OR ("%class%" = 10))
//truclass,m/t,m/c,bard_all,f/m,f/m/c,f/m/t
Okay, this is the end of the code you just waded trough. But one more (pretty important) question, please. As you might have noticed, the fill in names block will always fill in spwi112. That's not what I want to do... How do I access a set of strings that get patched in here? Maybe I sound unclear (I get that a lot), because I don't know enough about tp2's, but at this time I see it could be solved by making a set of strings, containing all spells, needed, and let the tp2 code jump from spell to spell... This smells like a 2da file a lot. Is it possible to make a dummy 2da file that
WeiDU reads?
Unless you're going to give them more or less spells than they had previously, I would forego the teardown/rebuild approach, though that's a personal preference.
That's exactly wahat I'm gonna do... but the teardown approach is a bit drastic since strings are pretty easy to overwrite.
Something I still don't get however (and this may sound stupid
) is this:
/* Now we start a new main WHILE loop to delete spells...*/
Why do you want to delete Barkskin if you have just replaced it with Aid? I mean, ther is *no* spell called Barkskin anymore.
Edited by Topaz, 28 October 2004 - 06:01 AM.