Skip to content

Instantly share code, notes, and snippets.

@Petethegoat
Last active May 21, 2019 05:48
Show Gist options
  • Save Petethegoat/62501f24a1fad09b6ebc514dc5f314b6 to your computer and use it in GitHub Desktop.
Save Petethegoat/62501f24a1fad09b6ebc514dc5f314b6 to your computer and use it in GitHub Desktop.
-- Tweakables
local ringScriptName = "mwseRingScript"
local cureJournalEntry = "MS_Nuccius"
local cureJournalIndex = 150 -- if the journal entry is equal to or higher than this index, cure the curse.
local tickDuration = .1 -- Tick the curse every X seconds
-- 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.simulate}
mwscript.stopScript(ringScriptName)
end
local function onInitialize(e)
mwscript.overrideScript(ringScriptName, ringCurseApply)
end
event.register("initialize", onInitialize)
--testing
--event.register("loaded", ringCurseApply)
--event.register("keyDown", ringCurseEnd, { filter = tes3.scanCode.k })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment