name: Nekroz
card_text: You can Ritual Summon this card with any "Nekroz" Ritual Spell. Must be Ritual Summoned, using monsters, and you cannot use Level 10 monsters. You can only use each of the following effects of "Nekroz of Areadbhair" once per turn.
  ● You can discard this card; Tribute up to 2 "Nekroz" monsters from your hand and/or field, and if you do, send that many "Nekroz" cards from your Deck to the GY.
  ● When a monster effect is activated (Quick Effect): You can Tribute 1 monster from your hand or field; negate the activation, and if you do, banish that card.
external_ids: local SETCARD_ID_0 = 0xb4 --Nekroz
  
lua: local SETCARD_ID_0 = 0xb4 --Nekroz
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--Cannot Special Summon
  	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)
  	--Burialing
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.tgcost)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  	--Negate
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_NEGATE + CATEGORY_REMOVE)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.negcon)
  	e3:SetCost(s.negcost)
  	e3:SetTarget(aux.nbtg)
  	e3:SetOperation(s.negop)
  	c:RegisterEffect(e3)
  end
  function s.mat_filter(c)
  	return not c:IsLevel(10)
  end
  function s.tgcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsDiscardable()
  	end
  	Duel.SendtoGrave(c, REASON_COST + REASON_DISCARD)
  end
  function s.filter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tgfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGrave()
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil) and Duel.CheckReleaseGroupEx(tp, s.filter, 1, REASON_EFFECT, true, e:GetHandler())
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetMatchingGroupCount(s.tgfilter, tp, LOCATION_DECK, 0, nil)
  	if ct == 0 then
  		ct = 1
  	end
  	if ct > 2 then
  		ct = 2
  	end
  	local g = Duel.SelectReleaseGroupEx(tp, s.filter, 1, ct, REASON_EFFECT, true, nil)
  	if g:GetCount() > 0 then
  		local rct = Duel.Release(g, REASON_EFFECT)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local tg = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, rct, rct, nil)
  		Duel.SendtoGrave(tg, REASON_EFFECT)
  	end
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev) and re:IsActiveType(TYPE_MONSTER)
  end
  function s.negcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroupEx(tp, nil, 1, REASON_COST, true, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local g = Duel.SelectReleaseGroupEx(tp, nil, 1, 1, REASON_COST, true, nil, tp)
  	Duel.Release(g, REASON_COST)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
  		Duel.Remove(eg, POS_FACEUP, REASON_EFFECT)
  	end
  end
  
  
source_text: Nekroz
  You can Ritual Summon this card with any "Nekroz" Ritual Spell. Must be Ritual Summoned, using monsters, and you cannot use Level 10 monsters. You can only use each of the following effects of "Nekroz of Areadbhair" once per turn.
  ● You can discard this card; Tribute up to 2 "Nekroz" monsters from your hand and/or field, and if you do, send that many "Nekroz" cards from your Deck to the GY.
  ● When a monster effect is activated (Quick Effect): You can Tribute 1 monster from your hand or field; negate the activation, and if you do, banish that card.
target_text: -- Nekroz
  local SETCARD_ID_0 = 0xb4 --Nekroz
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--Cannot Special Summon
  	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)
  	--Burialing
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.tgcost)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  	--Negate
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_NEGATE + CATEGORY_REMOVE)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.negcon)
  	e3:SetCost(s.negcost)
  	e3:SetTarget(aux.nbtg)
  	e3:SetOperation(s.negop)
  	c:RegisterEffect(e3)
  end
  function s.mat_filter(c)
  	return not c:IsLevel(10)
  end
  function s.tgcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsDiscardable()
  	end
  	Duel.SendtoGrave(c, REASON_COST + REASON_DISCARD)
  end
  function s.filter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tgfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGrave()
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil) and Duel.CheckReleaseGroupEx(tp, s.filter, 1, REASON_EFFECT, true, e:GetHandler())
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetMatchingGroupCount(s.tgfilter, tp, LOCATION_DECK, 0, nil)
  	if ct == 0 then
  		ct = 1
  	end
  	if ct > 2 then
  		ct = 2
  	end
  	local g = Duel.SelectReleaseGroupEx(tp, s.filter, 1, ct, REASON_EFFECT, true, nil)
  	if g:GetCount() > 0 then
  		local rct = Duel.Release(g, REASON_EFFECT)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local tg = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, rct, rct, nil)
  		Duel.SendtoGrave(tg, REASON_EFFECT)
  	end
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev) and re:IsActiveType(TYPE_MONSTER)
  end
  function s.negcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckReleaseGroupEx(tp, nil, 1, REASON_COST, true, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  	local g = Duel.SelectReleaseGroupEx(tp, nil, 1, 1, REASON_COST, true, nil, tp)
  	Duel.Release(g, REASON_COST)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
  		Duel.Remove(eg, POS_FACEUP, REASON_EFFECT)
  	end
  end
  
  