--Duelahan's Drowsy Glen local cid,id=GetID() function cid.initial_effect(c) --activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --def up local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_UPDATE_DEFENSE) e2:SetRange(LOCATION_FZONE) e2:SetTargetRange(LOCATION_MZONE,0) e2:SetTarget(cid.deftg) e2:SetValue(1000) c:RegisterEffect(e2) --indes local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_INDESTRUCTABLE_COUNT) e3:SetRange(LOCATION_FZONE) e3:SetTargetRange(LOCATION_MZONE,0) e3:SetTarget(cid.target) e3:SetValue(cid.indct) c:RegisterEffect(e3) --avoid battle damage local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_FIELD) e4:SetCode(EFFECT_AVOID_BATTLE_DAMAGE) e4:SetRange(LOCATION_FZONE) e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e4:SetTargetRange(1,0) e4:SetValue(1) e4:SetCondition(cid.damcon) c:RegisterEffect(e4) --special summon local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(id,0)) e5:SetCategory(CATEGORY_SPECIAL_SUMMON) e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e5:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e5:SetCode(EVENT_TO_GRAVE) e5:SetCountLimit(1,id) e5:SetRange(LOCATION_FZONE) e5:SetCondition(cid.spcon) e5:SetTarget(cid.sptg) e5:SetOperation(cid.spop) c:RegisterEffect(e5) end function cid.deftg(e,c) return c:IsSetCard(0x684) and c:GetSequence()<5 end function cid.cfilter1(c) return c:IsFaceup() and c:IsSetCard(0x684) and c:IsLinkState() end function cid.damcon(e) return Duel.IsExistingMatchingCard(cid.cfilter1,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil) end function cid.target(e,c) return c:IsSetCard(0x684) and c:IsLinkState() end function cid.indct(e,re,r,rp) if bit.band(r,REASON_BATTLE)~=0 then return 1 else return 0 end end function cid.cfilter(c,e,tp) return bit.band(c:GetPreviousTypeOnField(),TYPE_LINK)~=0 and c:IsPreviousSetCard(0x684) and c:GetCode() and c:IsPreviousLocation(LOCATION_MZONE) and c:GetPreviousControler()==tp and Duel.IsExistingMatchingCard(cid.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,c:GetCode()) end function cid.spcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(cid.cfilter,1,nil,e,tp) and not eg:IsContains(e:GetHandler()) end function cid.spfilter(c,e,tp,code) return c:IsSetCard(0x684) and c:IsLink(1) and not c:IsCode(code) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_LINK,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,ec,c,0x60)>0 end function cid.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local g=eg:Filter(cid.cfilter,nil,e,tp) local code=g:GetFirst():GetCode() e:SetLabel(code) return Duel.IsExistingMatchingCard(cid.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,code) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function cid.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,cid.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,e:GetLabel()) local tc=g:GetFirst() if tc and Duel.SpecialSummon(tc,SUMMON_TYPE_LINK,tp,tp,false,false,POS_FACEUP,0x60)>0 then tc:CompleteProcedure() end end