name: El
card_text: 1 "Shaddoll" monster + 1 EARTH monster
  Must first be Fusion Summoned. When a Special Summoned monster activates its effect while you have a "Shaddoll" card in your hand (Quick Effect): You can negate the activation, and if you do, destroy that monster, then send 1 "Shaddoll" card from your hand to the GY. You can only use this effect of "El Shaddoll Shekhinaga" once per turn. If this card is sent to the GY: You can target 1 "Shaddoll" Spell/Trap in your GY; add it to your hand.
external_ids: local SETCARD_ID_0 = 0x9d --Shaddoll
  
lua: local SETCARD_ID_0 = 0x9d --Shaddoll
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcFun2(c, function(mc)
  		return mc:IsFusionSetCard(SETCARD_ID_0)
  	end, function(mc)
  		return aux.FShaddollFilter2(mc, ATTRIBUTE_EARTH)
  	end, true)
  	--cannot spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE + EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e2:SetRange(LOCATION_EXTRA)
  	e2:SetValue(s.splimit)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetCondition(s.discon)
  	e3:SetTarget(s.distg)
  	e3:SetOperation(s.disop)
  	c:RegisterEffect(e3)
  	--tohand
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_TOHAND)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_TO_GRAVE)
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e4:SetTarget(s.thtg)
  	e4:SetOperation(s.thop)
  	c:RegisterEffect(e4)
  end
  function s.splimit(e, se, sp, st)
  	return bit.band(st, SUMMON_TYPE_FUSION) == SUMMON_TYPE_FUSION
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) then
  		return false
  	end
  	local loc = Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION)
  	return loc == LOCATION_MZONE and re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsSummonType(SUMMON_TYPE_SPECIAL) and Duel.IsChainNegatable(ev)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.distg(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.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) and Duel.Destroy(eg, REASON_EFFECT) > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.BreakEffect()
  			Duel.SendtoGrave(g, REASON_EFFECT)
  		end
  	end
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: El
  1 "Shaddoll" monster + 1 EARTH monster
  Must first be Fusion Summoned. When a Special Summoned monster activates its effect while you have a "Shaddoll" card in your hand (Quick Effect): You can negate the activation, and if you do, destroy that monster, then send 1 "Shaddoll" card from your hand to the GY. You can only use this effect of "El Shaddoll Shekhinaga" once per turn. If this card is sent to the GY: You can target 1 "Shaddoll" Spell/Trap in your GY; add it to your hand.
target_text: -- El
  local SETCARD_ID_0 = 0x9d --Shaddoll
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcFun2(c, function(mc)
  		return mc:IsFusionSetCard(SETCARD_ID_0)
  	end, function(mc)
  		return aux.FShaddollFilter2(mc, ATTRIBUTE_EARTH)
  	end, true)
  	--cannot spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE + EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e2:SetRange(LOCATION_EXTRA)
  	e2:SetValue(s.splimit)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetCondition(s.discon)
  	e3:SetTarget(s.distg)
  	e3:SetOperation(s.disop)
  	c:RegisterEffect(e3)
  	--tohand
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_TOHAND)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_TO_GRAVE)
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_DELAY)
  	e4:SetTarget(s.thtg)
  	e4:SetOperation(s.thop)
  	c:RegisterEffect(e4)
  end
  function s.splimit(e, se, sp, st)
  	return bit.band(st, SUMMON_TYPE_FUSION) == SUMMON_TYPE_FUSION
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) then
  		return false
  	end
  	local loc = Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION)
  	return loc == LOCATION_MZONE and re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsSummonType(SUMMON_TYPE_SPECIAL) and Duel.IsChainNegatable(ev)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.distg(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.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) and Duel.Destroy(eg, REASON_EFFECT) > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.BreakEffect()
  			Duel.SendtoGrave(g, REASON_EFFECT)
  		end
  	end
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.thfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.thfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  	end
  end
  
  