name: Rescue-ACE
card_text: During your Main Phase: You can choose the 1 Effect Monster your opponent controls with the highest ATK (your choice, if tied), and neither player can activate that monster's effects on the field this turn. When your opponent activates a monster effect on the field (Quick Effect): You can Tribute this card from your hand or face-up field; Special Summon 1 Machine "Rescue-ACE" monster from your Deck. You can only use each effect of "Rescue-ACE Impulse" once per turn.
external_ids: local SETCARD_ID_0 = 0x18b --Rescue-ACE
  
lua: local SETCARD_ID_0 = 0x18b --Rescue-ACE
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.ntg)
  	e1:SetOperation(s.nop)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_HAND + LOCATION_MZONE)
  	e2:SetCountLimit(1, id + o)
  	e2:SetCondition(s.spcon)
  	e2:SetCost(s.spcost)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.nfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_EFFECT)
  end
  function s.ntg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.nfilter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  end
  function s.nop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.nfilter, tp, 0, LOCATION_MZONE, nil)
  	if g:GetCount() > 0 then
  		local tg = g:GetMaxGroup(Card.GetAttack)
  		local tc
  		if tg:GetCount() > 1 then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  			local sg = tg:Select(tp, 1, 1, nil)
  			Duel.HintSelection(sg)
  			tc = sg:GetFirst()
  		else
  			Duel.HintSelection(tg)
  			tc = tg:GetFirst()
  		end
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CANNOT_TRIGGER)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1, true)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and re:IsActiveType(TYPE_MONSTER) and re:GetActivateLocation() == LOCATION_MZONE
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsReleasable() and Duel.GetMZoneCount(tp, c) > 0
  	end
  	Duel.Release(c, REASON_COST)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsRace(RACE_MACHINE) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetMZoneCount(tp) > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  		if g:GetCount() > 0 then
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  
source_text: Rescue-ACE
  During your Main Phase: You can choose the 1 Effect Monster your opponent controls with the highest ATK (your choice, if tied), and neither player can activate that monster's effects on the field this turn. When your opponent activates a monster effect on the field (Quick Effect): You can Tribute this card from your hand or face-up field; Special Summon 1 Machine "Rescue-ACE" monster from your Deck. You can only use each effect of "Rescue-ACE Impulse" once per turn.
target_text: -- Rescue-ACE
  local SETCARD_ID_0 = 0x18b --Rescue-ACE
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.ntg)
  	e1:SetOperation(s.nop)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_HAND + LOCATION_MZONE)
  	e2:SetCountLimit(1, id + o)
  	e2:SetCondition(s.spcon)
  	e2:SetCost(s.spcost)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.nfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_EFFECT)
  end
  function s.ntg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.nfilter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  end
  function s.nop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.nfilter, tp, 0, LOCATION_MZONE, nil)
  	if g:GetCount() > 0 then
  		local tg = g:GetMaxGroup(Card.GetAttack)
  		local tc
  		if tg:GetCount() > 1 then
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  			local sg = tg:Select(tp, 1, 1, nil)
  			Duel.HintSelection(sg)
  			tc = sg:GetFirst()
  		else
  			Duel.HintSelection(tg)
  			tc = tg:GetFirst()
  		end
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CANNOT_TRIGGER)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1, true)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and re:IsActiveType(TYPE_MONSTER) and re:GetActivateLocation() == LOCATION_MZONE
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return c:IsReleasable() and Duel.GetMZoneCount(tp, c) > 0
  	end
  	Duel.Release(c, REASON_COST)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsRace(RACE_MACHINE) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetMZoneCount(tp) > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  		if g:GetCount() > 0 then
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  