name: Ritual
card_text: 1 "Ritual Beast Ulti" monster + 1 "Ritual Beast Tamer" monster + 1 "Spiritual Beast" monster
  Must be Special Summoned (from your Extra Deck) by banishing the above cards you control. If Summoned this way, this card gains this effect.
  ● When a Spell/Trap Card, or monster effect, is activated (Quick Effect): You can banish 1 "Ritual Beast" card from your hand; negate the activation, and if you do, destroy it.
external_ids: local SETCARD_ID_0 = 0x40b5 --Ritual
  local SETCARD_ID_1 = 0xb5 --Ritual
  
lua: local SETCARD_ID_0 = 0x40b5 --Ritual
  local SETCARD_ID_1 = 0xb5 --Ritual
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	local mat_list = {}
  	for i = 0, 2 do
  		table.insert(mat_list, aux.FilterBoolFunction(Card.IsFusionSetCard, SETCARD_ID_1 | (0x1000 << i)))
  	end
  	aux.AddFusionProcMix(c, false, false, table.unpack(mat_list))
  	aux.AddContactFusionProcedure(c, s.cfilter, LOCATION_MZONE, 0, Duel.Remove, POS_FACEUP, REASON_COST):SetValue(SUMMON_VALUE_SELF)
  	--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)
  	c:RegisterEffect(e1)
  	--gain effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.condition)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  	--negate
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	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:SetCondition(s.discon)
  	e3:SetCost(s.discost)
  	e3:SetTarget(s.distg)
  	e3:SetOperation(s.disop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c)
  	return c:IsFusionSetCard(SETCARD_ID_1, 0x10b5, 0x20b5) and c:IsAbleToRemoveAsCost()
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_WITHOUT_TEMP_REMOVE, 0, 1)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetFlagEffect(id) ~= 0
  		and re ~= e
  		and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED)
  		and (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE))
  		and Duel.IsChainNegatable(ev)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToRemoveAsCost()
  end
  function s.discost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.distg(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.disop(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
  
  
source_text: Ritual
  1 "Ritual Beast Ulti" monster + 1 "Ritual Beast Tamer" monster + 1 "Spiritual Beast" monster
  Must be Special Summoned (from your Extra Deck) by banishing the above cards you control. If Summoned this way, this card gains this effect.
  ● When a Spell/Trap Card, or monster effect, is activated (Quick Effect): You can banish 1 "Ritual Beast" card from your hand; negate the activation, and if you do, destroy it.
target_text: -- Ritual
  local SETCARD_ID_0 = 0x40b5 --Ritual
  local SETCARD_ID_1 = 0xb5 --Ritual
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	local mat_list = {}
  	for i = 0, 2 do
  		table.insert(mat_list, aux.FilterBoolFunction(Card.IsFusionSetCard, SETCARD_ID_1 | (0x1000 << i)))
  	end
  	aux.AddFusionProcMix(c, false, false, table.unpack(mat_list))
  	aux.AddContactFusionProcedure(c, s.cfilter, LOCATION_MZONE, 0, Duel.Remove, POS_FACEUP, REASON_COST):SetValue(SUMMON_VALUE_SELF)
  	--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)
  	c:RegisterEffect(e1)
  	--gain effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.condition)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  	--negate
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	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:SetCondition(s.discon)
  	e3:SetCost(s.discost)
  	e3:SetTarget(s.distg)
  	e3:SetOperation(s.disop)
  	c:RegisterEffect(e3)
  end
  function s.cfilter(c)
  	return c:IsFusionSetCard(SETCARD_ID_1, 0x10b5, 0x20b5) and c:IsAbleToRemoveAsCost()
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_WITHOUT_TEMP_REMOVE, 0, 1)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetFlagEffect(id) ~= 0
  		and re ~= e
  		and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED)
  		and (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE))
  		and Duel.IsChainNegatable(ev)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToRemoveAsCost()
  end
  function s.discost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.distg(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.disop(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
  
  