Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Can some look over this script and tell me whats wrong. (blacksmiths can upgrade your gear)


Force85
 Share

Recommended Posts

So a few months back I asked if someone could make a script that would allow for blacksmiths to improve your gear (I really need to learn this stuff) and someone did, but we had a few glitches that needed to be ironed out. The project ended up going in the closest for awhile and I found it again. And I would like someone to look over the script and help me figure out what is causing the glitch that I was experiencing. The original scripter is no longer playing Skyrim and is too busy to help right now. So that is why I came here.

 

The mod has a MCM menu and in that menu you can select a number of options. And all but one works. The two main options is a toggle for the level lock and the second on is a toggle for an option that allows for smiths to have different levels of upgrade options. So not ever smith in Skyrim will be able to upgrade your gear to legendary status, and that is the option that is causing the problem. When the option is enabled it works, but if I try to disable it, which would allow all the smiths to have all of the upgrade options (fine to legendary) it will not work unless I first disable the level lock. So enabled it works, but disabling it won't work unless I first disable the level lock.

 

Any ideas as to whats wrong?

 

here is the script

 

Scriptname BO_HiredImprovingScript extends ReferenceAlias  
 
;--Properties--
Faction Property JobBlacksmithFaction Auto
MiscObject Property Gold001 Auto
Message Property BO_ImproveMessage Auto
Bool Property ImprovementDone = False Auto
 
;--Globals--
GlobalVariable Property BO_MaxImprovement Auto
GlobalVariable Property BO_Price1 Auto
GlobalVariable Property BO_Price2 Auto
GlobalVariable Property BO_Price3 Auto
GlobalVariable Property BO_Price4 Auto
GlobalVariable Property BO_Price5 Auto
GlobalVariable Property BO_Price6 Auto
GlobalVariable Property BO_Allowed1 Auto
GlobalVariable Property BO_Allowed2 Auto
GlobalVariable Property BO_Allowed3 Auto
GlobalVariable Property BO_Allowed4 Auto
GlobalVariable Property BO_Allowed5 Auto
GlobalVariable Property BO_Allowed6 Auto
 
;--Variable--
Float CostPerTier
Int Cost
Float BasePrice
Int ChosenButton
Int PlayerLevel
Int LoopTracker = -1
Float ChosenImprovement
Float CurrentImprovement
Float MaxImprovement
Form[] ItemList
 
;--Variable Abilities--
Int Smith
Actor[] Property Smiths Auto
Int[] Property SmithsLimits Auto
 
;--MCM--
BO_MCMScript Property BO_ManagerQuest Auto
Bool VariedAbilities
Int CostType
Float MinimumSmithing
Float CostMultiplier
Float CostConstant
 
Event OnInit()
ItemList = New Form[128]
EndEvent
 
Event OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
If ( ImprovementDone == True ) ;Prevents attempting multiple items at once
If ( UI.IsMenuOpen("GiftMenu") ) ;Ensures player is giving item to actor
Actor NPC = akDestContainer as Actor
If ( NPC.IsInFaction(JobBlacksmithFaction) ) ;Ensures receiving actor is still the smith
If ( aiItemCount > 1 )
akDestContainer.RemoveItem(akBaseItem, aiItemCount - 1, True, Game.GetPlayer()) ;Return any extra items (multiples might cause problems)
EndIf
LoopTracker += 1
ItemList[LoopTracker] = akBaseItem
If ( LoopTracker == 0 )
Utility.Wait(0.1)
ProcessImprovements(NPC, akItemReference, akDestContainer)
EndIf
EndIf
EndIf
EndIf
EndEvent
 
