Skip to content

Commit 4e4e45c

Browse files
authored
Script updates (#1275)
Fixed cards with effects written as "shuffle X into the Deck, and if you do, do Y" that were not properly checking if the card(s) actually went to the Deck (or Extra Deck, when it is possible) in order to do the second part of the effect
1 parent 84f9260 commit 4e4e45c

12 files changed

Lines changed: 155 additions & 178 deletions

‎official/c11637481.lua‎

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
--Scripted by AlphaKretin
44
local s,id=GetID()
55
function s.initial_effect(c)
6-
--Special Summon itself from the hand
6+
--You can Special Summon this card (from your hand) by returning 1 "U.A." monster you control to the hand, except "U.A. Libero Spiker"
77
local e1=Effect.CreateEffect(c)
88
e1:SetDescription(aux.Stringid(id,0))
99
e1:SetType(EFFECT_TYPE_FIELD)
@@ -15,39 +15,36 @@ function s.initial_effect(c)
1515
e1:SetTarget(s.sptg)
1616
e1:SetOperation(s.spop)
1717
c:RegisterEffect(e1)
18-
--Shuffle monster into the Deck and then Special Summon 1 "U.A." monster from deck
18+
--During your opponent's Main Phase (Quick Effect): You can shuffle 1 Level 5 or higher "U.A." monster from your hand into the Deck, and if you do, Special Summon 1 "U.A." monster from your Deck with a different name, then return this card to the hand
1919
local e2=Effect.CreateEffect(c)
2020
e2:SetDescription(aux.Stringid(id,1))
2121
e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TODECK+CATEGORY_TOHAND)
2222
e2:SetType(EFFECT_TYPE_QUICK_O)
2323
e2:SetCode(EVENT_FREE_CHAIN)
24-
e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER|TIMING_MAIN_END)
2524
e2:SetRange(LOCATION_MZONE)
25+
e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER|TIMING_MAIN_END)
2626
e2:SetCountLimit(1,{id,1})
27-
e2:SetCondition(s.spcon2)
27+
e2:SetCondition(function(e,tp) return Duel.IsTurnPlayer(1-tp) and Duel.IsMainPhase() end)
2828
e2:SetTarget(s.sptg2)
2929
e2:SetOperation(s.spop2)
3030
c:RegisterEffect(e2)
3131
end
3232
s.listed_names={id}
3333
s.listed_series={SET_UA}
34-
function s.spfilter(c,ft)
34+
function s.spfilter(c)
3535
return c:IsFaceup() and c:IsSetCard(SET_UA) and not c:IsCode(id) and c:IsAbleToHandAsCost()
36-
and (ft>0 or c:GetSequence()<5)
3736
end
3837
function s.spcon(e,c)
3938
if c==nil then return true end
4039
local tp=e:GetHandlerPlayer()
41-
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
42-
local rg=Duel.GetMatchingGroup(s.spfilter,tp,LOCATION_MZONE,0,nil,ft)
43-
return ft>-1 and #rg>0 and aux.SelectUnselectGroup(rg,e,tp,1,1,nil,0)
40+
local rg=Duel.GetMatchingGroup(s.spfilter,tp,LOCATION_MZONE,0,nil)
41+
return #rg>0 and aux.SelectUnselectGroup(rg,e,tp,1,1,aux.ChkfMMZ(1),0)
4442
end
4543
function s.sptg(e,tp,eg,ep,ev,re,r,rp,c)
4644
local c=e:GetHandler()
4745
local g=nil
48-
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
49-
local rg=Duel.GetMatchingGroup(s.spfilter,tp,LOCATION_MZONE,0,nil,ft)
50-
local g=aux.SelectUnselectGroup(rg,e,tp,1,1,nil,1,tp,HINTMSG_RTOHAND,nil,nil,true)
46+
local rg=Duel.GetMatchingGroup(s.spfilter,tp,LOCATION_MZONE,0,nil)
47+
local g=aux.SelectUnselectGroup(rg,e,tp,1,1,aux.ChkfMMZ(1),1,tp,HINTMSG_RTOHAND,nil,nil,true)
5148
if #g>0 then
5249
g:KeepAlive()
5350
e:SetLabelObject(g)
@@ -61,9 +58,6 @@ function s.spop(e,tp,eg,ep,ev,re,r,rp,c)
6158
Duel.SendtoHand(g,nil,REASON_COST)
6259
g:DeleteGroup()
6360
end
64-
function s.spcon2(e,tp,eg,ep,ev,re,r,rp)
65-
return Duel.IsTurnPlayer(1-tp) and Duel.IsMainPhase()
66-
end
6761
function s.tdfilter(c,e,tp)
6862
return c:IsSetCard(SET_UA) and c:IsLevelAbove(5) and c:IsAbleToDeck()
6963
and Duel.IsExistingMatchingCard(s.spfilter2,tp,LOCATION_DECK,0,1,nil,e,tp,c:GetCode())
@@ -79,18 +73,17 @@ function s.sptg2(e,tp,eg,ep,ev,re,r,rp,chk)
7973
Duel.SetOperationInfo(0,CATEGORY_TOHAND,e:GetHandler(),1,tp,LOCATION_ONFIELD)
8074
end
8175
function s.spop2(e,tp,eg,ep,ev,re,r,rp)
82-
local c=e:GetHandler()
8376
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
8477
local tc=Duel.SelectMatchingCard(tp,s.tdfilter,tp,LOCATION_HAND,0,1,1,nil,e,tp):GetFirst()
85-
if tc then
86-
Duel.ConfirmCards(1-tp,tc)
87-
if Duel.SendtoDeck(tc,tp,SEQ_DECKSHUFFLE,REASON_EFFECT)~=0 and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then
88-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
89-
local g=Duel.SelectMatchingCard(tp,s.spfilter2,tp,LOCATION_DECK,0,1,1,nil,e,tp,tc:GetCode())
90-
if #g>0 and Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)~=0 and c:IsRelateToEffect(e) then
91-
Duel.BreakEffect()
92-
Duel.SendtoHand(c,nil,REASON_EFFECT)
93-
end
78+
if not tc then return end
79+
Duel.ConfirmCards(1-tp,tc)
80+
if Duel.SendtoDeck(tc,tp,SEQ_DECKSHUFFLE,REASON_EFFECT)>0 and tc:IsLocation(LOCATION_DECK) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then
81+
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
82+
local g=Duel.SelectMatchingCard(tp,s.spfilter2,tp,LOCATION_DECK,0,1,1,nil,e,tp,tc:GetCode())
83+
local c=e:GetHandler()
84+
if #g>0 and Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)>0 and c:IsRelateToEffect(e) then
85+
Duel.BreakEffect()
86+
Duel.SendtoHand(c,nil,REASON_EFFECT)
9487
end
9588
end
9689
end

