--Guardiano del Cielo Brakadiano --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) aux.AddCodeList(c,54181389) --Activate local e0=Effect.CreateEffect(c) e0:SetDescription(aux.Stringid(id,0)) e0:SetType(EFFECT_TYPE_ACTIVATE) e0:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e0) --Can be activated during the turn it was Set local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN) e2:SetProperty(EFFECT_FLAG_SET_AVAILABLE) e2:SetCondition(s.actcon) c:RegisterEffect(e2) --SS local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,1)) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetCode(EVENT_DESTROYED) e1:SetRange(LOCATION_SZONE) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e1:SetCountLimit(1,id) e1:SetCondition(s.spcon) e1:SetTarget(s.sptg) e1:SetOperation(s.spop) c:RegisterEffect(e1) --SS Link local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,2)) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_DESTROYED) e3:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e3:SetCountLimit(1,id+100) e3:SetCondition(s.spcon2) e3:SetCost(s.spcost2) e3:SetTarget(s.sptg2) e3:SetOperation(s.spop2) c:RegisterEffect(e3) end function s.cf(c) return c:IsFaceup() and c:IsMonster(TYPE_SYNCHRO) and c:IsSetCard(0xb48) end function s.actcon(e) return Duel.GetFieldGroup(e:GetHandlerPlayer(),LOCATION_MZONE+LOCATION_EXTRA,0):FilterCount(s.cf,nil)>1 end function s.cfilter(c,tp) return c:IsPreviousSetCard(0xb48) and c:GetPreviousTypeOnField()&TYPE_MONSTER==TYPE_MONSTER and c:IsPreviousPosition(POS_FACEUP) and c:IsPreviousLocation(LOCATION_MZONE) and c:IsPreviousControler(tp) end function s.spcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(s.cfilter,1,nil,tp) end function s.filter(c,e,tp) return c:IsMonster() and c:IsLevel(3,6) and c:IsRace(RACE_DRAGON) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and (c:IsLocation(LOCATION_EXTRA) and c:IsFaceup() and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0 or not c:IsLocation(LOCATION_EXTRA) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE+LOCATION_EXTRA) end function s.spop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.filter),tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,1,nil,e,tp) if #g>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end function s.spcon2(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsPreviousPosition(POS_FACEUP) and c:IsReason(REASON_EFFECT) end function s.costfilter(c) return c:IsMonster() and c:IsSetCard(0xb48) and c:IsAbleToRemoveAsCost() and (c:IsFaceup() or not c:IsLocation(LOCATION_EXTRA)) end function s.sgcheck(sg,e,tp) return Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,sg,e,tp) end function s.spcost2(e,tp,eg,ep,ev,re,r,rp,chk) e:SetLabel(1) local sg=Duel.GetMatchingGroup(s.costfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,nil) if chk==0 then return #sg>0 and sg:CheckSubGroup(s.sgcheck,1,3,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=sg:SelectSubGroup(tp,s.sgcheck,false,1,3,e,tp) if #g>0 then Duel.Remove(g,POS_FACEUP,REASON_COST) end end function s.sptg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local check=(e:GetLabel()==1) or Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp) e:SetLabel(0) return aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_LMATERIAL) and check end e:SetLabel(0) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function s.spfilter(c,e,tp) return c:IsCode(54181389) and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0 and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_LINK,tp,false,false,POS_FACEUP_DEFENSE) end function s.spop2(e,tp,eg,ep,ev,re,r,rp) if not aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_LMATERIAL) 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 then Duel.SpecialSummon(tc,SUMMON_TYPE_LINK,tp,tp,false,false,POS_FACEUP) tc:CompleteProcedure() end end