Enderal SE https://mod.pub/enderal-se/38-enderal-se
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.3 KiB
115 lines
3.3 KiB
ScriptName PPNInventoryMonitor Extends ReferenceAlias
|
|
|
|
;-- Variables ---------------------------------------
|
|
Int renamed_potions = 0
|
|
Int user_config = 0
|
|
|
|
;-- Properties --------------------------------------
|
|
FormList Property PPNExempted Auto
|
|
|
|
;-- Functions ---------------------------------------
|
|
|
|
; Skipped compiler generated GetState
|
|
|
|
; Skipped compiler generated GotoState
|
|
|
|
Function rename_potion(Potion it)
|
|
String name = it.GetName()
|
|
Int user = jmap.valueType(user_config, name)
|
|
If user == 6
|
|
name = jmap.getStr(user_config, name, "")
|
|
it.SetName(name)
|
|
jformmap.setStr(renamed_potions, it as Form, name)
|
|
Return
|
|
ElseIf user != 0
|
|
Return
|
|
EndIf
|
|
If it.isFood() || it.GetNumEffects() < 2 || PPNExempted.Find(it as Form) >= 0
|
|
Return
|
|
EndIf
|
|
Int exempted = jdb.solveObj(".ProperPotionNames.exempted", 0)
|
|
If jformmap.hasKey(exempted, it as Form)
|
|
Return
|
|
EndIf
|
|
name = jformmap.getStr(renamed_potions, it as Form, "")
|
|
If name != ""
|
|
Return
|
|
EndIf
|
|
Int parts = jvalue.retain(jarray.object(), "")
|
|
Int i = it.GetNumEffects()
|
|
While i > 0
|
|
i -= 1
|
|
name = it.GetNthEffectMagicEffect(i).GetName()
|
|
Int len = stringutil.GetLength(name)
|
|
If stringutil.GetNthChar(name, len - 1) == "*"
|
|
name = stringutil.SubString(name, 0, len - 2)
|
|
EndIf
|
|
jarray.addStr(parts, name, -1)
|
|
EndWhile
|
|
name = ""
|
|
i = jarray.count(parts)
|
|
While i > 1
|
|
i -= 1
|
|
name += jarray.getStr(parts, i, "")
|
|
If i == 1
|
|
name += " & "
|
|
Else
|
|
name += ", "
|
|
EndIf
|
|
EndWhile
|
|
name += jarray.getStr(parts, 0, "")
|
|
If it.IsPoison()
|
|
name += " (Poison)"
|
|
Else
|
|
name += " (Potion)"
|
|
EndIf
|
|
it.SetName(name)
|
|
jformmap.setStr(renamed_potions, it as Form, name)
|
|
jvalue.release(parts)
|
|
EndFunction
|
|
|
|
Function initialize()
|
|
Potion it
|
|
Int exempted = jdb.solveObj(".ProperPotionNames.exempted", 0)
|
|
If exempted == 0
|
|
jdb.solveObjSetter(".ProperPotionNames.exempted", jformmap.object(), True)
|
|
exempted = jdb.solveObj(".ProperPotionNames.exempted", 0)
|
|
Debug.Trace("Proper Potion Names is exempting some well-known DLC and mod potions. Errors here are safe.", 0)
|
|
it = Game.GetFormFromFile(102131, "Dawnguard.esm") as Potion
|
|
If it != None
|
|
jformmap.setInt(exempted, it as Form, 1)
|
|
EndIf
|
|
it = Game.GetFormFromFile(80157, "Dawnguard.esm") as Potion
|
|
If it != None
|
|
jformmap.setInt(exempted, it as Form, 1)
|
|
EndIf
|
|
it = Game.GetFormFromFile(88606, "Dawnguard.esm") as Potion
|
|
If it != None
|
|
jformmap.setInt(exempted, it as Form, 1)
|
|
EndIf
|
|
Debug.Trace("Proper Potion names is done filing exemptions.", 0)
|
|
EndIf
|
|
If PPNExempted == None
|
|
PPNExempted = Game.GetFormFromFile(7561, "ProperPotionNames.esp") as FormList
|
|
EndIf
|
|
renamed_potions = jvalue.releaseAndRetain(renamed_potions, jformmap.object(), "ProperPotionNames")
|
|
user_config = jvalue.releaseAndRetain(user_config, jvalue.readFromFile("ppnconfig.json"), "ProperPotionNames")
|
|
Actor target = Self.GetActorRef()
|
|
Int i = target.GetNumItems()
|
|
While i > 0
|
|
i -= 1
|
|
it = target.GetNthForm(i) as Potion
|
|
If it != None
|
|
Self.rename_potion(it)
|
|
EndIf
|
|
EndWhile
|
|
EndFunction
|
|
|
|
Event OnInit()
|
|
Self.initialize()
|
|
EndEvent
|
|
|
|
Event OnPlayerLoadGame()
|
|
Debug.MessageBox((Self as PPNInventoryMonitor) as String)
|
|
Self.initialize()
|
|
EndEvent
|
|
|