Blackbird
When a monster your opponent controls activates its effect: You can send 1 face-up "Blackwing" monster you control to the GY; negate the activation, and if you do, destroy it, then, you can Special Summon 1 "Black-Winged Dragon" from your Extra Deck. If you control a "Blackwing" Synchro Monster or "Black-Winged Dragon", you can activate this card from your hand.
local CARD_ID_0 = 9012916 --Black-Winged Dragon
local SETCARD_ID_0 = 0x33 --Blackwing

local CARD_ID_0 = 9012916 --Black-Winged Dragon
local SETCARD_ID_0 = 0x33 --Blackwing
local s, id, o = GetID()
function s.initial_effect(c)
	aux.AddCodeList(c, CARD_ID_0)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_NEGATE + CATEGORY_DESTROY)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_CHAINING)
	e1:SetCondition(s.condition)
	e1:SetCost(s.cost)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
	--act in hand
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 1))
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetCode(EFFECT_TRAP_ACT_IN_HAND)
	e2:SetCondition(s.handcon)
	c:RegisterEffect(e2)
end
function s.condition(e, tp, eg, ep, ev, re, r, rp)
	local loc = Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION)
	return ep ~= tp and loc == LOCATION_MZONE and re:IsActiveType(TYPE_MONSTER) and Duel.IsChainNegatable(ev)
end
function s.discfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGraveAsCost()
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(s.discfilter, tp, LOCATION_MZONE, 0, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
	local g = Duel.SelectMatchingCard(tp, s.discfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
	Duel.SendtoGrave(g, REASON_COST)
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.sfilter(c, e, tp)
	return c:IsCode(CARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
end
function s.activate(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
		local sc = Duel.GetFirstMatchingCard(s.sfilter, tp, LOCATION_EXTRA, 0, nil, e, tp)
		if sc and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
			Duel.BreakEffect()
			Duel.SpecialSummon(sc, 0, tp, tp, false, false, POS_FACEUP)
		end
	end
end
function s.cfilter(c)
	return c:IsFaceup() and ((c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SYNCHRO)) or c:IsCode(CARD_ID_0))
end
function s.handcon(e)
	return Duel.IsExistingMatchingCard(s.cfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
end


Blackbird
When a monster your opponent controls activates its effect: You can send 1 face-up "Blackwing" monster you control to the GY; negate the activation, and if you do, destroy it, then, you can Special Summon 1 "Black-Winged Dragon" from your Extra Deck. If you control a "Blackwing" Synchro Monster or "Black-Winged Dragon", you can activate this card from your hand.
-- Blackbird
local CARD_ID_0 = 9012916 --Black-Winged Dragon
local SETCARD_ID_0 = 0x33 --Blackwing
local s, id, o = GetID()
function s.initial_effect(c)
	aux.AddCodeList(c, CARD_ID_0)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_NEGATE + CATEGORY_DESTROY)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_CHAINING)
	e1:SetCondition(s.condition)
	e1:SetCost(s.cost)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
	--act in hand
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 1))
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetCode(EFFECT_TRAP_ACT_IN_HAND)
	e2:SetCondition(s.handcon)
	c:RegisterEffect(e2)
end
function s.condition(e, tp, eg, ep, ev, re, r, rp)
	local loc = Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION)
	return ep ~= tp and loc == LOCATION_MZONE and re:IsActiveType(TYPE_MONSTER) and Duel.IsChainNegatable(ev)
end
function s.discfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToGraveAsCost()
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(s.discfilter, tp, LOCATION_MZONE, 0, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
	local g = Duel.SelectMatchingCard(tp, s.discfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
	Duel.SendtoGrave(g, REASON_COST)
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.sfilter(c, e, tp)
	return c:IsCode(CARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
end
function s.activate(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
		local sc = Duel.GetFirstMatchingCard(s.sfilter, tp, LOCATION_EXTRA, 0, nil, e, tp)
		if sc and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
			Duel.BreakEffect()
			Duel.SpecialSummon(sc, 0, tp, tp, false, false, POS_FACEUP)
		end
	end
end
function s.cfilter(c)
	return c:IsFaceup() and ((c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_SYNCHRO)) or c:IsCode(CARD_ID_0))
end
function s.handcon(e)
	return Duel.IsExistingMatchingCard(s.cfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
end