Function ProcessImprovements(Actor NPC, ObjectReference akItemReference, ObjectReference akDestContainer)
Debug.Notification("~1")
Int i = 0
While ( i <= LoopTracker )
Form akBaseItem = ItemList
ObjectReference NewGear = akDestContainer.DropObject(akBaseItem)
If ( akBaseItem.GetType() == 26 || akBaseItem.GetType() == 41 ) ;Ensures item is either a weapon or armor
BO_MCMScript MCM = BO_ManagerQuest as BO_MCMScript
CurrentImprovement = NewGear.GetItemHealthPercent()
;--Determine Pricing variables--
BasePrice = NewGear.GetGoldValue()
CostType = MCM.CurrentCost
If ( CostType == 0 )
CostMultiplier = 0.25
CostConstant = 0
ElseIf ( CostType == 1 )
CostMultiplier = 0.5
CostConstant = 0
ElseIf ( CostType == 2 )
CostMultiplier = 0.75
CostConstant = 150
Else
CostMultiplier = MCM.CostMultipleValue
CostConstant = MCM.CostConstantValue
EndIf
CostPerTier = Math.Floor(BasePrice*CostMultiplier)
 
;--Determine Smith to Apply Variations--
 
Smith = -1
Smith = Smiths.Find(NPC)
If Smith >= 0
MaxImprovement = (SmithsLimits[smith] as Float)/10 + 1
Else
MaxImprovement = 1.5
EndIf
;Debug.Notification("Smith: " + Smith + ", MaxImprovement: " + MaxImprovement)
;--Prepare Prices for Message--
BO_Price1.SetValue(CostPerTier*(1.1-CurrentImprovement)*10+CostConstant)
BO_Price2.SetValue(CostPerTier*(1.2-CurrentImprovement)*10+CostConstant)
BO_Price3.SetValue(CostPerTier*(1.3-CurrentImprovement)*10+CostConstant)
BO_Price4.SetValue(CostPerTier*(1.4-CurrentImprovement)*10+CostConstant)
BO_Price5.SetValue(CostPerTier*(1.5-CurrentImprovement)*10+CostConstant)
BO_Price6.SetValue(CostPerTier*(1.6-CurrentImprovement)*10+CostConstant)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price1)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price2)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price3)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price4)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price5)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price6)
;Debug.Notification("~1: "+BO_MaxImprovement.GetValue())
If ( BO_Price1.GetValue() < 0 )
BO_Price1.SetValue(0)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price1)
EndIf
If ( BO_Price2.GetValue() < 0 )
BO_Price2.SetValue(0)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price2)
EndIf
If ( BO_Price3.GetValue() < 0 )
BO_Price3.SetValue(0)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price3)
EndIf
If ( BO_Price4.GetValue() < 0 )
BO_Price4.SetValue(0)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price4)
EndIf
If ( BO_Price5.GetValue() < 0 )
BO_Price5.SetValue(0)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price5)
EndIf
If ( BO_Price6.GetValue() < 0 )
BO_Price6.SetValue(0)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_Price6)
EndIf
 
;--Prepare Level Lock--
If ( MCM.LevelLockState || MCM.VariedSkillState )
If MCM.VariedSkillState
MinimumSmithing = MCM.CurrentSmithingMinimum
Else
MinimumSmithing = 1.6
EndIf
MinimumSmithing /= 10
MinimumSmithing += 1.1
If ( MaxImprovement < MinimumSmithing )
MaxImprovement = MinimumSmithing
EndIf
BO_MaxImprovement.SetValue(MaxImprovement)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_MaxImprovement)
If ( MCM.LevelLockState )
PlayerLevel = Game.GetPlayer().GetLevel() as Int
Else
PlayerLevel = MCM.LegendaryValue as Int
EndIf
If ( PlayerLevel >= MCM.FineValue )
BO_Allowed1.SetValue(1)
Else
BO_Allowed1.SetValue(0)
EndIf
If ( PlayerLevel >= MCM.SuperiorValue )
BO_Allowed2.SetValue(1)
Else
BO_Allowed2.SetValue(0)
EndIf
If ( PlayerLevel >= MCM.ExquisiteValue )
BO_Allowed3.SetValue(1)
Else
BO_Allowed3.SetValue(0)
EndIf
If ( PlayerLevel >= MCM.FlawlessValue )
BO_Allowed4.SetValue(1)
Else
BO_Allowed4.SetValue(0)
EndIf
If ( PlayerLevel >= MCM.EpicValue )
BO_Allowed5.SetValue(1)
Else
BO_Allowed5.SetValue(0)
EndIf
If ( PlayerLevel >= MCM.LegendaryValue )
BO_Allowed6.SetValue(1)
Else
BO_Allowed6.SetValue(0)
EndIf
Else
BO_Allowed1.SetValue(1)
BO_Allowed2.SetValue(1)
BO_Allowed3.SetValue(1)
BO_Allowed4.SetValue(1)
BO_Allowed5.SetValue(1)
BO_Allowed6.SetValue(1)
BO_MaxImprovement.SetValue(1.6)
GetOwningQuest().UpdateCurrentInstanceGlobal(BO_MaxImprovement)
EndIf
 
;--Choose and Apply Improvement--
ImprovementDone = False
While !ImprovementDone
Utility.Wait(0.1)
(GetOwningQuest().GetAliasByName("ItemToImprove") as ReferenceAlias).ForceRefTo(NewGear)
ChosenButton = BO_ImproveMessage.Show()
ChosenImprovement = ChosenButton
ChosenImprovement = (ChosenImprovement + 10)/10
If ( ChosenButton != 0 )
Cost = Math.Floor((CostPerTier*(ChosenImprovement - CurrentImprovement)*10)+CostConstant)
If ( ChosenImprovement > CurrentImprovement )
If ( Game.GetPlayer().GetItemCount(Gold001) >= Cost )
NewGear.SetItemHealthPercent(ChosenImprovement)
Game.GetPlayer().RemoveItem(Gold001, Cost, false, akDestContainer)
ImprovementDone = True
 
;--Display issues encountered and Return Item--
Else
Debug.Notification("You do not have enough gold for that level of improvement.")
EndIf
Else
Debug.Notification("This item is already at or beyond the chosen level of improvement.")
EndIf
Else
ImprovementDone = True
EndIf
EndWhile
Else
Debug.Notification("This item is not an improvable item.")
EndIf
NewGear.SetActorOwner(NONE)
Game.GetPlayer().AddItem(NewGear)
ItemList = None
i += 1
EndWhile
LoopTracker = -1
ImprovementDone = False
EndFunction

 

And here is the MCM script.

scriptname BO_MCMScript extends SKI_ConfigBase
 
;--Properties and Variables
 
; Lists
String[] CostList
String[] SmithingMinimumList
 
; OIDs (B:Toggle S:Slider M:Menu)
Int LevelLock
Int VariedSkill
 
Int Fine_S
Int Superior_S
Int Exquisite_S
Int Flawless_S
Int Epic_S
Int Legendary_S
Int CostMultiple_S
Int CostConstant_S
Int Cost
Int SmithingMinimum
 
; State
Bool Property LevelLockState = True Auto
Bool Property VariedSkillState = True Auto
Float Property FineValue = 1.0 Auto
Float Property SuperiorValue = 1.0 Auto
Float Property ExquisiteValue = 15.0 Auto
Float Property FlawlessValue = 20.0 Auto
Float Property EpicValue = 25.0 Auto
Float Property LegendaryValue = 30.0 Auto
Float Property CostMultipleValue = 0.5 Auto
Float Property CostConstantValue = 0.0 Auto
Int Property CurrentCost = 1 Auto
Int Property CurrentSmithingMinimum = 1 Auto
 
; INITIALIZATION ----------------------------------------------------------------------------------
 
; @overrides SKI_ConfigBase
Event OnConfigInit()
Pages = New String[2]
Pages[0] = "Settings"
Pages[1] = "Advanced Settings"
 
CostList = New String[4]
CostList[0] = "Cheap"
CostList[1] = "Normal"
CostList[2] = "Expensive"
CostList[3] = "Advanced"
 
SmithingMinimumList = New String[6]
SmithingMinimumList[0] = "Fine"
SmithingMinimumList[1] = "Superior"
SmithingMinimumList[2] = "Exquisite"
SmithingMinimumList[3] = "Flawless"
SmithingMinimumList[4] = "Epic"
SmithingMinimumList[5] = "Legendary"
EndEvent
 
; EVENTS ------------------------------------------------------------------------------------------
 
; @implements SKI_ConfigBase
Event OnPageReset(String a_page)
{Called when a new page is selected, including the initial empty page}
 
