name: Fiend
card_text: "Cave Dragon" + "Lesser Fiend"
  (This card is always treated as an "Archfiend" card.)
  A Fusion Summon of this card can only be done with the above Fusion Material Monsters. Negate the effects of Flip Effect Monsters. Negate any Trap effects that target this card on the field, and if you do, destroy that Trap Card.
external_ids: local CARD_ID_0 = 16475472 --Lesser Fiend
  local CARD_ID_1 = 93220472 --Cave Dragon
  
lua: local CARD_ID_0 = 16475472 --Lesser Fiend
  local CARD_ID_1 = 93220472 --Cave Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcCode2(c, CARD_ID_1, CARD_ID_0, false, false)
  	--disable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e1:SetTarget(s.distg)
  	c:RegisterEffect(e1)
  	--disable effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_SOLVING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  	--disable
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_DISABLE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e3:SetTarget(s.distg2)
  	c:RegisterEffect(e3)
  	--self destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_SELF_DESTROY)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e4:SetTarget(s.distg2)
  	c:RegisterEffect(e4)
  end
  function s.distg(e, c)
  	return c:IsType(TYPE_FLIP)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	if re:IsActiveType(TYPE_FLIP) then
  		Duel.NegateEffect(ev)
  	end
  	if e:GetHandler():IsRelateToEffect(re) and re:IsActiveType(TYPE_TRAP) and re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  		if g and g:IsContains(e:GetHandler()) then
  			Duel.NegateEffect(ev)
  		end
  	end
  end
  function s.distg2(e, c)
  	return c:GetCardTargetCount() > 0 and c:IsType(TYPE_TRAP) and c:GetCardTarget():IsContains(e:GetHandler())
  end
  
  
source_text: Fiend
  "Cave Dragon" + "Lesser Fiend"
  (This card is always treated as an "Archfiend" card.)
  A Fusion Summon of this card can only be done with the above Fusion Material Monsters. Negate the effects of Flip Effect Monsters. Negate any Trap effects that target this card on the field, and if you do, destroy that Trap Card.
target_text: -- Fiend
  local CARD_ID_0 = 16475472 --Lesser Fiend
  local CARD_ID_1 = 93220472 --Cave Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--fusion material
  	c:EnableReviveLimit()
  	aux.AddFusionProcCode2(c, CARD_ID_1, CARD_ID_0, false, false)
  	--disable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e1:SetTarget(s.distg)
  	c:RegisterEffect(e1)
  	--disable effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_SOLVING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  	--disable
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_DISABLE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e3:SetTarget(s.distg2)
  	c:RegisterEffect(e3)
  	--self destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_SELF_DESTROY)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e4:SetTarget(s.distg2)
  	c:RegisterEffect(e4)
  end
  function s.distg(e, c)
  	return c:IsType(TYPE_FLIP)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	if re:IsActiveType(TYPE_FLIP) then
  		Duel.NegateEffect(ev)
  	end
  	if e:GetHandler():IsRelateToEffect(re) and re:IsActiveType(TYPE_TRAP) and re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  		if g and g:IsContains(e:GetHandler()) then
  			Duel.NegateEffect(ev)
  		end
  	end
  end
  function s.distg2(e, c)
  	return c:GetCardTargetCount() > 0 and c:IsType(TYPE_TRAP) and c:GetCardTarget():IsContains(e:GetHandler())
  end
  
  