Skip to content

Commit 7589a2a

Browse files
authored
Update "HEROES UNITE - FUSION!!"
Fusion Summon code cleanup/script modernization
1 parent 391d464 commit 7589a2a

File tree

1 file changed

+36
-84
lines changed

1 file changed

+36
-84
lines changed

skill/c300305001.lua

Lines changed: 36 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -7,98 +7,50 @@ end
77
s.listed_series={SET_ELEMENTAL_HERO}
88
--Fusion Summon Functions
99
function s.flipcon(e,tp,eg,ep,ev,re,r,rp)
10-
--condition
11-
return aux.CanActivateSkill(tp) and Duel.GetFlagEffect(tp,id)==0 and s.fusTarget(e,tp,eg,ep,ev,re,r,rp,0)
10+
return aux.CanActivateSkill(tp) and s.cost(e,tp,eg,ep,ev,re,r,rp,0) and not Duel.HasFlagEffect(tp,id)
1211
end
13-
function s.listedmatfilter(c,fusc)
14-
return c:IsFaceup() and fusc:ListsCodeAsMaterial(c:GetCode())
15-
end
16-
function s.fusfilter(c,e,tp,m,f,chkf)
17-
if not (c:IsType(TYPE_FUSION) and c:IsSetCard(SET_ELEMENTAL_HERO) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false)) then return false end
18-
if c.min_material_count>2 and Duel.IsExistingMatchingCard(s.listedmatfilter,tp,LOCATION_MZONE,0,2,nil,c) then
19-
local dg=Duel.GetMatchingGroup(s.matfilter,tp,LOCATION_DECK,0,nil,e,c)
20-
m:Merge(dg)
21-
end
22-
return (not f or f(c)) and c:CheckFusionMaterial(m,nil,chkf)
23-
end
24-
function s.cfilter(c,e,tp)
12+
function s.costfilter(c,e,tp,eg,ep,ev,re,r,rp)
2513
if not c:IsDiscardable() then return false end
26-
local chkf=tp
27-
local mg1=Duel.GetFusionMaterial(tp):Filter(aux.NOT(Card.IsImmuneToEffect),nil,e)
28-
local res=Duel.IsExistingMatchingCard(s.fusfilter,tp,LOCATION_EXTRA,0,1,c,e,tp,mg1-c,nil,chkf)
29-
if not res then
30-
local ce=Duel.GetChainMaterial(tp)
31-
if ce~=nil then
32-
local fgroup=ce:GetTarget()
33-
local mg2=fgroup(ce,e,tp)
34-
local mf=ce:GetValue()
35-
res=Duel.IsExistingMatchingCard(s.fusfilter,tp,LOCATION_EXTRA,0,1,c,e,tp,mg2-c,mf,chkf)
14+
local params={fusfilter=aux.FilterBoolFunction(Card.IsSetCard,SET_ELEMENTAL_HERO),extrafil=s.fextra(c)}
15+
return Fusion.SummonEffTG(params)(e,tp,eg,ep,ev,re,r,rp,0)
16+
end
17+
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
18+
if chk==0 then return Duel.IsExistingMatchingCard(s.costfilter,tp,LOCATION_HAND,0,1,nil,e,tp,eg,ep,ev,re,r,rp) end
19+
Duel.DiscardHand(tp,s.costfilter,1,1,REASON_COST|REASON_DISCARD,nil,e,tp,eg,ep,ev,re,r,rp)
20+
Duel.SetPossibleOperationInfo(0,CATEGORY_TOGRAVE,nil,0,tp,LOCATION_DECK)
21+
end
22+
function s.fextra(exc)
23+
return function(e,tp,mg)
24+
if mg:IsExists(Card.IsLocation,1,nil,LOCATION_MZONE) then
25+
local eg=Duel.GetMatchingGroup(Fusion.IsMonsterFilter(Card.IsAbleToGrave),tp,LOCATION_DECK,0,nil)
26+
if eg and #eg>0 then
27+
return eg,s.fcheck(exc)
28+
end
3629
end
3730
end
38-
return res
3931
end
40-
function s.fusTarget(e,tp,eg,ep,ev,re,r,rp,chk)
41-
if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_HAND,0,1,nil,e,tp) end
42-
Duel.DiscardHand(tp,s.cfilter,1,1,REASON_COST+REASON_DISCARD,nil,e,tp)
43-
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
32+
function s.fcheck(exc)
33+
return function(tp,sg,fc)
34+
if sg:IsExists(Card.IsLocation,1,nil,LOCATION_DECK) then
35+
local matgg=Duel.GetFusionMaterial(tp):Filter(s.matfilter,nil,fc)
36+
return #matg>1 and fc.min_material_count>2
37+
end
38+
return not (exc and sg:IsContains(exc))
39+
end
4440
end
4541
function s.flipop(e,tp,eg,ep,ev,re,r,rp)
4642
Duel.Hint(HINT_SKILL_FLIP,tp,id|(1<<32))
4743
Duel.Hint(HINT_CARD,tp,id)
48-
--Fusion Summon "Elemental HERO" Fusion monster
49-
local g2=s.fusTarget(e,tp,eg,ep,ev,re,r,rp,0)
50-
--OPD Register
44+
local params={fusfilter=aux.FilterBoolFunction(Card.IsSetCard,SET_ELEMENTAL_HERO),extrafil=s.fextra(c)}
45+
--You can only apply this effect once per Duel
5146
Duel.RegisterFlagEffect(tp,id,0,0,0)
52-
--Fusion Procedure
53-
s.fusTarget(e,tp,eg,ep,ev,re,r,rp,1)
54-
local chkf=tp
55-
local mg1=Duel.GetFusionMaterial(tp):Filter(aux.NOT(Card.IsImmuneToEffect),nil,e)
56-
local sg1=Duel.GetMatchingGroup(s.fusfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
57-
local mg2,sg2=nil,nil
58-
local ce=Duel.GetChainMaterial(tp)
59-
if ce~=nil then
60-
local fgroup=ce:GetTarget()
61-
mg2=fgroup(ce,e,tp)
62-
local mf=ce:GetValue()
63-
sg2=Duel.GetMatchingGroup(s.fusfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf)
64-
end
65-
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then
66-
local sg=sg1:Clone()
67-
if sg2 then sg:Merge(sg2) end
68-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
69-
local tg=sg:Select(tp,1,1,nil)
70-
local tc=tg:GetFirst()
71-
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then
72-
local fusg=Group.CreateGroup()
73-
local fg=Duel.GetMatchingGroup(s.matfilter,tp,LOCATION_MZONE,0,nil,e,tc)
74-
for sc in fg:Iter() do
75-
if tc:ListsCodeAsMaterial(sc:GetCode()) then
76-
fusg:AddCard(sc)
77-
end
78-
end
79-
if tc.min_material_count>2 and #fusg==2 then
80-
local dg=Duel.GetMatchingGroup(s.matfilter,tp,LOCATION_DECK,0,nil,e,tc)
81-
mg1:Merge(dg)
82-
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
83-
tc:SetMaterial(mat1)
84-
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
85-
Duel.BreakEffect()
86-
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
87-
else
88-
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
89-
tc:SetMaterial(mat1)
90-
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
91-
Duel.BreakEffect()
92-
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
93-
end
94-
else
95-
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf)
96-
local fop=ce:GetOperation()
97-
fop(ce,e,tp,tc,mat2)
98-
end
99-
tc:CompleteProcedure()
100-
end
101-
end
102-
function s.matfilter(c,e,fc)
103-
return c:IsSetCard(SET_ELEMENTAL_HERO) and not c:IsImmuneToEffect(e) and c:IsCanBeFusionMaterial(fc)
47+
--Discard 1 card
48+
s.cost(e,tp,eg,ep,ev,re,r,rp,1)
49+
--Fusion Summon 1 "Elemental HERO"" Fusion monster, using monsters from your hand or field as material
50+
--OR use monsters from your Deck if the Fusion Monster requires 3+ materials and you control 2 "Elemental HERO" monsters listed on it as material
51+
Fusion.SummonEffTG(params)(e,tp,eg,ep,ev,re,r,rp,1)
52+
Fusion.SummonEffOP(params)(e,tp,eg,ep,ev,re,r,rp)
53+
end
54+
function s.matfilter(c,fc)
55+
return c:IsCanBeFusionMaterial(fc) and fc:ListsCodeAsMaterial(c:GetCode()) and c:IsLocation(LOCATION_MZONE)
10456
end

0 commit comments

Comments
 (0)