Skip to content

Commit 2d5fdfb

Browse files
authored
"Sacred Sword Thanatos" fix
Fixed an issue where Tokens wouldn't be attempted to be destroyed if they had a protection effect that is only applied the first time they would be destroyed.
1 parent 851f959 commit 2d5fdfb

File tree

1 file changed

+33
-22
lines changed

1 file changed

+33
-22
lines changed

unofficial/c511009160.lua

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
1+
--霊剣タナトス
12
--Sacred Sword Thanatos
23
local s,id=GetID()
34
function s.initial_effect(c)
45
aux.AddEquipProcedure(c)
5-
--atkup
6-
local e3=Effect.CreateEffect(c)
7-
e3:SetType(EFFECT_TYPE_EQUIP)
8-
e3:SetCode(EFFECT_UPDATE_ATTACK)
9-
e3:SetValue(300)
10-
c:RegisterEffect(e3)
11-
--Token destroy and atk up
12-
local e4=Effect.CreateEffect(c)
13-
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
14-
e4:SetCode(EVENT_ADJUST)
15-
e4:SetRange(LOCATION_SZONE)
16-
e4:SetOperation(s.desop)
17-
c:RegisterEffect(e4)
6+
--The equipped monster gains 300 ATK
7+
local e1=Effect.CreateEffect(c)
8+
e1:SetType(EFFECT_TYPE_EQUIP)
9+
e1:SetCode(EFFECT_UPDATE_ATTACK)
10+
e1:SetValue(300)
11+
c:RegisterEffect(e1)
12+
--Destroy all Tokens on the field, and if you do, the equipped monster gains ATK equal to their ATK
13+
local e2=Effect.CreateEffect(c)
14+
e2:SetCategory(CATEGORY_DESTROY)
15+
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
16+
e2:SetCode(EVENT_ADJUST)
17+
e2:SetRange(LOCATION_SZONE)
18+
e2:SetOperation(s.desop)
19+
c:RegisterEffect(e2)
1820
end
19-
function s.filter(c,e)
20-
return c:IsType(TYPE_TOKEN) and c:IsDestructable(e)
21+
function s.desfilter(c,e,tp)
22+
if not c:IsType(TYPE_TOKEN) then return false end
23+
if c:IsDestructable(e) then return true end
24+
local indes_eff=c:IsHasEffect(EFFECT_INDESTRUCTABLE_EFFECT)
25+
return c:IsHasEffect(EFFECT_INDESTRUCTABLE_COUNT) and not (indes_eff
26+
and (type(indes_eff:GetValue())~='function' or indes_eff:GetValue()(indes_eff,e,tp,c)))
2127
end
2228
function s.desop(e,tp,eg,ep,ev,re,r,rp)
23-
local g=Duel.GetMatchingGroup(s.filter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,e)
24-
local atk=g:GetSum(Card.GetAttack)
25-
Duel.Destroy(g,REASON_EFFECT)
26-
if e:GetHandler():GetEquipTarget() and atk>0 then
27-
local e1=Effect.CreateEffect(e:GetHandler())
29+
local c=e:GetHandler()
30+
local ec=c:GetEquipTarget()
31+
if not ec then return end
32+
local g=Duel.GetMatchingGroup(s.desfilter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,e,tp)
33+
if #g>0 and Duel.Destroy(g,REASON_EFFECT)>0 then
34+
local atk=Duel.GetOperatedGroup():GetSum(Card.GetPreviousAttackOnField)
35+
if atk==0 then return end
36+
--The equipped monster gains ATK equal to the total ATK of the destroyed Tokens
37+
local e1=Effect.CreateEffect(c)
2838
e1:SetType(EFFECT_TYPE_SINGLE)
39+
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
2940
e1:SetCode(EFFECT_UPDATE_ATTACK)
30-
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
3141
e1:SetValue(atk)
32-
e:GetHandler():GetEquipTarget():RegisterEffect(e1)
42+
e1:SetReset(RESET_EVENT|RESETS_STANDARD)
43+
ec:RegisterEffect(e1)
3344
end
3445
end

0 commit comments

Comments
 (0)