Created
July 10, 2019 04:42
-
-
Save Petethegoat/9da77991479946f6d35bc79f21800d99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function dropPlayerItems() | |
local equippedItems = {} | |
for _, stack in pairs(tes3.player.object.equipment) do | |
table.insert(equippedItems, stack.object) | |
end | |
for _, object in pairs(equippedItems) do | |
--tes3.mobilePlayer:unequip{item = object} | |
end | |
tes3ui.forcePlayerInventoryUpdate() | |
local items = {} | |
for _, stack in pairs(tes3.player.object.inventory) do | |
table.insert(items, {object = stack.object, amount = stack.count}) | |
end | |
for _, v in pairs(items) do | |
tes3.player.object.inventory:dropItem(tes3.mobilePlayer, v.object, v.object.itemData, v.amount, tes3.mobilePlayer.position, tes3vector3.new(0,0, math.random())) | |
--I know the rotation is in radians, but 1 radian looks nicer than 360 degrees of randomisation. | |
end | |
tes3ui.forcePlayerInventoryUpdate() | |
return | |
end | |
local function onSpellCasted(e) | |
if e.caster == tes3.player then | |
for _, effect in ipairs(e.source.effects) do | |
if effect.id == tes3.effect.divineIntervention or effect.id == tes3.effect.almsiviIntervention then | |
dropPlayerItems() | |
end | |
end | |
end | |
end | |
event.register("spellCasted", onSpellCasted) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment