Bujin
Cannot be Normal Summoned/Set. Must first be Special Summoned (from your hand) by banishing 1 "Bujin" monster from your Graveyard, except "Bujin Hirume". If this card, which was Summoned this way, is destroyed by your opponent's card (by battle or card effect), and sent from your side of the field to your Graveyard, and both players have a hand: You can discard 1 card, then your opponent discards 1 card. You can only control 1 "Bujin Hirume".
local SETCARD_ID_0 = 0x88 --Bujin

local SETCARD_ID_0 = 0x88 --Bujin
local s, id, o = GetID()
function s.initial_effect(c)
	c:SetUniqueOnField(1, 0, id)
	c:EnableReviveLimit()
	--special summon
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetCode(EFFECT_SPSUMMON_PROC)
	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
	e1:SetRange(LOCATION_HAND)
	e1:SetValue(SUMMON_VALUE_SELF)
	e1:SetCondition(s.spcon)
	e1:SetTarget(s.sptg)
	e1:SetOperation(s.spop)
	c:RegisterEffect(e1)
	--discard
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 1))
	e2:SetCategory(CATEGORY_HANDES)
	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_DAMAGE_STEP)
	e2:SetCode(EVENT_TO_GRAVE)
	e2:SetCondition(s.hdcon)
	e2:SetTarget(s.hdtg)
	e2:SetOperation(s.hdop)
	c:RegisterEffect(e2)
end
function s.spfilter(c)
	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and not c:IsCode(id) and c:IsAbleToRemoveAsCost()
end
function s.spcon(e, c)
	if c == nil then
		return true
	end
	local tp = c:GetControler()
	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_GRAVE, 0, nil)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
	local tc = g:SelectUnselect(nil, tp, false, true, 1, 1)
	if tc then
		e:SetLabelObject(tc)
		return true
	else
		return false
	end
end
function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
	local g = e:GetLabelObject()
	Duel.Remove(g, POS_FACEUP, REASON_SPSUMMON)
end
function s.hdcon(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	return c:GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF and rp == 1 - tp and c:IsReason(REASON_DESTROY) and c:IsPreviousLocation(LOCATION_MZONE) and c:IsPreviousControler(tp)
end
function s.hdtg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) > 0 and Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND) > 0
	end
	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, PLAYER_ALL, 1)
end
function s.hdop(e, tp, eg, ep, ev, re, r, rp)
	if Duel.DiscardHand(tp, nil, 1, 1, REASON_EFFECT + REASON_DISCARD) ~= 0 then
		Duel.BreakEffect()
		Duel.DiscardHand(1 - tp, nil, 1, 1, REASON_EFFECT + REASON_DISCARD)
	end
end


Bujin
Cannot be Normal Summoned/Set. Must first be Special Summoned (from your hand) by banishing 1 "Bujin" monster from your Graveyard, except "Bujin Hirume". If this card, which was Summoned this way, is destroyed by your opponent's card (by battle or card effect), and sent from your side of the field to your Graveyard, and both players have a hand: You can discard 1 card, then your opponent discards 1 card. You can only control 1 "Bujin Hirume".
-- Bujin
local SETCARD_ID_0 = 0x88 --Bujin
local s, id, o = GetID()
function s.initial_effect(c)
	c:SetUniqueOnField(1, 0, id)
	c:EnableReviveLimit()
	--special summon
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetCode(EFFECT_SPSUMMON_PROC)
	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
	e1:SetRange(LOCATION_HAND)
	e1:SetValue(SUMMON_VALUE_SELF)
	e1:SetCondition(s.spcon)
	e1:SetTarget(s.sptg)
	e1:SetOperation(s.spop)
	c:RegisterEffect(e1)
	--discard
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 1))
	e2:SetCategory(CATEGORY_HANDES)
	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_DAMAGE_STEP)
	e2:SetCode(EVENT_TO_GRAVE)
	e2:SetCondition(s.hdcon)
	e2:SetTarget(s.hdtg)
	e2:SetOperation(s.hdop)
	c:RegisterEffect(e2)
end
function s.spfilter(c)
	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and not c:IsCode(id) and c:IsAbleToRemoveAsCost()
end
function s.spcon(e, c)
	if c == nil then
		return true
	end
	local tp = c:GetControler()
	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_GRAVE, 0, nil)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
	local tc = g:SelectUnselect(nil, tp, false, true, 1, 1)
	if tc then
		e:SetLabelObject(tc)
		return true
	else
		return false
	end
end
function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
	local g = e:GetLabelObject()
	Duel.Remove(g, POS_FACEUP, REASON_SPSUMMON)
end
function s.hdcon(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	return c:GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF and rp == 1 - tp and c:IsReason(REASON_DESTROY) and c:IsPreviousLocation(LOCATION_MZONE) and c:IsPreviousControler(tp)
end
function s.hdtg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) > 0 and Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND) > 0
	end
	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, PLAYER_ALL, 1)
end
function s.hdop(e, tp, eg, ep, ev, re, r, rp)
	if Duel.DiscardHand(tp, nil, 1, 1, REASON_EFFECT + REASON_DISCARD) ~= 0 then
		Duel.BreakEffect()
		Duel.DiscardHand(1 - tp, nil, 1, 1, REASON_EFFECT + REASON_DISCARD)
	end
end