‎official/c16259549.lua‎

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,52 @@
22
--Number 49: Fortune Tune
33
local s,id=GetID()
44
function s.initial_effect(c)
5-
--xyz summon
6-
Xyz.AddProcedure(c,nil,3,2)
75
c:EnableReviveLimit()
8-
--lpup
6+
--Xyz Summon procedure: 2 Level 3 monsters
7+
Xyz.AddProcedure(c,nil,3,2)
8+
--Neither player can target this card on the field with card effects
99
local e1=Effect.CreateEffect(c)
10-
e1:SetDescription(aux.Stringid(id,0))
11-
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
12-
e1:SetCategory(CATEGORY_RECOVER)
13-
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
14-
e1:SetCode(EVENT_PHASE|PHASE_STANDBY)
10+
e1:SetType(EFFECT_TYPE_SINGLE)
11+
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
12+
e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
1513
e1:SetRange(LOCATION_MZONE)
16-
e1:SetCountLimit(1)
17-
e1:SetCondition(s.reccon)
18-
e1:SetTarget(s.rectg)
19-
e1:SetOperation(s.recop)
14+
e1:SetValue(1)
2015
c:RegisterEffect(e1)
21-
--
16+
--If this card would be destroyed by battle or card effect, you can detach 1 material from this card instead
2217
local e2=Effect.CreateEffect(c)
23-
e2:SetType(EFFECT_TYPE_SINGLE)
18+
e2:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_SINGLE)
2419
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
25-
e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
20+
e2:SetCode(EFFECT_DESTROY_REPLACE)
2621
e2:SetRange(LOCATION_MZONE)
27-
e2:SetValue(1)
22+
e2:SetTarget(s.reptg)
2823
c:RegisterEffect(e2)
29-
--destroy replace
24+
--Once per turn, during your Standby Phase: Gain 500 LP
3025
local e3=Effect.CreateEffect(c)
31-
e3:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_SINGLE)
32-
e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
33-
e3:SetCode(EFFECT_DESTROY_REPLACE)
26+
e3:SetDescription(aux.Stringid(id,0))
27+
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
28+
e3:SetCategory(CATEGORY_RECOVER)
29+
e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
30+
e3:SetCode(EVENT_PHASE|PHASE_STANDBY)
3431
e3:SetRange(LOCATION_MZONE)
35-
e3:SetTarget(s.reptg)
32+
e3:SetCountLimit(1)
33+
e3:SetCondition(function(e,tp) return Duel.IsTurnPlayer(tp) end)
34+
e3:SetTarget(s.rectg)
35+
e3:SetOperation(s.recop)
3636
c:RegisterEffect(e3)
37-
--todeck
37+
--If this card is sent from the field to the GY: Target 2 Level 3 monsters in your GY; shuffle them both into the Deck, and if you do, return this card from your GY to the Extra Deck
3838
local e4=Effect.CreateEffect(c)
3939
e4:SetDescription(aux.Stringid(id,1))
4040
e4:SetCategory(CATEGORY_TODECK)
4141
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
42+
e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
4243
e4:SetCode(EVENT_TO_GRAVE)
4344
e4:SetCountLimit(1,id)
44-
e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
45-
e4:SetCondition(s.tdcon)
45+
e4:SetCondition(function(e,tp) return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD) end)
4646
e4:SetTarget(s.tdtg)
4747
e4:SetOperation(s.tdop)
4848
c:RegisterEffect(e4)
4949
end
5050
s.xyz_number=49
51-
function s.reccon(e,tp,eg,ep,ev,re,r,rp)
52-
return Duel.IsTurnPlayer(tp)
53-
end
5451
function s.rectg(e,tp,eg,ep,ev,re,r,rp,chk)
5552
if chk==0 then return true end
5653
Duel.SetTargetPlayer(tp)
@@ -69,9 +66,6 @@ function s.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
6966
return true
7067
else return false end
7168
end
72-
function s.tdcon(e,tp,eg,ep,ev,re,r,rp)
73-
return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
74-
end
7569
function s.filter(c,e)
7670
return c:GetLevel()==3 and c:IsCanBeEffectTarget(e) and c:IsAbleToDeck()
7771
end
@@ -83,17 +77,16 @@ function s.tdtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
8377
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
8478
local sg=g:Select(tp,2,2,nil)
8579
Duel.SetTargetCard(sg)
86-
Duel.SetOperationInfo(0,CATEGORY_TODECK,sg,2,0,0)
80+
Duel.SetOperationInfo(0,CATEGORY_TODECK,sg,2,tp,0)
8781
end
8882
end
8983
function s.tdop(e,tp,eg,ep,ev,re,r,rp)
90-
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
84+
local g=Duel.GetTargetCards(e)
9185
if not g then return end
92-
local tg=g:Filter(Card.IsRelateToEffect,nil,e)
93-
if #tg~=2 then return end
94-
Duel.SendtoDeck(tg,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)
95-
local c=e:GetHandler()
96-
if c:IsRelateToEffect(e) then
97-
Duel.SendtoDeck(c,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)
86+
if Duel.SendtoDeck(g,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)>0 and g:FilterCount(Card.IsLocation,nil,LOCATION_DECK|LOCATION_EXTRA)==2 then
87+
local c=e:GetHandler()
88+
if c:IsRelateToEffect(e) then
89+
Duel.SendtoDeck(c,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)
90+
end
9891
end
9992
end

