Trying to fix a bug with the Uvirith's Legacy Enchanting tom

Post » Fri Sep 30, 2011 10:57 am

For those of you who have not played the Uvirith's Legacy mod, at a certain point during a quest in it, you get access to tomes that allow you to make spells and enchant items at a discount price. During one of my playthroughs in the mod, I discovered that when you try to use the tome to chant items over a certain expense, the tome works but then blocks any future attempts to use it. This happened when I tried to enchant an Extravagant Ring with a Cast on use enchantment that fortified speed 100 pts. for 10 seconds, which cost 50,000 gold. I've never been very good at solving problems with loops, but I'm guessing the tome somehow gets trapped in an infinite loop when you use it to make an expensive enchantment and never resets.

From what I gather, the enchanting tome works in the following way. When the PC activates the item, it creates an invisible creature that forces a greeting with the PC, allowing the PC to do the enchantment. Once you enchant an item, this creature is disabled and the script attached to the book uses an algorithm to refund you part of the cost, so the items is effectively enchanted at a discount. The scripts for the "Book" and the "Creature" are posted below. These tomes are Suporstar's creations, not mine; I'm just trying to figure out how to fix them.

Book
Begin Enchant_Tome_Book
;restores some of the player's gold used in the Enchanting Tome's service

short Phase
short Button
short OnPCEquip
float Timer
Long CurrentGold
Long StartGold
short ETomeActivated

if ( GetJournalIndex HT_Spellbook < 70 )
If ( GetDisabled == 0 )
disable
Endif
endif

if ( GetJournalIndex HT_Spellbook >= 70 )
If ( GetDisabled == 1 )
enable
Endif
endif

if ( OnActivate == 1 )
If ( Phase == 0 )
If ( ETomeActivated==0)
PlaceAtPC Enchant_Tome 1 256 1
set Phase to 4
Set StartGold to player-> GetItemCount "Gold_001"
Player->AddItem Gold_001 30000
Set ETomeActivated to 1
Else
Set Phase to 1
Endif
Endif
Elseif(Phase==0)
Return
Elseif(Phase==3)
If(Timer < 5)
Set Timer to Timer + getSecondsPassed
Else
Set EnchantUsed to 1
Endif
Elseif (Phase == 4)
Set Phase to 5
Elseif (Phase == 5)
If(menuMode==0)
Set CurrentGold to player-> GetItemCount "Gold_001"
If(CurrentGold > StartGold + 2048)
Player->RemoveItem Gold_001 2048
ElseIf(CurrentGold > StartGold + 1024)
Player->RemoveItem Gold_001 1024
ElseIf(CurrentGold > StartGold + 512)
Player->RemoveItem Gold_001 512
ElseIf(CurrentGold > StartGold + 248)
Player->RemoveItem Gold_001 248
ElseIf(CurrentGold > StartGold + 124)
Player->RemoveItem Gold_001 124
ElseIf(CurrentGold > StartGold + 64)
Player->RemoveItem Gold_001 64
ElseIf(CurrentGold > StartGold + 32)
Player->RemoveItem Gold_001 32
ElseIf(CurrentGold > StartGold + 16)
Player->RemoveItem Gold_001 16
ElseIf(CurrentGold > StartGold + 8)
Player->RemoveItem Gold_001 8
ElseIf(CurrentGold > StartGold + 4)
Player->RemoveItem Gold_001 4
ElseIf(CurrentGold > StartGold + 2)
Player->RemoveItem Gold_001 2
ElseIf(CurrentGold > StartGold)
Player->RemoveItem Gold_001 1
ElseIf(CurrentGold==StartGold)
Set Phase to 0
Endif
Endif
Endif

If(Phase==1)
; MessageBox, "What do you want to do with the tome?" "Pick it up", "Study it"
; set Phase to 2
;elseif ( Phase == 2 )
; set button to GetButtonPressed
; if ( button == 0)
; set Phase to 0
; MessageBox "Sorry, fooled ya, can't pick it up yet."
; Disable
; set Phase to 3
; elseif ( button == 1 )
PlaceAtPC Enchant_Tome 1 256 1
set Phase to 4
Set StartGold to player-> GetItemCount "Gold_001"
Player->AddItem Gold_001 30000
; endif
endif

End Enchant_Tome_Book




Creature

Begin Enchant_Tome_Creature
;attached to creature version of Enchanting Tome
short DoOnce

If ( DoOnce == 0 )
ForceGreeting
Disable
Set DoOnce to 1
Endif

if ( EnchantUsed == 1 )
Set EnchantUsed to 0
Disable
Endif

End Enchant_Tome_Creature


I have very minimal experience scripting and in any event, was never adept and sifting my way through if/else loops to find errors. If anyone with more experience is able to help me figure out what the problem is so I can forward it to Gaius Atrius (who is developing a patch for UL) I would greatly appreciate it. Thanks so much!
User avatar
mishionary
 
Posts: 3414
Joined: Tue Feb 20, 2007 6:19 am

Return to III - Morrowind