Dances
When an opponent's monster declares a direct attack, while the combined ATK of all face-up monsters they control is 8000 or higher: Special Summon 3 monsters with different original names in Attack Position, 1 each from your hand, Deck, and GY. You can only activate 1 "Dances with Beasts" per turn.
local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon

local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local s, id, o = GetID()
function s.initial_effect(c)
	--activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetCondition(s.condition)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
end
function s.condition(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
	local atk = g:GetSum(Card.GetAttack)
	return Duel.GetAttacker():IsControler(1 - tp) and Duel.GetAttackTarget() == nil and atk >= 8000
end
function s.spfilter(c, e, tp)
	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_ATTACK)
end
function s.fcheck(c, g)
	return g:IsExists(Card.IsOriginalCodeRule, 1, c, c:GetOriginalCodeRule())
end
function s.fselect(g)
	return g:GetClassCount(Card.GetLocation) == g:GetCount() and not g:IsExists(s.fcheck, 1, nil, g)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE, 0, nil, e, tp)
	if chk == 0 then
		return g:CheckSubGroup(s.fselect, 3, 3)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 3, tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 3 or Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
		return
	end
	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE, 0, nil, e, tp)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local sg = g:SelectSubGroup(tp, s.fselect, false, 3, 3)
	if sg and sg:GetCount() == 3 then
		Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP_ATTACK)
	end
end


Dances
When an opponent's monster declares a direct attack, while the combined ATK of all face-up monsters they control is 8000 or higher: Special Summon 3 monsters with different original names in Attack Position, 1 each from your hand, Deck, and GY. You can only activate 1 "Dances with Beasts" per turn.
-- Dances
local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local s, id, o = GetID()
function s.initial_effect(c)
	--activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetCondition(s.condition)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
end
function s.condition(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, 0, LOCATION_MZONE, nil)
	local atk = g:GetSum(Card.GetAttack)
	return Duel.GetAttacker():IsControler(1 - tp) and Duel.GetAttackTarget() == nil and atk >= 8000
end
function s.spfilter(c, e, tp)
	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_ATTACK)
end
function s.fcheck(c, g)
	return g:IsExists(Card.IsOriginalCodeRule, 1, c, c:GetOriginalCodeRule())
end
function s.fselect(g)
	return g:GetClassCount(Card.GetLocation) == g:GetCount() and not g:IsExists(s.fcheck, 1, nil, g)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE, 0, nil, e, tp)
	if chk == 0 then
		return g:CheckSubGroup(s.fselect, 3, 3)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 3, tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 3 or Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
		return
	end
	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_DECK + LOCATION_GRAVE, 0, nil, e, tp)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local sg = g:SelectSubGroup(tp, s.fselect, false, 3, 3)
	if sg and sg:GetCount() == 3 then
		Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP_ATTACK)
	end
end