; Load custom logo in DDS format
If (a_page == "")
; Image size 256x256
; X offset = 376 - (height / 2) = 258
; Y offset = 223 - (width / 2) = 95
LoadCustomContent("skyui/res/mcm_logo.dds", 258, 95)
Return
Else
UnloadCustomContent()
EndIf
 
If (a_page == "Settings")
SetCursorFillMode(TOP_TO_BOTTOM)
 
LevelLock = AddToggleOption("Level Lock", LevelLockState)
VariedSkill = AddToggleOption("Varied Smith Skills", VariedSkillState)
Cost = AddMenuOption("Cost", CostList[CurrentCost])
 
ElseIf (a_page == "Advanced Settings")
 
SetCursorFillMode(LEFT_TO_RIGHT)
 
AddHeaderOption("Level Lock")
AddEmptyOption()
Fine_S = AddSliderOption("Fine unlocked at level:", FineValue)
Flawless_S = AddSliderOption("Flawless unlocked at level:", FlawlessValue)
Superior_S = AddSliderOption("Superior unlocked at level:", SuperiorValue)
Epic_S = AddSliderOption("Epic unlocked at level:", EpicValue)
Exquisite_S = AddSliderOption("Exquisite unlocked at level:", ExquisiteValue)
Legendary_S = AddSliderOption("Legendary unlocked at level:", LegendaryValue)
AddEmptyOption()
AddEmptyOption()
AddHeaderOption("Varied Smithing Skill")
AddEmptyOption()
SmithingMinimum = AddMenuOption("Minimum skill of all smiths: ", SmithingMinimumList[CurrentSmithingMinimum])
AddEmptyOption()
AddHeaderOption("Cost Formula Variables")
AddEmptyOption()
CostMultiple_S = AddSliderOption("Cost Multiple:", CostMultipleValue, "{1}")
CostConstant_S = AddSliderOption("Cost Constant:", CostConstantValue, "{0}")
EndIf
EndEvent
 
 
; @implements SKI_ConfigBase
Event OnOptionSelect(Int a_option)
{Called when the user selects a non-dialog option}
 
If (a_option == LevelLock)
LevelLockState = !LevelLockState
SetToggleOptionValue(a_option, LevelLockState)
ElseIf (a_option == VariedSkill)
VariedSkillState = !VariedSkillState
SetToggleOptionValue(a_option, VariedSkillState)
EndIf
EndEvent
 
; @implements SKI_ConfigBase
Event OnOptionSliderOpen(Int a_option)
{Called when the user selects a slider option}
 
If (a_option == Fine_S)
SetSliderDialogStartValue(FineValue)
SetSliderDialogDefaultValue(1)
SetSliderDialogRange(1, 100)
SetSliderDialogInterval(1)
ElseIf (a_option == Superior_S)
SetSliderDialogStartValue(SuperiorValue)
SetSliderDialogDefaultValue(1)
SetSliderDialogRange(1, 100)
SetSliderDialogInterval(1)
ElseIf (a_option == Exquisite_S)
SetSliderDialogStartValue(ExquisiteValue)
SetSliderDialogDefaultValue(15)
SetSliderDialogRange(1, 100)
SetSliderDialogInterval(1)
ElseIf (a_option == Flawless_S)
SetSliderDialogStartValue(FlawlessValue)
SetSliderDialogDefaultValue(20)
SetSliderDialogRange(1, 100)
SetSliderDialogInterval(1)
ElseIf (a_option == Epic_S)
SetSliderDialogStartValue(EpicValue)
SetSliderDialogDefaultValue(25)
SetSliderDialogRange(1, 100)
SetSliderDialogInterval(1)
ElseIf (a_option == Legendary_S)
SetSliderDialogStartValue(LegendaryValue)
SetSliderDialogDefaultValue(30)
SetSliderDialogRange(1, 100)
SetSliderDialogInterval(1)
ElseIf (a_option == CostMultiple_S)
SetSliderDialogStartValue(CostMultipleValue)
SetSliderDialogDefaultValue(0.5)
SetSliderDialogRange(0, 10)
SetSliderDialogInterval(0.1)
ElseIf (a_option == CostConstant_S)
SetSliderDialogStartValue(CostConstantValue)
SetSliderDialogDefaultValue(0)
SetSliderDialogRange(0, 1000)
SetSliderDialogInterval(1)
EndIf
EndEvent
 
