name: Lockout
card_text: When an opponent's monster declares a direct attack: You can Special Summon this card from your hand in Attack Position, and if you do, it cannot be destroyed by battle this turn. When an effect of a monster your opponent controls is activated that targets 1 Cyberse monster you control (and no other cards) (Quick Effect): You can negate the effects of both that Cyberse monster you control and that opponent's monster until the end of this turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	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_ATTACK_ANNOUNCE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--disable
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DISABLE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.discon)
  	e2:SetTarget(s.distg)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker():GetControler() ~= tp and Duel.GetAttackTarget() == nil
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_ATTACK)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP_ATTACK) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	if rp == tp or not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return false
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	if not g or g:GetCount() ~= 1 then
  		return false
  	end
  	local tc = g:GetFirst()
  	e:SetLabelObject(tc)
  	return re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsLocation(LOCATION_MZONE) and tc:IsControler(tp) and tc:IsFaceup() and tc:IsRace(RACE_CYBERSE) and tc:IsLocation(LOCATION_MZONE)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local tc = e:GetLabelObject()
  	if chk == 0 then
  		return true
  	end
  	local g = Group.FromCards(tc, re:GetHandler())
  	Duel.SetTargetCard(g)
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE, g, 2, 0, 0)
  end
  function s.disfilter(c, e)
  	return c:IsFaceup() and c:IsRelateToEffect(e)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(s.disfilter, nil, e)
  	if g:GetCount() < 2 then
  		return
  	end
  	local rc = re:GetHandler()
  	local sc = g:GetFirst()
  	if sc == rc then
  		sc = g:GetNext()
  	end
  	if sc:IsControler(tp) and sc:IsRace(RACE_CYBERSE) and rc:IsControler(1 - tp) then
  		sc = g:GetFirst()
  		while sc do
  			Duel.NegateRelatedChain(sc, RESET_TURN_SET)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			sc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_DISABLE_EFFECT)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			sc:RegisterEffect(e2)
  			sc = g:GetNext()
  		end
  	end
  end
  
  
source_text: Lockout
  When an opponent's monster declares a direct attack: You can Special Summon this card from your hand in Attack Position, and if you do, it cannot be destroyed by battle this turn. When an effect of a monster your opponent controls is activated that targets 1 Cyberse monster you control (and no other cards) (Quick Effect): You can negate the effects of both that Cyberse monster you control and that opponent's monster until the end of this turn.
target_text: -- Lockout
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	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_ATTACK_ANNOUNCE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--disable
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DISABLE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.discon)
  	e2:SetTarget(s.distg)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker():GetControler() ~= tp and Duel.GetAttackTarget() == nil
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_ATTACK)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP_ATTACK) ~= 0 then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	if rp == tp or not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
  		return false
  	end
  	local g = Duel.GetChainInfo(ev, CHAININFO_TARGET_CARDS)
  	if not g or g:GetCount() ~= 1 then
  		return false
  	end
  	local tc = g:GetFirst()
  	e:SetLabelObject(tc)
  	return re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsLocation(LOCATION_MZONE) and tc:IsControler(tp) and tc:IsFaceup() and tc:IsRace(RACE_CYBERSE) and tc:IsLocation(LOCATION_MZONE)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local tc = e:GetLabelObject()
  	if chk == 0 then
  		return true
  	end
  	local g = Group.FromCards(tc, re:GetHandler())
  	Duel.SetTargetCard(g)
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE, g, 2, 0, 0)
  end
  function s.disfilter(c, e)
  	return c:IsFaceup() and c:IsRelateToEffect(e)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(s.disfilter, nil, e)
  	if g:GetCount() < 2 then
  		return
  	end
  	local rc = re:GetHandler()
  	local sc = g:GetFirst()
  	if sc == rc then
  		sc = g:GetNext()
  	end
  	if sc:IsControler(tp) and sc:IsRace(RACE_CYBERSE) and rc:IsControler(1 - tp) then
  		sc = g:GetFirst()
  		while sc do
  			Duel.NegateRelatedChain(sc, RESET_TURN_SET)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			sc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_DISABLE_EFFECT)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			sc:RegisterEffect(e2)
  			sc = g:GetNext()
  		end
  	end
  end
  
  