--created by NeverThisAgain, coded by Lyris local s,id=GetID() function s.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1,id) e1:SetCondition(function(e,tp) return not Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_MZONE,0,1,nil) end) e1:SetCost(s.cost) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetTarget(s.target) e1:SetOperation(s.operation) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_RELEASE) e2:SetCountLimit(1,id+13) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCondition(function(e,tp,eg,ep,ev,re) return re~=e1 end) e2:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND) e2:SetTarget(s.dthtg) e2:SetOperation(s.dthop) c:RegisterEffect(e2) end function s.filter(c) return c:GetSummonLocation()==LOCATION_EXTRA and c:IsFaceup() and c:IsSummonType(SUMMON_TYPE_SPECIAL) end function s.cost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsReleasable() and Duel.CheckReleaseGroupEx(tp,Card.IsSetCard,1,e:GetHandler(),0x50b) end local rg=Duel.SelectReleaseGroupEx(tp,Card.IsSetCard,1,1,e:GetHandler(),0x50b)+c Duel.Release(rg,REASON_EFFECT) end function s.spfilter(c,e,tp) return c:IsType(TYPE_FUSION) and c:IsSetCard(0x50b) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCountFromEx(tp)>0 and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function s.operation(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCountFromEx(tp)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp) local tc=g:GetFirst() if tc and Duel.SpecialSummonStep(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP) then local c=e:GetHandler() local fid=c:GetFieldID() tc:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD,0,1,fid) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e3:SetCode(EVENT_PHASE+PHASE_END) e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e3:SetCountLimit(1) e3:SetLabel(fid) e3:SetLabelObject(tc) e3:SetCondition(s.rmcon1) e3:SetOperation(s.rmop1) Duel.RegisterEffect(e3,tp) Duel.SpecialSummonComplete() tc:CompleteProcedure() end end function s.rmcon1(e,tp,eg,ep,ev,re,r,rp) local tc=e:GetLabelObject() if tc:GetFlagEffectLabel(id)~=e:GetLabel() then e:Reset() return false else return true end end function s.rmop1(e,tp,eg,ep,ev,re,r,rp) Duel.Remove(e:GetLabelObject(),POS_FACEUP,REASON_EFFECT) end function s.dthfilter(c) return c:GetType()&0x82==0x82 and c:IsAbleToHand() end function s.dthtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.dthfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function s.dthop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,s.dthfilter,tp,LOCATION_DECK,0,1,1,nil) if #g>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end