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 9 monsters. You can only use each of these effects of "Nekroz of Trishula" once per turn.
  ● When a card or effect is activated that targets a "Nekroz" monster(s) you control (Quick Effect): You can discard this card; negate the activation.
  ● When this card is Ritual Summoned, you can: Banish exactly 3 of your opponent's cards, 1 each from their hand, field, and GY. (The card in the hand is chosen at random.)
external_ids: local CARD_ID_0 = 52068433 --Nekroz of Trishula
  local SETCARD_ID_0 = 0xb4 --Nekroz
  
lua: local CARD_ID_0 = 52068433 --Nekroz of Trishula
  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)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_NEGATE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.negcon)
  	e2:SetCost(s.negcost)
  	e2:SetTarget(s.negtg)
  	e2:SetOperation(s.negop)
  	c:RegisterEffect(e2)
  	--remove
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_REMOVE)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.remcon)
  	e3:SetTarget(s.remtg)
  	e3:SetOperation(s.remop)
  	c:RegisterEffect(e3)
  end
  function s.mat_filter(c)
  	return not c:IsLevel(9)
  end
  function s.tfilter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsControler(tp) and c:IsLocation(LOCATION_MZONE)
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return false
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	return g and g:IsExists(s.tfilter, 1, nil, tp) and Duel.IsChainNegatable(ev)
  end
  function s.negcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsDiscardable()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST + REASON_DISCARD)
  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)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.NegateActivation(ev)
  end
  function s.remcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_RITUAL)
  end
  function s.remtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, 0, LOCATION_HAND, 1, nil)
  			and Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, 0, LOCATION_ONFIELD, 1, nil)
  			and Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, 0, LOCATION_GRAVE, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 0, LOCATION_ONFIELD + LOCATION_GRAVE + LOCATION_HAND)
  end
  function s.remop(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_HAND, nil)
  	local g2 = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_ONFIELD, nil)
  	local g3 = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_GRAVE, nil)
  	if g1:GetCount() > 0 and g2:GetCount() > 0 and g3:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local sg1 = g1:RandomSelect(tp, 1)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local sg2 = g2:Select(tp, 1, 1, nil)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local sg3 = g3:Select(tp, 1, 1, nil)
  		sg1:Merge(sg2)
  		sg1:Merge(sg3)
  		Duel.HintSelection(sg1)
  		Duel.Remove(sg1, 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 9 monsters. You can only use each of these effects of "Nekroz of Trishula" once per turn.
  ● When a card or effect is activated that targets a "Nekroz" monster(s) you control (Quick Effect): You can discard this card; negate the activation.
  ● When this card is Ritual Summoned, you can: Banish exactly 3 of your opponent's cards, 1 each from their hand, field, and GY. (The card in the hand is chosen at random.)
target_text: -- Nekroz
  local CARD_ID_0 = 52068433 --Nekroz of Trishula
  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)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_NEGATE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.negcon)
  	e2:SetCost(s.negcost)
  	e2:SetTarget(s.negtg)
  	e2:SetOperation(s.negop)
  	c:RegisterEffect(e2)
  	--remove
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_REMOVE)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.remcon)
  	e3:SetTarget(s.remtg)
  	e3:SetOperation(s.remop)
  	c:RegisterEffect(e3)
  end
  function s.mat_filter(c)
  	return not c:IsLevel(9)
  end
  function s.tfilter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsControler(tp) and c:IsLocation(LOCATION_MZONE)
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return false
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	return g and g:IsExists(s.tfilter, 1, nil, tp) and Duel.IsChainNegatable(ev)
  end
  function s.negcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsDiscardable()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST + REASON_DISCARD)
  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)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.NegateActivation(ev)
  end
  function s.remcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_RITUAL)
  end
  function s.remtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, 0, LOCATION_HAND, 1, nil)
  			and Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, 0, LOCATION_ONFIELD, 1, nil)
  			and Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, 0, LOCATION_GRAVE, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 0, LOCATION_ONFIELD + LOCATION_GRAVE + LOCATION_HAND)
  end
  function s.remop(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_HAND, nil)
  	local g2 = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_ONFIELD, nil)
  	local g3 = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_GRAVE, nil)
  	if g1:GetCount() > 0 and g2:GetCount() > 0 and g3:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local sg1 = g1:RandomSelect(tp, 1)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local sg2 = g2:Select(tp, 1, 1, nil)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local sg3 = g3:Select(tp, 1, 1, nil)
  		sg1:Merge(sg2)
  		sg1:Merge(sg3)
  		Duel.HintSelection(sg1)
  		Duel.Remove(sg1, POS_FACEUP, REASON_EFFECT)
  	end
  end
  
  