--Svalbard, Dominio della Preservazione --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH) e1:SetOperation(s.activate) c:RegisterEffect(e1) --atk local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_UPDATE_ATTACK) e2:SetRange(LOCATION_FZONE) e2:SetTargetRange(LOCATION_MZONE,0) e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x29a)) e2:SetValue(400) c:RegisterEffect(e2) local e2x=e2:Clone() e2x:SetCode(EFFECT_UPDATE_DEFENSE) c:RegisterEffect(e2x) --fusion summon local e3=Effect.CreateEffect(c) e3:Desc(2) e3:SetCategory(CATEGORY_FUSION_SUMMON+CATEGORY_SPECIAL_SUMMON+CATEGORY_TODECK) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_FZONE) e3:SetCountLimit(1,id) e3:SetTarget(s.fustg) e3:SetOperation(s.fusop) c:RegisterEffect(e3) end function s.thfilter(c) return c:IsSetCard(0x29a) and c:IsAbleToHand() end function s.activate(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(s.thfilter,tp,LOCATION_DECK,0,nil) if #g>0 and Duel.SelectYesNo(tp,aux.Stringid(id,1)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=g:Select(tp,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) end end function s.filter00(c) return c:IsFusionType(TYPE_ST) and c:IsCanBeFusionMaterial() and c:IsAbleToGrave() and (c:IsFaceup() or not c:IsLocation(LOCATION_MZONE)) end function s.filter1(c) return c:IsFusionType(TYPE_SPELL) and c:IsAbleToDeck() and c:IsCanBeFusionMaterial() end function s.filter2(c,e) return not c:IsImmuneToEffect(e) end function s.spfilter(c,e,tp,m,f,chkf) return c:IsMonster(TYPE_FUSION) and c:IsSetCard(0x29a) and (not f or f(c)) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf) end function s.chkfilter(c,tp) return c:IsFusionType(TYPE_SPELL) and c:IsFusionSetCard(0x29a) and s.exfilter(c,tp) end function s.exfilter(c,tp) return c:IsControler(tp) and c:IsLocation(LOCATION_GRAVE) end function s.fcheck(tp,sg,fc) if sg:IsExists(s.chkfilter,1,nil,tp) then return true else return not sg:IsExists(s.exfilter,1,nil,tp) end end function s.fustg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local merged=false local chkf=tp local mg1=Duel.GetFusionMaterial(tp) local mg2=Duel.GetMatchingGroup(s.filter00,tp,LOCATION_HAND+LOCATION_ONFIELD,0,e:GetHandler()) local mg3=Duel.GetMatchingGroup(s.filter1,tp,LOCATION_GRAVE,0,nil) mg1:Merge(mg2) if mg3:IsExists(s.chkfilter,1,nil,tp) then merged=true mg1:Merge(mg3) end if merged then aux.FCheckAdditional=s.fcheck end local res=Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf) if not res then local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() local mg3=fgroup(ce,e,tp) local mf=ce:GetValue() res=Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg3,mf,chkf) end end if merged then aux.FCheckAdditional=nil end return res end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,0,tp,LOCATION_GRAVE) end function s.fusop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local merged=false local chkf=tp local mg1=Duel.GetFusionMaterial(tp):Filter(s.filter2,nil,e) local mg2=Duel.GetMatchingGroup(s.filter00,tp,LOCATION_HAND+LOCATION_ONFIELD,0,e:GetHandler()):Filter(s.filter2,nil,e) local mg3=Duel.GetMatchingGroup(s.filter1,tp,LOCATION_GRAVE,0,nil):Filter(s.filter2,nil,e) mg1:Merge(mg2) if mg3:IsExists(s.chkfilter,1,nil,tp) then merged=true mg1:Merge(mg3) end if merged then aux.FCheckAdditional=s.fcheck end local sg1=Duel.GetMatchingGroup(s.spfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf) local mg3=nil local sg2=nil local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() mg3=fgroup(ce,e,tp) local mf=ce:GetValue() sg2=Duel.GetMatchingGroup(s.spfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg3,mf,chkf) end if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then local sg=sg1:Clone() if sg2 then sg:Merge(sg2) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=sg:Select(tp,1,1,nil) local tc=tg:GetFirst() if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,c,chkf) tc:SetMaterial(mat1) local mat2=mat1:Filter(Card.IsLocation,nil,LOCATION_GRAVE) mat1:Sub(mat2) Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) Duel.SendtoDeck(mat2,nil,SEQ_DECKSHUFFLE,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) Duel.BreakEffect() Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP) else local mat2=Duel.SelectFusionMaterial(tp,tc,mg3,nil,chkf) local fop=ce:GetOperation() fop(ce,e,tp,tc,mat2) end tc:CompleteProcedure() end if merged then aux.FCheckAdditional=nil end end