name: Vampire
card_text: Once per turn: You can pay 1000 LP, then target 1 monster your opponent controls and 1 other "Vampire" monster you control; switch control of those monsters. At the end of the Battle Phase, if this card destroyed any monster(s) by battle: You can Special Summon them from the GYs to your field.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x8e --Vampire
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x8e --Vampire
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--control
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_CONTROL)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.ctcost)
  	e1:SetTarget(s.cttg)
  	e1:SetOperation(s.ctop)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCode(EVENT_BATTLE_DESTROYING)
  	e2:SetOperation(s.regop)
  	c:RegisterEffect(e2)
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.ctcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1000)
  	end
  	Duel.PayLPCost(tp, 1000)
  end
  function s.ctfilter1(c)
  	local tp = c:GetControler()
  	return c:IsAbleToChangeControler() and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0
  end
  function s.ctfilter2(c)
  	local tp = c:GetControler()
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToChangeControler() and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0
  end
  function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.ctfilter1, tp, 0, LOCATION_MZONE, 1, nil) and Duel.IsExistingTarget(s.ctfilter2, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g1 = Duel.SelectTarget(tp, s.ctfilter1, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g2 = Duel.SelectTarget(tp, s.ctfilter2, tp, LOCATION_MZONE, 0, 1, 1, e:GetHandler())
  	g1:Merge(g2)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g1, 2, 0, 0)
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local a = g:GetFirst()
  	local b = g:GetNext()
  	if a:IsRelateToEffect(e) and b:IsRelateToEffect(e) then
  		Duel.SwapControl(a, b)
  	end
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_BATTLE, 0, 1)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetFlagEffect(id) ~= 0
  end
  function s.spfilter(c, e, tp, rc, tid)
  	return c:IsReason(REASON_BATTLE) and c:GetReasonCard() == rc and c:GetTurnID() == tid and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_GRAVE, LOCATION_GRAVE, 1, nil, e, tp, e:GetHandler(), Duel.GetTurnCount())
  	end
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_GRAVE, LOCATION_GRAVE, nil, e, tp, e:GetHandler(), Duel.GetTurnCount())
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	local tg = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.spfilter), tp, LOCATION_GRAVE, LOCATION_GRAVE, nil, e, tp, e:GetHandler(), Duel.GetTurnCount())
  	local g = nil
  	if tg:GetCount() > ft then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		g = tg:Select(tp, ft, ft, nil)
  	else
  		g = tg
  	end
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Vampire
  Once per turn: You can pay 1000 LP, then target 1 monster your opponent controls and 1 other "Vampire" monster you control; switch control of those monsters. At the end of the Battle Phase, if this card destroyed any monster(s) by battle: You can Special Summon them from the GYs to your field.
target_text: -- Vampire
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x8e --Vampire
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--control
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_CONTROL)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.ctcost)
  	e1:SetTarget(s.cttg)
  	e1:SetOperation(s.ctop)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCode(EVENT_BATTLE_DESTROYING)
  	e2:SetOperation(s.regop)
  	c:RegisterEffect(e2)
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.ctcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 1000)
  	end
  	Duel.PayLPCost(tp, 1000)
  end
  function s.ctfilter1(c)
  	local tp = c:GetControler()
  	return c:IsAbleToChangeControler() and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0
  end
  function s.ctfilter2(c)
  	local tp = c:GetControler()
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToChangeControler() and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0
  end
  function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.ctfilter1, tp, 0, LOCATION_MZONE, 1, nil) and Duel.IsExistingTarget(s.ctfilter2, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g1 = Duel.SelectTarget(tp, s.ctfilter1, tp, 0, LOCATION_MZONE, 1, 1, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g2 = Duel.SelectTarget(tp, s.ctfilter2, tp, LOCATION_MZONE, 0, 1, 1, e:GetHandler())
  	g1:Merge(g2)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g1, 2, 0, 0)
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local a = g:GetFirst()
  	local b = g:GetNext()
  	if a:IsRelateToEffect(e) and b:IsRelateToEffect(e) then
  		Duel.SwapControl(a, b)
  	end
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_BATTLE, 0, 1)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetFlagEffect(id) ~= 0
  end
  function s.spfilter(c, e, tp, rc, tid)
  	return c:IsReason(REASON_BATTLE) and c:GetReasonCard() == rc and c:GetTurnID() == tid and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_GRAVE, LOCATION_GRAVE, 1, nil, e, tp, e:GetHandler(), Duel.GetTurnCount())
  	end
  	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_GRAVE, LOCATION_GRAVE, nil, e, tp, e:GetHandler(), Duel.GetTurnCount())
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	local tg = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.spfilter), tp, LOCATION_GRAVE, LOCATION_GRAVE, nil, e, tp, e:GetHandler(), Duel.GetTurnCount())
  	local g = nil
  	if tg:GetCount() > ft then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		g = tg:Select(tp, ft, ft, nil)
  	else
  		g = tg
  	end
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  