Evilswarm
3 Level 4 monsters
Once per turn: You can detach 1 material from this card, then activate 1 of these effects. Each effect can only be used once while this card is face-up on the field.
● Target 1 card your opponent controls; return that target to the hand.
● Send 1 random card from your opponent's hand to the GY.
● Target 1 card in your opponent's GY; banish that target.
local s, id, o = GetID()
function s.initial_effect(c)
	--xyz summon
	aux.AddXyzProcedure(c, nil, 4, 3)
	c:EnableReviveLimit()
	--tohand&handes&remove
	local e1 = Effect.CreateEffect(c)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_NO_TURN_RESET)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1)
	e1:SetCost(s.cost)
	e1:SetTarget(s.tg1)
	e1:SetOperation(s.op1)
	c:RegisterEffect(e1)
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
	end
	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
end
function s.tg1(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		if e:GetLabel() == 0 then
			return chkc:IsControler(1 - tp) and chkc:IsOnField() and chkc:IsAbleToHand()
		elseif e:GetLabel() == 2 then
			return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_GRAVE) and chkc:IsAbleToRemove()
		end
	end
	local c = e:GetHandler()
	local flag = c:GetFlagEffectLabel(id) or 0
	local b1 = (flag & 2 == 0) and Duel.IsExistingTarget(Card.IsAbleToHand, tp, 0, LOCATION_ONFIELD, 1, nil)
	local b2 = (flag & 4 == 0) and Duel.GetFieldGroupCount(1 - tp, LOCATION_HAND, 0) ~= 0
	local b3 = (flag & 8 == 0) and Duel.IsExistingTarget(Card.IsAbleToRemove, tp, 0, LOCATION_GRAVE, 1, nil)
	if chk == 0 then
		return b1 or b2 or b3
	end
	local op = aux.SelectFromOptions(tp, { b1, aux.Stringid(id, 1) }, { b2, aux.Stringid(id, 2) }, { b3, aux.Stringid(id, 3) })
	e:SetLabel(op)
	if flag == 0 then
		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1)
	end
	c:SetFlagEffectLabel(id, flag | (1 << op))
	if op == 1 then
		e:SetCategory(CATEGORY_TOHAND)
		e:SetProperty(EFFECT_FLAG_CARD_TARGET)
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
		local g = Duel.SelectTarget(tp, Card.IsAbleToHand, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
		Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
	elseif op == 2 then
		e:SetCategory(CATEGORY_TOGRAVE)
		e:SetProperty(0)
		Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, 1 - tp, LOCATION_HAND)
	else
		e:SetCategory(CATEGORY_REMOVE)
		e:SetProperty(EFFECT_FLAG_CARD_TARGET)
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
		local g = Duel.SelectTarget(tp, Card.IsAbleToRemove, tp, 0, LOCATION_GRAVE, 1, 1, nil)
		Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 1 - tp, LOCATION_GRAVE)
	end
end
function s.op1(e, tp, eg, ep, ev, re, r, rp)
	local op = e:GetLabel()
	if op == 1 then
		local tc = Duel.GetFirstTarget()
		if tc:IsRelateToEffect(e) then
			Duel.SendtoHand(tc, nil, REASON_EFFECT)
		end
	elseif op == 2 then
		local g = Duel.GetFieldGroup(1 - tp, LOCATION_HAND, 0)
		if g:GetCount() == 0 then
			return
		end
		local sg = g:RandomSelect(1 - tp, 1)
		Duel.SendtoGrave(sg, REASON_EFFECT)
	else
		local tc = Duel.GetFirstTarget()
		if tc:IsRelateToEffect(e) then
			Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
		end
	end
end


Evilswarm
3 Level 4 monsters
Once per turn: You can detach 1 material from this card, then activate 1 of these effects. Each effect can only be used once while this card is face-up on the field.
● Target 1 card your opponent controls; return that target to the hand.
● Send 1 random card from your opponent's hand to the GY.
● Target 1 card in your opponent's GY; banish that target.
-- Evilswarm
local s, id, o = GetID()
function s.initial_effect(c)
	--xyz summon
	aux.AddXyzProcedure(c, nil, 4, 3)
	c:EnableReviveLimit()
	--tohand&handes&remove
	local e1 = Effect.CreateEffect(c)
	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_NO_TURN_RESET)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1)
	e1:SetCost(s.cost)
	e1:SetTarget(s.tg1)
	e1:SetOperation(s.op1)
	c:RegisterEffect(e1)
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
	end
	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
end
function s.tg1(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		if e:GetLabel() == 0 then
			return chkc:IsControler(1 - tp) and chkc:IsOnField() and chkc:IsAbleToHand()
		elseif e:GetLabel() == 2 then
			return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_GRAVE) and chkc:IsAbleToRemove()
		end
	end
	local c = e:GetHandler()
	local flag = c:GetFlagEffectLabel(id) or 0
	local b1 = (flag & 2 == 0) and Duel.IsExistingTarget(Card.IsAbleToHand, tp, 0, LOCATION_ONFIELD, 1, nil)
	local b2 = (flag & 4 == 0) and Duel.GetFieldGroupCount(1 - tp, LOCATION_HAND, 0) ~= 0
	local b3 = (flag & 8 == 0) and Duel.IsExistingTarget(Card.IsAbleToRemove, tp, 0, LOCATION_GRAVE, 1, nil)
	if chk == 0 then
		return b1 or b2 or b3
	end
	local op = aux.SelectFromOptions(tp, { b1, aux.Stringid(id, 1) }, { b2, aux.Stringid(id, 2) }, { b3, aux.Stringid(id, 3) })
	e:SetLabel(op)
	if flag == 0 then
		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1)
	end
	c:SetFlagEffectLabel(id, flag | (1 << op))
	if op == 1 then
		e:SetCategory(CATEGORY_TOHAND)
		e:SetProperty(EFFECT_FLAG_CARD_TARGET)
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
		local g = Duel.SelectTarget(tp, Card.IsAbleToHand, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
		Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
	elseif op == 2 then
		e:SetCategory(CATEGORY_TOGRAVE)
		e:SetProperty(0)
		Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, 1 - tp, LOCATION_HAND)
	else
		e:SetCategory(CATEGORY_REMOVE)
		e:SetProperty(EFFECT_FLAG_CARD_TARGET)
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
		local g = Duel.SelectTarget(tp, Card.IsAbleToRemove, tp, 0, LOCATION_GRAVE, 1, 1, nil)
		Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 1 - tp, LOCATION_GRAVE)
	end
end
function s.op1(e, tp, eg, ep, ev, re, r, rp)
	local op = e:GetLabel()
	if op == 1 then
		local tc = Duel.GetFirstTarget()
		if tc:IsRelateToEffect(e) then
			Duel.SendtoHand(tc, nil, REASON_EFFECT)
		end
	elseif op == 2 then
		local g = Duel.GetFieldGroup(1 - tp, LOCATION_HAND, 0)
		if g:GetCount() == 0 then
			return
		end
		local sg = g:RandomSelect(1 - tp, 1)
		Duel.SendtoGrave(sg, REASON_EFFECT)
	else
		local tc = Duel.GetFirstTarget()
		if tc:IsRelateToEffect(e) then
			Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
		end
	end
end

