Split
When you take damage from your opponent's card effect or their monster's attack: Apply the appropriate effect based on the type of damage.
● Battle: Special Summon 1 monster from your GY, with ATK less than or equal to the damage, and if you do, end the Battle Phase after the Damage Step.
● Effect: Inflict double the damage you took to your opponent.
You can only activate 1 "Split Mirror of the Underworld" per turn.
local s, id, o = GetID()
function s.initial_effect(c)
	--special summon
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 1))
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_BATTLE_DAMAGE)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetCondition(s.spcon)
	e1:SetTarget(s.sptg)
	e1:SetOperation(s.spop)
	c:RegisterEffect(e1)
	--damage
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 2))
	e2:SetCategory(CATEGORY_DAMAGE + CATEGORY_GRAVE_SPSUMMON)
	e2:SetType(EFFECT_TYPE_ACTIVATE)
	e2:SetCode(EVENT_DAMAGE)
	e2:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
	e2:SetCondition(s.dacon)
	e2:SetOperation(s.daop)
	c:RegisterEffect(e2)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return ep == tp and Duel.GetAttacker():IsControler(1 - tp)
end
function s.filter(c, v, e, tp)
	return c:IsAttackBelow(v) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return r & REASON_EFFECT > 0 or Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE, 0, 1, nil, ev, e, tp)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_GRAVE)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local ss = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(aux.NecroValleyFilter(s.filter), tp, LOCATION_GRAVE, 0, 1, nil, ev, e, tp)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, ev, e, tp)
	if Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP) > 0 then
		local e1 = Effect.CreateEffect(c)
		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
		e1:SetCode(EVENT_DAMAGE_STEP_END)
		e1:SetOperation(s.skipop)
		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
		Duel.RegisterEffect(e1, tp)
	end
end
function s.skipop(e, tp, eg, ep, ev, re, r, rp)
	Duel.SkipPhase(Duel.GetTurnPlayer(), PHASE_BATTLE, RESET_PHASE + PHASE_BATTLE_STEP, 1)
end
function s.dacon(e, tp, eg, ep, ev, re, r, rp)
	if ep ~= tp then
		return false
	end
	return r & REASON_EFFECT > 0 and rp == 1 - tp
end
function s.daop(e, tp, eg, ep, ev, re, r, rp)
	Duel.Damage(1 - tp, ev * 2, REASON_EFFECT)
end


Split
When you take damage from your opponent's card effect or their monster's attack: Apply the appropriate effect based on the type of damage.
● Battle: Special Summon 1 monster from your GY, with ATK less than or equal to the damage, and if you do, end the Battle Phase after the Damage Step.
● Effect: Inflict double the damage you took to your opponent.
You can only activate 1 "Split Mirror of the Underworld" per turn.
-- Split
local s, id, o = GetID()
function s.initial_effect(c)
	--special summon
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 1))
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_BATTLE_DAMAGE)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetCondition(s.spcon)
	e1:SetTarget(s.sptg)
	e1:SetOperation(s.spop)
	c:RegisterEffect(e1)
	--damage
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 2))
	e2:SetCategory(CATEGORY_DAMAGE + CATEGORY_GRAVE_SPSUMMON)
	e2:SetType(EFFECT_TYPE_ACTIVATE)
	e2:SetCode(EVENT_DAMAGE)
	e2:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
	e2:SetCondition(s.dacon)
	e2:SetOperation(s.daop)
	c:RegisterEffect(e2)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return ep == tp and Duel.GetAttacker():IsControler(1 - tp)
end
function s.filter(c, v, e, tp)
	return c:IsAttackBelow(v) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return r & REASON_EFFECT > 0 or Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE, 0, 1, nil, ev, e, tp)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_GRAVE)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local ss = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(aux.NecroValleyFilter(s.filter), tp, LOCATION_GRAVE, 0, 1, nil, ev, e, tp)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, ev, e, tp)
	if Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP) > 0 then
		local e1 = Effect.CreateEffect(c)
		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
		e1:SetCode(EVENT_DAMAGE_STEP_END)
		e1:SetOperation(s.skipop)
		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
		Duel.RegisterEffect(e1, tp)
	end
end
function s.skipop(e, tp, eg, ep, ev, re, r, rp)
	Duel.SkipPhase(Duel.GetTurnPlayer(), PHASE_BATTLE, RESET_PHASE + PHASE_BATTLE_STEP, 1)
end
function s.dacon(e, tp, eg, ep, ev, re, r, rp)
	if ep ~= tp then
		return false
	end
	return r & REASON_EFFECT > 0 and rp == 1 - tp
end
function s.daop(e, tp, eg, ep, ev, re, r, rp)
	Duel.Damage(1 - tp, ev * 2, REASON_EFFECT)
end

