--Test Card Summoner Knight Proof function c249001238.initial_effect(c) c:EnableCounterPermit(0x8) local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_COUNTER) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetCode(EVENT_BATTLED) e1:SetCondition(c249001238.countercon) e1:SetTarget(c249001238.countertg) e1:SetOperation(c249001238.counterop) c:RegisterEffect(e1) --spsummon local e2=Effect.CreateEffect(c) e2:SetDescription(2) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetCountLimit(1) e2:SetRange(LOCATION_MZONE) e2:SetTarget(c249001238.sptg) e2:SetOperation(c249001238.spop) c:RegisterEffect(e2) --special summon local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_SPSUMMON_PROC) e3:SetProperty(EFFECT_FLAG_UNCOPYABLE) e3:SetRange(LOCATION_HAND) e3:SetCondition(c249001238.spcon) c:RegisterEffect(e3) --destroy local e4=Effect.CreateEffect(c) e4:SetCategory(CATEGORY_DESTROY) e4:SetProperty(EFFECT_FLAG_CARD_TARGET) e4:SetType(EFFECT_TYPE_QUICK_O) e4:SetCode(EVENT_FREE_CHAIN) e4:SetRange(LOCATION_MZONE) e4:SetCountLimit(1) e4:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE) e4:SetCost(c249001238.cost) e4:SetTarget(c249001238.target) e4:SetOperation(c249001238.operation) c:RegisterEffect(e4) end function c249001238.countercon(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():GetBattleTarget() == nil then return false end return e:GetHandler():GetBattleTarget():GetLevel()>0 or e:GetHandler():GetBattleTarget():GetRank()>0 or e:GetHandler():GetBattleTarget():GetLink()>0 end function c249001238.countertg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end local ct = e:GetHandler():GetBattleTarget():GetLevel() if ct == 0 then ct = e:GetHandler():GetBattleTarget():GetRank() * 2 end if ct == 0 then ct = e:GetHandler():GetBattleTarget():GetLink() * 2 end Duel.SetOperationInfo(0,CATEGORY_COUNTER,nil,ct,0,0x8) end function c249001238.counterop(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsRelateToEffect(e) and e:GetHandler():IsRelateToBattle() and e:GetHandler():GetBattleTarget():IsRelateToBattle() then local ct = e:GetHandler():GetBattleTarget():GetLevel() if ct == 0 then ct = e:GetHandler():GetBattleTarget():GetRank() * 2 end if ct == 0 then ct = e:GetHandler():GetBattleTarget():GetLink() * 2 end if ct > 0 then e:GetHandler():AddCounter(0x8,ct) end end end function c249001238.spfilter(c,cc,e,tp) return c:IsCanBeSpecialSummoned(e,0,tp,false,false) and c:GetLevel()>0 and cc:IsCanRemoveCounter(tp,0x8,c:GetLevel(),REASON_COST) end function c249001238.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c249001238.spfilter,tp,LOCATION_HAND+LOCATION_GRAVE+LOCATION_DECK,0,1,nil,e:GetHandler(),e,tp) end local g=Duel.GetMatchingGroup(c249001238.spfilter,tp,LOCATION_HAND+LOCATION_GRAVE+LOCATION_DECK,0,nil,e:GetHandler(),e,tp) local lvt={} local tc=g:GetFirst() while tc do local tlv=tc:GetLevel() lvt[tlv]=tlv tc=g:GetNext() end local pc=1 for i=1,12 do if lvt[i] then lvt[i]=nil lvt[pc]=i pc=pc+1 end end lvt[pc]=nil Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(6061630,1)) local lv=Duel.AnnounceNumber(tp,table.unpack(lvt)) e:GetHandler():RemoveCounter(tp,0x8,lv,REASON_COST) e:SetLabel(lv) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_GRAVE+LOCATION_DECK) end function c249001238.spfilter2(c,lv,e,tp) return c:IsCanBeSpecialSummoned(e,0,tp,false,false) and c:IsLevel(lv) end function c249001238.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end local lv=e:GetLabel() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(c249001238.spfilter2),tp,LOCATION_HAND+LOCATION_GRAVE+LOCATION_DECK,0,1,1,nil,lv,e,tp) local tc=g:GetFirst() if g:GetCount()>0 and Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP) then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) end Duel.SpecialSummonComplete() end function c249001238.spfilter3(c) return c:IsFaceup() and c:IsSetCard(0x234) and not c:IsCode(249001238) end function c249001238.spcon(e,c) if c==nil then return true end return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c249001238.spfilter3,c:GetControler(),LOCATION_MZONE,0,2,nil) end function c249001238.cost(e,tp,eg,ep,ev,re,r,rp,chk) e:SetLabel(1) return true end function c249001238.desfilter(c,tc,ec) return c:GetEquipTarget()~=tc and c~=ec end function c249001238.costfilter(c,ec,tp) return Duel.IsExistingTarget(c249001238.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,c,c,ec) end function c249001238.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) local c=e:GetHandler() if chkc then return chkc:IsOnField() and chkc~=c end if chk==0 then if e:GetLabel()==1 then e:SetLabel(0) return Duel.CheckReleaseGroup(tp,c249001238.costfilter,1,c,c,tp) else return Duel.IsExistingTarget(nil,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,c) end end if e:GetLabel()==1 then e:SetLabel(0) local sg=Duel.SelectReleaseGroup(tp,c249001238.costfilter,1,1,c,c,tp) Duel.Release(sg,REASON_COST) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,nil,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,2,c) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function c249001238.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) Duel.Destroy(sg,REASON_EFFECT) end