‎official/c20049870.lua‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
--JP name
1+
--GMX研究員セラン
22
--GMX Researcher Selande
33
--scripted by pyrQ
44
local s,id=GetID()
@@ -85,7 +85,7 @@ function s.distg(e,tp,eg,ep,ev,re,r,rp,chk)
8585
end
8686
function s.disop(e,tp,eg,ep,ev,re,r,rp)
8787
local c=e:GetHandler()
88-
if c:IsRelateToEffect(e) and Duel.SendtoDeck(c,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)>0 and c:IsLocation(LOCATION_DECK) then
88+
if c:IsRelateToEffect(e) and Duel.SendtoDeck(c,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)>0 and c:IsLocation(LOCATION_DECK|LOCATION_EXTRA) then
8989
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_NEGATE)
9090
local sc=Duel.SelectMatchingCard(tp,Card.IsNegatable,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil):GetFirst()
9191
if sc then

‎official/c2563463.lua‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
--Scripted by Hatter
44
local s,id=GetID()
55
function s.initial_effect(c)
6-
--Special Summon itself from the hand
6+
--During the Main Phase, if you control no monsters, or control an "Adventurer Token" (Quick Effect): You can 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)
@@ -16,7 +16,7 @@ function s.initial_effect(c)
1616
e1:SetTarget(s.sptg)
1717
e1:SetOperation(s.spop)
1818
c:RegisterEffect(e1)
19-
--Negate the activation of a card or effect
19+
-- When a card or effect is activated while you control an "Adventurer Token" (Quick Effect): You can shuffle this card into the Deck, and if you do, negate that activation, and if you do that, destroy that card
2020
local e2=Effect.CreateEffect(c)
2121
e2:SetDescription(aux.Stringid(id,1))
2222
e2:SetCategory(CATEGORY_TODECK+CATEGORY_NEGATE+CATEGORY_DESTROY)
@@ -51,15 +51,15 @@ end
5151
function s.ngtg(e,tp,eg,ep,ev,re,r,rp,chk)
5252
local c=e:GetHandler()
5353
if chk==0 then return not c:IsStatus(STATUS_BATTLE_DESTROYED) and c:IsAbleToDeck() and Duel.IsChainNegatable(ev) end
54-
Duel.SetOperationInfo(0,CATEGORY_TODECK,c,1,0,0)
55-
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
54+
Duel.SetOperationInfo(0,CATEGORY_TODECK,c,1,tp,0)
55+
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,tp,0)
5656
if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
57-
Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0)
57+
Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,tp,0)
5858
end
5959
end
6060
function s.ngop(e,tp,eg,ep,ev,re,r,rp)
6161
local c=e:GetHandler()
62-
if c:IsRelateToEffect(e) and Duel.SendtoDeck(c,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)>0 and c:IsLocation(LOCATION_DECK)
62+
if c:IsRelateToEffect(e) and Duel.SendtoDeck(c,nil,SEQ_DECKSHUFFLE,REASON_EFFECT)>0 and c:IsLocation(LOCATION_DECK|LOCATION_EXTRA)
6363
and Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
6464
Duel.Destroy(eg,REASON_EFFECT)
6565
end

0 commit comments

Comments
 (0)