Skip to content

Instantly share code, notes, and snippets.

@Petethegoat
Last active May 25, 2019 08:49
Show Gist options
  • Save Petethegoat/0199a2668407944c57f056fda89d167c to your computer and use it in GitHub Desktop.
Save Petethegoat/0199a2668407944c57f056fda89d167c to your computer and use it in GitHub Desktop.
local scriptNames = {
-- Services
travel = "showTravelScript",
barter = "showBarterScript",
repair = "showRepairScript",
spells = "showSpellsScript",
training = "showTrainingScript",
spellmaking = "showSpellmakingScript",
enchanting = "showEnchantingScript",
companion = "showCompanionScript",
-- Misc
cursedRing = "mwseRingScript",
}
-- Cursed Ring Tweakables
local cureJournalEntry = "MS_Nuccius"
local cureJournalIndex = 150 -- if the journal entry is equal to or higher than this index, cure the curse.
local tickDuration = 24 -- Tick the curse every X game hours
----------------------------------------------------
-- No editarino below this line unless you're pro --
----------------------------------------------------
local ringTimer
local startingAttributes = {}
local function ringCurseEnd()
ringTimer:cancel()
tes3.modStatistic{ reference = tes3.mobilePlayer,
attribute = tes3.attribute.luck,
value = startingAttributes.luck - tes3.mobilePlayer.luck.base}
tes3.modStatistic{ reference = tes3.mobilePlayer,
attribute = tes3.attribute.willpower,
value = startingAttributes.willpower - tes3.mobilePlayer.willpower.base}
end
local function ringJournalUpdate(e)
if e.topic.id == cureJournalEntry and e.index >= cureJournalIndex then
ringCurseEnd()
event.unregister("journal", ringJournalUpdate)
end
end
event.register("journal", ringJournalUpdate)
local function ringCurseTick()
if tes3.mobilePlayer.luck.base > 0 then
tes3.modStatistic{ reference = tes3.mobilePlayer,
attribute = tes3.attribute.luck,
limit = true,
value = -1}
elseif tes3.mobilePlayer.willpower.base > 0 then
tes3.modStatistic{ reference = tes3.mobilePlayer,
attribute = tes3.attribute.willpower,
limit = true,
value = -1}
else
ringTimer:cancel()
end
end
local function ringCurseApply()
startingAttributes.luck = tes3.mobilePlayer.luck.base
startingAttributes.willpower = tes3.mobilePlayer.willpower.base
ringTimer = timer.start{ duration = tickDuration, callback = ringCurseTick, iterations = -1, type = timer.game}
mwscript.stopScript(scriptNames.cursedRing)
end
local function showDialogMenu(ui_id, script)
tes3ui.findMenu(tes3ui.registerID("MenuDialog")):findChild(tes3ui.registerID(ui_id)):triggerEvent("mouseClick")
mwscript.stopScript(script)
end
local function showTravel(params)
showDialogMenu("MenuDialog_service_travel", scriptNames.travel)
end
local function showBarter(params)
showDialogMenu("MenuDialog_service_barter", scriptNames.barter)
end
local function showRepair(params)
showDialogMenu("MenuDialog_service_repair", scriptNames.repair)
end
local function showSpells(params)
showDialogMenu("MenuDialog_service_spells", scriptNames.spells)
end
local function showTraining(params)
showDialogMenu("MenuDialog_service_training", scriptNames.training)
end
local function showSpellmaking(params)
showDialogMenu("MenuDialog_service_spellmaking", scriptNames.spellmaking)
end
local function showEnchanting(params)
showDialogMenu("MenuDialog_service_enchanting", scriptNames.enchanting)
end
local function showCompanion(params)
showDialogMenu("MenuDialog_service_companion", scriptNames.companion)
end
local function onInitialize()
-- Services
mwse.overrideScript(scriptNames.travel, showTravel)
mwse.overrideScript(scriptNames.barter, showBarter)
mwse.overrideScript(scriptNames.repair, showRepair)
mwse.overrideScript(scriptNames.spells, showSpells)
mwse.overrideScript(scriptNames.training, showTraining)
mwse.overrideScript(scriptNames.spellmaking, showSpellmaking)
mwse.overrideScript(scriptNames.enchanting, showEnchanting)
mwse.overrideScript(scriptNames.companion, showCompanion)
-- Misc
mwse.overrideScript(scriptNames.cursedRing, ringCurseApply)
end
event.register("initialized", onInitialize)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment