local targetplayer = args.player

spell.pos = targetplayer.pos
spell:executeSilent("/particle minecraft:smoke ~ ~2 ~ 1 2 1 0 1000 force")
spell:executeSilent("/tellraw " .. targetplayer.name .. " {text:'You have been slapped',color:'dark_red'}")
spell:executeSilent("/playsound entity.lightning_bolt.thunder neutral " .. targetplayer.name ..  " ~ ~ ~ 100" )
-- spell:executeSilent("/summon lightning_bolt ~ ~ ~") -- Do not use, destroys the dropped item!

-- Throw player in a random direction, approx 10 blocks into the air
local randomXZangle = math.random() * 2*math.pi
local randomXZmagnitude = math.random() * 10
targetplayer.velocity = targetplayer.velocity + Vec3(randomXZmagnitude*math.sin(randomXZangle), 1.44, randomXZmagnitude*math.cos(randomXZangle))

local handitem = targetplayer:getItemInHand("MAIN_HAND")
if handitem then
	targetplayer:dropItem(handitem, 1)
	targetplayer:setItemInHand("MAIN_HAND", nil)
end

local headitem = targetplayer:getEquipment("head")
if headitem then
	targetplayer:dropItem(headitem, 1)
end
targetplayer:setEquipment("head", Item:new("dirt"))
