Commit acb378fd authored by Vury Leo's avatar Vury Leo Committed by wind2009

Add 覇王天龍の魂 to new fusion

parent bd85a74d
--覇王天龍の魂 --覇王天龍の魂
function c76840111.initial_effect(c) local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,13331639) aux.AddCodeList(c,13331639)
--activate --activate
local e1=Effect.CreateEffect(c) local e1=FusionSpell.CreateSummonEffect(c,{
fusfilter=s.fusfilter,
pre_select_mat_location=LOCATION_HAND|LOCATION_DECK|LOCATION_EXTRA|LOCATION_MZONE|LOCATION_GRAVE,
mat_operation_code_map={
{ [LOCATION_REMOVED]=FusionSpell.FUSION_OPERATION_GRAVE },
{ [0xff]=FusionSpell.FUSION_OPERATION_BANISH }
},
extra_target=s.extra_target,
stage_x_operation=s.stage_x_operation
})
e1:SetCategory(CATEGORY_REMOVE+CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON) e1:SetCategory(CATEGORY_REMOVE+CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER) e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER)
e1:SetCountLimit(1,76840111+EFFECT_COUNT_CODE_OATH) e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH)
e1:SetCost(c76840111.cost) e1:SetCost(s.cost)
e1:SetTarget(c76840111.target) e1:SetTarget(s.target)
e1:SetOperation(c76840111.activate)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
function c76840111.rfilter(c,tp)
return c:GetBaseAttack()==2500 and c:IsRace(RACE_SPELLCASTER) and c:IsType(TYPE_PENDULUM) --- @param c Card
function s.costfilter(c,e,tp)
if not (c:GetBaseAttack()==2500 and c:IsRace(RACE_SPELLCASTER) and c:IsType(TYPE_PENDULUM) and c:IsReleasable(REASON_COST)) then
return false
end
local res_cell=Duel.GetLocationCountFromEx(tp,tp,c,TYPE_FUSION)
--- Create a temp fusion effect that can not use candidate cost monster as material, if we have a slot on field, skip the location count check
local fusion_effect=FusionSpell.CreateSummonEffect(e:GetHandler(),{
fusfilter=s.fusfilter,
matfilter=function(mc) return mc~=c end,
pre_select_mat_location=LOCATION_HAND|LOCATION_DECK|LOCATION_EXTRA|LOCATION_MZONE|LOCATION_GRAVE,
mat_operation_code_map={
{ [LOCATION_REMOVED]=FusionSpell.FUSION_OPERATION_GRAVE },
{ [0xff]=FusionSpell.FUSION_OPERATION_BANISH }
},
extra_target=s.extra_target,
skip_location_count_check=(res_cell>0)
})
if fusion_effect:GetTarget()(e,tp,nil,nil,nil,nil,nil,nil,0)==false then
return false
end
return true
end end
function c76840111.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,c76840111.rfilter,1,nil,tp) end function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,function(c) return s.costfilter(c,e,tp) end,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
local g=Duel.SelectReleaseGroup(tp,c76840111.rfilter,1,1,nil,tp) local g=Duel.SelectReleaseGroup(tp,function(c) return s.costfilter(c,e,tp) end,1,1,nil)
Duel.Release(g,REASON_COST) Duel.Release(g,REASON_COST)
end end
function c76840111.filter0(c)
return c:IsAbleToRemove() function s.fusfilter(c)
end return c:IsCode(13331639)
function c76840111.filter1(c,e)
return c:IsAbleToRemove() and not c:IsImmuneToEffect(e)
end
function c76840111.filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and c:IsCode(13331639) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
end end
function c76840111.filter3(c)
return c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsAbleToRemove() function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if e:IsCostChecked() then
--- cost could be paid, location count check done there
local fusion_effect_no_location_count_check=FusionSpell.CreateSummonEffect(e:GetHandler(),{
fusfilter=s.fusfilter,
pre_select_mat_location=LOCATION_HAND|LOCATION_DECK|LOCATION_EXTRA|LOCATION_MZONE|LOCATION_GRAVE,
mat_operation_code_map={
{ [LOCATION_REMOVED]=FusionSpell.FUSION_OPERATION_GRAVE },
{ [0xff]=FusionSpell.FUSION_OPERATION_BANISH }
},
extra_target=s.extra_target,
skip_location_count_check=true
})
return fusion_effect_no_location_count_check:GetTarget()(e,tp,eg,ep,ev,re,r,rp,chk)
else
--- cost bypassed, location count check done here
local fusion_effect_with_location_count_check=FusionSpell.CreateSummonEffect(e:GetHandler(),{
fusfilter=s.fusfilter,
pre_select_mat_location=LOCATION_HAND|LOCATION_DECK|LOCATION_EXTRA|LOCATION_MZONE|LOCATION_GRAVE,
mat_operation_code_map={
{ [LOCATION_REMOVED]=FusionSpell.FUSION_OPERATION_GRAVE },
{ [0xff]=FusionSpell.FUSION_OPERATION_BANISH }
},
extra_target=s.extra_target,
skip_location_count_check=false
})
return fusion_effect_with_location_count_check:GetTarget()(e,tp,eg,ep,ev,re,r,rp,chk)
end
end end
function c76840111.target(e,tp,eg,ep,ev,re,r,rp,chk)
function s.extra_target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then if chk==0 then
local chkf=tp return true
local mg1=Duel.GetFusionMaterial(tp):Filter(c76840111.filter0,nil)
local mg2=Duel.GetMatchingGroup(c76840111.filter3,tp,LOCATION_DECK+LOCATION_EXTRA+LOCATION_GRAVE,0,nil)
mg1:Merge(mg2)
local res=Duel.IsExistingMatchingCard(c76840111.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(c76840111.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg3,mf,chkf)
end
end
return res
end end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_HAND+LOCATION_DECK+LOCATION_EXTRA+LOCATION_ONFIELD+LOCATION_GRAVE) Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_HAND+LOCATION_DECK+LOCATION_EXTRA+LOCATION_ONFIELD+LOCATION_GRAVE)
end end
function c76840111.activate(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler() --- @type FUSION_SPELL_STAGE_X_CALLBACK_FUNCTION
local chkf=tp function s.stage_x_operation(e,tc,tp,stage)
local mg1=Duel.GetFusionMaterial(tp):Filter(c76840111.filter1,nil,e) if stage==FusionSpell.STAGE_BEFORE_SUMMON_COMPLETE then
local mg2=Duel.GetMatchingGroup(c76840111.filter3,tp,LOCATION_DECK+LOCATION_EXTRA+LOCATION_GRAVE,0,nil) local b1=Duel.IsExistingMatchingCard(s.efilter1,tp,LOCATION_REMOVED,0,1,nil)
mg1:Merge(mg2) local b2=Duel.IsExistingMatchingCard(s.efilter2,tp,LOCATION_REMOVED,0,1,nil)
local sg1=Duel.GetMatchingGroup(c76840111.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf) local b3=Duel.IsExistingMatchingCard(s.efilter3,tp,LOCATION_REMOVED,0,1,nil)
local mg3=nil local b4=Duel.IsExistingMatchingCard(s.efilter4,tp,LOCATION_REMOVED,0,1,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(c76840111.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 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)
else
local mat2=Duel.SelectFusionMaterial(tp,tc,mg3,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
local b1=Duel.IsExistingMatchingCard(c76840111.efilter1,tp,LOCATION_REMOVED,0,1,nil)
local b2=Duel.IsExistingMatchingCard(c76840111.efilter2,tp,LOCATION_REMOVED,0,1,nil)
local b3=Duel.IsExistingMatchingCard(c76840111.efilter3,tp,LOCATION_REMOVED,0,1,nil)
local b4=Duel.IsExistingMatchingCard(c76840111.efilter4,tp,LOCATION_REMOVED,0,1,nil)
if not b1 or not b2 or not b3 or not b4 then if not b1 or not b2 or not b3 or not b4 then
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE) e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_DISABLE) e1:SetCode(EFFECT_DISABLE)
e1:SetReset(RESET_EVENT+RESETS_STANDARD) e1:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e1,true) tc:RegisterEffect(e1,true)
local e2=Effect.CreateEffect(c) local e2=Effect.CreateEffect(e:GetHandler())
e2:SetType(EFFECT_TYPE_SINGLE) e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetCode(EFFECT_DISABLE_EFFECT)
e2:SetValue(RESET_TURN_SET) e2:SetValue(RESET_TURN_SET)
e2:SetReset(RESET_EVENT+RESETS_STANDARD) e2:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e2,true) tc:RegisterEffect(e2,true)
end end
tc:CompleteProcedure()
end end
end end
function c76840111.efilter1(c)
function s.efilter1(c)
return c:IsSetCard(0x10f2) and c:IsFaceup() return c:IsSetCard(0x10f2) and c:IsFaceup()
end end
function c76840111.efilter2(c)
function s.efilter2(c)
return c:IsSetCard(0x2073) and c:IsFaceup() return c:IsSetCard(0x2073) and c:IsFaceup()
end end
function c76840111.efilter3(c)
function s.efilter3(c)
return c:IsSetCard(0x2017) and c:IsFaceup() return c:IsSetCard(0x2017) and c:IsFaceup()
end end
function c76840111.efilter4(c)
function s.efilter4(c)
return c:IsSetCard(0x1046) and c:IsFaceup() return c:IsSetCard(0x1046) and c:IsFaceup()
end end
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