name: Draco-Utopian
card_text: When your opponent activates a monster effect on the field: Negate the activation, and if you do, destroy that card, then, you can apply the following effect.
  ● Banish 1 monster from your hand, and if you do, Special Summon the monster that was destroyed and sent to the GY by this effect to your field, but negate its effects.
  You can only activate 1 "Draco-Utopian Aura" per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY + CATEGORY_REMOVE + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return ep == 1 - tp and re:GetActivateLocation() == LOCATION_MZONE and re:IsActiveType(TYPE_MONSTER) and Duel.IsChainNegatable(ev)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, eg, 1, 0, 0)
  	end
  end
  function s.filter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsAbleToRemove()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local rc = re:GetHandler()
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) and Duel.Destroy(eg, REASON_EFFECT) > 0 then
  		local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_HAND, 0, nil)
  		if
  			g:GetCount() > 0
  			and rc:IsType(TYPE_MONSTER)
  			and rc:IsLocation(LOCATION_GRAVE)
  			and aux.NecroValleyFilter()(rc)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and rc:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  			and Duel.SelectYesNo(tp, aux.Stringid(id, 0))
  		then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  			local sg = g:Select(tp, 1, 1, nil)
  			if sg:GetCount() > 0 and Duel.Remove(sg, POS_FACEUP, REASON_EFFECT) > 0 and sg:GetFirst():IsLocation(LOCATION_REMOVED) then
  				Duel.SpecialSummonStep(rc, 0, tp, tp, false, false, POS_FACEUP)
  				local e1 = Effect.CreateEffect(e:GetHandler())
  				e1:SetType(EFFECT_TYPE_SINGLE)
  				e1:SetCode(EFFECT_DISABLE)
  				e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  				rc:RegisterEffect(e1)
  				local e2 = Effect.CreateEffect(e:GetHandler())
  				e2:SetType(EFFECT_TYPE_SINGLE)
  				e2:SetCode(EFFECT_DISABLE_EFFECT)
  				e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  				e2:SetValue(RESET_TURN_SET)
  				rc:RegisterEffect(e2)
  				Duel.SpecialSummonComplete()
  			end
  		end
  	end
  end
  
  
source_text: Draco-Utopian
  When your opponent activates a monster effect on the field: Negate the activation, and if you do, destroy that card, then, you can apply the following effect.
  ● Banish 1 monster from your hand, and if you do, Special Summon the monster that was destroyed and sent to the GY by this effect to your field, but negate its effects.
  You can only activate 1 "Draco-Utopian Aura" per turn.
target_text: -- Draco-Utopian
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY + CATEGORY_REMOVE + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return ep == 1 - tp and re:GetActivateLocation() == LOCATION_MZONE and re:IsActiveType(TYPE_MONSTER) and Duel.IsChainNegatable(ev)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, eg, 1, 0, 0)
  	end
  end
  function s.filter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsAbleToRemove()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local rc = re:GetHandler()
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) and Duel.Destroy(eg, REASON_EFFECT) > 0 then
  		local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_HAND, 0, nil)
  		if
  			g:GetCount() > 0
  			and rc:IsType(TYPE_MONSTER)
  			and rc:IsLocation(LOCATION_GRAVE)
  			and aux.NecroValleyFilter()(rc)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and rc:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  			and Duel.SelectYesNo(tp, aux.Stringid(id, 0))
  		then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  			local sg = g:Select(tp, 1, 1, nil)
  			if sg:GetCount() > 0 and Duel.Remove(sg, POS_FACEUP, REASON_EFFECT) > 0 and sg:GetFirst():IsLocation(LOCATION_REMOVED) then
  				Duel.SpecialSummonStep(rc, 0, tp, tp, false, false, POS_FACEUP)
  				local e1 = Effect.CreateEffect(e:GetHandler())
  				e1:SetType(EFFECT_TYPE_SINGLE)
  				e1:SetCode(EFFECT_DISABLE)
  				e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  				rc:RegisterEffect(e1)
  				local e2 = Effect.CreateEffect(e:GetHandler())
  				e2:SetType(EFFECT_TYPE_SINGLE)
  				e2:SetCode(EFFECT_DISABLE_EFFECT)
  				e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  				e2:SetValue(RESET_TURN_SET)
  				rc:RegisterEffect(e2)
  				Duel.SpecialSummonComplete()
  			end
  		end
  	end
  end
  
  