local s,id=GetID() --Cosmicburst Dragon function s.initial_effect(c) c:EnableReviveLimit() aux.AddOrigBigbangType(c) aux.AddBigbangProc(c,aux.FilterEqualFunction(Card.GetVibe,0),1,aux.NOT(aux.FilterEqualFunction(Card.GetVibe,0)),1) --equip local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_SINGLE) e0:SetCode(EFFECT_MATERIAL_CHECK) e0:SetValue(s.matcheck) c:RegisterEffect(e0) local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_EQUIP) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetLabelObject(e0) e1:SetCondition(s.con1) e1:SetTarget(s.tg1) e1:SetOperation(s.op1) c:RegisterEffect(e1) --tribute then equip local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_EQUIP) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetCountLimit(1) e2:SetCost(s.cost2) e2:SetTarget(s.tg2) e2:SetOperation(s.op2) c:RegisterEffect(e2) --negate local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,2)) e3:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY) e3:SetType(EFFECT_TYPE_QUICK_O) e3:SetCode(EVENT_CHAINING) e3:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e3:SetRange(LOCATION_MZONE) e3:SetCondition(s.discon) e3:SetTarget(s.distg) e3:SetOperation(s.disop) c:RegisterEffect(e3) --destroy replace local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e4:SetRange(LOCATION_MZONE) e4:SetCode(EFFECT_DESTROY_REPLACE) e4:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e4:SetTarget(s.reptg) e4:SetValue(function(e,tc) return s.repfilter(tc,e:GetHandlerPlayer()) end) e4:SetOperation(s.repop) c:RegisterEffect(e4) end function s.matcheck(e,c) e:SetLabel(c:GetMaterial():FilterCount(aux.FilterEqualFunction(Card.GetVibe,0),nil)) end function s.con1(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsSummonType(SUMMON_TYPE_SPECIAL+340) end function s.filter(c,tp) return c:IsType(TYPE_MONSTER) and c:CheckUniqueOnField(tp) and not c:IsForbidden() end function s.tg1(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc,tp) end local mc=e:GetHandler():GetMaterialCount()-e:GetLabelObject():GetLabel() if chk==0 then return mc>0 and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingTarget(s.filter,tp,LOCATION_GRAVE,0,1,nil,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP) local g=Duel.SelectTarget(tp,aux.NecroValleyFilter(s.filter),tp,LOCATION_GRAVE,0,1,mc,nil,tp) Duel.SetOperationInfo(0,CATEGORY_EQUIP,g,#g,0,0) end function s.op1(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsFaceup() or not c:IsRelateToEffect(e) or Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS) local sg=g:Filter(Card.IsRelateToEffect,nil,e) local tc=sg:GetFirst() while tc and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 do if Duel.Equip(tp,tc,c,false) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_OWNER_RELATE) e1:SetCode(EFFECT_EQUIP_LIMIT) e1:SetReset(RESET_EVENT+RESETS_STANDARD) e1:SetLabelObject(c) e1:SetValue(s.eqlimit) tc:RegisterEffect(e1) end tc=sg:GetNext() end end function s.eqlimit(e,c) return e:GetOwner()==e:GetLabelObject() end function s.cost2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckReleaseGroup(tp,Card.IsReleasable,1,e:GetHandler()) end local g=Duel.SelectReleaseGroup(tp,Card.IsReleasable,1,1,e:GetHandler()) Duel.Release(g,REASON_COST) end function s.eqfilter2(c,tp) return c:IsType(TYPE_MONSTER) and c:IsLevelBelow(4) and not c:IsForbidden() and c:CheckUniqueOnField(tp) end function s.tg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.eqfilter2(chkc,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingTarget(s.eqfilter2,tp,LOCATION_GRAVE,0,1,nil,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP) local g=Duel.SelectTarget(tp,s.eqfilter2,tp,LOCATION_GRAVE,0,1,1,nil,tp) Duel.SetOperationInfo(0,CATEGORY_EQUIP,g,#g,0,0) end function s.op2(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end local c=e:GetHandler() local tc=Duel.GetFirstTarget() if c:IsFaceup() and c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) then if not Duel.Equip(tp,tc,c,false) then return end local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_EQUIP_LIMIT) e1:SetReset(RESET_EVENT+RESETS_STANDARD) e1:SetLabelObject(c) e1:SetValue(s.eqlimit) tc:RegisterEffect(e1) end end function s.cfilter(c,tp) return c:IsOnField() and c:IsControler(tp) end function s.discon(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) or not Duel.IsChainNegatable(ev) then return false end if re:IsHasCategory(CATEGORY_NEGATE) and Duel.GetChainInfo(ev-1,CHAININFO_TRIGGERING_EFFECT):IsHasType(EFFECT_TYPE_ACTIVATE) then return false end local ex1,tg1,tc1=Duel.GetOperationInfo(ev,CATEGORY_DESTROY) local ex2,tg2,tc2=Duel.GetOperationInfo(ev,CATEGORY_RELEASE) local ex3,tg3,tc3=Duel.GetOperationInfo(ev,CATEGORY_TOHAND) local ex4,tg4,tc4=Duel.GetOperationInfo(ev,CATEGORY_TODECK) local ex5,tg5,tc5=Duel.GetOperationInfo(ev,CATEGORY_TOEXTRA) local ex6,tg6,tc6=Duel.GetOperationInfo(ev,CATEGORY_TOGRAVE) local ex7,tg7,tc7=Duel.GetOperationInfo(ev,CATEGORY_REMOVE) return (ex1 and tg1~=nil and tc1+tg1:FilterCount(s.cfilter,nil,tp)-#tg1>0) or (ex2 and tg2~=nil and tc2+tg2:FilterCount(s.cfilter,nil,tp)-#tg2>0) or (ex3 and tg3~=nil and tc3+tg3:FilterCount(s.cfilter,nil,tp)-#tg3>0) or (ex4 and tg4~=nil and tc4+tg4:FilterCount(s.cfilter,nil,tp)-#tg4>0) or (ex5 and tg5~=nil and tc5+tg5:FilterCount(s.cfilter,nil,tp)-#tg5>0) or (ex6 and tg6~=nil and tc6+tg6:FilterCount(s.cfilter,nil,tp)-#tg6>0) or (ex7 and tg7~=nil and tc7+tg7:FilterCount(s.cfilter,nil,tp)-#tg7>0) end function s.distg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chk==0 then return e:GetHandler():GetEquipCount()>0 end Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler():GetEquipCount(),1,0,0) Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0) end end function s.disop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=e:GetHandler():GetEquipGroup():Select(tp,1,1,nil) if Duel.Destroy(g,REASON_EFFECT)~=0 then if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then Duel.Destroy(eg,REASON_EFFECT) end end end function s.repfilter(c,tp) return c:IsFaceup() and c:IsType(TYPE_MONSTER) and c:IsControler(tp) and c:IsLocation(LOCATION_ONFIELD) and c:IsReason(REASON_BATTLE) and not c:IsReason(REASON_REPLACE) end function s.drepfilter(c,e) return c:IsDestructable(e) and not c:IsStatus(STATUS_DESTROY_CONFIRMED+STATUS_BATTLE_DESTROYED) end function s.reptg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsOnField() and c:IsFaceup() and eg:IsExists(s.repfilter,1,nil,tp) and e:GetHandler():GetEquipGroup():IsExists(s.drepfilter,1,nil,e) end if Duel.SelectYesNo(tp,aux.Stringid(id,3)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESREPLACE) local g=e:GetHandler():GetEquipGroup():FilterSelect(tp,s.drepfilter,1,1,nil,e) e:SetLabelObject(g:GetFirst()) g:GetFirst():SetStatus(STATUS_DESTROY_CONFIRMED,true) return true else return false end end function s.repop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_CARD,0,id) local tc=e:GetLabelObject() tc:SetStatus(STATUS_DESTROY_CONFIRMED,false) Duel.Destroy(tc,REASON_EFFECT+REASON_REPLACE) end