name: Vampire
card_text: If this card in your possession is sent to your GY by your opponent's card: You can add 1 DARK "Vampire" monster or 1 "Vampire" Spell/Trap from your Deck to your hand. You can banish this card from your GY; 1 DARK "Vampire" monster you Normal Summon this turn can be Summoned without Tributing.
external_ids: local SETCARD_ID_0 = 0x8e --Vampire
  
lua: local SETCARD_ID_0 = 0x8e --Vampire
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCost(aux.bfgcost)
  	e2:SetOperation(s.sumop)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and e:GetHandler():IsPreviousControler(tp)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsType(TYPE_SPELL + TYPE_TRAP) or c:IsAttribute(ATTRIBUTE_DARK)) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.sumop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFlagEffect(tp, id) == 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetDescription(aux.Stringid(id, 2))
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetTargetRange(LOCATION_HAND, 0)
  		e1:SetCode(EFFECT_SUMMON_PROC)
  		e1:SetCountLimit(1)
  		e1:SetCondition(s.ntcon)
  		e1:SetTarget(s.nttg)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  		Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  function s.nttg(e, c)
  	return c:IsLevelAbove(5) and c:IsSetCard(SETCARD_ID_0) and c:IsAttribute(ATTRIBUTE_DARK)
  end
  
  
source_text: Vampire
  If this card in your possession is sent to your GY by your opponent's card: You can add 1 DARK "Vampire" monster or 1 "Vampire" Spell/Trap from your Deck to your hand. You can banish this card from your GY; 1 DARK "Vampire" monster you Normal Summon this turn can be Summoned without Tributing.
target_text: -- Vampire
  local SETCARD_ID_0 = 0x8e --Vampire
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCost(aux.bfgcost)
  	e2:SetOperation(s.sumop)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and e:GetHandler():IsPreviousControler(tp)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsType(TYPE_SPELL + TYPE_TRAP) or c:IsAttribute(ATTRIBUTE_DARK)) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.sumop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFlagEffect(tp, id) == 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetDescription(aux.Stringid(id, 2))
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetTargetRange(LOCATION_HAND, 0)
  		e1:SetCode(EFFECT_SUMMON_PROC)
  		e1:SetCountLimit(1)
  		e1:SetCondition(s.ntcon)
  		e1:SetTarget(s.nttg)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  		Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  function s.nttg(e, c)
  	return c:IsLevelAbove(5) and c:IsSetCard(SETCARD_ID_0) and c:IsAttribute(ATTRIBUTE_DARK)
  end
  
  