--Number i39: Utopia Dreams local s,id=GetID() function s.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,nil,1,2) c:EnableReviveLimit() --disable attack local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_TRIGGER_O) e1:SetRange(LOCATION_MZONE) e1:SetCode(EVENT_ATTACK_ANNOUNCE) e1:SetCountLimit(1) e1:SetOperation(s.atkop) c:RegisterEffect(e1) --spsummon local e2=Effect.CreateEffect(c) e2:Desc(1) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetRange(LOCATION_MZONE) e2:HOPT() e2:SetRelevantTimings() e2:SetCost(aux.DetachSelfCost()) e2:SetTarget(s.sptg) e2:SetOperation(s.spop) c:RegisterEffect(e2) --tohand local e3=Effect.CreateEffect(c) e3:Desc(2) e3:SetCategory(CATEGORIES_SEARCH) e3:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_TO_GRAVE) e3:SetProperty(EFFECT_FLAG_DELAY) e3:SetTarget(s.thtg) e3:SetOperation(s.thop) e3:HOPT() c:RegisterEffect(e3) end s.xyz_number=39 function s.atkop(e,tp,eg,ep,ev,re,r,rp) Duel.NegateAttack() end function s.spfilter(c,e,tp,mc) return c:IsMonster(TYPE_XYZ) and c:IsRank(4) and c:IsSetCard(ARCHE_UTOPIA) and mc:IsCanBeXyzMaterial(c) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,mc,c)>0 end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local c=e:GetHandler() return aux.MustMaterialCheck(c,tp,EFFECT_MUST_BE_XMATERIAL) and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,e:GetHandler()) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function s.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsFaceup() and c:IsRelateToChain() and not c:IsImmuneToEffect(e) and aux.MustMaterialCheck(c,tp,EFFECT_MUST_BE_XMATERIAL) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,c) local tc=g:GetFirst() if tc then local mg=c:GetOverlayGroup() if mg:GetCount()>0 then Duel.Overlay(tc,mg) end tc:SetMaterial(Group.FromCards(c)) Duel.Overlay(tc,Group.FromCards(c)) if Duel.SpecialSummon(tc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP)~=0 then tc:CompleteProcedure() end end end end function s.thfilter(c) return c:IsSetCard(ARCHE_ZW) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function s.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end