--Script - Reaching the Climax! --scripted by Rawstone local s,id=GetID() function s.initial_effect(c) aux.AddSetNameMonsterList(c,0x10ec) --banish GY local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetCategory(CATEGORY_REMOVE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(0,RELEVANT_TIMINGS) e1:SetTarget(s.target) e1:SetOperation(s.activate) c:RegisterEffect(e1) --SSummon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,3)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCode(EVENT_DESTROYED) e2:SetCondition(s.thcon) e2:SetTarget(s.thtg) e2:SetOperation(s.summon) c:RegisterEffect(e2) end function s.filter(c) return c:IsFaceup() and c:IsSetCard(0x10ec) and c:IsMonster(TYPE_PENDULUM) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) local g=Duel.GetMatchingGroup(s.filter,tp,LOCATION_MZONE,0,nil) if chk==0 then return #g>0 and Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,nil) end Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,1-tp,LOCATION_GRAVE) end function s.activate(e,tp,eg,ep,ev,re,r,rp) local ct=Duel.GetMatchingGroup(s.filter,tp,LOCATION_MZONE,0,nil):GetClassCount(Card.GetCode) if ct==0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(Card.IsAbleToRemove),tp,0,LOCATION_GRAVE,1,ct,nil) if #g>0 then Duel.HintSelection(g) if Duel.Remove(g,POS_FACEUP,REASON_EFFECT)>0 then local sg=Duel.GetMatchingGroup(s.filter,tp,LOCATION_MZONE,0,nil,tp) if sg:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(30003,1)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SELECT) local tg=sg:Select(tp,1,1,nil) if #tg>0 then Duel.HintSelection(tg) Duel.BreakEffect() local e2=Effect.CreateEffect(e:GetHandler()) e2:Desc(2) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_CLIENT_HINT) e2:SetRange(LOCATION_MZONE) e2:SetCode(EFFECT_IMMUNE_EFFECT) e2:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) e2:SetValue(s.efilter) tg:GetFirst():RegisterEffect(e2) end end end end end function s.efilter(e,re) return e:GetOwnerPlayer()~=re:GetOwnerPlayer() end function s.thcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsReason(REASON_EFFECT) and rp==1-tp and c:GetPreviousControler()==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.spfilter(c,e,tp) return c:IsSetCard(0x10ec) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP) end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE) end function s.summon(e,tp,eg,ep,ev,re,r,rp) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<=0 then return end if Duel.IsPlayerAffectedByEffect(tp,CARD_BLUEEYES_SPIRIT) then ft=1 end local g=Duel.GetMatchingGroup(aux.NecroValleyFilter(s.spfilter),tp,LOCATION_GRAVE,0,nil,e,tp) if g:GetCount()>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=g:Select(tp,1,ft,nil) if #sg>0 then Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP) end end end