Skip to content

Commit 96d7e54

Browse files
authored
Update "Nightmare Tri-Mirror"
Prevent script error from nil param/minor script update
1 parent 836d441 commit 96d7e54

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

unofficial/c511001561.lua

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,62 @@
33
--update by Larry126
44
local s,id=GetID()
55
function s.initial_effect(c)
6-
--Copy
6+
--Special Summon "Copy Tokens" equal to the number of monsters your opponent Summoned this turn, except by Normal Summon
77
local e1=Effect.CreateEffect(c)
88
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOKEN)
99
e1:SetType(EFFECT_TYPE_ACTIVATE)
1010
e1:SetCode(EVENT_FREE_CHAIN)
11-
e1:SetTarget(s.target)
12-
e1:SetOperation(s.operation)
11+
e1:SetTarget(s.tokentg)
12+
e1:SetOperation(s.tokenop)
1313
c:RegisterEffect(e1)
1414
aux.GlobalCheck(s,function()
1515
local ge1=Effect.CreateEffect(c)
1616
ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
1717
ge1:SetCode(EVENT_SPSUMMON_SUCCESS)
18-
ge1:SetOperation(s.chk)
18+
ge1:SetOperation(s.sumchk)
1919
Duel.RegisterEffect(ge1,0)
2020
local ge2=ge1:Clone()
2121
ge1:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
2222
Duel.RegisterEffect(ge1,0)
2323
end)
2424
end
25-
function s.chk(e,tp,eg,ep,ev,re,r,rp)
26-
for tc in aux.Next(eg) do
25+
function s.sumchk(e,tp,eg,ep,ev,re,r,rp)
26+
for tc in eg:Iter() do
2727
if tc:GetSummonPlayer()==0 then
2828
Duel.RegisterFlagEffect(0,id,RESET_PHASE|PHASE_END,0,1)
2929
else
3030
Duel.RegisterFlagEffect(1,id,RESET_PHASE|PHASE_END,0,1)
3131
end
3232
end
3333
end
34-
function s.filter(c,tp)
35-
return c:IsFaceup() and c:GetOriginalLevel()>0
34+
function s.tokenfilter(c,tp)
35+
return c:IsFaceup() and c:HasLevel()
3636
and Duel.IsPlayerCanSpecialSummonMonster(tp,id+1,c:GetOriginalSetCard(),c:GetOriginalType(),c:GetBaseAttack(),c:GetBaseDefense(),c:GetOriginalLevel(),c:GetOriginalRace(),c:GetOriginalAttribute())
3737
end
3838
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
3939
local ct=Duel.GetFlagEffect(1-tp,id)
4040
if ct>1 and Duel.IsPlayerAffectedByEffect(tp,CARD_BLUEEYES_SPIRIT) then return false end
4141
if chk==0 then return ct>0 and Duel.GetLocationCount(tp,LOCATION_MZONE)>=ct
42-
and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_MZONE,0,1,nil,tp) end
42+
and Duel.IsExistingMatchingCard(s.tokenfilter,tp,LOCATION_MZONE,0,1,nil,tp) end
4343
Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,ct,0,0)
4444
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,ct,0,0)
4545
end
4646
function s.operation(e,tp,eg,ep,ev,re,r,rp)
4747
local ct=Duel.GetFlagEffect(1-tp,id)
4848
if (ct>1 and Duel.IsPlayerAffectedByEffect(tp,CARD_BLUEEYES_SPIRIT)) or Duel.GetLocationCount(tp,LOCATION_MZONE)<ct
49-
or not Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_MZONE,0,1,nil,tp) then return end
49+
or not Duel.IsExistingMatchingCard(s.tokenfilter,tp,LOCATION_MZONE,0,1,nil,tp) then return end
5050
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
51-
local tc=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_MZONE,0,1,1,nil,tp):GetFirst()
51+
local tc=Duel.SelectMatchingCard(tp,s.tokenfilter,tp,LOCATION_MZONE,0,1,1,nil,tp):GetFirst()
5252
local c=e:GetHandler()
5353
for i=1,ct do
5454
local token=Duel.CreateToken(tp,id+1)
55+
--"Copy Token" information
5556
local e1=Effect.CreateEffect(c)
5657
e1:SetType(EFFECT_TYPE_SINGLE)
5758
e1:SetCode(EFFECT_SET_BASE_ATTACK)
5859
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
5960
e1:SetValue(tc:GetBaseAttack())
60-
e1:SetReset(RESET_EVENT+RESETS_STANDARD-RESET_TOFIELD)
61+
e1:SetReset(RESET_EVENT|RESETS_STANDARD&~RESET_TOFIELD)
6162
token:RegisterEffect(e1)
6263
local e2=e1:Clone()
6364
e2:SetCode(EFFECT_SET_BASE_DEFENSE)
@@ -84,17 +85,15 @@ function s.operation(e,tp,eg,ep,ev,re,r,rp)
8485
e7:SetValue(tc:GetOriginalType())
8586
token:RegisterEffect(e7)
8687
Duel.SpecialSummonStep(token,0,tp,tp,false,false,POS_FACEUP_ATTACK)
88+
--"Copy Tokens" cannot attack during your turn
8789
local e7=Effect.CreateEffect(c)
8890
e7:SetType(EFFECT_TYPE_SINGLE)
8991
e7:SetCode(EFFECT_CANNOT_ATTACK)
9092
e7:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
91-
e7:SetCondition(s.atkcon)
92-
e7:SetReset(RESET_EVENT+RESETS_STANDARD-RESET_TOFIELD)
93+
e7:SetCondition(function(e) return Duel.IsTurnPlayer(e:GetHandlerPlayer()) end)
94+
e7:SetReset(RESET_EVENT|RESETS_STANDARD&~RESET_TOFIELD)
9395
token:RegisterEffect(e7)
94-
token:CopyEffect(tc:GetOriginalCode(),RESET_EVENT+RESETS_STANDARD-RESET_TOFIELD,1)
96+
token:CopyEffect(tc:GetOriginalCode(),RESET_EVENT|RESETS_STANDARD&~RESET_TOFIELD,1)
9597
end
9698
Duel.SpecialSummonComplete()
9799
end
98-
function s.atkcon(e,tp,eg,ep,ev,re,r,rp)
99-
return Duel.IsTurnPlayer(tp)
100-
end

0 commit comments

Comments
 (0)