name: Evilswarm
card_text: 2 Level 4 "lswarm" monsters
  Once per turn: You can detach 1 Xyz Material from this card to target 1 face-up monster your opponent controls; discard 1 "lswarm" monster, and if you do, take control of that opponent's monster.
external_ids: local SETCARD_ID_0 = 0xa --lswarm
  
lua: local SETCARD_ID_0 = 0xa --lswarm
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), 4, 2)
  	c:EnableReviveLimit()
  	--attack up
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_CONTROL + CATEGORY_HANDES)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	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.filter(c)
  	return c:IsFaceup() and c:IsControlerCanBeChanged()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil) and Duel.IsExistingMatchingCard(s.dfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, tp, 1)
  end
  function s.dfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsDiscardable()
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local g = Duel.SelectMatchingCard(tp, s.dfilter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	if g:GetCount() == 0 then
  		return
  	end
  	Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.GetControl(tc, tp)
  	end
  end
  
  
source_text: Evilswarm
  2 Level 4 "lswarm" monsters
  Once per turn: You can detach 1 Xyz Material from this card to target 1 face-up monster your opponent controls; discard 1 "lswarm" monster, and if you do, take control of that opponent's monster.
target_text: -- Evilswarm
  local SETCARD_ID_0 = 0xa --lswarm
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), 4, 2)
  	c:EnableReviveLimit()
  	--attack up
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_CONTROL + CATEGORY_HANDES)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	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.filter(c)
  	return c:IsFaceup() and c:IsControlerCanBeChanged()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_MZONE, 1, nil) and Duel.IsExistingMatchingCard(s.dfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, tp, 1)
  end
  function s.dfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsDiscardable()
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local g = Duel.SelectMatchingCard(tp, s.dfilter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	if g:GetCount() == 0 then
  		return
  	end
  	Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.GetControl(tc, tp)
  	end
  end
  
  