--灯火之约定 local m=28327022 local cm=_G["c"..m] xpcall(function() require("expansions/script/c28327000") end,function() require("script/c28327000") end) function cm.initial_effect(c) aux.AddCodeList(c,28327000) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,m) e1:SetTarget(cm.target) e1:SetOperation(cm.activate) c:RegisterEffect(e1) --spsummon local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_GRAVE) e2:SetCountLimit(1,m+900) e2:SetCondition(cm.condition) e2:SetCost(cm.cost) e2:SetTarget(cm.target) e2:SetOperation(cm.activate) c:RegisterEffect(e2) Duel.AddCustomActivityCounter(m,ACTIVITY_SPSUMMON,cm.counterfilter) end function cm.counterfilter(c) return c:GetSummonLocation()~=LOCATION_EXTRA end function cm.spfilter(c,e,tp,mc) return c:IsCode(28327000) and bit.band(c:GetType(),0x81)==0x81 and (not c.mat_filter or c.mat_filter(mc,tp)) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_RITUAL,tp,false,true) and mc:IsCanBeRitualMaterial(c) end function cm.rfilter(c,mc) local mlv=mc:GetRitualLevel(c) if mlv==mc:GetLevel() then return false end local lv=c:GetLevel() return lv==bit.band(mlv,0xffff) or lv==bit.rshift(mlv,16) end function cm.filter(c,e,tp) local sg=Duel.GetMatchingGroup(cm.spfilter,tp,LOCATION_HAND,0,c,e,tp,c) return sg:IsExists(cm.rfilter,1,nil,c) or sg:CheckWithSumEqual(Card.GetLevel,c:GetLevel(),1,1) end function cm.mfilter(c) return c:GetLevel()>0 and c:IsAbleToGrave() end function cm.mzfilter(c,tp) return c:IsLocation(LOCATION_MZONE) and c:IsControler(tp) and c:GetSequence()<5 end function cm.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<0 then return false end local mg=Duel.GetRitualMaterial(tp) if ft>0 then local mg2=Duel.GetMatchingGroup(cm.mfilter,tp,LOCATION_EXTRA,0,nil) mg:Merge(mg2) else mg=mg:Filter(cm.mzfilter,nil,tp) end return mg:IsExists(cm.filter,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND) end function cm.activate(e,tp,eg,ep,ev,re,r,rp) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<0 then return end local mg=Duel.GetRitualMaterial(tp) if ft>0 then local mg2=Duel.GetMatchingGroup(cm.mfilter,tp,LOCATION_EXTRA,0,nil) mg:Merge(mg2) else mg=mg:Filter(cm.mzfilter,nil,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE) local mat=mg:FilterSelect(tp,cm.filter,1,1,nil,e,tp) local mc=mat:GetFirst() if not mc then return end local sg=Duel.GetMatchingGroup(cm.spfilter,tp,LOCATION_HAND,0,mc,e,tp,mc) if mc:IsLocation(LOCATION_MZONE) then ft=ft+1 end if Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end local b1=sg:IsExists(cm.rfilter,1,nil,mc) local b2=sg:CheckWithSumEqual(Card.GetLevel,mc:GetLevel(),1,1) if b1 and (not b2 or Duel.SelectYesNo(tp,aux.Stringid(m,0))) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=sg:FilterSelect(tp,cm.rfilter,1,1,nil,mc) local tc=tg:GetFirst() tc:SetMaterial(mat) if not mc:IsLocation(LOCATION_EXTRA) then Duel.ReleaseRitualMaterial(mat) else Duel.SendtoGrave(mat,REASON_EFFECT+REASON_MATERIAL+REASON_RITUAL) end Duel.BreakEffect() Duel.SpecialSummon(tc,SUMMON_TYPE_RITUAL,tp,tp,false,true,POS_FACEUP) tc:CompleteProcedure() else Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=sg:SelectWithSumEqual(tp,Card.GetLevel,mc:GetLevel(),1,1) local tc=tg:GetFirst() while tc do tc:SetMaterial(mat) tc=tg:GetNext() end if not mc:IsLocation(LOCATION_EXTRA) then Duel.ReleaseRitualMaterial(mat) else Duel.SendtoGrave(mat,REASON_EFFECT+REASON_MATERIAL+REASON_RITUAL) end Duel.BreakEffect() tc=tg:GetFirst() while tc do Duel.SpecialSummonStep(tc,SUMMON_TYPE_RITUAL,tp,tp,false,true,POS_FACEUP) tc:CompleteProcedure() tc=tg:GetNext() end Duel.SpecialSummonComplete() end end function cm.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0 and aux.exccon(e) end function cm.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetCustomActivityCount(m,tp,ACTIVITY_SPSUMMON)==0 and aux.bfgcost(e,tp,eg,ep,ev,re,r,rp,0) end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetTargetRange(1,0) e1:SetTarget(cm.splimit) Duel.RegisterEffect(e1,tp) aux.bfgcost(e,tp,eg,ep,ev,re,r,rp,1) end function cm.splimit(e,c) return c:IsLocation(LOCATION_EXTRA) end