--Runefall Guardian local cid,id=GetID() function cid.initial_effect(c) --link summon c:EnableReviveLimit() aux.AddLinkProcedure(c,cid.matfilter,1) --special summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCountLimit(1,id) e1:SetCost(cid.spcost) e1:SetTarget(cid.sptg) e1:SetOperation(cid.spop) c:RegisterEffect(e1) --excavate local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_SZONE) e2:SetCountLimit(1,id+100) e2:SetTarget(cid.thtg) e2:SetOperation(cid.thop) c:RegisterEffect(e2) --spsummon local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,1)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_DESTROYED) e3:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e3:SetRange(LOCATION_SZONE) e3:SetCountLimit(1,id+1000) e3:SetCondition(cid.scon) e3:SetTarget(cid.stg) e3:SetOperation(cid.sop) c:RegisterEffect(e3) Duel.AddCustomActivityCounter(id,ACTIVITY_SPSUMMON,cid.counterfilter) end function cid.counterfilter(c) return c:IsSetCard(0x522) end function cid.matfilter(c) return c:IsSetCard(0x522) and not c:IsCode(id) end function cid.costfilter(c,e,tp) return c:IsSetCard(0x522) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function cid.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.costfilter,tp,LOCATION_DECK,0,1,nil,e,tp) and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.GetCustomActivityCount(id,tp,ACTIVITY_SPSUMMON)==0 end c=e:GetHandler() if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end if Duel.MoveToField(c,tp,tp,LOCATION_SZONE,POS_FACEUP,true) then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetCode(EFFECT_CHANGE_TYPE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_EVENT+0x1fc0000) e1:SetValue(TYPE_TRAP+TYPE_CONTINUOUS) c:RegisterEffect(e1) local e2=Effect.CreateEffect(e:GetHandler()) e2:SetType(EFFECT_TYPE_FIELD) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e2:SetReset(RESET_PHASE+PHASE_END) e2:SetTargetRange(1,0) e2:SetTarget(cid.splimit) Duel.RegisterEffect(e2,tp) end end function cid.splimit(e,c,sump,sumtype,sumpos,targetp,se) return not c:IsSetCard(0x522) end function cid.spfilter(c,e,tp) return c:IsSetCard(0x522) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function cid.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(cid.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function cid.spop(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,cid.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end function cid.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chk==0 then return Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)>=3 end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOHAND) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,0,LOCATION_DECK) end function cid.thfilter(c) return c:IsSetCard(0x522) and c:IsAbleToHand() end function cid.thop(e,tp,eg,ep,ev,re,r,rp) Duel.ConfirmDecktop(tp,3) local g=Duel.GetDecktopGroup(tp,3) if g:GetCount()>0 then if g:IsExists(Card.IsSetCard,1,nil,0x522) then if g:IsExists(cid.thfilter,1,nil) and Duel.SelectYesNo(tp,aux.Stringid(id,2)) then Duel.Hint(HINT_SELECTMSG,p,HINTMSG_ATOHAND) local sg=g:FilterSelect(tp,cid.thfilter,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) Duel.ShuffleHand(tp) end end Duel.ShuffleDeck(tp) end end function cid.sfilter(c,tp) return (c:IsReason(REASON_BATTLE) or c:IsReason(REASON_EFFECT) and c:GetReasonPlayer()==1-tp) and c:IsPreviousSetCard(0x522) and c:GetPreviousControler()==tp and c:IsPreviousLocation(LOCATION_MZONE) end function cid.scon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(cid.sfilter,1,nil,tp) end function cid.stg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function cid.sop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP) end end