name: Herald
card_text: You can Ritual Summon this card with "Oracle of the Herald". Must be Ritual Summoned. When your opponent would Special Summon a monster(s), OR activates a Spell/Trap Card, or a monster effect (Quick Effect): You can send 1 Fairy monster from your hand to the GY; negate the Special Summon or activation, and if you do, destroy that card.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--spsummon condition
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.ritlimit)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.negcon)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.negtg)
  	e2:SetOperation(s.negop)
  	c:RegisterEffect(e2)
  	--disable spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DISABLE_SUMMON + CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EVENT_SPSUMMON)
  	e3:SetCondition(s.discon)
  	e3:SetCost(s.cost)
  	e3:SetTarget(s.distg)
  	e3:SetOperation(s.disop)
  	c:RegisterEffect(e3)
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if ep == tp or c:IsStatus(STATUS_BATTLE_DESTROYED) then
  		return false
  	end
  	return (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE)) and Duel.IsChainNegatable(ev)
  end
  function s.cfilter(c)
  	return c:IsRace(RACE_FAIRY) and c:IsAbleToGraveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, s.cfilter, 1, 1, REASON_COST)
  end
  function s.negtg(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.negop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
  		Duel.Destroy(eg, REASON_EFFECT)
  	end
  end
  function s.filter(c, tp)
  	return c:IsSummonPlayer(tp)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentChain() == 0 and eg:IsExists(s.filter, 1, nil, 1 - tp)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = eg:Filter(s.filter, nil, 1 - tp)
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE_SUMMON, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local g = eg:Filter(s.filter, nil, 1 - tp)
  	Duel.NegateSummon(g)
  	Duel.Destroy(g, REASON_EFFECT)
  end
  
  
source_text: Herald
  You can Ritual Summon this card with "Oracle of the Herald". Must be Ritual Summoned. When your opponent would Special Summon a monster(s), OR activates a Spell/Trap Card, or a monster effect (Quick Effect): You can send 1 Fairy monster from your hand to the GY; negate the Special Summon or activation, and if you do, destroy that card.
target_text: -- Herald
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--spsummon condition
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.ritlimit)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.negcon)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.negtg)
  	e2:SetOperation(s.negop)
  	c:RegisterEffect(e2)
  	--disable spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DISABLE_SUMMON + CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EVENT_SPSUMMON)
  	e3:SetCondition(s.discon)
  	e3:SetCost(s.cost)
  	e3:SetTarget(s.distg)
  	e3:SetOperation(s.disop)
  	c:RegisterEffect(e3)
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if ep == tp or c:IsStatus(STATUS_BATTLE_DESTROYED) then
  		return false
  	end
  	return (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE)) and Duel.IsChainNegatable(ev)
  end
  function s.cfilter(c)
  	return c:IsRace(RACE_FAIRY) and c:IsAbleToGraveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, s.cfilter, 1, 1, REASON_COST)
  end
  function s.negtg(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.negop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
  		Duel.Destroy(eg, REASON_EFFECT)
  	end
  end
  function s.filter(c, tp)
  	return c:IsSummonPlayer(tp)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentChain() == 0 and eg:IsExists(s.filter, 1, nil, 1 - tp)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local g = eg:Filter(s.filter, nil, 1 - tp)
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE_SUMMON, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local g = eg:Filter(s.filter, nil, 1 - tp)
  	Duel.NegateSummon(g)
  	Duel.Destroy(g, REASON_EFFECT)
  end
  
  