--Heterochromic Rank Enhancer Duel.LoadScript("bannedlist.lua") function c249000438.initial_effect(c) --summon success local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(249000438,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY) e1:SetTarget(c249000438.sumtg) e1:SetOperation(c249000438.sumop) c:RegisterEffect(e1) --special summon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(31786629,0)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1) e2:SetCost(c249000438.cost) e2:SetTarget(c249000438.target) e2:SetOperation(c249000438.operation) c:RegisterEffect(e2) end function c249000438.filter(c,e,tp) return c:GetRank() > 0 and c:GetRank() <= 4 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c249000438.sumtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c249000438.filter(chkc,e,tp) end if chk==0 then return Duel.IsExistingTarget(c249000438.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c249000438.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c249000438.sumop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP_DEFENCE) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DISABLE) e1:SetReset(RESET_EVENT+0x1fe0000) tc:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetReset(RESET_EVENT+0x1fe0000) tc:RegisterEffect(e2) end Duel.SpecialSummonComplete() end function c249000438.costfilter(c) return c:IsSetCard(0x1BE) and c:IsAbleToRemoveAsCost() end function c249000438.costfilter2(c,e) return c:IsSetCard(0x1BE) and not c:IsPublic() and c~=e:GetHandler() end function c249000438.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return (Duel.IsExistingMatchingCard(c249000438.costfilter,tp,LOCATION_GRAVE,0,1,nil) or Duel.IsExistingMatchingCard(c249000438.costfilter2,tp,LOCATION_HAND,0,1,nil,e)) end local option if Duel.IsExistingMatchingCard(c249000438.costfilter2,tp,LOCATION_HAND,0,1,nil,e) then option=0 end if Duel.IsExistingMatchingCard(c249000438.costfilter,tp,LOCATION_GRAVE,0,1,nil) then option=1 end if Duel.IsExistingMatchingCard(c249000438.costfilter,tp,LOCATION_GRAVE,0,1,nil) and Duel.IsExistingMatchingCard(c249000438.costfilter2,tp,LOCATION_HAND,0,1,nil,e) then option=Duel.SelectOption(tp,526,1102) end if option==0 then g=Duel.SelectMatchingCard(tp,c249000438.costfilter2,tp,LOCATION_HAND,0,1,1,nil,e) Duel.ConfirmCards(1-tp,g) Duel.ShuffleHand(tp) end if option==1 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c249000438.costfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end end function c249000438.filter1(c,e,tp) local rk=c:GetRank() return rk>0 and c:IsFaceup() end function c249000438.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and c249000438.filter1(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and Duel.IsExistingTarget(c249000438.filter1,tp,LOCATION_MZONE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) local g=Duel.SelectTarget(tp,c249000438.filter1,tp,LOCATION_MZONE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c249000438.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() local att=tc:GetOriginalAttribute() local rk=tc:GetRank() if tc:IsFacedown() or not tc:IsRelateToEffect(e) or tc:IsControler(1-tp) or tc:IsImmuneToEffect(e) then return end if Duel.SendtoGrave(tc,REASON_EFFECT)==0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local ac=Duel.AnnounceCardFilter(tp,tc:GetOriginalAttribute(),OPCODE_ISATTRIBUTE,TYPE_XYZ,OPCODE_ISTYPE,OPCODE_AND,249000438,OPCODE_ISCODE,OPCODE_OR) local sc=Duel.CreateToken(tp,ac) if sc:IsCode(249000438) then return end while not (sc:IsType(TYPE_XYZ) and sc:GetRank() == rk +2 and sc:IsAttribute(att) and sc:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) and not banned_list_table[ac]) do ac=Duel.AnnounceCardFilter(tp,tc:GetOriginalAttribute(),OPCODE_ISATTRIBUTE,TYPE_XYZ,OPCODE_ISTYPE,OPCODE_AND,249000438,OPCODE_ISCODE,OPCODE_OR) sc=Duel.CreateToken(tp,ac) if sc:IsCode(249000438) then return end end if sc then Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP) sc:CompleteProcedure() local tc2=Duel.GetFieldCard(tp,LOCATION_GRAVE,Duel.GetFieldGroupCount(tp,LOCATION_GRAVE,0)-1) if tc2 then Duel.Overlay(sc,tc2) end tc2=Duel.GetFieldCard(tp,LOCATION_GRAVE,Duel.GetFieldGroupCount(tp,LOCATION_GRAVE,0)-1) if tc2 then Duel.Overlay(sc,tc2) end end end