--Mysterious Starquid local s,id=GetID() function s.initial_effect(c) aux.AddOrigPandemoniumType(c) --P-When an effect is activated: You can destroy this card, and change that effect to "Both players can add 1 Level 6 or lower Pandemonium monster from their Decks to their hands, except "Mysterious Starquid".". (HOPT1) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_CHAINING) e1:SetRange(LOCATION_SZONE) e1:SetCategory(CATEGORY_DESTROY+CATEGORY_TODECK) e1:SetCondition(aux.PandActCheck) e1:SetTarget(s.chtg) e1:SetOperation(s.chop) c:RegisterEffect(e1) aux.EnablePandemoniumAttribute(c,e1) --M-When this card is Summoned: You can add 1 "Mysterious" monster from your Deck, Extra Deck or GY to your Hand, except "Mysterious Starquid". local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_SUMMON_SUCCESS) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetCost(s.thcost) e2:SetTarget(s.thtg) e2:SetOperation(s.thop) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e3) local e4=e2:Clone() e4:SetCode(EVENT_FLIP_SUMMON_SUCCESS) c:RegisterEffect(e4) --M-When this card leaves the field: You can set 1 "Mysterious" Pandemonium monster directly from your Deck to your Spell & Trap card zone except "Mysterious Starquid". local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e5:SetCode(EVENT_LEAVE_FIELD) e5:SetTarget(s.settg) e5:SetOperation(s.setop) c:RegisterEffect(e5) end --filters function s.filter(c) return c:IsLevelBelow(6) and c:IsType(TYPE_PANDEMONIUM) and not c:IsCode(id) end function s.cfilter(c) return c:IsFaceup() and c:IsSetCard(0xcf6) and c:IsType(TYPE_MONSTER) and c:IsAbleToDeck() end function s.thcostfilter(c) return c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost() end function s.thfilter(c) return c:IsType(TYPE_MONSTER) and c:IsSetCard(0xcf6) and c:IsAbleToHand() and not c:IsCode(id) end function s.setfilter(c) return c:IsSetCard(0xcf6) and c:IsPandemoniumSSetable() and not c:IsCode(id) end --change effect function s.chtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsDestructable() and Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_REMOVED,0,1,e:GetHandler()) and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil) and Duel.GetFlagEffect(tp,id)==0 end Duel.RegisterFlagEffect(tp,id,RESET_PHASE+PHASE_END,0,1) Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler(),1,0,0) Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,1,tp,LOCATION_REMOVED) end function s.chop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end if Duel.Destroy(e:GetHandler(),REASON_EFFECT)~=0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local tg=Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_REMOVED,0,1,1,e:GetHandler()) if tg:GetCount()<=0 then return end if Duel.SendtoDeck(tg,nil,2,REASON_EFFECT)~=0 then local g=Group.CreateGroup() Duel.ChangeTargetCard(ev,g) Duel.ChangeChainOperation(ev,s.repop) end end end function s.repop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsType(TYPE_SPELL+TYPE_TRAP) and not c:IsType(TYPE_EQUIP) and c:IsOnField() then c:CancelToGrave(false) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g1=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK,0,1,1,nil) local tc1=g1:GetFirst() Duel.Hint(HINT_SELECTMSG,1-tp,HINTMSG_ATOHAND) local g2=Duel.SelectMatchingCard(1-tp,s.filter,tp,0,LOCATION_DECK,1,1,nil) local tc2=g2:GetFirst() g1:Merge(g2) Duel.SendtoHand(g1,nil,REASON_EFFECT) if tc1 then Duel.ConfirmCards(1-tp,tc1) end if tc2 then Duel.ConfirmCards(tp,tc2) end end -- function s.thcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.thcostfilter,tp,LOCATION_HAND,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,s.thcostfilter,tp,LOCATION_HAND,0,1,1,nil) if g:GetCount()>0 then Duel.Remove(g,POS_FACEUP,REASON_COST) end 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+LOCATION_GRAVE+LOCATION_EXTRA,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_EXTRA) end function s.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.thfilter),tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_EXTRA,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end -- function s.settg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingMatchingCard(s.setfilter,tp,LOCATION_DECK,0,1,nil) end end function s.setop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,1601) local g=Duel.SelectMatchingCard(tp,s.setfilter,tp,LOCATION_DECK,0,1,1,nil) local tc=g:GetFirst() if tc then Duel.PandSSet(tc,e,tp,REASON_EFFECT) end end