--Sunhewer of Economics, Advant local ref,id=GetID() Duel.LoadScript("Sunhew.lua") function ref.initial_effect(c) c:EnableReviveLimit() aux.AddXyzProcedure(c,nil,1,2,nil,nil,99) --Rank-Up local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCost(ref.xyzcost) e1:SetTarget(ref.xyztg) e1:SetOperation(ref.xyzop) c:RegisterEffect(e1) --Negate local e2=Effect.CreateEffect(c) e2:Desc(1) e2:SetCategory(CATEGORY_DISABLE) e2:SetType(EFFECT_TYPE_XMATERIAL+EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetCountLimit(1) --e2:SetCondition(ref.discon) e2:SetCost(ref.discost) e2:SetTarget(ref.distg) e2:SetOperation(ref.disop) c:RegisterEffect(e2) end --Rank-Up function ref.xyzfilter(c,e,tp,mc,rk) return c:IsRank(rk) and mc:IsCanBeXyzMaterial(c) and c:IsRace(RACE_ROCK) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,mc,c)>0 end function ref.xyzcost(e,tp,eg,ep,ev,re,r,rp,chk) local ec=Duel.GetEngagedCard(tp) if chk==0 then return ec and ec:IsCanResetEnergy(tp,REASON_COST) end ec:ResetEnergy(tp,REASON_EFFECT,nil,e:GetHandler()) end function ref.xyztg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return aux.MustMaterialCheck(c,tp,EFFECT_MUST_BE_XMATERIAL) and Duel.IsExistingMatchingCard(ref.xyzfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,c,c:GetOverlayCount()+2) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function ref.xyzop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not aux.MustMaterialCheck(c,tp,EFFECT_MUST_BE_XMATERIAL) then return end if c:IsFacedown() or not c:IsRelateToEffect(e) or c:IsImmuneToEffect(e) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,ref.xyzfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,c,c:GetOverlayCount()+2) local sc=g:GetFirst() if sc then local mg=c:GetOverlayGroup() if mg:GetCount()~=0 then Duel.SendtoGrave(mg,REASON_RULE) end sc:SetMaterial(Group.FromCards(c)) Duel.Overlay(sc,Group.FromCards(c)) Duel.SpecialSummon(sc,0,tp,tp,false,false,POS_FACEUP) end end --Negate function ref.discon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsRace(RACE_ROCK) end function ref.discost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.IsExistingMatchingCard(Card.IsCanOverlay,tp,LOCATION_HAND+LOCATION_ONFIELD,0,1,c) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL) local g=Duel.SelectMatchingCard(tp,Card.IsCanOverlay,tp,LOCATION_HAND+LOCATION_ONFIELD,0,1,1,c) Duel.Overlay(c,g) if g:GetFirst():IsType(TYPE_DRIVE) then e:SetLabel(1) else e:SetLabel(0) end end function ref.distg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsOnField() and aux.NegateAnyFilter(chkc) end if chk==0 then return Duel.IsExistingMatchingCard(aux.NegateAnyFilter,tp,0,LOCATION_ONFIELD,1,nil) end end function ref.disop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISABLE) local g=Duel.SelectMatchingCard(tp,aux.NegateAnyFilter,tp,0,LOCATION_ONFIELD,1,1,nil) if #g<1 then return end Duel.HintSelection(g) local tc=g:GetFirst() if tc:IsCanBeDisabledByEffect(e,false) then Duel.NegateRelatedChain(tc,RESET_TURN_SET) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DISABLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e2:SetValue(RESET_TURN_SET) e2:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e2) if tc:IsType(TYPE_TRAPMONSTER) then local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e3:SetCode(EFFECT_DISABLE_TRAPMONSTER) e3:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e3) end if e:GetLabel()==1 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local dg=Duel.SelectMatchingCard(tp,Card.IsDestructable,tp,0,LOCATION_ONFIELD,1,1,nil) if #dg>0 then Duel.HintSelection(dg) Duel.Destroy(dg,REASON_EFFECT) end end end end