name: Tearlaments
card_text: "Tearlaments Kitkallos" + 1 "Tearlaments" monster
  Other Aqua monsters you control cannot be destroyed by battle. You can only use each of the following effects of "Tearlaments Rulkallos" once per turn. When your opponent activates a card or effect that includes an effect that Special Summons a monster(s) (Quick Effect): You can negate the activation, and if you do, destroy it, then, send 1 "Tearlaments" card from your hand or face-up field to the GY. If this Fusion Summoned card is sent to the GY by a card effect: You can Special Summon this card.
external_ids: local CARD_ID_1 = 92731385 --Tearlaments Kitkallos
  local SETCARD_ID_0 = 0x181 --Tearlaments
  
lua: local CARD_ID_1 = 92731385 --Tearlaments Kitkallos
  local SETCARD_ID_0 = 0x181 --Tearlaments
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--fusion material
  	aux.AddFusionProcCodeFun(c, CARD_ID_1, aux.FilterBoolFunction(Card.IsFusionSetCard, SETCARD_ID_0), 1, true, true)
  	--indestructable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.indtg)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY + CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.discon)
  	e2:SetTarget(s.distg)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.indtg(e, c)
  	return c:IsRace(RACE_AQUA) and c ~= e:GetHandler()
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) or not Duel.IsChainNegatable(ev) then
  		return false
  	end
  	return re:IsHasCategory(CATEGORY_SPECIAL_SUMMON) and ep ~= tp
  end
  function s.tgfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsLocation(LOCATION_HAND) or c:IsFaceup()) and c:IsAbleToGrave()
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, nil)
  	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
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_HAND + LOCATION_ONFIELD)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) and Duel.Destroy(eg, REASON_EFFECT) ~= 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, 1, nil)
  		if #g > 0 then
  			Duel.BreakEffect()
  			Duel.SendtoGrave(g, REASON_EFFECT)
  		end
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE) and c:IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Tearlaments
  "Tearlaments Kitkallos" + 1 "Tearlaments" monster
  Other Aqua monsters you control cannot be destroyed by battle. You can only use each of the following effects of "Tearlaments Rulkallos" once per turn. When your opponent activates a card or effect that includes an effect that Special Summons a monster(s) (Quick Effect): You can negate the activation, and if you do, destroy it, then, send 1 "Tearlaments" card from your hand or face-up field to the GY. If this Fusion Summoned card is sent to the GY by a card effect: You can Special Summon this card.
target_text: -- Tearlaments
  local CARD_ID_1 = 92731385 --Tearlaments Kitkallos
  local SETCARD_ID_0 = 0x181 --Tearlaments
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--fusion material
  	aux.AddFusionProcCodeFun(c, CARD_ID_1, aux.FilterBoolFunction(Card.IsFusionSetCard, SETCARD_ID_0), 1, true, true)
  	--indestructable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(s.indtg)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY + CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.discon)
  	e2:SetTarget(s.distg)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  	--spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  end
  function s.indtg(e, c)
  	return c:IsRace(RACE_AQUA) and c ~= e:GetHandler()
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) or not Duel.IsChainNegatable(ev) then
  		return false
  	end
  	return re:IsHasCategory(CATEGORY_SPECIAL_SUMMON) and ep ~= tp
  end
  function s.tgfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsLocation(LOCATION_HAND) or c:IsFaceup()) and c:IsAbleToGrave()
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, nil)
  	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
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_HAND + LOCATION_ONFIELD)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) and Duel.Destroy(eg, REASON_EFFECT) ~= 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, 1, nil)
  		if #g > 0 then
  			Duel.BreakEffect()
  			Duel.SendtoGrave(g, REASON_EFFECT)
  		end
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE) and c:IsSummonType(SUMMON_TYPE_FUSION)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  