Mathmech
You can Tribute 1 Cyberse monster you control in the Extra Monster Zone; Special Summon up to 1 Level 4 Cyberse monster each from your hand and GY. If this card is sent to the GY: You can target 1 face-up monster on the field; its ATK becomes halved until the end of this turn. You can only use each effect of "Mathmech Division" once 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)
	--spsummon
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1, id)
	e1:SetCost(s.cost)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
	--half attack
	local e2 = Effect.CreateEffect(c)
	e2:SetCategory(CATEGORY_ATKCHANGE)
	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
	e2:SetCode(EVENT_TO_GRAVE)
	e2:SetCountLimit(1, id + 1)
	e2:SetTarget(s.atktg)
	e2:SetOperation(s.atkop)
	c:RegisterEffect(e2)
end
function s.costfilter(c, tp)
	return c:IsRace(RACE_CYBERSE) and Duel.GetMZoneCount(tp, c, tp) > 0 and c:GetSequence() >= 5
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.CheckReleaseGroup(tp, s.costfilter, 1, nil, tp)
	end
	local g = Duel.SelectReleaseGroup(tp, s.costfilter, 1, 1, nil, tp)
	Duel.Release(g, REASON_COST)
end
function s.filter(c, e, tp)
	return c:IsRace(RACE_CYBERSE) and c:IsLevel(4) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
end
function s.fselect(g)
	return g:GetClassCount(Card.GetLocation) == g:GetCount()
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil, e, tp)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local ft = math.min((Duel.GetLocationCount(tp, LOCATION_MZONE)), 2)
	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter), tp, LOCATION_HAND + LOCATION_GRAVE, 0, nil, e, tp)
	if ft <= 0 or g:GetCount() == 0 then
		return
	end
	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
		ft = 1
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local sg = g:SelectSubGroup(tp, s.fselect, false, 1, ft)
	if sg and sg:GetCount() > 0 then
		Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
	end
end
function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup()
	end
	if chk == 0 then
		return Duel.IsExistingTarget(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
	Duel.SelectTarget(tp, Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
end
function s.atkop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
		local atk = tc:GetAttack()
		local e1 = Effect.CreateEffect(e:GetHandler())
		e1:SetType(EFFECT_TYPE_SINGLE)
		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
		e1:SetValue(math.ceil(atk / 2))
		tc:RegisterEffect(e1)
	end
end


Mathmech
You can Tribute 1 Cyberse monster you control in the Extra Monster Zone; Special Summon up to 1 Level 4 Cyberse monster each from your hand and GY. If this card is sent to the GY: You can target 1 face-up monster on the field; its ATK becomes halved until the end of this turn. You can only use each effect of "Mathmech Division" once per turn.
-- Mathmech
local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local s, id, o = GetID()
function s.initial_effect(c)
	--spsummon
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1, id)
	e1:SetCost(s.cost)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
	--half attack
	local e2 = Effect.CreateEffect(c)
	e2:SetCategory(CATEGORY_ATKCHANGE)
	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
	e2:SetCode(EVENT_TO_GRAVE)
	e2:SetCountLimit(1, id + 1)
	e2:SetTarget(s.atktg)
	e2:SetOperation(s.atkop)
	c:RegisterEffect(e2)
end
function s.costfilter(c, tp)
	return c:IsRace(RACE_CYBERSE) and Duel.GetMZoneCount(tp, c, tp) > 0 and c:GetSequence() >= 5
end
function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.CheckReleaseGroup(tp, s.costfilter, 1, nil, tp)
	end
	local g = Duel.SelectReleaseGroup(tp, s.costfilter, 1, 1, nil, tp)
	Duel.Release(g, REASON_COST)
end
function s.filter(c, e, tp)
	return c:IsRace(RACE_CYBERSE) and c:IsLevel(4) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
end
function s.fselect(g)
	return g:GetClassCount(Card.GetLocation) == g:GetCount()
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil, e, tp)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local ft = math.min((Duel.GetLocationCount(tp, LOCATION_MZONE)), 2)
	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter), tp, LOCATION_HAND + LOCATION_GRAVE, 0, nil, e, tp)
	if ft <= 0 or g:GetCount() == 0 then
		return
	end
	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
		ft = 1
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local sg = g:SelectSubGroup(tp, s.fselect, false, 1, ft)
	if sg and sg:GetCount() > 0 then
		Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
	end
end
function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup()
	end
	if chk == 0 then
		return Duel.IsExistingTarget(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
	Duel.SelectTarget(tp, Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
end
function s.atkop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
		local atk = tc:GetAttack()
		local e1 = Effect.CreateEffect(e:GetHandler())
		e1:SetType(EFFECT_TYPE_SINGLE)
		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
		e1:SetCode(EFFECT_SET_ATTACK_FINAL)
		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
		e1:SetValue(math.ceil(atk / 2))
		tc:RegisterEffect(e1)
	end
end