; @implements SKI_ConfigBase
Event OnOptionSliderAccept(Int a_option, Float a_value)
{Called when the user accepts a new slider value}
 
If (a_option == Fine_S)
FineValue = a_value
SetSliderOptionValue(a_option, a_value)
ElseIf (a_option == Superior_S)
SuperiorValue = a_value
SetSliderOptionValue(a_option, a_value)
ElseIf (a_option == Exquisite_S)
ExquisiteValue = a_value
SetSliderOptionValue(a_option, a_value)
ElseIf (a_option == Flawless_S)
FlawlessValue = a_value
SetSliderOptionValue(a_option, a_value)
ElseIf (a_option == Epic_S)
EpicValue = a_value
SetSliderOptionValue(a_option, a_value)
ElseIf (a_option == Legendary_S)
LegendaryValue = a_value
SetSliderOptionValue(a_option, a_value)
ElseIf (a_option == CostMultiple_S)
CostMultipleValue = a_value
SetSliderOptionValue(a_option, a_value, "{1}")
ElseIf (a_option == CostConstant_S)
CostConstantValue = a_value
SetSliderOptionValue(a_option, a_value, "{0}")
EndIf
EndEvent
 
; @implements SKI_ConfigBase
Event OnOptionMenuOpen(Int a_option)
{Called when the user selects a menu option}
 
If (a_option == Cost)
SetMenuDialogStartIndex(CurrentCost)
SetMenuDialogDefaultIndex(1)
SetMenuDialogOptions(CostList)
ElseIf (a_option == SmithingMinimum)
SetMenuDialogStartIndex(CurrentSmithingMinimum)
SetMenuDialogDefaultIndex(1)
SetMenuDialogOptions(SmithingMinimumList)
EndIf
EndEvent
 
; @implements SKI_ConfigBase
Event OnOptionMenuAccept(Int a_option, Int a_index)
{Called when the user accepts a new menu entry}
 
If (a_option == Cost)
CurrentCost = a_index
SetMenuOptionValue(a_option, CostList[CurrentCost])
ElseIf (a_option == SmithingMinimum)
CurrentSmithingMinimum = a_index
SetMenuOptionValue(a_option, SmithingMinimumList[CurrentSmithingMinimum])
EndIf
EndEvent
 
; @implements SKI_ConfigBase
Event OnOptionHighlight(Int a_option)
{Called when the user highlights an option}
 
If (a_option == LevelLock)
SetInfoText("If checked, your character level will determine your ability to pay for higher tiers of upgrades.")
ElseIf (a_option == VariedSkill)
SetInfoText("If checked, different smiths will have the ability to improve gear to different tiers.")
ElseIf (a_option == Cost)
SetInfoText("The overall cost of paying a smith to improve your gear (If 'Advanced', then the values in 'Advanced Settings' are applied).")
ElseIf (a_option == Fine_S)
SetInfoText("Choose the level at which Fine improvable become available.")
ElseIf (a_option == Superior_S)
SetInfoText("Choose the level at which Superior improvable become available.")
ElseIf (a_option == Exquisite_S)
SetInfoText("Choose the level at which Exquisite improvable become available.")
ElseIf (a_option == Flawless_S)
SetInfoText("Choose the level at which Flawless improvable become available.")
ElseIf (a_option == Epic_S)
SetInfoText("Choose the level at which Epic improvable become available.")
ElseIf (a_option == Legendary_S)
SetInfoText("Choose the level at which Legendary improvable become available.")
ElseIf (a_option == SmithingMinimum)
SetInfoText("Choose the minimum tier of improvements available at all smiths.")
ElseIf (a_option == CostMultiple_S)
SetInfoText("Set the multiple for the cost formula: ItemValue*CostMultiple+CostConstant.")
ElseIf (a_option == CostConstant_S)
SetInfoText("Set the constant for the cost formula: ItemValue*CostMultiple+CostConstant.")
EndIf
EndEvent

Link to comment
Share on other sites

  • 4 weeks later...

Join the conversation

You can post now and register later. 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.

 Share

×
×
  • Create New...