Malefic
Banish 2 "Malefic" cards from your GY; add 2 "Malefic" cards from your Deck to your hand, except "Malefic Selector", with different names from each other and from the banished cards. You can only activate 1 "Malefic Selector" per turn.
local SETCARD_ID_0 = 0x23 --Malefic

local SETCARD_ID_0 = 0x23 --Malefic
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetLabel(0)
	e1:SetCost(s.cost)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
end
function s.cfilter(c)
	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemoveAsCost()
end
function s.thfilter(c, code1, code2)
	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand() and not c:IsCode(id, code1, code2)
end
function s.costcheck(g, tp)
	local code1 = g:GetFirst():GetCode()
	local code2 = g:GetNext():GetCode()
	local tg = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_DECK, 0, nil, code1, code2)
	return tg:GetClassCount(Card.GetCode) >= 2
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	e:SetLabel(100)
	return true
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_GRAVE, 0, nil)
	if chk == 0 then
		if e:GetLabel() ~= 100 then
			return false
		end
		e:SetLabel(0)
		return g:CheckSubGroup(s.costcheck, 2, 2, tp)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
	local sg = g:SelectSubGroup(tp, s.costcheck, false, 2, 2, tp)
	Duel.Remove(sg, POS_FACEUP, REASON_COST)
	sg:KeepAlive()
	e:SetLabelObject(sg)
	e:SetLabel(0)
	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 2, tp, LOCATION_DECK)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local g = e:GetLabelObject()
	local code1 = g:GetFirst():GetCode()
	local code2 = g:GetNext():GetCode()
	local tg = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_DECK, 0, nil, code1, code2)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
	local sg = tg:SelectSubGroup(tp, aux.dncheck, false, 2, 2)
	if sg then
		Duel.SendtoHand(sg, nil, REASON_EFFECT)
		Duel.ConfirmCards(1 - tp, sg)
	end
end


Malefic
Banish 2 "Malefic" cards from your GY; add 2 "Malefic" cards from your Deck to your hand, except "Malefic Selector", with different names from each other and from the banished cards. You can only activate 1 "Malefic Selector" per turn.
-- Malefic
local SETCARD_ID_0 = 0x23 --Malefic
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetLabel(0)
	e1:SetCost(s.cost)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
end
function s.cfilter(c)
	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemoveAsCost()
end
function s.thfilter(c, code1, code2)
	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand() and not c:IsCode(id, code1, code2)
end
function s.costcheck(g, tp)
	local code1 = g:GetFirst():GetCode()
	local code2 = g:GetNext():GetCode()
	local tg = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_DECK, 0, nil, code1, code2)
	return tg:GetClassCount(Card.GetCode) >= 2
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	e:SetLabel(100)
	return true
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_GRAVE, 0, nil)
	if chk == 0 then
		if e:GetLabel() ~= 100 then
			return false
		end
		e:SetLabel(0)
		return g:CheckSubGroup(s.costcheck, 2, 2, tp)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
	local sg = g:SelectSubGroup(tp, s.costcheck, false, 2, 2, tp)
	Duel.Remove(sg, POS_FACEUP, REASON_COST)
	sg:KeepAlive()
	e:SetLabelObject(sg)
	e:SetLabel(0)
	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 2, tp, LOCATION_DECK)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local g = e:GetLabelObject()
	local code1 = g:GetFirst():GetCode()
	local code2 = g:GetNext():GetCode()
	local tg = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_DECK, 0, nil, code1, code2)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
	local sg = tg:SelectSubGroup(tp, aux.dncheck, false, 2, 2)
	if sg then
		Duel.SendtoHand(sg, nil, REASON_EFFECT)
		Duel.ConfirmCards(1 - tp, sg)
	end
end

