Jump to content


Photo

Bug with adding spells


7 replies to this topic

#1 Miloch

Miloch

    Barbarian

  • Modders
  • 4715 posts
  • Gender:Male
  • Location:At Large

Posted 22 November 2010 - 11:29 AM

I've replicated a bug several times now editing CREs with DLTCEP. Fortunately it only surfaces with spellcasters, but it's pretty nasty.

When adding multiple spells, the memorization spell index gets botched, apparently in some random manner. So for example, I've added a 1st level priest spell, which starts at 0, as it should, being the first spell info table. The next one should start at 1, since I added only 1 spell, but it starts at 4. If I go down the list (in NI, since DLTCEP isn't useful for this since it doesn't display the indices), several start at 4, some start at 2, some 1, then 4 again, etc. They should proceed in order. Now DLTCEP and apparently the game will read these files without complaining, but if you try to do something like ADD_MEMORIZED_SPELL with WeiDU (which I'm sure expects the indices to be in order) it'll hose the spells something bad, like push them all into the 3rd level priest slot - wizard spells and all.

I have CREs that show this bug from before and after I've fixed it (with NI) and could probably explain how to replicate it. Basically take any CRE in the game, add a few spells, save it, repeat if you don't see the bug the first time.
Mod Contributions
Aurora (new release!) * BG1 NPC * Gnomes * Haiass * Level 1 NPCs * Lost Items * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * In Progress: Adjusted Portraits * DSotSC (Tutu)
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * PSPad Highlighters * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Wherefore do ye toil; is it not that ye may live and be happy? And if ye toil only that ye may toil more,
when shall happiness find you?" -H.P. Lovecraft, The Quest of Iranon

#2 Miloch

Miloch

    Barbarian

  • Modders
  • 4715 posts
  • Gender:Male
  • Location:At Large

Posted 22 November 2010 - 10:53 PM

Here's what I'm talking about...
Posted Image
The 2nd priest spell table I've got selected should start at 1 not 4, because I added 1 spell to the 1st level priest table. And it should stay at 1 until the 2nd wizard spell table (info 9) because I added 2 spells to the previous table (info 8) which would bring it to 3, and only after that should it be 4 for the remaining tables. But instead, they're all over the place.
Mod Contributions
Aurora (new release!) * BG1 NPC * Gnomes * Haiass * Level 1 NPCs * Lost Items * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * In Progress: Adjusted Portraits * DSotSC (Tutu)
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * PSPad Highlighters * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Wherefore do ye toil; is it not that ye may live and be happy? And if ye toil only that ye may toil more,
when shall happiness find you?" -H.P. Lovecraft, The Quest of Iranon

#3 Avenger

Avenger
  • Modders
  • 3399 posts
  • Gender:Male
  • Location:Hungary

Posted 22 November 2010 - 11:07 PM

Ok, just to get this straight, the format is fine, the IE, NI, GemRB, DLTCEP, etc can use the file without fuss. Just WeiDU is a whiny pussy :) Or rather, your weidu script is :laugh:

I will try to fix the order, but i don't promise anything soon.

#4 Miloch

Miloch

    Barbarian

  • Modders
  • 4715 posts
  • Gender:Male
  • Location:At Large

Posted 23 November 2010 - 05:14 AM

Ok, just to get this straight, the format is fine, the IE, NI, GemRB, DLTCEP, etc can use the file without fuss. Just WeiDU is a whiny pussy :) Or rather, your weidu script is :laugh:

Hey, it's not *my* WeiDU script ;). And actually, only a few lines of WeiDU code can fix it (or prevent problems from occuring with later spell patches anyway).
DEFINE_PATCH_MACRO t-enforce_spell_order
  smx = 0
  READ_LONG 0x2a8 smf //Spell memo tables offset
  READ_LONG 0x2ac smc //Spell memo tables count
  FOR (i = 0; i < smc; i += 1) BEGIN
	WRITE_LONG (i * 0x10 + smf + 8) smx //Spell memo array index
	READ_LONG (i * 0x10 + smf + 0xc) smn //Memorized spells count
	smx += smn
  END
END
Probably doesn't take much more code in C++ or whatever DLTCEP is using. You're already fixing "nonstandard orders" so why not this too?
Mod Contributions
Aurora (new release!) * BG1 NPC * Gnomes * Haiass * Level 1 NPCs * Lost Items * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * In Progress: Adjusted Portraits * DSotSC (Tutu)
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * PSPad Highlighters * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Wherefore do ye toil; is it not that ye may live and be happy? And if ye toil only that ye may toil more,
when shall happiness find you?" -H.P. Lovecraft, The Quest of Iranon

#5 Avenger

Avenger
  • Modders
  • 3399 posts
  • Gender:Male
  • Location:Hungary

Posted 23 November 2010 - 01:07 PM

Yes, I will add the reordering code. It is just not trivial. I could fix the problem with 1-2 line changes, but it would work only correctly ordered creatures (that's why i used the method that causes seemingly random order). So, i need to do a reordering, i don't know how many lines. Plus keeping the order while inserting spells. This is something for the weekend :)

#6 Miloch

Miloch

    Barbarian

  • Modders
  • 4715 posts
  • Gender:Male
  • Location:At Large

Posted 24 November 2010 - 04:50 AM

Cool. Don't suppose you could fix the "Default rogue" and "Default wizard" saving throw buttons while you're at it? :) Right now they just give zeros, though the other two (warrior and priest) seem to work.
Mod Contributions
Aurora (new release!) * BG1 NPC * Gnomes * Haiass * Level 1 NPCs * Lost Items * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * In Progress: Adjusted Portraits * DSotSC (Tutu)
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * PSPad Highlighters * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Wherefore do ye toil; is it not that ye may live and be happy? And if ye toil only that ye may toil more,
when shall happiness find you?" -H.P. Lovecraft, The Quest of Iranon

#7 Avenger

Avenger
  • Modders
  • 3399 posts
  • Gender:Male
  • Location:Hungary

Posted 25 November 2010 - 08:59 AM

Fixed both.
But i didn't add any reordering, so already messed up spellbooks will need reordering.
I just made efforts to keep existing order.

Maybe later I will add the ordering code too, as you already mentioned, I reorder lots of things already.

#8 Miloch

Miloch

    Barbarian

  • Modders
  • 4715 posts
  • Gender:Male
  • Location:At Large

Posted 26 November 2010 - 10:08 AM

Cheers. I came up with some revised WeiDU reordering code here but I don't know if it could be adapted to DLTCEP. With WeiDU I had to resort to a lot of hackery to sort the spell indices; maybe there's a better array sorting function in C++.
Mod Contributions
Aurora (new release!) * BG1 NPC * Gnomes * Haiass * Level 1 NPCs * Lost Items * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * In Progress: Adjusted Portraits * DSotSC (Tutu)
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * PSPad Highlighters * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Wherefore do ye toil; is it not that ye may live and be happy? And if ye toil only that ye may toil more,
when shall happiness find you?" -H.P. Lovecraft, The Quest of Iranon



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users