Skip to content

Commit 9d3925a

Browse files
authored
Update "The Dragon Hunting Swordsman"
Cleaned up Fusion Summon code to be more inline with modern script
1 parent afaacd1 commit 9d3925a

File tree

1 file changed

+35
-65
lines changed

1 file changed

+35
-65
lines changed

skill/c300307009.lua

Lines changed: 35 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ s.listed_names={CARD_BUSTER_BLADER}
1717
function s.op(e,tp,eg,ep,ev,re,r,rp)
1818
Duel.Hint(HINT_SKILL_FLIP,tp,id|(1<<32))
1919
Duel.Hint(HINT_CARD,tp,id)
20-
--Fusion Summon 1 Fusion Monster that mentions "Buster Blader"
20+
--Fusion Summon 1 Fusion Monster that lists "Buster Blader" as material
2121
local e1=Effect.CreateEffect(e:GetHandler())
2222
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
2323
e1:SetCode(EVENT_FREE_CHAIN)
2424
e1:SetRange(0x5f)
25-
e1:SetCondition(function(_,tp) return aux.CanActivateSkill(tp) and Duel.GetFlagEffect(tp,id)==0 end)
26-
e1:SetOperation(s.flipop)
25+
e1:SetCondition(s.fuscon)
26+
e1:SetOperation(s.fusop)
2727
Duel.RegisterEffect(e1,tp)
2828
--Opponent's GY becomes Dragon monsters
2929
local e2=Effect.CreateEffect(e:GetHandler())
@@ -36,76 +36,46 @@ function s.op(e,tp,eg,ep,ev,re,r,rp)
3636
e2:SetValue(RACE_DRAGON)
3737
Duel.RegisterEffect(e2,tp)
3838
end
39-
function s.flipop(e,tp,eg,ep,ev,re,r,rp)
40-
local g2=s.fusTarget(e,tp,eg,ep,ev,re,r,rp,0)
41-
--OPD Register
39+
function s.costfilter(c,e,tp,eg,ep,ev,re,r,rp)
40+
if not c:IsDiscardable() then return false end
41+
local params={fusfilter=aux.FilterBoolFunction(Card.ListsCodeAsMaterial,CARD_BUSTER_BLADER),extrafil=s.fextra(c)}
42+
return Fusion.SummonEffTG(params)(e,tp,eg,ep,ev,re,r,rp,0)
43+
end
44+
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
45+
if chk==0 then return Duel.IsExistingMatchingCard(s.costfilter,tp,LOCATION_HAND,0,1,nil,e,tp,eg,ep,ev,re,r,rp) end
46+
Duel.DiscardHand(tp,s.costfilter,1,1,REASON_COST|REASON_DISCARD,nil,e,tp,eg,ep,ev,re,r,rp)
47+
end
48+
function s.fuscon(e,tp,eg,ep,ev,re,r,rp)
49+
return aux.CanActivateSkill(tp) and s.cost(e,tp,eg,ep,ev,re,r,rp,0) and not Duel.HasFlagEffect(tp,id)
50+
end
51+
function s.fusop(e,tp,eg,ep,ev,re,r,rp)
52+
Duel.Hint(HINT_SKILL_FLIP,tp,id|(1<<32))
53+
Duel.Hint(HINT_CARD,tp,id)
54+
local params={fusfilter=aux.FilterBoolFunction(Card.ListsCodeAsMaterial,CARD_BUSTER_BLADER),extrafil=s.fextra(c)}
55+
--You can only apply this effect once per Duel
4256
Duel.RegisterFlagEffect(tp,id,0,0,0)
43-
--Fusion Summon 1 Fusion Monster that lists "Buster Blader" as material
44-
s.fusTarget(e,tp,eg,ep,ev,re,r,rp,1)
45-
local chkf=tp
46-
local mg1=Duel.GetFusionMaterial(tp):Filter(aux.NOT(Card.IsImmuneToEffect),nil,e)
47-
local sg1=Duel.GetMatchingGroup(s.fusfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
48-
local mg2=nil
49-
local sg2=nil
50-
local ce=Duel.GetChainMaterial(tp)
51-
if ce~=nil then
52-
local fgroup=ce:GetTarget()
53-
mg2=fgroup(ce,e,tp)
54-
local mf=ce:GetValue()
55-
sg2=Duel.GetMatchingGroup(s.fusfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf)
56-
end
57-
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then
58-
local sg=sg1:Clone()
59-
if sg2 then sg:Merge(sg2) end
60-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
61-
local tg=sg:Select(tp,1,1,nil)
62-
local tc=tg:GetFirst()
63-
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then
64-
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
65-
tc:SetMaterial(mat1)
66-
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
67-
Duel.BreakEffect()
68-
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
69-
else
70-
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf)
71-
local fop=ce:GetOperation()
72-
fop(ce,e,tp,tc,mat2)
73-
end
74-
tc:CompleteProcedure()
75-
end
57+
--Discard 1 card
58+
s.cost(e,tp,eg,ep,ev,re,r,rp,1)
59+
--Fusion Summon 1 Fusion Monster that lists "Buster Blader" as material, using monsters from your hand or field as material
60+
Fusion.SummonEffTG(params)(e,tp,eg,ep,ev,re,r,rp,1)
61+
Fusion.SummonEffOP(params)(e,tp,eg,ep,ev,re,r,rp)
7662
end
77-
--Fusion Summon Functions
78-
function s.cfilter(c,e,tp)
79-
if not c:IsDiscardable() then return false end
80-
local chkf=tp
81-
local mg1=Duel.GetFusionMaterial(tp)
82-
local res=Duel.IsExistingMatchingCard(s.fusfilter,tp,LOCATION_EXTRA,0,1,c,e,tp,mg1-c,nil,chkf)
83-
if not res then
84-
local ce=Duel.GetChainMaterial(tp)
85-
if ce~=nil then
86-
local fgroup=ce:GetTarget()
87-
local mg2=fgroup(ce,e,tp)
88-
local mf=ce:GetValue()
89-
res=Duel.IsExistingMatchingCard(s.fusfilter,tp,LOCATION_EXTRA,0,1,c,e,tp,mg2-c,mf,chkf)
90-
end
63+
function s.fextra(exc)
64+
return function(e,tp,mg)
65+
return nil,s.fcheck(exc)
9166
end
92-
return res
9367
end
94-
function s.fusfilter(c,e,tp,m,f,chkf)
95-
return c:IsType(TYPE_FUSION) and (not f or f(c)) and c:ListsCodeAsMaterial(CARD_BUSTER_BLADER)
96-
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
97-
end
98-
function s.fusTarget(e,tp,eg,ep,ev,re,r,rp,chk)
99-
if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_HAND,0,1,nil,e,tp) end
100-
Duel.DiscardHand(tp,s.cfilter,1,1,REASON_COST+REASON_DISCARD,nil,e,tp)
101-
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
68+
function s.fcheck(exc)
69+
return function(tp,sg,fc)
70+
return not (exc and sg:IsContains(exc))
71+
end
10272
end
10373
--Race Change Functions
104-
function s.bfilter(c)
74+
function s.busterbladerfilter(c)
10575
return c:IsFaceup() and (c:IsCode(CARD_BUSTER_BLADER) or (c:IsType(TYPE_FUSION) and c:ListsCodeAsMaterial(CARD_BUSTER_BLADER)))
10676
end
10777
function s.racecon(e)
10878
local tp=e:GetHandlerPlayer()
10979
local g=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
110-
return #g==1 and Duel.IsExistingMatchingCard(s.bfilter,tp,LOCATION_MZONE,0,1,nil)
111-
end
80+
return #g==1 and Duel.IsExistingMatchingCard(s.busterbladerfilter,tp,LOCATION_MZONE,0,1,nil)
81+
end

0 commit comments

Comments
 (0)