name: Abyss
card_text: Target 1 "Abyss Actor" monster you control; if it destroys your opponent's monster by battle this turn, your opponent banishes 3 monsters from their Extra Deck (their choice). If this Set card in its owner's control is destroyed by an opponent's card effect, and you have a face-up "Abyss Actor" Pendulum Monster in your Extra Deck: You can look at your opponent's Extra Deck, also banish 1 monster from their Extra Deck. You can only use this effect of "Abyss Script - Fire Dragon's Lair" once per turn.
external_ids: local SETCARD_ID_0 = 0x10ec --Abyss
  
lua: local SETCARD_ID_0 = 0x10ec --Abyss
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--destroyed
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_REMOVE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_DESTROYED)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.rmcon2)
  	e2:SetTarget(s.rmtg2)
  	e2:SetOperation(s.rmop2)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		tc:RegisterFlagEffect(id, RESET_EVENT + 0x1220000 + RESET_PHASE + PHASE_END, EFFECT_FLAG_CLIENT_HINT, 1, 0, aux.Stringid(id, 0))
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_BATTLE_DESTROYING)
  		e1:SetLabelObject(tc)
  		e1:SetCondition(s.rmcon1)
  		e1:SetOperation(s.rmop1)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.rmcon1(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	return eg:IsContains(tc) and tc:GetFlagEffect(id) ~= 0
  end
  function s.rmop1(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_EXTRA, nil)
  	if g:GetCount() < 3 then
  		return
  	end
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_REMOVE)
  	local mg = g:Select(1 - tp, 3, 3, nil)
  	if mg:GetCount() > 0 then
  		Duel.Remove(mg, POS_FACEUP, REASON_EFFECT)
  	end
  end
  function s.rmcon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return rp == 1 - tp
  		and c:IsReason(REASON_EFFECT)
  		and c:IsPreviousControler(tp)
  		and c:IsPreviousLocation(LOCATION_ONFIELD)
  		and c:IsPreviousPosition(POS_FACEDOWN)
  		and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil)
  end
  function s.rmtg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, 0, LOCATION_EXTRA, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 0, 0)
  end
  function s.rmop2(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_EXTRA)
  	if g:GetCount() == 0 then
  		return
  	end
  	Duel.ConfirmCards(tp, g, true)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local mg = g:FilterSelect(tp, Card.IsAbleToRemove, 1, 1, nil)
  	if mg:GetCount() > 0 then
  		Duel.Remove(mg, POS_FACEUP, REASON_EFFECT)
  	end
  	Duel.ShuffleExtra(1 - tp)
  end
  
  
source_text: Abyss
  Target 1 "Abyss Actor" monster you control; if it destroys your opponent's monster by battle this turn, your opponent banishes 3 monsters from their Extra Deck (their choice). If this Set card in its owner's control is destroyed by an opponent's card effect, and you have a face-up "Abyss Actor" Pendulum Monster in your Extra Deck: You can look at your opponent's Extra Deck, also banish 1 monster from their Extra Deck. You can only use this effect of "Abyss Script - Fire Dragon's Lair" once per turn.
target_text: -- Abyss
  local SETCARD_ID_0 = 0x10ec --Abyss
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--destroyed
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_REMOVE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_DESTROYED)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.rmcon2)
  	e2:SetTarget(s.rmtg2)
  	e2:SetOperation(s.rmop2)
  	c:RegisterEffect(e2)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		tc:RegisterFlagEffect(id, RESET_EVENT + 0x1220000 + RESET_PHASE + PHASE_END, EFFECT_FLAG_CLIENT_HINT, 1, 0, aux.Stringid(id, 0))
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_BATTLE_DESTROYING)
  		e1:SetLabelObject(tc)
  		e1:SetCondition(s.rmcon1)
  		e1:SetOperation(s.rmop1)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.rmcon1(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetLabelObject()
  	return eg:IsContains(tc) and tc:GetFlagEffect(id) ~= 0
  end
  function s.rmop1(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsAbleToRemove, tp, 0, LOCATION_EXTRA, nil)
  	if g:GetCount() < 3 then
  		return
  	end
  	Duel.Hint(HINT_CARD, 0, id)
  	Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_REMOVE)
  	local mg = g:Select(1 - tp, 3, 3, nil)
  	if mg:GetCount() > 0 then
  		Duel.Remove(mg, POS_FACEUP, REASON_EFFECT)
  	end
  end
  function s.rmcon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return rp == 1 - tp
  		and c:IsReason(REASON_EFFECT)
  		and c:IsPreviousControler(tp)
  		and c:IsPreviousLocation(LOCATION_ONFIELD)
  		and c:IsPreviousPosition(POS_FACEDOWN)
  		and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil)
  end
  function s.rmtg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, 0, LOCATION_EXTRA, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, 0, 0)
  end
  function s.rmop2(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_EXTRA)
  	if g:GetCount() == 0 then
  		return
  	end
  	Duel.ConfirmCards(tp, g, true)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local mg = g:FilterSelect(tp, Card.IsAbleToRemove, 1, 1, nil)
  	if mg:GetCount() > 0 then
  		Duel.Remove(mg, POS_FACEUP, REASON_EFFECT)
  	end
  	Duel.ShuffleExtra(1 - tp)
  end
  
  