Mad
If a monster(s) is Special Summoned to your opponent's field (except during the Damage Step): You can Special Summon this card from your hand. During the End Phase: You can banish this card you control; take control of 1 monster your opponent controls with the lowest ATK (your choice, if tied), but while it is face-up on your field, it cannot activate its effects also you cannot Special Summon monsters from the Extra Deck, except Link Monsters. You can only use each effect of "Mad Hacker" once per turn.
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_FIELD + EFFECT_TYPE_TRIGGER_O)
	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
	e1:SetProperty(EFFECT_FLAG_DELAY)
	e1:SetRange(LOCATION_HAND)
	e1:SetCountLimit(1, id)
	e1:SetCondition(s.spcon)
	e1:SetTarget(s.sptg)
	e1:SetOperation(s.spop)
	c:RegisterEffect(e1)
	--control
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 1))
	e2:SetCategory(CATEGORY_CONTROL)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e2:SetCode(EVENT_PHASE + PHASE_END)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCountLimit(1, id + 1)
	e2:SetCost(aux.bfgcost)
	e2:SetTarget(s.cttg)
	e2:SetOperation(s.ctop)
	c:RegisterEffect(e2)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return eg:IsExists(Card.IsControler, 1, nil, 1 - tp)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	if c:IsRelateToEffect(e) then
		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
	end
end
function s.ctfilter(c)
	return c:IsFaceup() and c:IsControlerCanBeChanged()
end
function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		local c = e:GetHandler()
		local g = Duel.GetMatchingGroup(s.ctfilter, tp, 0, LOCATION_MZONE, nil)
		return g:GetCount() > 0 and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0
	end
	Duel.SetOperationInfo(0, CATEGORY_CONTROL, nil, 1, 1 - tp, LOCATION_MZONE)
end
function s.ctop(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetMatchingGroup(s.ctfilter, tp, 0, LOCATION_MZONE, nil)
	if g:GetCount() <= 0 or Duel.GetMZoneCount(tp, nil, tp, LOCATION_REASON_CONTROL) <= 0 then
		return
	end
	local tg = g:GetMinGroup(Card.GetAttack)
	local tc = tg:GetFirst()
	if tg:GetCount() > 1 then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
		local sg = tg:Select(tp, 1, 1, nil)
		Duel.HintSelection(sg)
		tc = sg:GetFirst()
	end
	Duel.GetControl(tc, tp)
	if not tc:IsControler(tp) then
		return
	end
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
	e1:SetRange(LOCATION_MZONE)
	e1:SetTargetRange(1, 0)
	e1:SetCondition(s.limitcon)
	e1:SetTarget(s.splimit)
	tc:RegisterEffect(e1)
	local e2 = Effect.CreateEffect(e:GetHandler())
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetCode(EFFECT_CANNOT_TRIGGER)
	e2:SetCondition(s.limitcon)
	e2:SetReset(RESET_EVENT + RESETS_STANDARD)
	tc:RegisterEffect(e2)
end
function s.limitcon(e)
	return e:GetHandler():IsControler(e:GetOwnerPlayer())
end
function s.splimit(e, c)
	return c:IsLocation(LOCATION_EXTRA) and not c:IsType(TYPE_LINK)
end


Mad
If a monster(s) is Special Summoned to your opponent's field (except during the Damage Step): You can Special Summon this card from your hand. During the End Phase: You can banish this card you control; take control of 1 monster your opponent controls with the lowest ATK (your choice, if tied), but while it is face-up on your field, it cannot activate its effects also you cannot Special Summon monsters from the Extra Deck, except Link Monsters. You can only use each effect of "Mad Hacker" once per turn.
-- Mad
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_FIELD + EFFECT_TYPE_TRIGGER_O)
	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
	e1:SetProperty(EFFECT_FLAG_DELAY)
	e1:SetRange(LOCATION_HAND)
	e1:SetCountLimit(1, id)
	e1:SetCondition(s.spcon)
	e1:SetTarget(s.sptg)
	e1:SetOperation(s.spop)
	c:RegisterEffect(e1)
	--control
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 1))
	e2:SetCategory(CATEGORY_CONTROL)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e2:SetCode(EVENT_PHASE + PHASE_END)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCountLimit(1, id + 1)
	e2:SetCost(aux.bfgcost)
	e2:SetTarget(s.cttg)
	e2:SetOperation(s.ctop)
	c:RegisterEffect(e2)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return eg:IsExists(Card.IsControler, 1, nil, 1 - tp)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	if c:IsRelateToEffect(e) then
		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
	end
end
function s.ctfilter(c)
	return c:IsFaceup() and c:IsControlerCanBeChanged()
end
function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		local c = e:GetHandler()
		local g = Duel.GetMatchingGroup(s.ctfilter, tp, 0, LOCATION_MZONE, nil)
		return g:GetCount() > 0 and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0
	end
	Duel.SetOperationInfo(0, CATEGORY_CONTROL, nil, 1, 1 - tp, LOCATION_MZONE)
end
function s.ctop(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetMatchingGroup(s.ctfilter, tp, 0, LOCATION_MZONE, nil)
	if g:GetCount() <= 0 or Duel.GetMZoneCount(tp, nil, tp, LOCATION_REASON_CONTROL) <= 0 then
		return
	end
	local tg = g:GetMinGroup(Card.GetAttack)
	local tc = tg:GetFirst()
	if tg:GetCount() > 1 then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
		local sg = tg:Select(tp, 1, 1, nil)
		Duel.HintSelection(sg)
		tc = sg:GetFirst()
	end
	Duel.GetControl(tc, tp)
	if not tc:IsControler(tp) then
		return
	end
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
	e1:SetRange(LOCATION_MZONE)
	e1:SetTargetRange(1, 0)
	e1:SetCondition(s.limitcon)
	e1:SetTarget(s.splimit)
	tc:RegisterEffect(e1)
	local e2 = Effect.CreateEffect(e:GetHandler())
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetCode(EFFECT_CANNOT_TRIGGER)
	e2:SetCondition(s.limitcon)
	e2:SetReset(RESET_EVENT + RESETS_STANDARD)
	tc:RegisterEffect(e2)
end
function s.limitcon(e)
	return e:GetHandler():IsControler(e:GetOwnerPlayer())
end
function s.splimit(e, c)
	return c:IsLocation(LOCATION_EXTRA) and not c:IsType(TYPE_LINK)
end

