--Verglascent Matriarch local cid,id=GetID() function cid.initial_effect(c) --link summon aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkRace,RACE_DRAGON),2,2,cid.lcheck) c:EnableReviveLimit() --Damage to 0 local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_PRE_DAMAGE_CALCULATE) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1,id) e1:SetCondition(cid.dmcon) e1:SetCost(cid.dmcost) e1:SetOperation(cid.dmop) c:RegisterEffect(e1) --tohand local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET) e2:SetCountLimit(1,id+100) e2:SetCondition(cid.srcon) e2:SetTarget(cid.target) e2:SetOperation(cid.operation) c:RegisterEffect(e2) --atk & def local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_UPDATE_ATTACK) e3:SetRange(LOCATION_MZONE) e3:SetTargetRange(LOCATION_MZONE,0) e3:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x1996)) e3:SetValue(300) c:RegisterEffect(e3) local e4=e3:Clone() e4:SetCode(EFFECT_UPDATE_DEFENSE) c:RegisterEffect(e4) end function cid.matfilter(c) return c:IsLinkSetCard(0x1996) end function cid.lcheck(g,lc) return g:IsExists(cid.matfilter,1,nil) end function cid.cfilter1(c) return c:IsSetCard(0x1996) and c:IsAbleToDeck() and c:IsAbleToHand() end function cid.srcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK) end function cid.dmcon(e,tp,eg,ep,ev,re,r,rp) local d=Duel.GetAttackTarget() return d and d:IsControler(tp) and d:IsSetCard(0x1996) and Duel.GetBattleDamage(tp)>0 end function cid.dmcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD) local g=Duel.SelectMatchingCard(tp,Card.IsDiscardable,tp,LOCATION_HAND,0,1,1,nil) Duel.SendtoGrave(g,REASON_COST+REASON_DISCARD) end function cid.dmop(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_AVOID_BATTLE_DAMAGE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(1,0) e1:SetReset(RESET_PHASE+PHASE_DAMAGE) Duel.RegisterEffect(e1,tp) end function cid.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return false end if chk==0 then return Duel.IsExistingTarget(cid.cfilter1,tp,LOCATION_GRAVE,0,2,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) local g=Duel.SelectTarget(tp,cid.cfilter1,tp,LOCATION_GRAVE,0,2,2,nil) Duel.SetOperationInfo(0,CATEGORY_TODECK,g,1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) end function cid.operation(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS) local sg=g:Filter(Card.IsRelateToEffect,nil,e) if sg:GetCount()>1 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local sg1=sg:Select(tp,1,1,nil) local c=e:GetHandler() Duel.SendtoDeck(sg1,nil,2,REASON_EFFECT) Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOHAND) sg:Sub(sg1) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) end end