--Garleth Sellva's Skydianborn Protection --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) --Negate effect local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_DISABLE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_CHAINING) e1:SHOPT() e1:SetCondition(s.discon) e1:SetTarget(s.distg) e1:SetOperation(s.disop) c:RegisterEffect(e1) --Mill local e2=Effect.CreateEffect(c) e2:Desc(1) e2:SetCategory(CATEGORY_TOHAND) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetRange(LOCATION_GRAVE) e2:SHOPT() e2:SetHintTiming(0,RELEVANT_TIMINGS) e2:SetCondition(aux.MainPhaseCond(0)) e2:SetCost(aux.bfgcost) e2:SetTarget(s.thtg) e2:SetOperation(s.thop) c:RegisterEffect(e2) end function s.disconfilter(c,tp) return c:IsFaceup() and c:IsOnField() and c:IsControler(tp) and c:IsSetCard(0x223,0x222,0x528,0xd0a1) end function s.discon(e,tp,eg,ep,ev,re,r,rp) if rp~=1-tp or not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return false end local tg=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS) return tg and tg:IsExists(s.disconfilter,1,nil,tp) and Duel.IsChainDisablable(ev) end function s.distg(e,tp,eg,ep,ev,re,r,rp,chk) local rc=re:GetHandler() local relation=rc:IsRelateToEffect(re) if chk==0 then return not rc:IsStatus(STATUS_DISABLED) and (rc:IsAbleToRemove(tp) or (not relation and Duel.IsPlayerCanRemove(tp))) end Duel.SetOperationInfo(0,CATEGORY_DISABLE,eg,1,0,0) if relation then Duel.SetOperationInfo(0,CATEGORY_REMOVE,rc,1,rc:GetControler(),rc:GetLocation()) else Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,0,0,rc:GetPreviousLocation()) end end function s.disop(e,tp,eg,ep,ev,re,r,rp) if Duel.NegateEffect(ev) and re:GetHandler():IsRelateToChain(ev) then Duel.Remove(eg,POS_FACEUP,REASON_EFFECT) end end function s.thfilter(c) return c:IsSetCard(0x223,0x222,0x528,0xd0a1) and not c:IsCode(id) and c:NotBanishedOrFaceup() end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_GRAVE|LOCATION_REMOVED,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE|LOCATION_REMOVED) end function s.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.thfilter),tp,LOCATION_GRAVE|LOCATION_REMOVED,0,1,1,nil) if #g>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end