name: Skydive
card_text: Target 1 "Elemental HERO" Fusion Monster you control; destroy as many monsters your opponent controls as possible, with ATK higher than that monster's, then inflict damage to your opponent equal to the highest original ATK among those destroyed monsters in the Graveyard (your choice, if tied). If a "Skyscraper" Field Spell Card is in your Field Zone, inflict damage to your opponent equal to the combined original ATK of those destroyed monsters in the Graveyard, instead.
external_ids: local SETCARD_ID_0 = 0xf6 --Skyscraper
  local SETCARD_ID_1 = 0x3008 --Elemental
  
lua: local SETCARD_ID_0 = 0xf6 --Skyscraper
  local SETCARD_ID_1 = 0x3008 --Elemental
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_FUSION) and Duel.IsExistingMatchingCard(s.desfilter, tp, 0, LOCATION_MZONE, 1, nil, c:GetAttack())
  end
  function s.desfilter(c, atk)
  	return c:IsFaceup() and c:GetAttack() > atk
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local tg = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil, tp)
  	local atk = tg:GetFirst():GetAttack()
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, 0, LOCATION_MZONE, nil, atk)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  	local fc = Duel.GetFieldCard(tp, LOCATION_FZONE, 0)
  	local dam = 0
  	if fc and s.ffilter(fc) then
  		dam = g:GetSum(Card.GetBaseAttack)
  	else
  		g, dam = g:GetMaxGroup(Card.GetBaseAttack)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 1, 1 - tp, dam)
  end
  function s.ffilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) or tc:IsFacedown() then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, 0, LOCATION_MZONE, nil, tc:GetAttack())
  	if g:GetCount() > 0 and Duel.Destroy(g, REASON_EFFECT) > 0 then
  		local og = Duel.GetOperatedGroup():Filter(Card.IsLocation, nil, LOCATION_GRAVE)
  		if og:GetCount() == 0 then
  			return
  		end
  		local fc = Duel.GetFieldCard(tp, LOCATION_FZONE, 0)
  		local dam = 0
  		if fc and s.ffilter(fc) then
  			dam = og:GetSum(Card.GetBaseAttack)
  		else
  			g, dam = og:GetMaxGroup(Card.GetBaseAttack)
  		end
  		if dam > 0 then
  			Duel.BreakEffect()
  			Duel.Damage(1 - tp, dam, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Skydive
  Target 1 "Elemental HERO" Fusion Monster you control; destroy as many monsters your opponent controls as possible, with ATK higher than that monster's, then inflict damage to your opponent equal to the highest original ATK among those destroyed monsters in the Graveyard (your choice, if tied). If a "Skyscraper" Field Spell Card is in your Field Zone, inflict damage to your opponent equal to the combined original ATK of those destroyed monsters in the Graveyard, instead.
target_text: -- Skydive
  local SETCARD_ID_0 = 0xf6 --Skyscraper
  local SETCARD_ID_1 = 0x3008 --Elemental
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_FUSION) and Duel.IsExistingMatchingCard(s.desfilter, tp, 0, LOCATION_MZONE, 1, nil, c:GetAttack())
  end
  function s.desfilter(c, atk)
  	return c:IsFaceup() and c:GetAttack() > atk
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local tg = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil, tp)
  	local atk = tg:GetFirst():GetAttack()
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, 0, LOCATION_MZONE, nil, atk)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  	local fc = Duel.GetFieldCard(tp, LOCATION_FZONE, 0)
  	local dam = 0
  	if fc and s.ffilter(fc) then
  		dam = g:GetSum(Card.GetBaseAttack)
  	else
  		g, dam = g:GetMaxGroup(Card.GetBaseAttack)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 1, 1 - tp, dam)
  end
  function s.ffilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) or tc:IsFacedown() then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, 0, LOCATION_MZONE, nil, tc:GetAttack())
  	if g:GetCount() > 0 and Duel.Destroy(g, REASON_EFFECT) > 0 then
  		local og = Duel.GetOperatedGroup():Filter(Card.IsLocation, nil, LOCATION_GRAVE)
  		if og:GetCount() == 0 then
  			return
  		end
  		local fc = Duel.GetFieldCard(tp, LOCATION_FZONE, 0)
  		local dam = 0
  		if fc and s.ffilter(fc) then
  			dam = og:GetSum(Card.GetBaseAttack)
  		else
  			g, dam = og:GetMaxGroup(Card.GetBaseAttack)
  		end
  		if dam > 0 then
  			Duel.BreakEffect()
  			Duel.Damage(1 - tp, dam, REASON_EFFECT)
  		end
  	end
  end
  
  