name: Frightfur
card_text: When an opponent's Spell/Trap Card, or monster effect, is activated that targets a "Frightfur" monster(s) you control: Negate the activation, and if you do, destroy that card, then you can send 1 of the targeted "Frightfur" monsters to the Graveyard, and if you do, Special Summon 1 Level 8 or higher "Frightfur" Fusion Monster from your Extra Deck. (This Special Summon is treated as a Fusion Summon.) During your next End Phase, banish the monster Special Summoned by this effect.
external_ids: local SETCARD_ID_0 = 0xad --Frightfur
  
lua: local SETCARD_ID_0 = 0xad --Frightfur
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_NEGATE + CATEGORY_DESTROY + CATEGORY_FUSION_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, tp)
  	return c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	if rp == tp or 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.filter, 1, nil, tp) and Duel.IsChainNegatable(ev) and (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE))
  end
  function s.target(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.tgfilter(c, e, tp)
  	return c:IsAbleToGrave() and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, c)
  end
  function s.spfilter(c, e, tp, tc)
  	return c:IsType(TYPE_FUSION)
  		and c:IsLevelAbove(8)
  		and c:IsSetCard(SETCARD_ID_0)
  		and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_FUSION, tp, false, false)
  		and c:CheckFusionMaterial()
  		and Duel.GetLocationCountFromEx(tp, tp, tc, c) > 0
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS):Filter(s.filter, nil, tp)
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) and Duel.Destroy(eg, REASON_EFFECT) ~= 0 then
  		local tg = g:Filter(Card.IsRelateToEffect, nil, re)
  		if tg:IsExists(s.tgfilter, 1, nil, e, tp) and aux.MustMaterialCheck(nil, tp, EFFECT_MUST_BE_FMATERIAL) and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  			local tc = tg:FilterSelect(tp, s.tgfilter, 1, 1, nil, e, tp):GetFirst()
  			if Duel.SendtoGrave(tc, REASON_EFFECT) == 0 or not tc:IsLocation(LOCATION_GRAVE) then
  				return
  			end
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local sc = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, nil):GetFirst()
  			sc:SetMaterial(nil)
  			if Duel.SpecialSummonStep(sc, SUMMON_TYPE_FUSION, tp, tp, false, false, POS_FACEUP) then
  				local c = e:GetHandler()
  				local fid = c:GetFieldID()
  				local e1 = Effect.CreateEffect(c)
  				e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  				e1:SetCode(EVENT_PHASE + PHASE_END)
  				e1:SetCountLimit(1)
  				e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  				e1:SetLabelObject(sc)
  				e1:SetCondition(s.rmcon)
  				e1:SetOperation(s.rmop)
  				if Duel.GetTurnPlayer() == tp and Duel.GetCurrentPhase() == PHASE_END then
  					e1:SetLabel(Duel.GetTurnCount(), fid)
  					e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 2)
  					sc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_SELF_TURN, 0, 2, fid)
  				else
  					e1:SetLabel(0, fid)
  					e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN)
  					sc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_SELF_TURN, 0, 1, fid)
  				end
  				Duel.RegisterEffect(e1, tp)
  				Duel.SpecialSummonComplete()
  				sc:CompleteProcedure()
  			end
  		end
  	end
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	local turn, fid = e:GetLabel()
  	return Duel.GetTurnPlayer() == tp and Duel.GetTurnCount() ~= turn and tc:GetFlagEffectLabel(id) == fid
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
  end
  
  
source_text: Frightfur
  When an opponent's Spell/Trap Card, or monster effect, is activated that targets a "Frightfur" monster(s) you control: Negate the activation, and if you do, destroy that card, then you can send 1 of the targeted "Frightfur" monsters to the Graveyard, and if you do, Special Summon 1 Level 8 or higher "Frightfur" Fusion Monster from your Extra Deck. (This Special Summon is treated as a Fusion Summon.) During your next End Phase, banish the monster Special Summoned by this effect.
target_text: -- Frightfur
  local SETCARD_ID_0 = 0xad --Frightfur
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_NEGATE + CATEGORY_DESTROY + CATEGORY_FUSION_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, tp)
  	return c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:IsSetCard(SETCARD_ID_0)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	if rp == tp or 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.filter, 1, nil, tp) and Duel.IsChainNegatable(ev) and (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE))
  end
  function s.target(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.tgfilter(c, e, tp)
  	return c:IsAbleToGrave() and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, c)
  end
  function s.spfilter(c, e, tp, tc)
  	return c:IsType(TYPE_FUSION)
  		and c:IsLevelAbove(8)
  		and c:IsSetCard(SETCARD_ID_0)
  		and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_FUSION, tp, false, false)
  		and c:CheckFusionMaterial()
  		and Duel.GetLocationCountFromEx(tp, tp, tc, c) > 0
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS):Filter(s.filter, nil, tp)
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) and Duel.Destroy(eg, REASON_EFFECT) ~= 0 then
  		local tg = g:Filter(Card.IsRelateToEffect, nil, re)
  		if tg:IsExists(s.tgfilter, 1, nil, e, tp) and aux.MustMaterialCheck(nil, tp, EFFECT_MUST_BE_FMATERIAL) and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  			local tc = tg:FilterSelect(tp, s.tgfilter, 1, 1, nil, e, tp):GetFirst()
  			if Duel.SendtoGrave(tc, REASON_EFFECT) == 0 or not tc:IsLocation(LOCATION_GRAVE) then
  				return
  			end
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local sc = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, nil):GetFirst()
  			sc:SetMaterial(nil)
  			if Duel.SpecialSummonStep(sc, SUMMON_TYPE_FUSION, tp, tp, false, false, POS_FACEUP) then
  				local c = e:GetHandler()
  				local fid = c:GetFieldID()
  				local e1 = Effect.CreateEffect(c)
  				e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  				e1:SetCode(EVENT_PHASE + PHASE_END)
  				e1:SetCountLimit(1)
  				e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  				e1:SetLabelObject(sc)
  				e1:SetCondition(s.rmcon)
  				e1:SetOperation(s.rmop)
  				if Duel.GetTurnPlayer() == tp and Duel.GetCurrentPhase() == PHASE_END then
  					e1:SetLabel(Duel.GetTurnCount(), fid)
  					e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 2)
  					sc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_SELF_TURN, 0, 2, fid)
  				else
  					e1:SetLabel(0, fid)
  					e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN)
  					sc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END + RESET_SELF_TURN, 0, 1, fid)
  				end
  				Duel.RegisterEffect(e1, tp)
  				Duel.SpecialSummonComplete()
  				sc:CompleteProcedure()
  			end
  		end
  	end
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	local turn, fid = e:GetLabel()
  	return Duel.GetTurnPlayer() == tp and Duel.GetTurnCount() ~= turn and tc:GetFlagEffectLabel(id) == fid
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
  end
  
  