--Starforce Enigma local s,id=GetID() function s.initial_effect(c) --search local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_TOHAND|CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetCountLimit(1,id) e1:SetRange(LOCATION_HAND) e1:SetCost(aux.DiscardSelfCost) e1:SetTarget(s.target) e1:SetOperation(s.operation) c:RegisterEffect(e1) --spsummon local GYCheck=aux.AddThisCardInGraveAlreadyCheck(c) GYCheck:SetOperation(s.modified_check) local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetRange(LOCATION_GRAVE) e2:SetCode(EVENT_CHAINING) e2:SetCountLimit(1,id+100) e2:SetLabelObject(GYCheck) e2:SetCondition(s.spcon1) e2:SetTarget(s.sptg) e2:SetOperation(s.spop) c:RegisterEffect(e2) --spsummon local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(id,2)) e4:SetCategory(CATEGORY_SPECIAL_SUMMON) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_MZONE) e4:SetCountLimit(1,id+200) e4:SetCost(aux.TributeForSummonSelfCost(aux.Filter(Card.IsSetCard,0x24f))) e4:SetTarget(s.sptg1) e4:SetOperation(s.spop1) c:RegisterEffect(e4) end function s.filter(c) return c:IsCode(39316) and c:IsAbleToHand() end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK|LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK|LOCATION_GRAVE) end function s.operation(e,tp,eg,ep,ev,re,r,rp) Duel.HintMessage(tp,HINTMSG_ATOHAND) local tg=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.filter),tp,LOCATION_DECK|LOCATION_GRAVE,0,1,1,nil) if #tg>0 then Duel.SendtoHand(tg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tg) end end function s.modified_check(e,tp,eg,ep,ev,re,r,rp) if (r&REASON_COST)>0 then e:SetLabelObject(re) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_CHAIN_END) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetOperation(Auxiliary.ThisCardInGraveAlreadyReset1) e1:SetLabelObject(e) Duel.RegisterEffect(e1,tp) end end function s.spcon1(e,tp,eg,ep,ev,re,r,rp) local rc=re:GetHandler() local se=e:GetLabelObject():GetLabelObject() return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:IsActiveType(TYPE_SPELL) and rp==tp and rc:IsSetCard(0x24f) and (se==nil or re~=se) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetCardOperationInfo(c,CATEGORY_SPECIAL_SUMMON,c) end function s.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsRelateToChain() and re:GetHandler():IsSetCard(0x24f) then Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP) end end function s.spfilter(c,e,tp) return c:IsSetCard(0x24f) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.sptg1(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local check = e:GetLabel()==1 or (Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp)) e:SetLabel(0) return check end e:SetLabel(0) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function s.spop1(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) if #g>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end