Skip to content

Commit 2643967

Browse files
authored
Thunder Ball
- Shouldn't be able to use its 1st effect if damage calculation isn't conducted - The destroy effect should resolve doing nothing if this card has already left the field when it resolves - Shouldn't roll a die if the target has already left the GY when it resolves
1 parent c60f745 commit 2643967

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

official/c84813516.lua

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,27 @@
33
--scripted by Naim
44
local s,id=GetID()
55
function s.initial_effect(c)
6-
--Special Summon itself from the hand
6+
--Special Summon this card from your hand
77
local e1=Effect.CreateEffect(c)
88
e1:SetDescription(aux.Stringid(id,0))
99
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
1010
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
1111
e1:SetCode(EVENT_DAMAGE_STEP_END)
1212
e1:SetRange(LOCATION_HAND)
1313
e1:SetCountLimit(1,id)
14+
e1:SetCondition(function() return Duel.HasFlagEffect(0,id) end)
1415
e1:SetTarget(s.sptg)
1516
e1:SetOperation(s.spop)
1617
c:RegisterEffect(e1)
17-
--Destroy all other monsters in the same column
18+
--Keep track of damage calculation being performed
19+
aux.GlobalCheck(s,function()
20+
local ge1=Effect.CreateEffect(c)
21+
ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
22+
ge1:SetCode(EVENT_BATTLED)
23+
ge1:SetOperation(function() Duel.RegisterFlagEffect(0,id,RESET_PHASE|PHASE_DAMAGE,0,1) end)
24+
Duel.RegisterEffect(ge1,0)
25+
end)
26+
--Destroy all other monsters in this card's column
1827
local e2=Effect.CreateEffect(c)
1928
e2:SetDescription(aux.Stringid(id,1))
2029
e2:SetCategory(CATEGORY_DESTROY)
@@ -25,15 +34,15 @@ function s.initial_effect(c)
2534
e2:SetTarget(s.destg)
2635
e2:SetOperation(s.desop)
2736
c:RegisterEffect(e2)
28-
--Return a card from the GY to the hand
37+
--Roll a six-sided die, and if the result is 6, add 1 card from your GY to your hand
2938
local e3=Effect.CreateEffect(c)
3039
e3:SetDescription(aux.Stringid(id,2))
3140
e3:SetCategory(CATEGORY_DICE+CATEGORY_TOHAND)
3241
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
3342
e3:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET)
34-
e3:SetCode(EVENT_TO_GRAVE)
43+
e3:SetCode(EVENT_DESTROYED)
3544
e3:SetCountLimit(1,{id,2})
36-
e3:SetCondition(s.thcond)
45+
e3:SetCondition(s.thcon)
3746
e3:SetTarget(s.thtg)
3847
e3:SetOperation(s.thop)
3948
c:RegisterEffect(e3)
@@ -43,51 +52,52 @@ function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
4352
local c=e:GetHandler()
4453
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
4554
and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end
46-
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,tp,LOCATION_HAND)
55+
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,tp,0)
4756
end
4857
function s.spop(e,tp,eg,ep,ev,re,r,rp)
4958
local c=e:GetHandler()
5059
if c:IsRelateToEffect(e) then
5160
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
5261
end
5362
end
54-
function s.cstfilter(c)
55-
return c:IsTrap() and c:IsAbleToGraveAsCost() and (c:IsLocation(LOCATION_HAND) or c:IsFacedown())
63+
function s.descostfilter(c)
64+
return c:IsTrap() and (c:IsLocation(LOCATION_HAND) or c:IsFacedown()) and c:IsAbleToGraveAsCost()
5665
end
5766
function s.descost(e,tp,eg,ep,ev,re,r,rp,chk)
58-
if chk==0 then return Duel.IsExistingMatchingCard(s.cstfilter,tp,LOCATION_HAND|LOCATION_ONFIELD,0,1,nil) end
67+
if chk==0 then return Duel.IsExistingMatchingCard(s.descostfilter,tp,LOCATION_HAND|LOCATION_ONFIELD,0,1,nil) end
5968
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
60-
local g=Duel.SelectMatchingCard(tp,s.cstfilter,tp,LOCATION_HAND|LOCATION_ONFIELD,0,1,1,nil)
69+
local g=Duel.SelectMatchingCard(tp,s.descostfilter,tp,LOCATION_HAND|LOCATION_ONFIELD,0,1,1,nil)
6170
Duel.SendtoGrave(g,REASON_COST)
6271
end
6372
function s.destg(e,tp,eg,ep,ev,re,r,rp,chk)
6473
local c=e:GetHandler()
65-
local cg=c:GetColumnGroup():Filter(Card.IsMonster,c)
74+
local cg=c:GetColumnGroup():Match(Card.IsMonster,c)
6675
if chk==0 then return #cg>0 end
6776
Duel.SetOperationInfo(0,CATEGORY_DESTROY,cg,#cg,tp,0)
6877
end
6978
function s.desop(e,tp,eg,ep,ev,re,r,rp)
7079
local c=e:GetHandler()
71-
local cg=c:GetColumnGroup():Filter(Card.IsMonster,c)
80+
if not c:IsRelateToEffect(e) then return end
81+
local cg=c:GetColumnGroup():Match(Card.IsMonster,c)
7282
if #cg>0 then
7383
Duel.Destroy(cg,REASON_EFFECT)
7484
end
7585
end
76-
function s.thcond(e,tp,eg,ep,ev,re,r,rp)
86+
function s.thcon(e,tp,eg,ep,ev,re,r,rp)
7787
local c=e:GetHandler()
78-
return c:IsReason(REASON_DESTROY) and c:IsPreviousLocation(LOCATION_MZONE) and c:IsReason(REASON_BATTLE|REASON_EFFECT)
88+
return c:IsPreviousLocation(LOCATION_MZONE) and c:IsReason(REASON_BATTLE|REASON_EFFECT) and c:IsLocation(LOCATION_GRAVE)
7989
end
80-
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
90+
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
91+
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) end
8192
if chk==0 then return Duel.IsExistingTarget(Card.IsAbleToHand,tp,LOCATION_GRAVE,0,1,nil) end
8293
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
8394
local g=Duel.SelectTarget(tp,Card.IsAbleToHand,tp,LOCATION_GRAVE,0,1,1,nil)
8495
Duel.SetOperationInfo(0,CATEGORY_DICE,nil,0,tp,1)
85-
Duel.SetPossibleOperationInfo(0,CATEGORY_TOHAND,g,1,tp,LOCATION_GRAVE)
96+
Duel.SetPossibleOperationInfo(0,CATEGORY_TOHAND,g,1,tp,0)
8697
end
8798
function s.thop(e,tp,eg,ep,ev,re,r,rp)
88-
local res=Duel.TossDice(tp,1)
8999
local tc=Duel.GetFirstTarget()
90-
if res==6 and tc:IsRelateToEffect(e) then
100+
if tc:IsRelateToEffect(e) and Duel.TossDice(tp,1)==6 then
91101
Duel.SendtoHand(tc,nil,REASON_EFFECT)
92102
end
93-
end
103+
end

0 commit comments

Comments
 (0)