--created by LeonDuvall, coded by Lyris --Magitate Flux local s,id,o=GetID() function s.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:HOPT(true) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetOperation(s.activate) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_REMOVE) e2:SetRange(LOCATION_FZONE) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCategory(CATEGORY_TOGRAVE) e2:SetCondition(s.tgcon) e2:SetTarget(s.tgtg) e2:SetOperation(s.tgop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_DESTROYED) e3:SetProperty(EFFECT_FLAG_DELAY) e3:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND) e3:SetCondition(s.thcon) e3:SetCost(aux.bfgcost) e3:SetTarget(s.thtg) e3:SetOperation(s.thop) c:RegisterEffect(e3) end function s.filter(c,e,tp) return c:IsSetCard(0xd16) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.activate(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(s.filter,tp,LOCATION_HAND,0,nil,e,tp) if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and #g>0 and Duel.SelectEffectYesNo(tp,e:GetHandler()) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) Duel.SpecialSummon(g:Select(tp,1,1,nil),0,tp,tp,false,false,POS_FACEUP) end end function s.cfilter(c,tp) return c:IsSetCard(0xd16) and c:IsType(TYPE_MONSTER) and c:IsPreviousControler(tp) and c:IsPreviousLocation(LOCATION_GRAVE) end function s.tgcon(e,tp,eg) return eg:FilterCount(s.cfilter,nil,tp)==1 end function s.gfilter(c) return c:IsSetCard(0x1d16) and c:IsAbleToGrave() end function s.tgtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.gfilter,tp,LOCATION_EXTRA,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_EXTRA) end function s.tgop(e,tp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) Duel.SendtoGrave(Duel.SelectMatchingCard(tp,s.gfilter,tp,LOCATION_EXTRA,0,1,1,nil),REASON_EFFECT) end function s.thcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return rp==1-tp and c:IsReason(REASON_EFFECT) and c:IsLocation(LOCATION_GRAVE) end function s.sfilter(c) return c:IsSetCard(0xd16) and c:IsAbleToHand() end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.sfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function s.thop(e,tp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,s.sfilter,tp,LOCATION_DECK,0,1,1,nil) Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end