name: ALERT!
card_text: (This card is always treated as a "Rescue-ACE" card.)
  Add 1 "Rescue-ACE" monster from your GY to your hand, or if you control "Rescue-ACE Hydrant", you can add 1 "Rescue-ACE" monster from your Deck to your hand instead. You can only activate 1 "ALERT!" per turn.
external_ids: local CARD_ID_0 = 37617348 --Rescue-ACE Hydrant
  local SETCARD_ID_0 = 0x18b --Rescue-ACE
  
lua: local CARD_ID_0 = 37617348 --Rescue-ACE Hydrant
  local SETCARD_ID_0 = 0x18b --Rescue-ACE
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_GRAVE_ACTION)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.checkfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsFaceup()
  end
  function s.thfilter(c, check)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() and (c:IsLocation(LOCATION_GRAVE) or check)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local check = Duel.IsExistingMatchingCard(s.checkfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_GRAVE + LOCATION_DECK, 0, 1, nil, check)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local check = Duel.IsExistingMatchingCard(s.checkfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.thfilter), tp, LOCATION_GRAVE + LOCATION_DECK, 0, 1, 1, nil, check)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  
source_text: ALERT!
  (This card is always treated as a "Rescue-ACE" card.)
  Add 1 "Rescue-ACE" monster from your GY to your hand, or if you control "Rescue-ACE Hydrant", you can add 1 "Rescue-ACE" monster from your Deck to your hand instead. You can only activate 1 "ALERT!" per turn.
target_text: -- ALERT!
  local CARD_ID_0 = 37617348 --Rescue-ACE Hydrant
  local SETCARD_ID_0 = 0x18b --Rescue-ACE
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_GRAVE_ACTION)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.checkfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsFaceup()
  end
  function s.thfilter(c, check)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() and (c:IsLocation(LOCATION_GRAVE) or check)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local check = Duel.IsExistingMatchingCard(s.checkfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_GRAVE + LOCATION_DECK, 0, 1, nil, check)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local check = Duel.IsExistingMatchingCard(s.checkfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.thfilter), tp, LOCATION_GRAVE + LOCATION_DECK, 0, 1, 1, nil, check)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  