Skip to content

Commit 8ba9860

Browse files
authored
Update "Believe in your Bro"
Fusion Summon code cleanup/general script polishing and modernization
1 parent 967e9b9 commit 8ba9860

File tree

1 file changed

+92
-130
lines changed

1 file changed

+92
-130
lines changed

skill/c300305011.lua

Lines changed: 92 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -5,120 +5,93 @@ function s.initial_effect(c)
55
--Activate
66
aux.AddSkillProcedure(c,1,false,s.flipcon,s.flipop,1)
77
local e1=Effect.CreateEffect(c)
8-
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
9-
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
10-
e1:SetCode(EVENT_STARTUP)
11-
e1:SetCountLimit(1)
12-
e1:SetRange(0x5f)
13-
e1:SetLabelObject(e)
14-
e1:SetLabel(0)
15-
e1:SetOperation(s.op)
16-
c:RegisterEffect(e1)
8+
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
9+
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
10+
e1:SetCode(EVENT_STARTUP)
11+
e1:SetCountLimit(1)
12+
e1:SetRange(0x5f)
13+
e1:SetLabelObject(e)
14+
e1:SetLabel(0)
15+
e1:SetOperation(s.op)
16+
c:RegisterEffect(e1)
1717
end
1818
s.listed_series={SET_ELEMENTAL_HERO,SET_ROID}
1919
function s.op(e,tp,eg,ep,ev,re,r,rp)
20-
Duel.Hint(HINT_SKILL_FLIP,tp,id|(1<<32))
20+
Duel.Hint(HINT_SKILL_FLIP,tp,id|(1<<32))
2121
Duel.Hint(HINT_CARD,tp,id)
2222
end
2323
function s.flipcon(e,tp,eg,ep,ev,re,r,rp)
2424
local g=Duel.GetMatchingGroup(aux.FaceupFilter(Card.IsMonster),tp,LOCATION_MZONE,0,nil)
2525
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
26-
local b1=g:FilterCount(Card.IsSetCard,nil,SET_ELEMENTAL_HERO)>0 and Duel.IsExistingMatchingCard(s.dtpfilter,tp,LOCATION_HAND,0,1,nil) and Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_GRAVE,0,1,nil) and Duel.GetFlagEffect(tp,id)==0
27-
local b2=g:FilterCount(s.rfilter,nil)>0 and Duel.IsExistingMatchingCard(s.dspfilter,tp,LOCATION_HAND,0,1,nil) and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) and ft>0 and Duel.GetFlagEffect(tp,id+100)==0
28-
local b3=g:FilterCount(s.rhfilter,nil,tp)>0 and s.fusTarget(e,tp,eg,ep,ev,re,r,rp,0) and Duel.GetFlagEffect(tp,id+200)==0
29-
return aux.CanActivateSkill(tp) and (b1 or b2 or b3)
26+
local b1=g:FilterCount(Card.IsSetCard,nil,SET_ELEMENTAL_HERO)>0 and Duel.IsExistingMatchingCard(s.discardtrapfilter,tp,LOCATION_HAND,0,1,nil)
27+
and Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_GRAVE,0,1,nil) and not Duel.HasFlagEffect(tp,id)
28+
local b2=g:FilterCount(s.machineroidfilter,nil)>0 and Duel.IsExistingMatchingCard(s.discardspellfilter,tp,LOCATION_HAND,0,1,nil)
29+
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) and ft>0 and not Duel.HasFlagEffect(tp,id+100)
30+
local b3=g:FilterCount(s.roidherofilter,nil,tp)>0 and s.fuscost(e,tp,eg,ep,ev,re,r,rp,0) and not Duel.HasFlagEffect(tp,id+200)
31+
return aux.CanActivateSkill(tp) and (b1 or b2 or b3)
3032
end
3133
function s.flipop(e,tp,eg,ep,ev,re,r,rp)
32-
Duel.Hint(HINT_CARD,0,id)
33-
--Apply effect
34-
local g=Duel.GetMatchingGroup(aux.FaceupFilter(Card.IsMonster),tp,LOCATION_MZONE,0,nil)
35-
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
36-
local b1=g:FilterCount(Card.IsSetCard,nil,SET_ELEMENTAL_HERO)>0 and Duel.IsExistingMatchingCard(s.dtpfilter,tp,LOCATION_HAND,0,1,nil) and Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_GRAVE,0,1,nil) and Duel.GetFlagEffect(tp,id)==0
37-
local b2=g:FilterCount(s.rfilter,nil)>0 and ft>0 and Duel.IsExistingMatchingCard(s.dspfilter,tp,LOCATION_HAND,0,1,nil) and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) and Duel.GetFlagEffect(tp,id+100)==0
38-
local b3=g:FilterCount(s.rhfilter,nil,tp)>0 and s.fusTarget(e,tp,eg,ep,ev,re,r,rp,0) and Duel.GetFlagEffect(tp,id+200)==0
39-
local op=Duel.SelectEffect(tp,{b1,aux.Stringid(id,0)},{b2,aux.Stringid(id,1)},{b3,aux.Stringid(id,2)})
40-
--Discard 1 Trap to add 1 Machine "roid" and potentially destroy 1 opponent's monster
41-
if op==1 then
42-
--OPD register
43-
Duel.RegisterFlagEffect(tp,id,0,0,0)
44-
--Discard 1 Trap to add "roid" to hand
45-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD)
46-
local dtc=Duel.SelectMatchingCard(tp,s.dtpfilter,tp,LOCATION_HAND,0,1,1,nil)
47-
if Duel.SendtoGrave(dtc,REASON_COST+REASON_DISCARD)>0 then
48-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
49-
local thc=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_GRAVE,0,1,1,nil):GetFirst()
50-
local atk=thc:GetAttack()
51-
if Duel.SendtoHand(thc,tp,REASON_EFFECT)>0 then
52-
Duel.ConfirmCards(1-tp,thc)
53-
if Duel.IsExistingMatchingCard(s.desfilter,tp,0,LOCATION_MZONE,1,nil,atk) and Duel.SelectYesNo(tp,aux.Stringid(id,3)) then
54-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
55-
local dc=Duel.SelectMatchingCard(tp,s.desfilter,tp,0,LOCATION_MZONE,1,1,nil,atk):GetFirst()
56-
Duel.HintSelection(dc)
57-
Duel.Destroy(dc,REASON_EFFECT)
58-
end
59-
end
60-
end
61-
--Discard 1 Spell to Special Summon 1 Level 6 or lower Machine "roid" or "Elemental HERO" from Deck
62-
elseif op==2 then
63-
--OPD Register
64-
Duel.RegisterFlagEffect(tp,id+100,0,0,0)
65-
--Discard 1 Spell to Special Summon "roid" or "Elemental HERO" monster
66-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD)
67-
local dsc=Duel.SelectMatchingCard(tp,s.dspfilter,tp,LOCATION_HAND,0,1,1,nil)
68-
if Duel.SendtoGrave(dsc,REASON_COST+REASON_DISCARD)>0 then
69-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
70-
local sc=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp):GetFirst()
71-
if Duel.SpecialSummon(sc,0,tp,tp,false,false,POS_FACEUP_DEFENSE)>0 then
72-
local e1=Effect.CreateEffect(e:GetHandler())
73-
e1:SetType(EFFECT_TYPE_SINGLE)
74-
e1:SetCode(EFFECT_DISABLE_EFFECT)
75-
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_UNCOPYABLE)
76-
e1:SetReset(RESET_EVENT+RESETS_STANDARD-RESET_TOFIELD)
77-
sc:RegisterEffect(e1)
78-
end
79-
end
80-
--Discard 1 card to Fusion Summon using only "roid" or "HERO" monsters you control
34+
Duel.Hint(HINT_CARD,0,id)
35+
--Apply effect
36+
local g=Duel.GetMatchingGroup(aux.FaceupFilter(Card.IsMonster),tp,LOCATION_MZONE,0,nil)
37+
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
38+
local b1=g:FilterCount(Card.IsSetCard,nil,SET_ELEMENTAL_HERO)>0 and Duel.IsExistingMatchingCard(s.discardtrapfilter,tp,LOCATION_HAND,0,1,nil)
39+
and Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_GRAVE,0,1,nil) and not Duel.HasFlagEffect(tp,id)
40+
local b2=g:FilterCount(s.machineroidfilter,nil)>0 and ft>0 and Duel.IsExistingMatchingCard(s.discardspellfilter,tp,LOCATION_HAND,0,1,nil)
41+
and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) and not Duel.HasFlagEffect(tp,id+100)
42+
local b3=g:FilterCount(s.roidherofilter,nil,tp)>0 and s.fuscost(e,tp,eg,ep,ev,re,r,rp,0) and not Duel.HasFlagEffect(tp,id+200)
43+
local op=Duel.SelectEffect(tp,{b1,aux.Stringid(id,0)},{b2,aux.Stringid(id,1)},{b3,aux.Stringid(id,2)})
44+
--Discard 1 Trap to add 1 Machine "roid" to your hand and destroy 1 opponent's monster
45+
if op==1 then
46+
--OPD register (First Skill)
47+
Duel.RegisterFlagEffect(tp,id,0,0,0)
48+
--Discard 1 Trap to add 1 Machine "roid" monster to hand and destroy opponent's monster
49+
if Duel.DiscardHand(tp,s.discardtrapfilter,1,1,REASON_COST|REASON_DISCARD,nil)>0 then
50+
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
51+
local thc=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_GRAVE,0,1,1,nil):GetFirst()
52+
local atk=thc:GetAttack()
53+
if Duel.SendtoHand(thc,tp,REASON_EFFECT)>0 then
54+
Duel.ConfirmCards(1-tp,thc)
55+
if Duel.IsExistingMatchingCard(s.desfilter,tp,0,LOCATION_MZONE,1,nil,atk) and Duel.SelectYesNo(tp,aux.Stringid(id,3)) then
56+
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
57+
local dc=Duel.SelectMatchingCard(tp,s.desfilter,tp,0,LOCATION_MZONE,1,1,nil,atk):GetFirst()
58+
Duel.HintSelection(dc,true)
59+
Duel.Destroy(dc,REASON_EFFECT)
60+
end
61+
end
62+
end
63+
--Discard 1 Spell to Special Summon 1 Level 6 or lower Machine "roid" or "Elemental HERO" from Deck
64+
elseif op==2 then
65+
--OPD Register (Second Skill)
66+
Duel.RegisterFlagEffect(tp,id+100,0,0,0)
67+
--Discard 1 Spell to Special Summon "roid" or "Elemental HERO" monster with its effects negated
68+
if Duel.DiscardHand(tp,s.discardspellfilter,1,1,REASON_COST|REASON_DISCARD,nil)>0 then
69+
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
70+
local sc=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp):GetFirst()
71+
if Duel.SpecialSummon(sc,0,tp,tp,false,false,POS_FACEUP_DEFENSE)>0 then
72+
local e1=Effect.CreateEffect(e:GetHandler())
73+
e1:SetType(EFFECT_TYPE_SINGLE)
74+
e1:SetCode(EFFECT_DISABLE_EFFECT)
75+
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_UNCOPYABLE)
76+
e1:SetReset(RESET_EVENT|RESETS_STANDARD&~RESET_TOFIELD)
77+
sc:RegisterEffect(e1)
78+
end
79+
end
80+
--Discard 1 card to Fusion Summon 1 Fusion monster using only "roid" or "HERO" monsters you control
8181
elseif op==3 then
82-
local g2=s.fusTarget(e,tp,eg,ep,ev,re,r,rp,0)
83-
--OPD Register
84-
Duel.RegisterFlagEffect(tp,id+200,0,0,0)
85-
--Fusion Procedure
86-
s.fusTarget(e,tp,eg,ep,ev,re,r,rp,1)
87-
local chkf=tp
88-
local mg1=Duel.GetFusionMaterial(tp):Filter(s.matfilter,nil,e)
89-
local sg1=Duel.GetMatchingGroup(s.fusfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
90-
local mg2,sg2=nil,nil
91-
local ce=Duel.GetChainMaterial(tp)
92-
if ce~=nil then
93-
local fgroup=ce:GetTarget()
94-
mg2=fgroup(ce,e,tp)
95-
local mf=ce:GetValue()
96-
sg2=Duel.GetMatchingGroup(s.fusfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf)
97-
end
98-
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then
99-
local sg=sg1:Clone()
100-
if sg2 then sg:Merge(sg2) end
101-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
102-
local tg=sg:Select(tp,1,1,nil)
103-
local tc=tg:GetFirst()
104-
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then
105-
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
106-
tc:SetMaterial(mat1)
107-
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
108-
Duel.BreakEffect()
109-
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
110-
else
111-
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf)
112-
local fop=ce:GetOperation()
113-
fop(ce,e,tp,tc,mat2)
114-
end
115-
tc:CompleteProcedure()
116-
end
117-
end
82+
local params={matfilter=Fusion.OnFieldMat(s.matfilter)}
83+
--OPD register (Third Skill)
84+
Duel.RegisterFlagEffect(tp,id+200,0,0,0)
85+
--Discard 1 card
86+
s.fuscost(e,tp,eg,ep,ev,re,r,rp,1)
87+
--Fusion Summon 1 Fusion monster using only "HERO" and "roid" monsters you control
88+
Fusion.SummonEffTG(params)(e,tp,eg,ep,ev,re,r,rp,1)
89+
Fusion.SummonEffOP(params)(e,tp,eg,ep,ev,re,r,rp)
90+
end
11891
end
11992
--Discard/Search/Destroy Functions
120-
function s.dtpfilter(c)
121-
return c:IsTrap() and c:IsAbleToGraveAsCost()
93+
function s.discardtrapfilter(c)
94+
return c:IsTrap() and c:IsDiscardable(REASON_COST)
12295
end
12396
function s.thfilter(c)
12497
return c:IsLevelBelow(6) and c:IsSetCard(SET_ROID) and c:IsRace(RACE_MACHINE) and c:IsAbleToHand()
@@ -127,39 +100,28 @@ function s.desfilter(c,atk)
127100
return c:IsFaceup() and c:IsMonster() and c:IsAttackBelow(atk)
128101
end
129102
--Discard/Special Summon functions
130-
function s.rfilter(c)
131-
return c:IsRace(RACE_MACHINE) and c:IsSetCard(SET_ROID) and c:IsMonster()
103+
function s.machineroidfilter(c)
104+
return c:IsRace(RACE_MACHINE) and c:IsSetCard(SET_ROID)
132105
end
133-
function s.dspfilter(c)
134-
return c:IsSpell() and c:IsAbleToGraveAsCost()
106+
function s.discardspellfilter(c)
107+
return c:IsSpell() and c:IsDiscardable(REASON_COST)
135108
end
136109
function s.spfilter(c,e,tp)
137-
return ((s.rfilter(c) and c:IsLevelBelow(6)) or c:IsSetCard(SET_ELEMENTAL_HERO)) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE)
110+
return ((s.machineroidfilter(c) and c:IsLevelBelow(6)) or c:IsSetCard(SET_ELEMENTAL_HERO)) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE)
111+
end
112+
--Discard/Fusion Summon functions
113+
function s.roidherofilter(c)
114+
return c:IsSetCard(SET_ELEMENTAL_HERO) and Duel.IsExistingMatchingCard(s.machineroidfilter,c:GetControler(),LOCATION_MZONE,0,1,nil)
138115
end
139-
--Fusion Summon functions
140-
function s.rhfilter(c,tp)
141-
return c:IsSetCard(SET_ELEMENTAL_HERO) and c:IsMonster() and c:IsFaceup() and Duel.IsExistingMatchingCard(aux.FaceupFilter(s.rfilter),tp,LOCATION_MZONE,0,1,nil)
116+
function s.costfilter(c,e,tp,eg,ep,ev,re,r,rp)
117+
if not c:IsDiscardable(REASON_COST) then return false end
118+
local params={matfilter=Fusion.OnFieldMat(s.matfilter)}
119+
return Fusion.SummonEffTG(params)(e,tp,eg,ep,ev,re,r,rp,0)
142120
end
143-
function s.fusfilter(c,e,tp,m,f,chkf)
144-
return c:IsType(TYPE_FUSION) and (not f or f(c)) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
121+
function s.fuscost(e,tp,eg,ep,ev,re,r,rp,chk)
122+
` if chk==0 then return Duel.IsExistingMatchingCard(s.costfilter,tp,LOCATION_HAND,0,1,nil,e,tp,eg,ep,ev,re,r,rp) end
123+
Duel.DiscardHand(tp,s.costfilter,1,1,REASON_COST|REASON_DISCARD,nil,e,tp,eg,ep,ev,re,r,rp)
145124
end
146-
function s.fusTarget(e,tp,eg,ep,ev,re,r,rp,chk)
147-
local chkf=tp
148-
local mg1=Duel.GetFusionMaterial(tp):Filter(s.matfilter,nil,e)
149-
local res=Duel.IsExistingMatchingCard(s.fusfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf)
150-
if not res then
151-
local ce=Duel.GetChainMaterial(tp)
152-
if ce~=nil then
153-
local fgroup=ce:GetTarget()
154-
local mg2=fgroup(ce,e,tp)
155-
local mf=ce:GetValue()
156-
res=Duel.IsExistingMatchingCard(s.fusfilter,tp,LOCATION_EXTRA,0,1,c,e,tp,mg2,mf,chkf)
157-
end
158-
end
159-
if chk==0 then return res and Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_HAND,0,1,nil,e,tp) end
160-
Duel.DiscardHand(tp,Card.IsAbleToGraveAsCost,1,1,REASON_COST+REASON_DISCARD,nil,e,tp)
161-
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
125+
function s.matfilter(c)
126+
return (c:IsSetCard(SET_ELEMENTAL_HERO) or c:IsSetCard(SET_ROID)) and c:IsCanBeFusionMaterial()
162127
end
163-
function s.matfilter(c,e)
164-
return not c:IsImmuneToEffect(e) and (c:IsSetCard(SET_ELEMENTAL_HERO) or c:IsSetCard(SET_ROID)) and c:IsOnField()
165-
end

0 commit comments

Comments
 (0)