Commit 25f91572 authored by root's avatar root

Refresh on 2025-07-12 19:40:34

parent ac431ad0
--螢焅聖 アレクウス
local s,id,o=GetID()
function s.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH)
e1:SetCondition(s.spcon)
c:RegisterEffect(e1)
--destroy & draw
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,0))
e2:SetCategory(CATEGORY_DESTROY+CATEGORY_DRAW)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCountLimit(1,id)
e2:SetTarget(s.destg)
e2:SetOperation(s.desop)
c:RegisterEffect(e2)
--Attach
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET)
e3:SetCode(EVENT_DESTROYED)
e3:SetCountLimit(1,id+o)
e3:SetTarget(s.xyztg)
e3:SetOperation(s.xyzop)
c:RegisterEffect(e3)
end
function s.spcfilter(c)
return c:IsFaceup() and c:GetSequence()<5
end
function s.spcon(e,c)
if c==nil then return true end
local tp=c:GetControler()
return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(s.spcfilter,tp,LOCATION_SZONE,0,1,nil)
end
function s.desfilter(c)
return c:IsFaceup() and c:IsType(TYPE_SPELL+TYPE_TRAP)
end
function s.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local c=e:GetHandler()
if chkc then return chkc:IsOnField() and chkc:IsControler(tp) and chkc~=c and s.desfilter(chkc) end
if chk==0 then return c:IsDestructable()
and Duel.IsExistingTarget(s.desfilter,tp,LOCATION_ONFIELD,0,1,c)
and Duel.IsPlayerCanDraw(tp,1) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,s.desfilter,tp,LOCATION_ONFIELD,0,1,1,c)
g:AddCard(c)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end
function s.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsRelateToChain() and tc:IsRelateToChain() then
local g=Group.FromCards(c,tc)
if Duel.Destroy(g,REASON_EFFECT)==2 then
Duel.BreakEffect()
Duel.Draw(tp,1,REASON_EFFECT)
end
end
end
function s.xyzfilter(c)
return c:IsFaceup() and c:IsType(TYPE_XYZ)
end
function s.xyztg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local c=e:GetHandler()
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.xyzfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.xyzfilter,tp,LOCATION_MZONE,0,1,nil)
and e:GetHandler():IsCanOverlay() end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
Duel.SelectTarget(tp,s.xyzfilter,tp,LOCATION_MZONE,0,1,1,nil)
if c:IsLocation(LOCATION_GRAVE) then
Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,c,1,0,0)
end
end
function s.xyzop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsRelateToChain() and not tc:IsImmuneToEffect(e)
and c:IsRelateToChain() and c:IsCanOverlay() and aux.NecroValleyFilter()(c) then
Duel.Overlay(tc,Group.FromCards(c))
end
end
--フルスピード・ウォリアー
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,63977008,60800381)
--search
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetCountLimit(1,id)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetTarget(s.thtg)
e1:SetOperation(s.thop)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
--atk up
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_UPDATE_ATTACK)
e3:SetRange(LOCATION_MZONE)
e3:SetTargetRange(LOCATION_MZONE,0)
e3:SetCondition(s.atkcon)
e3:SetTarget(s.atktg)
e3:SetValue(900)
c:RegisterEffect(e3)
end
function s.thfilter(c)
return (aux.IsCodeListed(c,60800381) and c:IsType(TYPE_SPELL+TYPE_TRAP) or c:IsCode(63977008)) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if #g>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
function s.atkcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsBattlePhase() and Duel.GetTurnPlayer()==e:GetHandlerPlayer()
end
function s.atktg(e,c)
return aux.IsCodeListed(c,60800381) or c:IsOriginalSetCard(0x66) and c:IsType(TYPE_SYNCHRO)
end
--アンカーボルト・ヘッジホーグ
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,60800381)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(LOCATION_GRAVE)
e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e1:SetCountLimit(1,id)
e1:SetCondition(s.spcon)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
end
function s.cfilter(c)
return c:IsFaceup() and not c:IsCode(id)
and (c:IsCode(60800381) or aux.IsCodeListed(c,60800381) and c:IsType(TYPE_MONSTER))
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_ONFIELD,0,1,nil)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToChain() and aux.NecroValleyFilter()(c) then
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e1:SetTargetRange(1,0)
e1:SetTarget(s.splimit)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
end
function s.splimit(e,c)
return not c:IsType(TYPE_SYNCHRO) and c:IsLocation(LOCATION_EXTRA)
end
--シンクロ・フェローズ
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddMaterialCodeList(c,63977008,60800381,44508094)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH+CATEGORY_HANDES)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1)
--lvdown
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetRange(LOCATION_GRAVE)
e2:SetCost(aux.bfgcost)
e2:SetTarget(s.lvtg)
e2:SetOperation(s.lvop)
c:RegisterEffect(e2)
end
function s.thfilter1(c)
return c:IsCode(63977008) and c:IsAbleToHand()
end
function s.thfilter2(c)
return (aux.IsCodeListed(c,60800381) or aux.IsCodeListed(c,44508094)) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function s.thfilter(c)
return (c:IsCode(63977008) or (aux.IsCodeListed(c,60800381) or aux.IsCodeListed(c,44508094)) and c:IsType(TYPE_MONSTER))
and c:IsAbleToHand()
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local g=Duel.GetMatchingGroup(s.thfilter,tp,LOCATION_DECK,0,nil)
return g:CheckSubGroup(aux.gffcheck,2,2,s.thfilter1,nil,s.thfilter2,nil)
end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,2,tp,LOCATION_DECK)
end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(s.thfilter,tp,LOCATION_DECK,0,nil)
if not g:CheckSubGroup(aux.gffcheck,2,2,s.thfilter1,nil,s.thfilter2,nil) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local tg1=g:SelectSubGroup(tp,aux.gffcheck,false,2,2,s.thfilter1,nil,s.thfilter2,nil)
if #tg1==2 then
Duel.SendtoHand(tg1,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,tg1)
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD)
local dg=Duel.SelectMatchingCard(tp,aux.TRUE,tp,LOCATION_HAND,0,1,1,nil)
Duel.ShuffleHand(tp)
Duel.SendtoGrave(dg,REASON_EFFECT+REASON_DISCARD)
end
end
function s.lvfilter(c)
return c:IsType(TYPE_SYNCHRO) and c:GetLevel()>1 and c:IsFaceup()
end
function s.lvtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and s.lvfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.lvfilter,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
Duel.SelectTarget(tp,s.lvfilter,tp,LOCATION_MZONE,0,1,1,nil)
end
function s.lvop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsRelateToChain() and tc:IsFaceup() and tc:IsType(TYPE_MONSTER) and tc:GetLevel()>1
and not tc:IsImmuneToEffect(e) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_LEVEL)
e1:SetValue(-1)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e1)
if Duel.IsPlayerCanSummon(tp) and Duel.IsPlayerCanAdditionalSummon(tp) and Duel.GetFlagEffect(tp,id)==0 then
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetDescription(aux.Stringid(id,2))
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetTargetRange(LOCATION_HAND+LOCATION_MZONE,0)
e2:SetCode(EFFECT_EXTRA_SUMMON_COUNT)
e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x1017))
e2:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e2,tp)
Duel.RegisterFlagEffect(tp,id,RESET_PHASE+PHASE_END,0,1)
end
end
end
--ジャンク・ウォリアー・エクストリーム
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddMaterialCodeList(c,63977008)
--synchro summon
aux.AddSynchroProcedure(c,s.tfilter,aux.NonTuner(nil),1)
c:EnableReviveLimit()
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCountLimit(1,id)
e1:SetCondition(s.spcon)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
--special summon 2
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_BATTLE_DESTROYING)
e2:SetCountLimit(1,id+o)
e2:SetCondition(aux.bdocon)
e2:SetCost(aux.bfgcost)
e2:SetTarget(s.sptg2)
e2:SetOperation(s.spop2)
c:RegisterEffect(e2)
end
s.material_setcode=0x1017
function s.tfilter(c)
return c:IsCode(63977008) or c:IsHasEffect(20932152)
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
end
function s.spfilter(c,e,tp)
return c:IsLevelBelow(2) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
local tg=Duel.GetMatchingGroup(aux.NecroValleyFilter(s.spfilter),tp,LOCATION_GRAVE,0,nil,e,tp)
if ft>0 then
if Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end
local g=nil
if tg:GetCount()>ft then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
g=tg:Select(tp,ft,ft,nil)
else
g=tg
end
if g:GetCount()>0 then
for tc in aux.Next(g) do
Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_TRIGGER)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
end
Duel.SpecialSummonComplete()
end
end
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e2:SetTargetRange(1,0)
e2:SetLabel(s.getsummoncount(tp))
e2:SetTarget(s.splimit)
e2:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e2,tp)
local e3=Effect.CreateEffect(e:GetHandler())
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_LEFT_SPSUMMON_COUNT)
e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e3:SetTargetRange(1,0)
e3:SetLabel(s.getsummoncount(tp))
e3:SetValue(s.countval)
e3:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e3,tp)
end
function s.getsummoncount(tp)
return Duel.GetActivityCount(tp,ACTIVITY_SPSUMMON)
end
function s.splimit(e,c,sump,sumtype,sumpos,targetp,se)
return s.getsummoncount(sump)>e:GetLabel()
end
function s.countval(e,re,tp)
if s.getsummoncount(tp)>e:GetLabel() then return 0 else return 1 end
end
function s.spfilter2(c,e,tp,ec)
return c:IsSetCard(0x43) and c:IsType(TYPE_SYNCHRO) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_SYNCHRO,tp,false,false)
and Duel.GetLocationCountFromEx(tp,tp,ec,c)>0
end
function s.sptg2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_SMATERIAL)
and Duel.IsExistingMatchingCard(s.spfilter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,e:GetHandler()) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function s.spop2(e,tp,eg,ep,ev,re,r,rp)
if not aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_SMATERIAL) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,s.spfilter2,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,nil)
local tc=g:GetFirst()
if tc then
tc:SetMaterial(nil)
if Duel.SpecialSummon(tc,SUMMON_TYPE_SYNCHRO,tp,tp,false,false,POS_FACEUP)>0 then
tc:CompleteProcedure()
end
end
end
--見えざる手イブエル
local s,id,o=GetID()
function s.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_TODECK+CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1,id)
e1:SetCost(s.spcost)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
--indes
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e2:SetTarget(s.indtg)
e2:SetValue(1)
c:RegisterEffect(e2)
--special summon 2
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_TO_GRAVE)
e3:SetCountLimit(1,id+o)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e3:SetTarget(s.sptg2)
e3:SetOperation(s.spop2)
c:RegisterEffect(e3)
end
function s.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return not e:GetHandler():IsPublic() end
end
function s.spfilter(c,e,tp)
return not c:IsCode(id) and c:IsSetCard(0x2d4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp)
and c:IsAbleToDeck() end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToChain() and Duel.SendtoDeck(c,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)~=0
and c:IsLocation(LOCATION_DECK) then
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.BreakEffect()
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
end
end
end
function s.indtg(e,c)
local tc=e:GetHandler()
return c==tc or c==tc:GetBattleTarget()
end
function s.spfilter2(c,e,tp)
return not c:IsCode(id) and c:IsSetCard(0x2d4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function s.sptg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter2(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(s.spfilter2,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,s.spfilter2,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function s.spop2(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToChain() and aux.NecroValleyFilter()(tc) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
--見えざる手ヤドエル
local s,id,o=GetID()
function s.initial_effect(c)
--search
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_TODECK+CATEGORY_SEARCH+CATEGORY_TOHAND)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1,id)
e1:SetCost(s.thcost)
e1:SetTarget(s.thtg)
e1:SetOperation(s.thop)
c:RegisterEffect(e1)
--indes
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e2:SetTarget(s.indtg)
e2:SetValue(1)
c:RegisterEffect(e2)
--special summon 2
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_TO_GRAVE)
e3:SetCountLimit(1,id+o)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e3:SetTarget(s.settg)
e3:SetOperation(s.setop)
c:RegisterEffect(e3)
end
function s.thcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return not e:GetHandler():IsPublic() end
end
function s.thfilter(c)
return c:IsSetCard(0x2d4) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil)
and c:IsAbleToDeck() end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToChain() and Duel.SendtoDeck(c,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)~=0
and c:IsLocation(LOCATION_DECK) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.BreakEffect()
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
end
function s.indtg(e,c)
local tc=e:GetHandler()
return c==tc or c==tc:GetBattleTarget()
end
function s.setfilter(c)
return c:IsSetCard(0x2d4) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable()
end
function s.settg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.setfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.setfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET)
local g=Duel.SelectTarget(tp,s.setfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,g,1,0,0)
end
function s.setop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToChain() and aux.NecroValleyFilter()(tc) then
Duel.SSet(tp,tc)
end
end
--見えざる手ゴッドス
local s,id,o=GetID()
function s.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCode(EVENT_TO_HAND)
e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1,id)
e1:SetCondition(s.spcon)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
--indes
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e2:SetTarget(s.indtg)
e2:SetValue(1)
c:RegisterEffect(e2)
--special summon
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetRange(LOCATION_MZONE)
e3:SetCode(EVENT_FREE_CHAIN)
e3:SetCountLimit(1,id+o)
e3:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_MAIN_END)
e3:SetCondition(s.spcon2)
e3:SetTarget(s.sptg2)
e3:SetOperation(s.spop2)
c:RegisterEffect(e3)
end
function s.cfilter(c,tp)
return c:IsControler(tp)
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()~=PHASE_DRAW and eg:IsExists(s.cfilter,1,nil,1-tp)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToChain() then
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
end
function s.indtg(e,c)
local tc=e:GetHandler()
return c==tc or c==tc:GetBattleTarget()
end
function s.spcon2(e,tp,eg,ep,ev,re,r,rp)
local ph=Duel.GetCurrentPhase()
return Duel.GetTurnPlayer()~=tp and (ph==PHASE_MAIN1 or ph==PHASE_MAIN2)
end
function s.spfilter(c,e,tp)
return c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function s.sptg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1-tp) and s.spfilter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(s.spfilter,tp,0,LOCATION_GRAVE,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,s.spfilter,tp,0,LOCATION_GRAVE,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function s.spop2(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsRelateToChain() and aux.NecroValleyFilter()(tc)
and Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetValue(LOCATION_REMOVED)
e1:SetReset(RESET_EVENT+RESETS_REDIRECT)
tc:RegisterEffect(e1,true)
end
Duel.SpecialSummonComplete()
end
--見えざる手ガイガス
local s,id,o=GetID()
function s.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCode(EVENT_TO_HAND)
e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1,id)
e1:SetCondition(s.spcon)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
--indes
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e2:SetTarget(s.indtg)
e2:SetValue(1)
c:RegisterEffect(e2)
--special summon 2
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_DECKDES)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1,id+o)
e3:SetTarget(s.sptg2)
e3:SetOperation(s.spop2)
c:RegisterEffect(e3)
end
function s.cfilter(c,tp)
return c:IsControler(tp)
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()~=PHASE_DRAW and eg:IsExists(s.cfilter,1,nil,1-tp)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToChain() then
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
end
function s.indtg(e,c)
local tc=e:GetHandler()
return c==tc or c==tc:GetBattleTarget()
end
function s.sptg2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetFieldGroupCount(tp,0,LOCATION_DECK)>2 end
end
function s.spfilter(c,e,tp)
return c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function s.spop2(e,tp,eg,ep,ev,re,r,rp)
Duel.ConfirmDecktop(1-tp,3)
local g=Duel.GetDecktopGroup(1-tp,3)
if Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and g:IsExists(s.spfilter,1,nil,e,tp)
and Duel.SelectYesNo(tp,aux.Stringid(id,2)) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:FilterSelect(tp,s.spfilter,1,1,nil,e,tp)
if sg:GetCount()>0 then
Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP)
end
end
Duel.ShuffleDeck(1-tp)
end
--見えざる手ブレアス
local s,id,o=GetID()
function s.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCode(EVENT_TO_HAND)
e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1,id)
e1:SetCondition(s.spcon)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
--indes
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e2:SetTarget(s.indtg)
e2:SetValue(1)
c:RegisterEffect(e2)
--special summon 2
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1,id+o)
e3:SetTarget(s.sptg2)
e3:SetOperation(s.spop2)
c:RegisterEffect(e3)
end
function s.cfilter(c,tp)
return c:IsControler(tp)
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()~=PHASE_DRAW and eg:IsExists(s.cfilter,1,nil,1-tp)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToChain() then
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
end
function s.indtg(e,c)
local tc=e:GetHandler()
return c==tc or c==tc:GetBattleTarget()
end
function s.sptg2(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetFieldGroupCount(tp,0,LOCATION_HAND)>0 end
end
function s.spop2(e,tp,eg,ep,ev,re,r,rp)
local hg=Duel.GetFieldGroup(tp,0,LOCATION_HAND)
local tc=hg:RandomSelect(tp,1):GetFirst()
if not tc then return end
Duel.ConfirmCards(1-tp,tc)
if Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and tc:IsCanBeSpecialSummoned(e,0,tp,false,false)
and Duel.SelectYesNo(tp,aux.Stringid(id,2)) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
Duel.ShuffleHand(1-tp)
end
--見えざる神ジャウザー
local s,id,o=GetID()
function s.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFun2(c,aux.FilterBoolFunction(Card.IsFusionSetCard,0x2d4),aux.FilterBoolFunction(Card.IsRace,RACE_ILLUSION),true)
--special summon
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_FIELD)
e0:SetCode(EFFECT_SPSUMMON_PROC)
e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e0:SetRange(LOCATION_EXTRA)
e0:SetCondition(s.spcon)
e0:SetTarget(s.sptg)
e0:SetOperation(s.spop)
c:RegisterEffect(e0)
--special summon condition
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
e1:SetRange(LOCATION_EXTRA)
e1:SetValue(aux.fuslimit)
c:RegisterEffect(e1)
--tohand
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,0))
e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1,id)
e2:SetTarget(s.thtg)
e2:SetOperation(s.thop)
c:RegisterEffect(e2)
--indes
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e3:SetRange(LOCATION_MZONE)
e3:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e3:SetTarget(s.indtg)
e3:SetValue(1)
c:RegisterEffect(e3)
end
function s.cfilter(c,tp,g)
return c:GetOwner()==1-tp and c:IsFaceup() and g:IsExists(Card.IsRace,1,c,RACE_ILLUSION)
end
function s.fselect(g,tp,ec)
return g:IsExists(s.cfilter,1,nil,tp,g) and Duel.GetLocationCountFromEx(tp,tp,g,ec)>0
end
function s.spcon(e,c)
if c==nil then return true end
local tp=c:GetControler()
local rg=Duel.GetReleaseGroup(tp,false,REASON_SPSUMMON):Filter(Card.IsCanBeFusionMaterial,nil,c,SUMMON_TYPE_SPECIAL)
return rg:CheckSubGroup(s.fselect,2,2,tp,c)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk,c)
local rg=Duel.GetReleaseGroup(tp,false,REASON_SPSUMMON):Filter(Card.IsCanBeFusionMaterial,nil,c,SUMMON_TYPE_SPECIAL)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
local sg=rg:SelectSubGroup(tp,s.fselect,true,2,2,tp,c)
if sg then
sg:KeepAlive()
e:SetLabelObject(sg)
return true
else return false end
end
function s.spop(e,tp,eg,ep,ev,re,r,rp,c)
local g=e:GetLabelObject()
c:SetMaterial(g)
Duel.Release(g,REASON_SPSUMMON|REASON_MATERIAL)
g:DeleteGroup()
end
function s.thfilter(c)
return c:IsSetCard(0x2d4) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.thfilter),tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil)
if #g>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
function s.indtg(e,c)
local tc=e:GetHandler()
return c==tc or c==tc:GetBattleTarget()
end
--見えざる神ゼノ
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddFusionProcFunRep(c,s.ffilter,3,true)
c:EnableReviveLimit()
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(LOCATION_MZONE)
e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_MAIN_END)
e1:SetCountLimit(1,id)
e1:SetCondition(s.spcon)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
--indes
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e2:SetTarget(s.indtg)
e2:SetValue(1)
c:RegisterEffect(e2)
--control
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetCategory(CATEGORY_CONTROL)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_DELAY)
e3:SetCode(EVENT_DESTROYED)
e3:SetCountLimit(1,id+o)
e3:SetCondition(s.ctcon)
e3:SetTarget(s.cttg)
e3:SetOperation(s.ctop)
c:RegisterEffect(e3)
end
function s.ffilter(c)
return c:IsFusionSetCard(0x2d4)
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsMainPhase()
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsFacedown,tp,0,LOCATION_EXTRA,2,nil) end
end
function s.spfilter(c,e,tp)
return c:IsCanBeSpecialSummoned(e,0,tp,false,false)
and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local hg=Duel.GetFieldGroup(tp,0,LOCATION_EXTRA):Filter(Card.IsFacedown,nil)
local g=hg:RandomSelect(tp,2)
if g:GetCount()<1 then return end
Duel.ConfirmCards(tp,g)
if g:IsExists(s.spfilter,1,nil,e,tp)
and Duel.SelectYesNo(tp,aux.Stringid(id,2)) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:FilterSelect(tp,s.spfilter,1,1,nil,e,tp)
if sg:GetCount()>0 then
Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP)
end
end
end
function s.indtg(e,c)
local tc=e:GetHandler()
return c==tc or c==tc:GetBattleTarget()
end
function s.ctcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return rp==1-tp and c:IsPreviousControler(tp) and c:IsPreviousLocation(LOCATION_MZONE)
and c:IsSummonType(SUMMON_TYPE_FUSION) and c:IsReason(REASON_EFFECT)
end
function s.cttg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsControlerCanBeChanged,tp,0,LOCATION_MZONE,1,nil) end
local g=Duel.GetMatchingGroup(Card.IsControlerCanBeChanged,tp,0,LOCATION_MZONE,nil)
Duel.SetOperationInfo(0,CATEGORY_CONTROL,g,1,0,0)
end
function s.ctop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local ct=Duel.GetLocationCount(tp,LOCATION_MZONE)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONTROL)
local g=Duel.SelectMatchingCard(tp,Card.IsControlerCanBeChanged,tp,0,LOCATION_MZONE,1,ct,nil)
if g:GetCount()>0 then
Duel.HintSelection(g)
Duel.GetControl(g,tp)
end
end
--見えざる幽獄
local s,id,o=GetID()
function s.initial_effect(c)
--activate
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON+CATEGORY_REMOVE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_FUSION_SUMMON|EFFECT_FLAG_CARD_TARGET)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1)
end
function s.cfilter(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function s.filter1(c,e)
return c:IsOnField() and c:IsAbleToRemove() and not c:IsImmuneToEffect(e)
end
function s.filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and c:IsSetCard(0x2d4) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
end
function s.filter3(c)
return c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsAbleToRemove()
end
function s.ffilter(e,c)
return c:IsFaceup() and c:GetOwner()==1-e:GetHandlerPlayer()
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local b1=Duel.IsExistingTarget(s.cfilter,tp,0,LOCATION_ONFIELD,1,nil)
and (not e:IsCostChecked()
or Duel.GetFlagEffect(tp,id)==0
and Duel.IsExistingMatchingCard(aux.AND(Card.IsFaceup,Card.IsSetCard),tp,LOCATION_MZONE,0,1,nil,0x2d4))
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp):Filter(s.filter1,nil,e)
local mg2=Duel.GetMatchingGroup(s.filter3,tp,LOCATION_GRAVE,0,nil)
mg1:Merge(mg2)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_ADD_FUSION_SETCODE)
e1:SetTargetRange(LOCATION_MZONE,0)
e1:SetTarget(s.ffilter)
e1:SetValue(0x2d4)
Duel.RegisterEffect(e1,tp)
local res=Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf)
if not res then
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
local mg3=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg3,mf,chkf)
end
end
local b2=res
and (not e:IsCostChecked()
or Duel.GetFlagEffect(tp,id+o)==0)
e1:Reset()
if chk==0 then return b1 or b2 end
local op=0
if b1 or b2 then
op=aux.SelectFromOptions(tp,
{b1,aux.Stringid(id,1),1},
{b2,aux.Stringid(id,2),2})
end
e:SetLabel(op)
if op==1 then
if e:IsCostChecked() then
e:SetCategory(CATEGORY_TOHAND)
e:SetProperty(EFFECT_FLAG_FUSION_SUMMON|EFFECT_FLAG_CARD_TARGET)
Duel.RegisterFlagEffect(tp,id,RESET_PHASE+PHASE_END,0,1)
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g=Duel.SelectTarget(tp,s.cfilter,tp,0,LOCATION_ONFIELD,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
elseif op==2 then
if e:IsCostChecked() then
e:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON+CATEGORY_REMOVE)
e:SetProperty(EFFECT_FLAG_FUSION_SUMMON)
Duel.RegisterFlagEffect(tp,id+o,RESET_PHASE+PHASE_END,0,1)
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_ONFIELD+LOCATION_GRAVE)
end
end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
if e:GetLabel()==1 then
local tc=Duel.GetFirstTarget()
if tc:IsRelateToChain() then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
elseif e:GetLabel()==2 then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_ADD_FUSION_SETCODE)
e1:SetTargetRange(LOCATION_MZONE,0)
e1:SetTarget(s.ffilter)
e1:SetValue(0x2d4)
Duel.RegisterEffect(e1,tp)
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp):Filter(s.filter1,nil,e)
local mg2=Duel.GetMatchingGroup(s.filter3,tp,LOCATION_GRAVE,0,nil)
mg1:Merge(mg2)
local sg1=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
local mg3=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
mg3=fgroup(ce,e,tp)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg3,mf,chkf)
end
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then
local sg=sg1:Clone()
if sg2 then sg:Merge(sg2) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=sg:Select(tp,1,1,nil)
local tc=tg:GetFirst()
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or ce and not Duel.SelectYesNo(tp,ce:GetDescription())) then
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
tc:SetMaterial(mat1)
Duel.Remove(mat1,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
elseif ce then
local mat2=Duel.SelectFusionMaterial(tp,tc,mg3,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
tc:CompleteProcedure()
end
e1:Reset()
end
end
--見えざる誘い手
local s,id,o=GetID()
function s.initial_effect(c)
--negate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY+CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_CHAINING)
e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH)
e1:SetCondition(s.condition)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1)
end
function s.cfilter1(c)
return c:IsFaceup() and c:IsSetCard(0x2d4)
end
function s.condition(e,tp,eg,ep,ev,re,r,rp)
return rp~=tp and re:IsActiveType(TYPE_MONSTER) and Duel.IsChainNegatable(ev)
and Duel.IsExistingMatchingCard(s.cfilter1,tp,LOCATION_MZONE,0,1,nil)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
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.activate(e,tp,eg,ep,ev,re,r,rp)
local rc=re:GetHandler()
if not Duel.NegateActivation(ev) then return end
if rc:IsRelateToChain(ev) and Duel.Destroy(eg,REASON_EFFECT)~=0
and not (rc:IsLocation(LOCATION_HAND+LOCATION_DECK) or rc:IsLocation(LOCATION_REMOVED) and rc:IsFacedown())
and aux.NecroValleyFilter()(rc) then
if rc:IsType(TYPE_MONSTER) and (not rc:IsLocation(LOCATION_EXTRA) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0
or rc:IsLocation(LOCATION_EXTRA) and rc:IsFaceup() and Duel.GetLocationCountFromEx(tp,tp,nil,rc)>0)
and rc:IsCanBeSpecialSummoned(e,0,tp,false,false)
and Duel.SelectYesNo(tp,aux.Stringid(id,1)) then
Duel.BreakEffect()
Duel.SpecialSummon(rc,0,tp,tp,false,false,POS_FACEUP)
end
end
end
--見えざる招き手
local s,id,o=GetID()
function s.initial_effect(c)
--negate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_CHAINING)
e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH)
e1:SetCondition(s.condition)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1)
end
function s.cfilter1(c)
return c:IsFaceup() and c:IsSetCard(0x2d4)
end
function s.condition(e,tp,eg,ep,ev,re,r,rp)
return rp~=tp and re:IsHasType(EFFECT_TYPE_ACTIVATE) and Duel.IsChainNegatable(ev)
and Duel.IsExistingMatchingCard(s.cfilter1,tp,LOCATION_MZONE,0,1,nil)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
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.activate(e,tp,eg,ep,ev,re,r,rp)
local rc=re:GetHandler()
if not Duel.NegateActivation(ev) then return end
if rc:IsRelateToChain(ev) and Duel.Destroy(eg,REASON_EFFECT)~=0
and not (rc:IsLocation(LOCATION_HAND+LOCATION_DECK) or rc:IsLocation(LOCATION_REMOVED) and rc:IsFacedown())
and aux.NecroValleyFilter()(rc) then
if (rc:IsType(TYPE_FIELD) or Duel.GetLocationCount(tp,LOCATION_SZONE)>0)
and rc:IsSSetable(true) and Duel.SelectYesNo(tp,aux.Stringid(id,1)) then
Duel.BreakEffect()
Duel.SSet(tp,rc)
end
end
end
\ No newline at end of file
--終刻竜機ⅩⅡ-ドラスティア
local s,id,o=GetID()
function s.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_DESTROY+CATEGORY_EQUIP)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1,id)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
--spsummon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetRange(LOCATION_MZONE)
e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e2:SetCountLimit(1,id+o)
e2:SetCondition(s.xyzcon)
e2:SetTarget(s.xyztg)
e2:SetOperation(s.xyzop)
c:RegisterEffect(e2)
end
function s.desfilter(c,tp)
return c:IsFaceup() and c:IsSetCard(0x2d3) and Duel.GetMZoneCount(tp,c)>0
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local c=e:GetHandler()
if chkc then return chkc:IsLocation(LOCATION_ONFIELD) and chkc:IsControler(tp) and s.desfilter(chkc,tp) end
if chk==0 then return c:IsCanBeSpecialSummoned(e,0,tp,false,false)
and Duel.IsExistingTarget(s.desfilter,tp,LOCATION_ONFIELD,0,1,nil,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,s.desfilter,tp,LOCATION_ONFIELD,0,1,1,nil,tp)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0)
end
function s.eqfilter(c,ec,tp)
return c:IsType(TYPE_EQUIP) and c:CheckEquipTarget(ec) and c:CheckUniqueOnField(tp,LOCATION_SZONE) and not c:IsForbidden()
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsRelateToChain() and Duel.Destroy(tc,REASON_EFFECT)~=0 then
if c:IsRelateToChain() and Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)~=0
and Duel.IsExistingMatchingCard(s.eqfilter,tp,LOCATION_DECK,0,1,nil,c,tp)
and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.SelectYesNo(tp,aux.Stringid(id,2)) then
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectMatchingCard(tp,s.eqfilter,tp,LOCATION_DECK,0,1,1,nil,c,tp)
local ec=g:GetFirst()
if ec then Duel.Equip(tp,ec,c) end
end
end
end
function s.xyzcon(e,tp,eg,ep,ev,re,r,rp)
local g=e:GetHandler():GetEquipGroup()
return g:GetCount()>0 and not g:IsExists(aux.NOT(Card.IsCanOverlay),1,nil)
end
function s.spfilter(c,e,tp,lv)
return c:IsRace(RACE_MACHINE) and c:IsAttribute(ATTRIBUTE_WIND) and c:IsRank(lv)
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0
end
function s.xyztg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsCanOverlay()
and aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_XMATERIAL)
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,c:GetLevel()) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function s.xyzop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToChain() or c:IsFacedown() then return end
if not aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_XMATERIAL) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,c:GetLevel())
local sc=sg:GetFirst()
if sc and Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP)~=0 then
sc:CompleteProcedure()
local g=c:GetEquipGroup()
g:AddCard(c)
Duel.Overlay(sc,g)
end
end
--終刻竜機Ⅴ-アマルテ
local s,id,o=GetID()
function s.initial_effect(c)
--search
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCountLimit(1,id)
e1:SetTarget(s.thtg)
e1:SetOperation(s.thop)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
local e3=e1:Clone()
e3:SetCode(EVENT_DESTROYED)
e3:SetCondition(s.thcon)
c:RegisterEffect(e3)
--spsummon
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,1))
e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
e4:SetType(EFFECT_TYPE_QUICK_O)
e4:SetCode(EVENT_FREE_CHAIN)
e4:SetRange(LOCATION_MZONE)
e4:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e4:SetCountLimit(1,id+o)
e4:SetCondition(s.xyzcon)
e4:SetTarget(s.xyztg)
e4:SetOperation(s.xyzop)
c:RegisterEffect(e4)
end
function s.thcon(e,tp,eg,ep,ev,re,r,rp,chk)
return e:GetHandler():IsReason(REASON_EFFECT)
end
function s.thfilter(c)
return not c:IsCode(id) and c:IsSetCard(0x2d3) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if #g>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
function s.xyzcon(e,tp,eg,ep,ev,re,r,rp)
local g=e:GetHandler():GetEquipGroup()
return g:GetCount()>0 and not g:IsExists(aux.NOT(Card.IsCanOverlay),1,nil)
end
function s.spfilter(c,e,tp,lv)
return c:IsRace(RACE_MACHINE) and c:IsAttribute(ATTRIBUTE_WIND) and c:IsRank(lv)
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0
end
function s.xyztg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsCanOverlay()
and aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_XMATERIAL)
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,c:GetLevel()) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function s.xyzop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToChain() or c:IsFacedown() then return end
if not aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_XMATERIAL) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,c:GetLevel())
local sc=sg:GetFirst()
if sc and Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP)~=0 then
sc:CompleteProcedure()
local g=c:GetEquipGroup()
g:AddCard(c)
Duel.Overlay(sc,g)
end
end
--終刻竜機Ⅶ-エララ
local s,id,o=GetID()
function s.initial_effect(c)
--set
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCountLimit(1,id)
e1:SetTarget(s.settg)
e1:SetOperation(s.setop)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
local e3=e1:Clone()
e3:SetCode(EVENT_DESTROYED)
e3:SetCondition(s.setcon)
c:RegisterEffect(e3)
--spsummon
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,1))
e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
e4:SetType(EFFECT_TYPE_QUICK_O)
e4:SetCode(EVENT_FREE_CHAIN)
e4:SetRange(LOCATION_MZONE)
e4:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e4:SetCountLimit(1,id+o)
e4:SetCondition(s.xyzcon)
e4:SetTarget(s.xyztg)
e4:SetOperation(s.xyzop)
c:RegisterEffect(e4)
end
function s.setcon(e,tp,eg,ep,ev,re,r,rp,chk)
return e:GetHandler():IsReason(REASON_EFFECT)
end
function s.setfilter(c)
return c:IsSetCard(0x2d3) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable()
end
function s.settg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.setfilter,tp,LOCATION_DECK,0,1,nil) end
end
function s.setop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET)
local g=Duel.SelectMatchingCard(tp,s.setfilter,tp,LOCATION_DECK,0,1,1,nil)
local tc=g:GetFirst()
if tc then
Duel.SSet(tp,tc)
end
end
function s.xyzcon(e,tp,eg,ep,ev,re,r,rp)
local g=e:GetHandler():GetEquipGroup()
return g:GetCount()>0 and not g:IsExists(aux.NOT(Card.IsCanOverlay),1,nil)
end
function s.spfilter(c,e,tp,lv)
return c:IsRace(RACE_MACHINE) and c:IsAttribute(ATTRIBUTE_WIND) and c:IsRank(lv)
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0
end
function s.xyztg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsCanOverlay()
and aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_XMATERIAL)
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,c:GetLevel()) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function s.xyzop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToChain() or c:IsFacedown() then return end
if not aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_XMATERIAL) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,c:GetLevel())
local sc=sg:GetFirst()
if sc and Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP)~=0 then
sc:CompleteProcedure()
local g=c:GetEquipGroup()
g:AddCard(c)
Duel.Overlay(sc,g)
end
end
--獄神機Doom-Z
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,101302044)
--splimit
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetRange(LOCATION_MZONE)
e1:SetTargetRange(1,0)
e1:SetTarget(s.splimit)
c:RegisterEffect(e1)
--xyz summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1,id)
e2:SetTarget(s.sptg)
e2:SetOperation(s.spop)
c:RegisterEffect(e2)
--to grave
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_DELAY)
e3:SetCode(EVENT_DESTROYED)
e3:SetCountLimit(1,id+o)
e3:SetTarget(s.thtg)
e3:SetOperation(s.thop)
c:RegisterEffect(e3)
end
function s.splimit(e,c)
return not c:IsType(TYPE_XYZ) and c:IsLocation(LOCATION_EXTRA)
end
function s.cfilter(c,e,tp)
return c:IsFaceup() and c:IsLevelAbove(1) and c:IsType(TYPE_EFFECT)
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,c)
and aux.MustMaterialCheck(c,tp,EFFECT_MUST_BE_XMATERIAL)
end
function s.spfilter(c,e,tp,mc)
return c:IsRank(mc:GetLevel()) and (c:IsSetCard(0x2d3) or c:IsCode(101302044)) and c:IsAllTypes(TYPE_XYZ+TYPE_MONSTER)
and mc:IsCanBeXyzMaterial(c) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false)
and Duel.GetLocationCountFromEx(tp,tp,mc,c)>0
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingTarget(s.cfilter,tp,LOCATION_MZONE,0,1,e:GetHandler(),e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
Duel.SelectTarget(tp,s.cfilter,tp,LOCATION_MZONE,0,1,1,e:GetHandler(),e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if not aux.MustMaterialCheck(tc,tp,EFFECT_MUST_BE_XMATERIAL) then return end
if tc:IsFacedown() or not tc:IsRelateToChain() or not tc:IsType(TYPE_MONSTER)
or tc:IsControler(1-tp) or tc:IsImmuneToEffect(e) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,tc)
local sc=g:GetFirst()
if sc then
local mg=tc:GetOverlayGroup()
if mg:GetCount()~=0 then
Duel.Overlay(sc,mg)
end
sc:SetMaterial(Group.FromCards(tc))
Duel.Overlay(sc,Group.FromCards(tc))
Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP)
sc:CompleteProcedure()
if c:IsRelateToChain() and c:IsControler(tp) then
if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then
Duel.SendtoGrave(c,REASON_RULE)
return
end
if not Duel.Equip(tp,c,sc) then return end
--equip limit
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_EQUIP_LIMIT)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetLabelObject(sc)
e1:SetValue(s.eqlimit)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
c:RegisterEffect(e1)
end
end
end
function s.eqlimit(e,c)
return c==e:GetLabelObject()
end
function s.thfilter(c)
return c:IsSetCard(0x2d3) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if #g>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
--サイキッカー・オラクル
local s,id,o=GetID()
function s.initial_effect(c)
--material
aux.AddFusionProcFun2(c,aux.FilterBoolFunction(Card.IsRace,RACE_PSYCHO),aux.FilterBoolFunction(Card.IsFusionType,TYPE_SYNCHRO+TYPE_XYZ+TYPE_LINK),true)
--atkup
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_MATERIAL_CHECK)
e1:SetValue(s.matcheck)
c:RegisterEffect(e1)
--Negate summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,0))
e2:SetCategory(CATEGORY_DISABLE_SUMMON+CATEGORY_REMOVE)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EVENT_SPSUMMON)
e2:SetCountLimit(1,id)
e2:SetCondition(s.discon)
e2:SetTarget(s.distg)
e2:SetOperation(s.disop)
c:RegisterEffect(e2)
--spsummon
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_TO_GRAVE)
e3:SetProperty(EFFECT_FLAG_DELAY)
e3:SetCountLimit(1,id+o)
e3:SetCondition(s.spcon)
e3:SetCost(s.spcost)
e3:SetTarget(s.sptg)
e3:SetOperation(s.spop)
c:RegisterEffect(e3)
end
function s.matfilter(c)
return c:IsFusionType(TYPE_SYNCHRO+TYPE_XYZ+TYPE_LINK)
end
function s.matcheck(e,c)
local g=c:GetMaterial():Filter(s.matfilter,nil)
local atk=g:GetCount()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(atk*1000)
e1:SetReset(RESET_EVENT+RESETS_STANDARD-RESET_TOFIELD+RESET_DISABLE+RESET_PHASE+PHASE_END,2)
c:RegisterEffect(e1)
end
function s.discon(e,tp,eg,ep,ev,re,r,rp)
return tp~=ep and Duel.GetCurrentChain()==0
end
function s.distg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsPlayerCanRemove(tp) end
Duel.SetOperationInfo(0,CATEGORY_DISABLE_SUMMON,eg,eg:GetCount(),0,0)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,eg,eg:GetCount(),0,0)
end
function s.disop(e,tp,eg,ep,ev,re,r,rp)
Duel.NegateSummon(eg)
Duel.Remove(eg,POS_FACEUP,REASON_EFFECT)
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsPreviousLocation(LOCATION_MZONE) and c:IsSummonType(SUMMON_TYPE_FUSION)
end
function s.cfilter(c)
return (c:GetType()==TYPE_SPELL or c:IsType(TYPE_QUICKPLAY)) and c:IsSetCard(0x1cc) and c:IsAbleToRemoveAsCost()
end
function s.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_GRAVE,0,1,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_GRAVE,0,1,1,e:GetHandler())
Duel.Remove(g,POS_FACEUP,REASON_COST)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToChain() and aux.NecroValleyFilter()(c) then
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
end
--静寂のサイコソーサレス
local s,id,o=GetID()
function s.initial_effect(c)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1)
c:EnableReviveLimit()
--set
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetCountLimit(1,id)
e1:SetCondition(s.setcon)
e1:SetCost(s.setcost)
e1:SetTarget(s.settg)
e1:SetOperation(s.setop)
c:RegisterEffect(e1)
--to hand
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetCountLimit(1,id+o)
e2:SetCondition(s.thcon)
e2:SetTarget(s.thtg)
e2:SetOperation(s.thop)
c:RegisterEffect(e2)
end
function s.setcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
end
function s.setcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckLPCost(tp,1000) end
Duel.PayLPCost(tp,1000)
end
function s.setfilter(c)
return c:IsFaceupEx() and c:IsSetCard(0x1cc) and (c:GetType()==TYPE_SPELL or c:IsType(TYPE_QUICKPLAY)) and c:IsSSetable()
end
function s.settg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.setfilter,tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_REMOVED,0,1,nil) end
end
function s.setop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.setfilter),tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_REMOVED,0,1,1,nil)
local tc=g:GetFirst()
if tc then
Duel.SSet(tp,tc)
end
end
function s.thcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsPreviousLocation(LOCATION_MZONE) and c:IsSummonType(SUMMON_TYPE_SYNCHRO)
end
function s.cfilter(c)
return c:IsFaceup() and c:IsRace(RACE_PSYCHO) and c:IsType(TYPE_FUSION+TYPE_SYNCHRO)
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local ct=1
if Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_MZONE,0,1,nil) then
ct=2
end
if chkc then return chkc:IsOnField() and chkc:IsControler(1-tp) and chkc:IsAbleToHand() end
if chk==0 then return Duel.IsExistingTarget(Card.IsAbleToHand,tp,0,LOCATION_ONFIELD,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g=Duel.SelectTarget(tp,Card.IsAbleToHand,tp,0,LOCATION_ONFIELD,1,ct,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,g:GetCount(),0,0)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local tg=g:Filter(Card.IsRelateToChain,nil)
if tg:GetCount()>0 then
Duel.SendtoHand(tg,nil,REASON_EFFECT)
end
end
--壊獄神ユピテル
local s,id,o=GetID()
function s.initial_effect(c)
--xyz summon
aux.AddXyzProcedure(c,nil,10,3,s.ovfilter,aux.Stringid(id,0),3,s.xyzop)
c:EnableReviveLimit()
--equip
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,1))
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCondition(s.eqcon)
e1:SetTarget(s.eqtg)
e1:SetOperation(s.eqop)
c:RegisterEffect(e1)
--atk
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(s.atkcon)
e2:SetValue(3000)
c:RegisterEffect(e2)
--spsummon
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,2))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_DESTROY)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1)
e3:SetCost(s.spcost)
e3:SetTarget(s.sptg)
e3:SetOperation(s.spop)
c:RegisterEffect(e3)
end
function s.ovfilter(c)
return c:IsFaceup() and c:GetEquipCount()>2
end
function s.xyzop(e,tp,chk)
if chk==0 then return Duel.GetFlagEffect(tp,id)==0 end
Duel.RegisterFlagEffect(tp,id,RESET_PHASE+PHASE_END,EFFECT_FLAG_OATH,1)
end
function s.eqcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
end
function s.eqfilter(c,tp,ec)
return c:IsType(TYPE_EQUIP) and not c:IsForbidden() and c:CheckUniqueOnField(tp,LOCATION_SZONE) and c:CheckEquipTarget(ec)
end
function s.eqtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingMatchingCard(s.eqfilter,tp,LOCATION_GRAVE,0,1,nil,tp,e:GetHandler()) end
Duel.SetOperationInfo(0,CATEGORY_EQUIP,nil,1,tp,LOCATION_GRAVE)
end
function s.eqop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsFacedown() or not c:IsRelateToChain() then return end
local ft=Duel.GetLocationCount(tp,LOCATION_SZONE)
if ft<1 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.eqfilter),tp,LOCATION_GRAVE,0,1,ft,nil,tp,c)
if g:GetCount()>0 then
for tc in aux.Next(g) do
Duel.Equip(tp,tc,c,false,true)
end
Duel.EquipComplete()
end
end
function s.atkcon(e)
return e:GetHandler():GetOverlayGroup():IsExists(Card.IsType,1,nil,TYPE_XYZ)
end
function s.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end
e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST)
end
function s.spfilter(c,e,tp)
return c:IsSetCard(0x2d3)
and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.spfilter),tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
if #g>0 and Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)~=0
and Duel.SelectYesNo(tp,aux.Stringid(id,3)) then
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local sg=Duel.GetFieldGroup(tp,LOCATION_ONFIELD,LOCATION_ONFIELD):Select(tp,1,1,nil)
Duel.HintSelection(sg)
Duel.Destroy(sg,REASON_EFFECT)
end
end
--終獄龍機ⅩⅡ-ドラストリウス
local s,id,o=GetID()
function s.initial_effect(c)
--xyz summon
aux.AddXyzProcedure(c,nil,8,3)
c:EnableReviveLimit()
--equip
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCountLimit(1,id)
e1:SetCondition(s.eqcon)
e1:SetTarget(s.eqtg)
e1:SetOperation(s.eqop)
c:RegisterEffect(e1)
--indes
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
e2:SetCountLimit(1)
e2:SetValue(s.indct)
c:RegisterEffect(e2)
--negate
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetCategory(CATEGORY_DISABLE+CATEGORY_EQUIP)
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1,id+o)
e3:SetCode(EVENT_CHAINING)
e3:SetCondition(s.negcon)
e3:SetCost(s.negcost)
e3:SetTarget(s.negtg)
e3:SetOperation(s.negop)
c:RegisterEffect(e3)
end
function s.eqcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
end
function s.eqfilter(c,tp)
return c:IsFaceup() and (c:IsControler(tp) or c:IsAbleToChangeControler())
end
function s.eqtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingMatchingCard(s.eqfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,e:GetHandler(),tp) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function s.eqop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end
if c:IsFacedown() or not c:IsRelateToChain() then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectMatchingCard(tp,s.eqfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,aux.ExceptThisCard(e),tp)
local tc=g:GetFirst()
if tc then
Duel.HintSelection(g)
if not Duel.Equip(tp,tc,c) then return end
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_OWNER_RELATE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_EQUIP_LIMIT)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
e1:SetValue(s.eqlimit)
tc:RegisterEffect(e1)
end
end
function s.eqlimit(e,c)
return e:GetOwner()==c
end
function s.indct(e,re,r,rp)
return bit.band(r,REASON_BATTLE+REASON_EFFECT)~=0
end
function s.negcon(e,tp,eg,ep,ev,re,r,rp)
local loc=Duel.GetChainInfo(ev,CHAININFO_TRIGGERING_LOCATION)
return ep~=tp and (LOCATION_ONFIELD+LOCATION_GRAVE)&loc~=0
and re:IsActiveType(TYPE_MONSTER) and Duel.IsChainDisablable(ev)
end
function s.negcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end
e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST)
end
function s.negtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_DISABLE,eg,1,0,0)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function s.negop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if Duel.NegateEffect(ev)~=0 and Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingMatchingCard(s.eqfilter,tp,0,LOCATION_MZONE,1,nil,tp)
and c:IsRelateToChain() and c:IsFaceup()
and Duel.SelectYesNo(tp,aux.Stringid(id,2)) then
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectMatchingCard(tp,s.eqfilter,tp,0,LOCATION_MZONE,1,1,aux.ExceptThisCard(e),tp)
local tc=g:GetFirst()
if tc then
Duel.HintSelection(g)
if not Duel.Equip(tp,tc,c) then return end
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_OWNER_RELATE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_EQUIP_LIMIT)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
e1:SetValue(s.eqlimit)
tc:RegisterEffect(e1)
end
end
end
--終刻獄徒 ディアクトロス
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,97556336)
--xyz summon
aux.AddXyzProcedure(c,nil,4,2)
c:EnableReviveLimit()
--destroy
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCountLimit(1,id)
e1:SetTarget(s.destg)
e1:SetOperation(s.desop)
c:RegisterEffect(e1)
--to hand
local e4=Effect.CreateEffect(c)
e4:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH+CATEGORY_TOGRAVE+CATEGORY_DECKDES)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_DESTROYED)
e4:SetProperty(EFFECT_FLAG_DELAY)
e4:SetCountLimit(1,id+o)
e4:SetCondition(s.thcon)
e4:SetTarget(s.thtg)
e4:SetOperation(s.thop)
c:RegisterEffect(e4)
end
function s.desfilter(c)
return c:IsFaceupEx() and c:IsSetCard(0x2d3)
end
function s.destg(e,tp,eg,ep,ev,re,r,rp,chk)
local g=Duel.GetMatchingGroup(s.desfilter,tp,LOCATION_HAND+LOCATION_ONFIELD,0,nil)
if chk==0 then return #g>0 end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function s.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectMatchingCard(tp,s.desfilter,tp,LOCATION_HAND+LOCATION_ONFIELD,0,1,1,nil)
local fg=g:Filter(Card.IsLocation,nil,LOCATION_ONFIELD)
if fg:GetCount()>0 then
Duel.HintSelection(fg)
end
if Duel.Destroy(g,REASON_EFFECT)>0
and Duel.IsExistingMatchingCard(aux.TRUE,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil)
and Duel.SelectYesNo(tp,aux.Stringid(id,2)) then
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectMatchingCard(tp,aux.TRUE,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
if g:GetCount()>0 then
Duel.HintSelection(g)
Duel.Destroy(g,REASON_EFFECT)
end
end
end
function s.cfilter(c)
return c:IsSetCard(0x2d3) and c:IsType(TYPE_MONSTER) or c:IsCode(97556336)
end
function s.thcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local g=c:GetOverlayGroup()
return c:IsReason(REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE)
and g:IsExists(s.cfilter,1,nil)
end
function s.thfilter(c)
return c:IsType(TYPE_EQUIP)
and (c:IsAbleToHand() or c:IsAbleToGrave())
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil) end
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_OPERATECARD)
local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()<=0 then return end
local tc=g:GetFirst()
if tc:IsAbleToHand() and (not tc:IsAbleToGrave() or Duel.SelectOption(tp,1190,1191)==0) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,tc)
elseif tc:IsAbleToGrave() then
Duel.SendtoGrave(tc,REASON_EFFECT)
end
end
--終刻撃針
local s,id,o=GetID()
function s.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--tohand
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,0))
e2:SetCategory(CATEGORY_DESTROY+CATEGORY_TOHAND+CATEGORY_SEARCH+CATEGORY_SPECIAL_SUMMON+CATEGORY_DECKDES)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_SZONE)
e2:SetCountLimit(1,id)
e2:SetTarget(s.thtg)
e2:SetOperation(s.thop)
c:RegisterEffect(e2)
--destroy
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetCategory(CATEGORY_DESTROY)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET)
e3:SetCode(EVENT_DESTROYED)
e3:SetCountLimit(1,id)
e3:SetCondition(s.descon)
e3:SetTarget(s.destg)
e3:SetOperation(s.desop)
c:RegisterEffect(e3)
end
function s.cfilter(c,e,tp)
return c:IsSetCard(0x2d3) and c:IsFaceupEx()
and Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil,e,tp,c)
end
function s.thfilter(c,e,tp,ec)
return c:IsSetCard(0x2d3) and c:IsType(TYPE_MONSTER)
and (c:IsAbleToHand() or (Duel.GetMZoneCount(tp,ec)>0 and c:IsCanBeSpecialSummoned(e,0,tp,false,false)))
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_HAND+LOCATION_ONFIELD,0,1,e:GetHandler(),e,tp) end
local g=Duel.GetMatchingGroup(s.cfilter,tp,LOCATION_HAND+LOCATION_ONFIELD,0,e:GetHandler(),e,tp)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local dg=Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_HAND+LOCATION_ONFIELD,0,1,1,aux.ExceptThisCard(e),e,tp)
if dg:GetCount()>0 then
local fg=dg:Filter(Card.IsLocation,nil,LOCATION_ONFIELD)
if fg:GetCount()>0 then
Duel.HintSelection(fg)
end
if Duel.Destroy(dg,REASON_EFFECT)~=0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_OPERATECARD)
local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp,nil)
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
local tc=g:GetFirst()
if tc then
Duel.BreakEffect()
if tc:IsAbleToHand() and (not tc:IsCanBeSpecialSummoned(e,0,tp,false,false) or ft<=0 or Duel.SelectOption(tp,1190,1152)==0) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,tc)
else
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
end
end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(1,0)
e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetTarget(s.splimit)
Duel.RegisterEffect(e1,tp)
end
function s.splimit(e,c)
return not c:IsType(TYPE_XYZ) and c:IsLocation(LOCATION_EXTRA)
end
function s.descon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsReason(REASON_EFFECT)
end
function s.desfilter(c)
return c:IsFaceup()
end
function s.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and s.desfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.desfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,s.desfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
end
function s.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToChain() and tc:IsType(TYPE_MONSTER) then
Duel.Destroy(tc,REASON_EFFECT)
end
end
--終刻起動『D.O.O.M.D.U.R.G.』
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddEquipSpellEffect(c,true,true,Card.IsFaceup,nil)
--dam
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_DAMAGE)
e1:SetType(EFFECT_TYPE_TRIGGER_F+EFFECT_TYPE_FIELD)
e1:SetRange(LOCATION_SZONE)
e1:SetCode(EVENT_PHASE+PHASE_STANDBY)
e1:SetCountLimit(1)
e1:SetCondition(s.damcon)
e1:SetTarget(s.damtg)
e1:SetOperation(s.damop)
c:RegisterEffect(e1)
--get effect
--indestructable
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_EQUIP)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e2:SetCondition(s.ibcon)
e2:SetValue(s.tgoval)
c:RegisterEffect(e2)
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_XMATERIAL)
e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e3:SetRange(LOCATION_MZONE)
e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e3:SetCondition(s.tgcon)
e3:SetValue(aux.tgoval)
c:RegisterEffect(e3)
--destroy
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,1))
e4:SetCategory(CATEGORY_DISABLE)
e4:SetType(EFFECT_TYPE_QUICK_O)
e4:SetCode(EVENT_FREE_CHAIN)
e4:SetRange(LOCATION_MZONE)
e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL)
e4:SetHintTiming(TIMING_DAMAGE_STEP,TIMING_DAMAGE_STEP+TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e4:SetCountLimit(1)
e4:SetTarget(s.atktg)
e4:SetOperation(s.atkop)
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_GRANT)
e5:SetRange(LOCATION_SZONE)
e5:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e5:SetTarget(s.eftg)
e5:SetLabelObject(e4)
c:RegisterEffect(e5)
local e6=e4:Clone()
e6:SetType(EFFECT_TYPE_XMATERIAL+EFFECT_TYPE_QUICK_O)
e6:SetCondition(s.tgcon)
c:RegisterEffect(e6)
--change type
local e7=Effect.CreateEffect(c)
e7:SetType(EFFECT_TYPE_EQUIP)
e7:SetCode(EFFECT_ADD_TYPE)
e7:SetValue(TYPE_EFFECT)
e7:SetCondition(s.efcon)
c:RegisterEffect(e7)
local e8=e7:Clone()
e8:SetCode(EFFECT_REMOVE_TYPE)
e8:SetValue(TYPE_NORMAL)
c:RegisterEffect(e8)
local e9=Effect.CreateEffect(c)
e9:SetType(EFFECT_TYPE_XMATERIAL)
e9:SetCode(EFFECT_ADD_TYPE)
e9:SetValue(TYPE_EFFECT)
e9:SetCondition(s.tgcon)
c:RegisterEffect(e9)
local e10=e9:Clone()
e10:SetCode(EFFECT_REMOVE_TYPE)
e10:SetValue(TYPE_NORMAL)
c:RegisterEffect(e10)
end
function s.ibcon(e,tp,eg,ep,ev,re,r,rp)
local ec=e:GetHandler():GetEquipTarget()
return ec:IsSetCard(0x2d3) and not ec:IsDisabled()
end
function s.tgoval(e,re,rp)
local ec=e:GetHandler():GetEquipTarget()
return rp~=ec:GetControler()
end
function s.damcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetEquipTarget()
end
function s.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
local dp=e:GetHandler():GetEquipTarget():GetControler()
if chk==0 then return true end
Duel.SetTargetPlayer(dp)
Duel.SetTargetParam(500)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,dp,500)
end
function s.damop(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Damage(p,d,REASON_EFFECT)
end
function s.eftg(e,c)
return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x2d3) and c:GetEquipGroup():IsContains(e:GetHandler())
end
function s.tgcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsRace(RACE_MACHINE) and c:IsAttribute(ATTRIBUTE_WIND)
end
function s.atktg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,LOCATION_ONFIELD,0,e:GetHandler())
if chk==0 then return g:GetCount()>0 and s.lv_or_rk(c)>0 end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
Duel.Hint(HINT_OPSELECTED,1-tp,aux.Stringid(id,1))
end
function s.lv_or_rk(c)
if c:IsLevelAbove(1) then
return c:GetLevel()*100
elseif c:IsRankAbove(1) then
return c:GetRank()*100
else
return 0
end
end
function s.atkop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectMatchingCard(tp,Card.IsFaceup,tp,LOCATION_ONFIELD,0,1,1,aux.ExceptThisCard(e))
if g:GetCount()>0 then
Duel.HintSelection(g)
Duel.Destroy(g,REASON_EFFECT)
end
if c:IsRelateToChain() and c:IsFaceup() then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(s.lv_or_rk(c))
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_DISABLE+RESET_PHASE+PHASE_END)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DIRECT_ATTACK)
e2:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
c:RegisterEffect(e2)
local e3=Effect.CreateEffect(c)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e3:SetCode(EVENT_DAMAGE_STEP_END)
e3:SetOperation(s.desop)
e3:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_DAMAGE+PHASE_END)
c:RegisterEffect(e3)
end
end
function s.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToBattle() and c:IsFaceup() then
Duel.Destroy(c,REASON_EFFECT)
end
end
function s.efcon(e,tp,eg,ep,ev,re,r,rp)
local ec=e:GetHandler():GetEquipTarget()
return ec:IsSetCard(0x2d3)
end
--破滅なる予幻視
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,97556336)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,1))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e1:SetCountLimit(1,id)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1)
--lv
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetRange(LOCATION_GRAVE)
e2:SetCountLimit(1,id+o)
e2:SetCost(aux.bfgcost)
e2:SetTarget(s.lvtg)
e2:SetOperation(s.lvop)
c:RegisterEffect(e2)
end
function s.spfilter(c,e,tp)
return c:IsFaceupEx() and c:IsCode(97556336) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE+LOCATION_REMOVED) and chkc:IsControler(tp) and s.spfilter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(s.spfilter,tp,LOCATION_GRAVE+LOCATION_REMOVED,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,s.spfilter,tp,LOCATION_GRAVE+LOCATION_REMOVED,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToChain() and aux.NecroValleyFilter()(tc) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
function s.lvfilter(c)
return c:IsFaceup() and c:IsLevelAbove(1)
end
function s.lvtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.lvfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(s.lvfilter,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
local g=Duel.SelectTarget(tp,s.lvfilter,tp,LOCATION_MZONE,0,1,1,nil)
local lv=g:GetFirst():GetLevel()
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(id,2))
e:SetLabel(Duel.AnnounceLevel(tp,1,10,lv))
end
function s.lvop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToChain() and not tc:IsLevel(e:GetLabel()) then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_LEVEL)
e1:SetValue(e:GetLabel())
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
end
end
--アルトメギア・ムーヴメント-血統-
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,74733322)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,id)
e1:SetCondition(s.condition)
e1:SetCost(s.cost)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1)
--to hand
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetProperty(EFFECT_FLAG_DELAY)
e2:SetCountLimit(1,id+o)
e2:SetCondition(s.thcon)
e2:SetCost(s.cost)
e2:SetTarget(s.thtg)
e2:SetOperation(s.thop)
c:RegisterEffect(e2)
Duel.AddCustomActivityCounter(id,ACTIVITY_SPSUMMON,s.counterfilter)
end
function s.counterfilter(c)
return not c:IsSummonLocation(LOCATION_EXTRA) or c:IsType(TYPE_FUSION)
end
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetCustomActivityCount(id,tp,ACTIVITY_SPSUMMON)==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:SetTargetRange(1,0)
e1:SetTarget(s.splimit)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
end
function s.splimit(e,c,sump,sumtype,sumpos,targetp,se)
return not c:IsType(TYPE_FUSION) and c:IsLocation(LOCATION_EXTRA)
end
function s.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)<Duel.GetFieldGroupCount(1-tp,LOCATION_MZONE,0)
end
function s.cfilter(c,code)
return c:IsFaceup() and c:IsCode(code)
end
function s.spfilter(c,e,tp)
return c:IsSetCard(0x1cd) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE)
and not Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_ONFIELD,0,1,nil,c:GetCode())
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
end
end
function s.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsReason(REASON_COST) and re:IsActivated() and re:GetHandler():IsCode(74733322)
end
function s.thfilter(c)
return c:IsFaceupEx() and c:IsSetCard(0x1cd) and c:IsType(TYPE_TRAP) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_GRAVE+LOCATION_REMOVED,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE+LOCATION_REMOVED)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.thfilter),tp,LOCATION_GRAVE+LOCATION_REMOVED,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
--あないみじや玉の緒ふたつ
local s,id,o=GetID()
function s.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_CONTINUOUS_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(s.target)
e1:SetOperation(s.operation)
c:RegisterEffect(e1)
--equip limit
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_EQUIP_LIMIT)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetValue(s.eqlimit)
c:RegisterEffect(e2)
--destroy
local custom_code=aux.RegisterMergedDelayedEvent_ToSingleCard(c,id,EVENT_SPSUMMON_SUCCESS)
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetCategory(CATEGORY_DESTROY+CATEGORY_DAMAGE)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(custom_code)
e3:SetRange(LOCATION_SZONE)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e3:SetCondition(s.descon)
e3:SetTarget(s.destg)
e3:SetOperation(s.desop)
c:RegisterEffect(e3)
end
function s.eqlimit(e,c)
return c:IsSummonLocation(LOCATION_EXTRA) and c:IsControler(e:GetHandlerPlayer())
end
function s.eqfilter(c,tp)
return c:IsFaceup() and c:IsSummonLocation(LOCATION_EXTRA)
and c:IsControler(tp)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and s.eqfilter(chkc,tp) end
if chk==0 then return Duel.IsExistingTarget(s.eqfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,s.eqfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil,tp)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function s.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsRelateToChain() and tc:IsRelateToChain() and tc:IsControler(tp) and tc:IsFaceup() then
Duel.Equip(tp,c,tc)
end
end
function s.desfilter(c,tp,e,ec)
return c:IsSummonLocation(LOCATION_EXTRA) and c:IsLocation(LOCATION_MZONE) and c:IsSummonPlayer(1-tp) and c:IsCanBeEffectTarget(e) and c:IsFaceup()
and c:IsAttackAbove(ec:GetAttack()+1)
end
function s.descon(e,tp,eg,ep,ev,re,r,rp)
local ec=e:GetHandler():GetEquipTarget()
return ec and eg:IsExists(s.desfilter,1,nil,tp,e,ec)
end
function s.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local c=e:GetHandler()
local ec=c:GetEquipTarget()
local g=eg:Filter(s.desfilter,nil,tp,e,ec)
if chkc then return g:IsContains(chkc) end
if chk==0 then return #g>0 end
local sg
if g:GetCount()==1 then
sg=g:Clone()
Duel.SetTargetCard(sg)
else
Duel.Hint(HINTMSG_DESTROY,tp,HINTMSG_DESTROY)
sg=Duel.SelectTarget(tp,aux.IsInGroup,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil,g)
end
local dg=sg:Clone()
dg:AddCard(ec)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,dg,2,0,0)
if sg:GetFirst():IsFaceup() and math.max(0,sg:GetFirst():GetTextAttack())>0 then
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,PLAYER_ALL,0)
end
end
function s.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local ec=c:GetEquipTarget()
local tc=Duel.GetFirstTarget()
local g=Group.FromCards(ec,tc)
if tc:IsRelateToChain() and tc:IsType(TYPE_MONSTER) and Duel.Destroy(g,REASON_EFFECT)~=0 then
local sg=Duel.GetOperatedGroup()
local atk=0
for dc in aux.Next(sg) do
atk=atk+math.max(0,dc:GetTextAttack())
end
if atk>0 then
local val=Duel.Damage(tp,atk,REASON_EFFECT)
if val>0 and Duel.GetLP(tp)>0 then
Duel.BreakEffect()
Duel.Damage(1-tp,val,REASON_EFFECT)
end
end
end
end
--終刻決壊
local s,id,o=GetID()
function s.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCountLimit(1,id)
e1:SetCost(s.cost)
e1:SetTarget(s.target)
e1:SetOperation(s.operation)
c:RegisterEffect(e1)
--equip
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_EQUIP)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET)
e2:SetCode(EVENT_DESTROYED)
e2:SetCountLimit(1,id+o)
e2:SetCondition(s.eqcon)
e2:SetTarget(s.eqtg)
e2:SetOperation(s.eqop)
c:RegisterEffect(e2)
end
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local c=e:GetHandler()
local cid=Duel.GetChainInfo(0,CHAININFO_CHAIN_ID)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_REMAIN_FIELD)
e1:SetProperty(EFFECT_FLAG_OATH)
e1:SetReset(RESET_CHAIN)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_CHAIN_DISABLED)
e2:SetOperation(s.tgop)
e2:SetLabel(cid)
e2:SetReset(RESET_CHAIN)
Duel.RegisterEffect(e2,tp)
end
function s.tgop(e,tp,eg,ep,ev,re,r,rp)
local cid=Duel.GetChainInfo(ev,CHAININFO_CHAIN_ID)
if cid~=e:GetLabel() then return end
if e:GetOwner():IsRelateToChain(ev) then
e:GetOwner():CancelToGrave(false)
end
end
function s.eqfilter(c)
return c:IsFaceup() and c:IsSetCard(0x2d3) and c:IsType(TYPE_XYZ)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.eqfilter(chkc) end
if chk==0 then return e:IsCostChecked()
and Duel.IsExistingTarget(s.eqfilter,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,s.eqfilter,tp,LOCATION_MZONE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function s.eqlimit(e,c)
return e:GetHandler():GetEquipTarget()==c and c:IsSetCard(0x2d3)
or c:IsControler(e:GetHandlerPlayer()) and c:IsType(TYPE_XYZ)
end
function s.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsLocation(LOCATION_SZONE) then return end
if not c:IsRelateToChain() or c:IsStatus(STATUS_LEAVE_CONFIRMED) then return end
local tc=Duel.GetFirstTarget()
if tc:IsRelateToChain() and tc:IsFaceup() then
Duel.Equip(tp,c,tc)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_TO_HAND)
e1:SetRange(LOCATION_SZONE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(0,1)
e1:SetTarget(aux.TargetBoolFunction(Card.IsLocation,LOCATION_DECK))
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_EQUIP_LIMIT)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetValue(s.eqlimit)
e2:SetReset(RESET_EVENT+RESETS_STANDARD)
c:RegisterEffect(e2)
else
c:CancelToGrave(false)
end
end
function s.eqcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsReason(REASON_EFFECT)
end
function s.tgfilter(c)
return c:IsFaceup()
end
function s.eqfilter2(c,tp)
return c:IsSetCard(0x2d3) and c:IsType(TYPE_MONSTER) and not c:IsForbidden()
and c:CheckUniqueOnField(tp,LOCATION_SZONE)
end
function s.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and s.tgfilter(chkc) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingTarget(s.tgfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil)
and Duel.IsExistingMatchingCard(s.eqfilter2,tp,LOCATION_DECK,0,1,nil,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,s.tgfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,nil,1,tp,LOCATION_DECK)
end
function s.eqop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToChain() and tc:IsFaceup() and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectMatchingCard(tp,s.eqfilter2,tp,LOCATION_DECK,0,1,1,nil,tp)
local ec=g:GetFirst()
if ec then
if not Duel.Equip(tp,ec,tc) then return end
--equip limit
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_EQUIP_LIMIT)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetLabelObject(tc)
e1:SetValue(s.eqlimit2)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
ec:RegisterEffect(e1)
end
end
end
function s.eqlimit2(e,c)
return c==e:GetLabelObject()
end
--アルトメギア・ペリペティア-激動-
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,74733322)
--activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOHAND+CATEGORY_TOEXTRA)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e1:SetCountLimit(1,id)
e1:SetCost(s.cost)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1)
--to hand
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetProperty(EFFECT_FLAG_DELAY)
e2:SetCountLimit(1,id+o)
e2:SetCondition(s.thcon)
e2:SetCost(s.cost)
e2:SetTarget(s.thtg)
e2:SetOperation(s.thop)
c:RegisterEffect(e2)
Duel.AddCustomActivityCounter(id,ACTIVITY_SPSUMMON,s.counterfilter)
end
function s.counterfilter(c)
return not c:IsSummonLocation(LOCATION_EXTRA) or c:IsType(TYPE_FUSION)
end
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetCustomActivityCount(id,tp,ACTIVITY_SPSUMMON)==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:SetTargetRange(1,0)
e1:SetTarget(s.splimit)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
end
function s.splimit(e,c,sump,sumtype,sumpos,targetp,se)
return not c:IsType(TYPE_FUSION) and c:IsLocation(LOCATION_EXTRA)
end
function s.spfilter(c,e,tp)
return c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function s.thefilter(c,tp,chk)
return c:IsFaceup() and c:IsSetCard(0x1cd) and (c:IsAbleToHand() or c:IsAbleToExtra())
and (Duel.GetMZoneCount(tp,c)>0 or not chk)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1-tp) and s.spfilter(chkc,e,tp) end
if chk==0 then return Duel.IsExistingTarget(s.spfilter,tp,0,LOCATION_GRAVE,1,nil,e,tp)
and Duel.IsExistingMatchingCard(s.thefilter,tp,LOCATION_MZONE,0,1,nil,tp,true) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,s.spfilter,tp,0,LOCATION_GRAVE,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local rg=nil
if Duel.IsExistingMatchingCard(s.thefilter,tp,LOCATION_MZONE,0,1,nil,tp,true) then
rg=Duel.SelectMatchingCard(tp,s.thefilter,tp,LOCATION_MZONE,0,1,1,nil,tp,true)
else
rg=Duel.SelectMatchingCard(tp,s.thefilter,tp,LOCATION_MZONE,0,1,1,nil,tp,false)
end
if rg and rg:GetCount()>0 then
Duel.HintSelection(rg)
if Duel.SendtoHand(rg,nil,REASON_EFFECT)~=0 and rg:IsExists(Card.IsLocation,1,nil,LOCATION_HAND+LOCATION_EXTRA) and tc:IsRelateToChain()
and Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_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:SetValue(RESET_TURN_SET)
e2:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e2)
end
Duel.SpecialSummonComplete()
end
end
function s.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsReason(REASON_COST) and re:IsActivated() and re:GetHandler():IsCode(74733322)
end
function s.thfilter(c)
return c:IsFaceupEx() and c:IsSetCard(0x1cd) and c:IsType(TYPE_SPELL) and c:IsAbleToHand()
end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_GRAVE+LOCATION_REMOVED,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE+LOCATION_REMOVED)
end
function s.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.thfilter),tp,LOCATION_GRAVE+LOCATION_REMOVED,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
...@@ -4,6 +4,7 @@ function cm.initial_effect(c) ...@@ -4,6 +4,7 @@ function cm.initial_effect(c)
e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCategory(CATEGORY_REMOVE) e1:SetCategory(CATEGORY_REMOVE)
e1:SetCode(EVENT_FREE_CHAIN) e1:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(LOCATION_HAND)
e1:SetCondition(cm.con) e1:SetCondition(cm.con)
e1:SstCost(cm.cost) e1:SstCost(cm.cost)
e1:SetTarget(cm.tg) e1:SetTarget(cm.tg)
......
...@@ -74,6 +74,7 @@ function s.sttg(e,tp,eg,ep,ev,re,r,rp,chk) ...@@ -74,6 +74,7 @@ function s.sttg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.stfilter,tp,LOCATION_DECK+LOCATION_HAND+LOCATION_GRAVE,0,1,nil) end if chk==0 then return Duel.IsExistingMatchingCard(s.stfilter,tp,LOCATION_DECK+LOCATION_HAND+LOCATION_GRAVE,0,1,nil) end
end end
function s.stop(e,tp,eg,ep,ev,re,r,rp) function s.stop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET)
local g=Duel.SelectMatchingCard(tp,s.stfilter,tp,LOCATION_DECK+LOCATION_HAND+LOCATION_GRAVE,0,1,1,nil) local g=Duel.SelectMatchingCard(tp,s.stfilter,tp,LOCATION_DECK+LOCATION_HAND+LOCATION_GRAVE,0,1,1,nil)
local g2=g:GetFirst() local g2=g:GetFirst()
......
...@@ -15,21 +15,21 @@ function s.initial_effect(c) ...@@ -15,21 +15,21 @@ function s.initial_effect(c)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
function s.disfilter(c) function s.disfilter(c)
return c:IsType(TYPE_SPELL) and not c:IsType(TYPE_CONTINUOUS+TYPE_EQUIP+TYPE_QUICKPLAY+TYPE_RITUAL+TYPE_FIELD) and c:IsAbleToGraveAsCost() return c:IsType(TYPE_SPELL) and not c:IsType(TYPE_CONTINUOUS+TYPE_EQUIP+TYPE_QUICKPLAY+TYPE_RITUAL+TYPE_FIELD) and c:IsAbleToGraveAsCost() and c:GetActivateEffect()~=nil
end end
function s.confilter(c) function s.confilter(c)
return c:GetSummonType()==SUMMON_TYPE_SPECIAL return c:IsSummonType(SUMMON_TYPE_SPECIAL)
end end
function s.condition(e,tp,eg,ep,ev,re,r,rp) function s.condition(e,tp,eg,ep,ev,re,r,rp)
return not Duel.IsExistingMatchingCard(s.confilter,tp,LOCATION_MZONE,0,1,nil) return not Duel.IsExistingMatchingCard(s.confilter,tp,LOCATION_MZONE,0,1,nil) and Duel.GetTurnPlayer()~=tp
end end
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk) function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler() local c=e:GetHandler()
if chk==0 then return c:IsAbleToGraveAsCost() and Duel.IsExistingMatchingCard(s.disfilter,tp,LOCATION_HAND,0,1,c) end if chk==0 then return c:IsAbleToGraveAsCost() and Duel.IsExistingMatchingCard(s.disfilter,tp,LOCATION_HAND,0,1,c) end
local g=Duel.SelectMatchingCard(tp,s.disfilter,tp,LOCATION_HAND,0,1,1,c) local g=Duel.SelectMatchingCard(tp,s.disfilter,tp,LOCATION_HAND,0,1,1,c)
e:SetLabelObject(g:GetFirst())
g:AddCard(c) g:AddCard(c)
Duel.SendtoGrave(g,REASON_COST) Duel.SendtoGrave(g,REASON_COST)
e:SetLabelObject(g:GetFirst())
end end
function s.operation(e,tp,eg,ep,ev,re,r,rp) function s.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetLabelObject() local c=e:GetLabelObject()
......
...@@ -31,8 +31,8 @@ function s.operation(e,tp,eg,ep,ev,re,r,rp) ...@@ -31,8 +31,8 @@ function s.operation(e,tp,eg,ep,ev,re,r,rp)
local g1=Duel.GetMatchingGroup(s.filter1,tp,LOCATION_DECK,0,nil) local g1=Duel.GetMatchingGroup(s.filter1,tp,LOCATION_DECK,0,nil)
local g2=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_DECK,0,nil) local g2=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_DECK,0,nil)
local g=Group.CreateGroup() local g=Group.CreateGroup()
if #g1>0 and Duel.SelectYesNo(tp,aux.Stringid(id,1)) then if #g1>0 and (#g2==0 or Duel.SelectYesNo(tp,aux.Stringid(id,0))) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET)
local sg=g1:Select(tp,1,1,nil) local sg=g1:Select(tp,1,1,nil)
g:Merge(sg) g:Merge(sg)
Duel.MoveToField(sg:GetFirst(),tp,tp,LOCATION_SZONE,POS_FACEUP,true) Duel.MoveToField(sg:GetFirst(),tp,tp,LOCATION_SZONE,POS_FACEUP,true)
...@@ -44,8 +44,8 @@ function s.operation(e,tp,eg,ep,ev,re,r,rp) ...@@ -44,8 +44,8 @@ function s.operation(e,tp,eg,ep,ev,re,r,rp)
e2:SetReset(RESET_PHASE+PHASE_END) e2:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e2,tp) Duel.RegisterEffect(e2,tp)
end end
if #g2>0 and Duel.SelectYesNo(tp,aux.Stringid(id,2)) then if #g==0 or (#g2>0 and Duel.SelectYesNo(tp,aux.Stringid(id,1))) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET)
local sg=g2:Select(tp,1,1,nil) local sg=g2:Select(tp,1,1,nil)
g:Merge(sg) g:Merge(sg)
Duel.SSet(tp,sg) Duel.SSet(tp,sg)
......
...@@ -30,7 +30,7 @@ function s.filter(c) ...@@ -30,7 +30,7 @@ function s.filter(c)
end end
function s.costfilter(c) function s.costfilter(c)
local te=c:GetActivateEffect() local te=c:GetActivateEffect()
return c:GetType()==TYPE_TRAP and c:IsAbleToGraveAsCost() return c:GetType()==TYPE_TRAP and c:IsAbleToGraveAsCost() and te and te:GetCode()==EVENT_ATTACK_ANNOUNCE
end end
function s.costfilter2(c) function s.costfilter2(c)
return c:IsAbleToGraveAsCost() and c:IsType(TYPE_MONSTER) return c:IsAbleToGraveAsCost() and c:IsType(TYPE_MONSTER)
......
...@@ -40,6 +40,7 @@ function s.activate(e,tp,eg,ep,ev,re,r,rp) ...@@ -40,6 +40,7 @@ function s.activate(e,tp,eg,ep,ev,re,r,rp)
Duel.RegisterEffect(e,tp) Duel.RegisterEffect(e,tp)
end end
-- override effect -- override effect
local c=e:GetHandler()
local e2=Effect.CreateEffect(c) local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_CHAIN_SOLVING) e2:SetCode(EVENT_CHAIN_SOLVING)
......
...@@ -62,7 +62,7 @@ function s.ngop(e,tp,eg,ep,ev,re,r,rp) ...@@ -62,7 +62,7 @@ function s.ngop(e,tp,eg,ep,ev,re,r,rp)
end end
end end
function s.handcon(e,tp,eg,ep,ev,re,r,rp) function s.handcon(e,c)
return Duel.GetCustomActivityCount(id,e:GetHandlerPlayer(),ACTIVITY_CHAIN)==0 --and ep~=tp return Duel.GetCustomActivityCount(id,e:GetHandlerPlayer(),ACTIVITY_CHAIN)==0 --and ep~=tp
end end
function s.chainfilter(re,tp,cid) function s.chainfilter(re,tp,cid)
......
--スクラップ・フィスト
function c8529136.initial_effect(c)
aux.AddCodeList(c,60800381)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCondition(c8529136.condition)
e1:SetTarget(c8529136.target)
e1:SetOperation(c8529136.activate)
c:RegisterEffect(e1)
end
function c8529136.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()<PHASE_MAIN2
end
function c8529136.filter(c)
return c:IsFaceup() and c:IsCode(60800381) and c:GetFlagEffect(8529136)==0
end
function c8529136.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and c8529136.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c8529136.filter,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,c8529136.filter,tp,LOCATION_MZONE,0,1,1,nil)
end
function c8529136.activate(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
if tc:GetFlagEffect(8529136)==0 then
tc:RegisterFlagEffect(8529136,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END,0,1)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EFFECT_CANNOT_ACTIVATE)
e1:SetRange(LOCATION_MZONE)
e1:SetTargetRange(0,1)
e1:SetCondition(c8529136.actcon)
e1:SetValue(1)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1,true)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_PIERCE)
e2:SetCondition(c8529136.effcon)
e2:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e2)
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_CHANGE_BATTLE_DAMAGE)
e3:SetCondition(c8529136.damcon)
e3:SetValue(aux.ChangeBattleDamage(1,DOUBLE_DAMAGE))
e3:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e3,true)
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e4:SetCondition(c8529136.effcon)
e4:SetValue(1)
e4:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e4)
end
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e5:SetCode(EVENT_DAMAGE_STEP_END)
e5:SetCondition(c8529136.descon)
e5:SetOperation(c8529136.desop)
e5:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e5,true)
end
end
function c8529136.actcon(e)
local c=e:GetHandler()
return (Duel.GetAttacker()==c or Duel.GetAttackTarget()==c) and c:GetBattleTarget()~=nil
and e:GetOwnerPlayer()==e:GetHandlerPlayer()
end
function c8529136.effcon(e)
return e:GetOwnerPlayer()==e:GetHandlerPlayer()
end
function c8529136.damcon(e)
return e:GetHandler():GetBattleTarget()~=nil
end
function c8529136.descon(e,tp,eg,ep,ev,re,r,rp)
local tc=e:GetHandler():GetBattleTarget()
return tc and tc:IsRelateToBattle() and e:GetOwnerPlayer()==tp
end
function c8529136.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=e:GetHandler():GetBattleTarget()
Duel.Hint(HINT_CARD,0,8529136)
Duel.Destroy(tc,REASON_EFFECT)
end
--Fusion check function --Fusion check functions
Auxiliary.FCheckAdditional=nil Auxiliary.FCheckAdditional=nil
Auxiliary.FGoalCheckAdditional=nil Auxiliary.FGoalCheckAdditional=nil
...@@ -2501,7 +2501,7 @@ function FusionSpell.GetSummonOperation( ...@@ -2501,7 +2501,7 @@ function FusionSpell.GetSummonOperation(
return function(e,tp,eg,ep,ev,re,r,rp) return function(e,tp,eg,ep,ev,re,r,rp)
local tc=nil local tc=nil
-- if gc is gone, terminate -- if gc is gone, terminate
if gc(e)==nil or gc(e):IsRelateToEffect(e) then if gc(e)==nil or gc(e):IsRelateToEffect(e) or e:GetHandler()~=gc(e) then
local fusion_targets=Group.CreateGroup() local fusion_targets=Group.CreateGroup()
local sg=Duel.GetMatchingGroup(function(c) local sg=Duel.GetMatchingGroup(function(c)
return FusionSpell.SummonTargetFilter( return FusionSpell.SummonTargetFilter(
...@@ -3367,1063 +3367,3 @@ function FusionSpell.GetCheckFieldPlayer(tp,skip_location_count_check) ...@@ -3367,1063 +3367,3 @@ function FusionSpell.GetCheckFieldPlayer(tp,skip_location_count_check)
end end
return tp return tp
end end
--- Synchro
Synchro = {}
-- Use this as the "infinite" maximum count
Synchro.Infinite=math.huge
-- a tiny enum for clarity
Synchro.Role={
TUNER=1,
NON_TUNER=2,
}
--- Shadowing Duel.GetSynchroMaterial as we have different definition on hand materials
function Synchro.GetSynchroMaterial(tp,tc,level_mapper)
local mg=Duel.GetMatchingGroup(function(mc) return mc:IsFaceup() and mc:IsOnField() end,tp,LOCATION_MZONE,0,nil)
local mg_hand=Duel.GetMatchingGroup(function(mc) return mc:IsFaceupEx() end,tp,LOCATION_HAND,0,nil)
local mg_oppoent=Duel.GetMatchingGroup(function(mc)
if not (mc:IsFaceup() and mc:IsOnField()) then
return false
end
local effs={mc:IsHasEffect(EFFECT_EXTRA_SYNCHRO_MATERIAL)}
for _,eff in ipairs(effs) do
local v=eff:GetValue()
if type(v)=='function' and v(eff,tc) then
return true
elseif v then
return true
end
end
return false
end,tp,0,LOCATION_MZONE,nil)
mg:Merge(mg_hand)
mg:Merge(mg_oppoent)
mg=mg:Filter(function(mc) return not mc:IsForbidden() end,nil)
mg=mg:Filter(function(mc) return mc:IsType(TYPE_MONSTER) end,nil)
mg=mg:Filter(function(mc)
local effs={mc:IsHasEffect(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL)}
for _,eff in ipairs(effs) do
local v=eff:GetValue()
if type(v)=='function' and v(eff,tc)==true then
return false
elseif v then
return false
end
end
return true
end,nil)
--- it must have a level
mg=mg:Filter(function(mc)
local lvls=level_mapper(mc,tc)
if #lvls==0 then
return false
end
return true
end,nil)
return mg
end
--- Add Synchro procedure effect to a card using a single params table
--- @param c Card -- the Synchro monster card
--- @param params? table -- parameters table with keys: f1,f2,minc,maxc
function Synchro.AddSynchroProcedure(c,params)
params=params or {}
local tuner_race=params.tuner_race or RACE_ALL
local tuner_filter=params.tuner_filter or aux.TRUE
local non_tuner_race=params.non_tuner_race or RACE_ALL
local non_tuner_filter=params.non_tuner_filter or aux.TRUE
local tuner_min=params.tuner_min or 1
local tuner_max=params.tuner_max or 1
local non_tuner_min=params.non_tuner_min or 1
local non_tuner_max=params.non_tuner_max or Synchro.Infinite
local level_mapper=params.level_mapper or Synchro.DefaultLevelMapper
local scheck=params.scheck or aux.TRUE
local hand_count_mapper=params.hand_count_mapper or Synchro.DefaultHandCountMapper
local drop_default_tuner_filter=params.drop_default_tuner_filter or false
local drop_default_non_tuner_filter=params.drop_default_non_tuner_filter or false
if not drop_default_tuner_filter then
tuner_filter=aux.AND(Synchro.DefaultTunerFilter,tuner_filter)
end
if not drop_default_non_tuner_filter then
non_tuner_filter=aux.AND(Synchro.DefaultNonTunerFilter,non_tuner_filter)
end
local e1=Effect.CreateEffect(c)
-- e1:SetDescription(1164)
e1:SetDescription(1379) --- 启用扩展卡包调试模式
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetRange(LOCATION_EXTRA)
e1:SetCondition(Synchro.SynCondition(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper,scheck))
e1:SetTarget(Synchro.SynTarget(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper,scheck))
e1:SetOperation(Synchro.SynOperation())
e1:SetValue(SUMMON_TYPE_SYNCHRO)
c:RegisterEffect(e1)
--- accel synchro mode
local e2=Effect.CreateEffect(c)
-- e2:SetDescription(1164)
e2:SetDescription(1379) --- 启用扩展卡包调试模式
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_SPSUMMON_PROC)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e2:SetRange(LOCATION_EXTRA)
e2:SetCondition(Synchro.SynCondition(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper,scheck))
e2:SetTarget(Synchro.SynTarget(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper,scheck))
e2:SetOperation(Synchro.SynOperation())
e2:SetValue(SUMMON_TYPE_SYNCHRO)
c:RegisterEffect(e2)
end
-- Entry point: prepares and invokes the DFS
--- @param tc Card
function Synchro.FindValidSelection(candidates,target_level,
tuner_race,tuner_filter,
non_tuner_race,non_tuner_filter,tc,
tuner_min,tuner_max,
non_tuner_min,non_tuner_max,
level_mapper,hand_count_mapper,scheck,
pre_select,state)
Synchro.SortMaterials(candidates,tc,tuner_filter)
-- Find the index of the last level card
local level_prune_index=0
for i, c in ipairs(candidates) do
if Synchro.IsLevelAlter(c) then
level_prune_index=i
end
end
-- Find the index of the last hand card
local hand_prune_index=0
for i, c in ipairs(candidates) do
if Synchro.IsHandAlter(c,tc) then
hand_prune_index=i
end
end
-- Find the index of the last race card
local race_prune_index=0
for i, c in ipairs(candidates) do
if Synchro.IsRaceAlter(c) then
race_prune_index=i
end
end
-- 3) Invoke the core DFS, passing last_dyn along
return Synchro.CanCompleteSelection(
candidates,target_level,
tuner_race,tuner_filter,
non_tuner_race,non_tuner_filter,tc,
tuner_min,tuner_max,
non_tuner_min,non_tuner_max,
level_mapper,hand_count_mapper,scheck,
pre_select or {},
1,
state or { -- initial state
possible_sums={[0]=true},
tuner_count=0,
non_tuner_count=0,
level_mapper=level_mapper,
level_mapper_priority=0,
hand_count_mapper=hand_count_mapper,
hand_count_limit=0,
hand_count=0,
genomix_race=nil,
material_limit_filter=aux.TRUE,
selected_roles={}
},
{
level_prune_index=level_prune_index,
hand_prune_index=hand_prune_index,
race_prune_index=race_prune_index,
}
)
end
--- Check if there exists a valid Synchro material selection via DFS,
--- pruning on tuner/non-tuner counts, total level sums, race constraints,
--- hand limits, dynamic level mappers, and optional synchro‐group checks.
---
--- @param candidates Card[] -- Candidate material cards.
--- @param target_level integer -- Required total level.
--- @param tuner_race integer -- Bitmask of allowed tuner races.
--- @param tuner_filter fun(mc:Card,tc:Card):boolean -- Tests if mc can be a Tuner.
--- @param non_tuner_race integer -- Bitmask of allowed non-tuner races.
--- @param non_tuner_filter fun(mc:Card,tc:Card):boolean -- Tests if mc can be a non-Tuner.
--- @param tc Card -- Synchro monster being summoned.
--- @param tuner_min integer -- Minimum number of Tuners.
--- @param tuner_max integer|table -- Maximum number of Tuners.
--- @param non_tuner_min integer -- Minimum number of non-Tuners.
--- @param non_tuner_max integer|table -- Maximum number of non-Tuners.
--- @param level_mapper fun(mc:Card,tc:Card):integer[] -- Returns possible levels for mc.
--- @param scheck fun(selected:Card[]):boolean -- Optional card-group check (e.g. Judgment’s same-Attribute).
--- @param selected Card[] -- Materials chosen so far.
--- @param index integer -- Next candidate index (1-based).
--- @param state table -- DFS state:
--- possible_sums table -- map[level_sum]=true of reachable sums.
--- tuner_count number -- how many Tuners so far.
--- non_tuner_count number-- how many non-Tuners so far.
--- level_mapper fun -- current dynamic level mapping function.
--- level_mapper_priority number
--- hand_count_limit number
--- hand_count number
--- genomix_race integer|nil
--- material_limit_filter fun
--- selected_roles table -- parallel array of Role.TUNER/NON_TUNER.
--- @param prune_indexes table -- Cutoff indices:
--- level_prune_index integer
--- hand_prune_index integer
--- race_prune_index integer
--- @return boolean True if a valid selection exists, false otherwise.
function Synchro.CanCompleteSelection(candidates,target_level,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tc,
tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper,scheck,selected,index,state,prune_indexes)
if state.tuner_count>tuner_max then return false end
if state.non_tuner_count>non_tuner_max then return false end
local prune_tuner_filter=tuner_filter
local prune_non_tuner_filter=non_tuner_filter
if index>prune_indexes.race_prune_index then
if state.genomix_race~=nil then
prune_tuner_filter=aux.AND(function() return state.genomix_race&tuner_race~=0 end,tuner_filter)
prune_non_tuner_filter=aux.AND(function() return state.genomix_race&non_tuner_race~=0 end,non_tuner_filter)
else
prune_tuner_filter=aux.AND(function(c) return c:IsRace(tuner_race) end,tuner_filter)
prune_non_tuner_filter=aux.AND(function(c) return c:IsRace(non_tuner_race) end,non_tuner_filter)
end
end
local prune_level=target_level
-- prune after all level dynamic cards consumed
if index<prune_indexes.level_prune_index then
prune_level=math.huge -- infinity
end
--- prune on hand count
if index==prune_indexes.hand_prune_index+1 then
if state.hand_count>state.hand_count_limit then
return false
end
end
--- one‐time prune on selected materials considering race
if index==prune_indexes.race_prune_index+1 then
for i,sc in ipairs(selected) do
local role=state.selected_roles[i]
if role==Synchro.Role.TUNER then
if not prune_tuner_filter(sc,tc) then
return false
end
elseif role==Synchro.Role.NON_TUNER then
if not prune_non_tuner_filter(sc,tc) then
return false
end
else
error("Synchro.CanCompleteSelection: unknown role for selected["..i.."]")
end
end
end
if index>#candidates then
-- check if target_level achievable exactly
if state.possible_sums[target_level] and
state.tuner_count>=tuner_min and
state.non_tuner_count>=non_tuner_min then
return true
end
return false
end
local mc=candidates[index]
local can_include,append_material_limit_filter =
Synchro.CanIncludeMaterial(
mc,state,selected,tc,
prune_tuner_filter,prune_non_tuner_filter,scheck,
prune_indexes,index
)
--- include branch
if can_include then
for _,diff in ipairs(Synchro.GenerateVariantForCard(
state,mc,selected,tc,tuner_race,prune_tuner_filter,non_tuner_race,prune_non_tuner_filter
)) do
-- apply diff
local branch_state=Synchro.ApplyVariantState(
state,mc,diff,tuner_race,prune_tuner_filter,non_tuner_race,prune_non_tuner_filter,tc,prune_level,append_material_limit_filter
)
table.insert(selected,mc)
if Synchro.CanCompleteSelection(
candidates,target_level,
tuner_race,tuner_filter,
non_tuner_race,non_tuner_filter,tc,
tuner_min,tuner_max,non_tuner_min,non_tuner_max,
level_mapper,hand_count_mapper,scheck,
selected,index+1,branch_state,prune_indexes
) then
table.remove(selected)
return true
end
table.remove(selected)
end
end
-- exclude branch
if Synchro.CanCompleteSelection(candidates,target_level,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tc,
tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper,scheck,selected,index+1,state,prune_indexes) then
return true
end
return false
end
--- Synchro condition generator using tuner/non-tuner min/max counts and filters
function Synchro.SynCondition(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper,scheck)
--- @param mg Group
return function(e,c,smat,mg,min,max)
if c==nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
-- add リペア・ジェネクス・コントローラー to scheck
if Duel.IsPlayerAffectedByEffect(c:GetOwner(),8173184) then
local old_scheck=scheck
--- @param g Group
scheck=aux.AND(function(g)
if not g:IsExists(function(mc) return mc:IsType(TYPE_TUNER) and mc:IsSetCard(0x2) end,1,nil) then
return false
end
return true
end,
old_scheck)
end
local target_level=c:GetLevel()
mg=mg or Synchro.GetSynchroMaterial(c:GetControler(),c,level_mapper)
local smat_states=nil
local smat_arr=nil
local candidates={}
for mc in aux.Next(mg) do
if mc~=smat then
table.insert(candidates,mc)
end
end
if smat~=nil then
if not mg:IsContains(smat) then
return false
end
smat_arr={}
table.insert(smat_arr,smat)
smat_states=Synchro.BuildStatesFromSelection(smat_arr,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,level_mapper,hand_count_mapper,c,math.huge)
for _,state in ipairs(smat_states) do
if Synchro.FindValidSelection(candidates,target_level,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,c,tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper,scheck,smat_arr,state) then
return true
end
end
return false
else
return Synchro.FindValidSelection(candidates,target_level,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,c,tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper,scheck)
end
end
end
function Synchro.SynTarget(tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper,scheck)
return function(e,tp,eg,ep,ev,re,r,rp,chk,tc,smat,mg,min,max)
if mg~=nil and #mg==min then
e:SetLabelObject(mg)
return true
end
mg=mg or Synchro.GetSynchroMaterial(tp,tc,level_mapper)
-- add リペア・ジェネクス・コントローラー to scheck
if Duel.IsPlayerAffectedByEffect(tp,8173184) then
local old_scheck=scheck
--- @param g Group
scheck=aux.AND(function(g)
if not g:IsExists(function(mc) return mc:IsType(TYPE_TUNER) and mc:IsSetCard(0x2) end,1,nil) then
return false
end
return true
end,
old_scheck)
end
local sg=Group.CreateGroup()
if smat~=nil then
if not mg:IsContains(smat) then
return false
end
sg:AddCard(smat)
end
local function GroupToArray(group)
local arr={}
for card in aux.Next(group) do table.insert(arr,card) end
return arr
end
while true do
local addable=Group.CreateGroup()
local sg_arr=GroupToArray(sg)
local cg_arr=GroupToArray(mg-sg)
local target_level=tc:GetLevel()
local selected_level_min=target_level
local selected_states=Synchro.BuildStatesFromSelection(
sg_arr,
tuner_race,tuner_filter,
non_tuner_race,non_tuner_filter,
level_mapper,hand_count_mapper,
tc,math.huge
)
--- use the min select level as hint
for _,state in ipairs(selected_states) do
for lvl,_ in pairs(state.possible_sums) do
if lvl<selected_level_min then
selected_level_min=lvl
end
end
end
assert(#selected_states>0,"we selected an invalid state")
for _,candidate in ipairs(cg_arr) do
for _,state in ipairs(selected_states) do
local can_include=Synchro.CanIncludeMaterial(
candidate,state,sg_arr,tc,
tuner_filter,non_tuner_filter,scheck
)
if can_include then
-- simulate adding candidate to sg_arr
local test_selection={}
for _, card in ipairs(sg_arr) do table.insert(test_selection,card) end
table.insert(test_selection,candidate)
-- build rest_candidates without candidate
local rest_candidates={}
for _, other in ipairs(cg_arr) do
if other~=candidate then
table.insert(rest_candidates,other)
end
end
local base_states=Synchro.BuildStatesFromSelection(
test_selection,
tuner_race,tuner_filter,
non_tuner_race,non_tuner_filter,
level_mapper,hand_count_mapper,
tc,math.huge
)
for _,init_state in ipairs(base_states) do
if Synchro.FindValidSelection(
rest_candidates,target_level,
tuner_race,tuner_filter,
non_tuner_race,non_tuner_filter,tc,
tuner_min,tuner_max,non_tuner_min,non_tuner_max,
level_mapper,hand_count_mapper,scheck,test_selection,init_state)
then
addable:AddCard(candidate)
break
end
end
if addable:IsContains(candidate) then
break
end
end
end
end
if #addable==0 then
break
end
local finishable=Synchro.IsSelectionValid(sg_arr,target_level,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tc,tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL)
local picked=Group.SelectUnselect(addable,sg,tp,finishable,true,selected_level_min,target_level)
if not picked then
-- user clicked Complete
if finishable then
break
else
-- user clicked Cancel
return false
end
else
if sg:IsContains(picked) then
if picked~=smat then
sg:RemoveCard(picked)
end
else
sg:AddCard(picked)
end
end
end
sg:KeepAlive()
e:SetLabelObject(sg)
return true
end
end
--- Synchro operation function that applies selected materials
function Synchro.SynOperation()
return function(e,tp,eg,ep,ev,re,r,rp,c)
local g=e:GetLabelObject()
c:SetMaterial(g)
-- confirm hand hard
local confirm_cards=g:Filter(function(c) return c:IsLocation(LOCATION_HAND) end,nil)
Duel.ConfirmCards(1-tp,confirm_cards)
Duel.HintSelection(g-confirm_cards)
for mc in aux.Next(g) do
if Synchro.IsRevolution(mc,c) then
local revo_effect=mc:IsHasEffect(97682931)
Duel.Hint(HINT_CARD,0,mc:GetCode())
revo_effect:UseCountLimit(mc:GetControler())
end
end
-- Detect whether Tatsunecro’s effect was actually used:
-- (a) Tatsunecro itself was used as material, AND
-- (b) At least one hand card was included.
local used_tatsunecro_effect=g:IsExists(function(card) return Synchro.IsTatsunecro(card) end,1,nil)
and g:IsExists(function(card) return card:IsLocation(LOCATION_HAND) end,1,nil)
-- Detect which effect-bearing monster(s) were used as material:
-- Tatsunecro ⇒ banish clause; Tatsunoko ⇒ normal GY clause
local has_tatsunecro=g:IsExists(function(card) return Synchro.IsTatsunecro(card) end,1,nil)
local has_tatsunoko=g:IsExists(function(card) return Synchro.IsTatsunoko(card) end,1,nil)
if used_tatsunecro_effect then
if has_tatsunecro and not has_tatsunoko then
-- Only Tatsunecro applies: banish all materials
Duel.Remove(g, POS_FACEUP, REASON_MATERIAL+REASON_SYNCHRO)
elseif has_tatsunoko and not has_tatsunecro then
-- Only Tatsunoko applies: send all materials to the GY
Duel.SendtoGrave(g, REASON_MATERIAL+REASON_SYNCHRO)
else
-- Both apply: prompt the player to choose
local opts={
1005, -- banish
1004, -- grave
}
local choice=Duel.SelectOption(tp,table.unpack(opts))
if choice==0 then
Duel.Hint(HINT_CARD,0,3096468)
Duel.Remove(g,POS_FACEUP,REASON_MATERIAL+REASON_SYNCHRO)
else
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_SYNCHRO)
end
end
else
-- Tatsunecro’s banish clause not used: always send to the GY
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_SYNCHRO)
end
g:DeleteGroup()
end
end
function Synchro.IsSelectionValid(selection,target_level,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tc,tuner_min,tuner_max,non_tuner_min,non_tuner_max,level_mapper,hand_count_mapper)
local states=Synchro.BuildStatesFromSelection(
selection,
tuner_race,tuner_filter,
non_tuner_race,non_tuner_filter,
level_mapper,hand_count_mapper,
tc,target_level
)
for _,state in ipairs(states) do
if state.tuner_count<=tuner_max
and state.non_tuner_count<=non_tuner_max
and state.possible_sums[target_level]
and state.tuner_count>=tuner_min
and state.non_tuner_count>=non_tuner_min
and state.hand_count<=state.hand_count_limit
then
return true
end
end
return false
end
--- Returns a list of possible levels this card can be treated as when used as Synchro material.
--- @param card Card -- The candidate material card.
--- @param tc Card -- The Synchro monster being summoned.
--- @return integer[] -- Array of possible level integers (e.g., {1} or {1,2}).
function Synchro.DefaultLevelMapper(card,tc)
local level_dict={}
local mandatory=false
local effs={card:IsHasEffect(EFFECT_SYNCHRO_LEVEL)}
if #effs>0 then
local val=effs[1]:GetValue()(effs[1],tc)
if type(val)=="table" then
for _, v in ipairs(val) do
level_dict[v]=true
end
elseif type(val)=="number" then
if val>=(1<<16) then -- compatibility
val=val>>16
else
mandatory=true
end
level_dict[val]=true
end
end
effs={card:IsHasEffect(61052897)} --- レアル・ジェネクス・チューリング
if #effs>0 then
local val=effs[1]:GetValue()(effs[1],tc)
for _, v in ipairs(val) do
level_dict[v]=true
end
end
if not mandatory then
-- include original level
if card:IsLevelAbove(1) then
level_dict[card:GetLevel()]=true
end
end
-- Convert dictionary keys back to array
local levels={}
for lvl,_ in pairs(level_dict) do
table.insert(levels,lvl)
end
return levels
end
function Synchro.DefaultHandCountMapper(card,tc)
-- Revolution Synchron effect
if Synchro.IsRevolution(card,tc) then
return 0
end
return 1
end
function Synchro.DefaultTunerFilter(mc,tc)
-- if this card has EFFECT_TUNER, always count it as a Tuner
for _,e in ipairs({mc:IsHasEffect(EFFECT_TUNER)}) do
local v=e:GetValue()
if type(v)=="function" then
if v(e,tc) then return true end
elseif v then
return true
end
end
return mc:IsType(TYPE_TUNER)
end
function Synchro.DefaultNonTunerFilter(mc,tc)
-- if this card has EFFECT_NONTUNER, always count it as a non-Tuner
for _,e in ipairs({mc:IsHasEffect(EFFECT_NONTUNER)}) do
local v=e:GetValue()
if type(v)=="function" then
if v(e,tc) then
return true
end
elseif v then
return true
end
end
return not mc:IsType(TYPE_TUNER)
end
function Synchro.UpdatepossibleSums(possible_sums,card_levels,prune_level)
local new_sums={}
for sum, _ in pairs(possible_sums) do
for _, lvl in ipairs(card_levels) do
local newSum=sum+lvl
if newSum<=prune_level then
new_sums[newSum]=true
end
end
end
return new_sums
end
function Synchro.BuildStatesFromSelection(selection,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,level_mapper,hand_count_mapper,tc,prune_level)
local states={
{
possible_sums={[0]=true},
tuner_count=0,
non_tuner_count=0,
level_mapper=level_mapper,
level_mapper_priority=0,
hand_count_mapper=hand_count_mapper,
hand_count_limit=0,
hand_count=0,
genomix_race=nil,
material_limit_filter=aux.TRUE,
selected_roles={}
}
}
Synchro.SortMaterials(selection,tc,tuner_filter)
local selected={}
for _,card in ipairs(selection)do
local next_states={}
local material_limit_effect=card:IsHasEffect(EFFECT_TUNER_MATERIAL_LIMIT) or card:IsHasEffect(EFFECT_SCRAP_CHIMERA)
local append_material_limit_filter=nil
if material_limit_effect~=nil then
append_material_limit_filter=material_limit_effect:GetTarget()
end
for _,st in ipairs(states) do
for _,diff in ipairs(Synchro.GenerateVariantForCard(
st,card,selected,tc,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter
)) do
-- merge diff into full state
local new_state = Synchro.ApplyVariantState(
st,card,diff,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tc,prune_level,append_material_limit_filter
)
table.insert(next_states,new_state)
end
end
table.insert(selected,card)
states=next_states
if #states==0 then
break
end
end
return states
end
--- @param c Card
function Synchro.IsMono(c)
return c:IsHasEffect(56897896)~=nil
end
--- @param c Card
function Synchro.IsFlower(c)
return c:IsHasEffect(89818984)~=nil
end
--- @param c Card
function Synchro.IsTatsunoko(c)
return c:IsHasEffect(55863245)~=nil
end
--- @param c Card
function Synchro.IsTatsunecro(c)
return c:IsHasEffect(3096468)~=nil
end
--- @param c Card
function Synchro.IsRevolution(c,tc)
local revo_e=c:IsHasEffect(97682931)
if revo_e==nil or revo_e:CheckCountLimit(c:GetControler())==false then
return false
end
return revo_e:GetValue()(revo_e,tc)
end
--- @param c Card
function Synchro.IsTGCyberMagician(c,tc)
local tg_e=c:IsHasEffect(64910482)
if tg_e==nil then
return false
end
return tg_e:GetValue()(tg_e,tc)
end
--- @param c Card
function Synchro.IsGenomix(c)
return c:IsHasEffect(42155488)~=nil
end
function Synchro.SortMaterials(materials,tc,tuner_filter)
table.sort(materials,function(a,b)
if Synchro.IsMono(a)~=Synchro.IsMono(b) then
return Synchro.IsMono(a) -- monos first
end
if Synchro.IsFlower(a)~=Synchro.IsFlower(b) then
return Synchro.IsFlower(a) -- then flowers
end
if Synchro.IsGenomix(a)~=Synchro.IsGenomix(b) then
return Synchro.IsGenomix(a) -- then Genomix
end
if Synchro.IsTatsunoko(a)~=Synchro.IsTatsunoko(b) then
return Synchro.IsTatsunoko(a) -- then tatsunoko
end
if Synchro.IsTatsunecro(a)~=Synchro.IsTatsunecro(b) then
return Synchro.IsTatsunecro(a) -- then tatsunecro
end
if tuner_filter(a,tc)~=tuner_filter(b,tc) then
return tuner_filter(a,tc) -- then tuner
end
-- otherwise normals: sort descending by level
return a:GetLevel()>b:GetLevel()
end)
end
function Synchro.IsLevelAlter(c)
return Synchro.IsMono(c) or Synchro.IsFlower(c)
end
function Synchro.IsHandAlter(c,tc)
return Synchro.IsTatsunoko(c) or Synchro.IsTatsunecro(c) or Synchro.IsTGCyberMagician(c,tc)
end
function Synchro.IsRaceAlter(c)
return Synchro.IsGenomix(c)
end
function Synchro.IsMandatory(c)
return Synchro.IsMono(c) or Synchro.IsGenomix(c)
end
function Synchro.IsNoHarm(c)
return Synchro.IsTatsunoko(c) or Synchro.IsTatsunecro(c)
end
-- Helper to generate only the variant-specific diffs for a card
function Synchro.GenerateVariantForCard(st,card,selected,tc,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter)
local base_variants = {}
-- MonoSynchron first/second
if Synchro.IsMono(card) then
if st.level_mapper_priority<2 then
local firstMono = card
table.insert(base_variants,{
possible_sums={[#selected+card:GetLevel()]=true},
level_mapper=function(c)
return (c==firstMono) and {c:GetLevel()} or {1}
end,
level_mapper_priority=2,
})
elseif st.level_mapper_priority==2 then
table.insert(base_variants,{
possible_sums={[#selected+1]=true},
level_mapper=function() return {1} end,
})
end
end
if Synchro.IsGenomix(card) then
local declared_race=card:IsHasEffect(42155488):GetLabel()
if st.genomix_race~=nil then
assert(declared_race==st.genomix_race,"we activated 2 Genomix Fighter with 2 different races but we still have monster to summon")
end
table.insert(base_variants,{genomix_race=declared_race})
end
-- Normal branch
if not (Synchro.IsMandatory(card) or Synchro.IsNoHarm(card)) then
table.insert(base_variants,{})
end
-- Flower Cardian override
if Synchro.IsFlower(card) and st.level_mapper_priority<1 then
table.insert(base_variants,{
possible_sums={[2*(#selected+1)]=true},
level_mapper=function() return {2} end,
level_mapper_priority=1,
})
end
-- Tatsunoko effect
if Synchro.IsTatsunoko(card) then
table.insert(base_variants,{
hand_count_limit=1,
})
end
-- Tatsunecro effect
if Synchro.IsTatsunecro(card) then
table.insert(base_variants,{
hand_count_limit=1,
})
end
-- TG Cyber Magician effect
if Synchro.IsTGCyberMagician(card,tc) then
local new_hand_count_mapper=function(mc,p_tc)
if not mc:IsType(TYPE_TUNER) and mc:IsSetCard(0x27) then
return 0
end
return Synchro.DefaultHandCountMapper(mc,p_tc)
end
local previous_hand_count=0
if card:IsLocation(LOCATION_HAND) then
previous_hand_count=new_hand_count_mapper(card,tc)
end
for _,sc in ipairs(selected) do
if sc:IsLocation(LOCATION_HAND) then
previous_hand_count=previous_hand_count+new_hand_count_mapper(sc,tc)
end
end
table.insert(base_variants,{
hand_count=previous_hand_count,
hand_count_mapper=new_hand_count_mapper,
})
end
-- now wrap each base_variant in role‐specific diffs
local variants={}
local can_be_tuner=tuner_filter(card,tc)
local can_be_non_tuner=non_tuner_filter(card,tc)
for _, base in ipairs(base_variants) do
-- tuner branch
if can_be_tuner then
table.insert(variants,{
possible_sums=base.possible_sums,
level_mapper=base.level_mapper,
level_mapper_priority=base.level_mapper_priority,
hand_count_limit=base.hand_count_limit,
append_material_limit_filter=base.append_material_limit_filter,
genomix_race=base.genomix_race,
hand_count=base.hand_count,
hand_count_mapper=base.hand_count_mapper,
-- role-specific
tuner_delta=1,
non_tuner_delta=0,
role=Synchro.Role.TUNER,
})
end
-- non-tuner branch
if can_be_non_tuner then
table.insert(variants,{
possible_sums=base.possible_sums,
level_mapper=base.level_mapper,
level_mapper_priority=base.level_mapper_priority,
hand_count_limit=base.hand_count_limit,
append_material_limit_filter=base.append_material_limit_filter,
genomix_race=base.genomix_race,
hand_count=base.hand_count,
hand_count_mapper=base.hand_count_mapper,
-- role-specific
tuner_delta=0,
non_tuner_delta=1,
role=Synchro.Role.NON_TUNER,
})
end
end
return variants
end
-- Helper to apply a diff to a base state
function Synchro.ApplyVariantState(st,card,diff,tuner_race,tuner_filter,non_tuner_race,non_tuner_filter,tc,prune_level,append_material_limit_filter)
-- compute increments using provided filters
local tuner_inc=diff.tuner_delta
local non_tuner_inc=diff.non_tuner_delta
local new_selected_roles={ table.unpack(st.selected_roles) }
table.insert(new_selected_roles,diff.role)
local possible_sums=Synchro.UpdatepossibleSums(
st.possible_sums,
st.level_mapper(card,tc),
prune_level
)
local hand_inc=0
if card:IsLocation(LOCATION_HAND) then
hand_inc=st.hand_count_mapper(card,tc)
end
local new_material_limit_filter=st.material_limit_filter
if append_material_limit_filter~=nil then
new_material_limit_filter=aux.AND(append_material_limit_filter,st.material_limit_filter)
end
return {
possible_sums=diff.possible_sums or possible_sums,
tuner_count=st.tuner_count+tuner_inc,
non_tuner_count=st.non_tuner_count+non_tuner_inc,
level_mapper=diff.level_mapper or st.level_mapper,
level_mapper_priority=diff.level_mapper_priority or st.level_mapper_priority,
hand_count_mapper=diff.hand_count_mapper or st.hand_count_mapper,
hand_count_limit=diff.hand_count_limit or st.hand_count_limit,
hand_count=diff.hand_count or st.hand_count+hand_inc,
genomix_race=diff.genomix_race or st.genomix_race,
material_limit_filter=new_material_limit_filter,
selected_roles=new_selected_roles,
}
end
--- Determine whether a candidate card can be included as a material
--- @param mc Card -- the material candidate
--- @param state table -- current DFS state
--- @param selected Card[] -- already-selected materials
--- @param tc Card -- the Synchro monster being summoned
--- @param prune_tuner_filter function -- tuner filter (with pruning applied)
--- @param prune_non_tuner_filter function -- non-tuner filter (with pruning applied)
--- @param prune_indexes? table -- index thresholds for pruning
--- @param index? integer -- current position in candidates
--- @return boolean can_include
--- @return function|nil append_material_limit_filter
function Synchro.CanIncludeMaterial(mc,state,selected,tc,
prune_tuner_filter,prune_non_tuner_filter,scheck,
prune_indexes,index)
prune_indexes=prune_indexes or {
hand_prune_index=math.huge,
race_prune_index=math.huge,
level_prune_index=math.huge,
}
index=index or -1
-- global material‐limit check
if not state.material_limit_filter(mc) then
return false,nil
end
local append_material_limit_filter
-- per-card EFFECT_TUNER_MATERIAL_LIMIT check against already‐selected
local eff=mc:IsHasEffect(EFFECT_TUNER_MATERIAL_LIMIT)
if eff then
append_material_limit_filter=function(c) return eff:GetTarget()(eff,c) end
for _, sel in ipairs(selected) do
if not append_material_limit_filter(sel) then
return false,nil
end
end
end
-- must satisfy at least one of the tuner/non-tuner filters
if not (prune_tuner_filter(mc,tc) or prune_non_tuner_filter(mc,tc)) then
return false,nil
end
-- hand‐location count limit
if mc:IsLocation(LOCATION_HAND) and index>prune_indexes.hand_prune_index then
if state.hand_count+state.hand_count_mapper(mc,tc)>state.hand_count_limit then
return false,nil
end
end
-- build a temporary Group = already selected cards + this mc
local sg=Group.FromCards(table.unpack(selected))
sg:AddCard(mc)
-- if either check fails on this partial group, drop this branch
if (not scheck(sg)) or (aux.AdditionalSCheck and not aux.AdditionalSCheck(sg)) then
return false,nil
end
return true,append_material_limit_filter
end
...@@ -4,3 +4,6 @@ ...@@ -4,3 +4,6 @@
!setname 0x2d0 死伟王 !setname 0x2d0 死伟王
!setname 0x2d1 绚岚 !setname 0x2d1 绚岚
!setname 0x2d2 奏悦机组 !setname 0x2d2 奏悦机组
!setname 0x2d3 终刻
!setname 0x2d4 不可见
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment