Skip to content

Commit e833e2a

Browse files
authored
Machina Citadel
- Use "Card.AddMustBeSpecialSummonedByCardEffect" - Should check for the destroyed card's name on the field rather than after it's destroyed
1 parent bec1c7d commit e833e2a

1 file changed

Lines changed: 42 additions & 55 deletions

File tree

official/c87074380.lua

Lines changed: 42 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,85 +4,72 @@
44
local s,id=GetID()
55
function s.initial_effect(c)
66
c:EnableUnsummonable()
7-
--splimit
7+
c:AddMustBeSpecialSummonedByCardEffect()
8+
--Destroy 1 Machine monster you control and all monsters your opponent controls with ATK less than or equal to it
89
local e1=Effect.CreateEffect(c)
9-
e1:SetType(EFFECT_TYPE_SINGLE)
10-
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
11-
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
12-
e1:SetValue(s.splimit)
10+
e1:SetDescription(aux.Stringid(id,0))
11+
e1:SetCategory(CATEGORY_DESTROY)
12+
e1:SetType(EFFECT_TYPE_QUICK_O)
13+
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
14+
e1:SetCode(EVENT_FREE_CHAIN)
15+
e1:SetRange(LOCATION_MZONE)
16+
e1:SetCountLimit(1,id)
17+
e1:SetHintTiming(0,TIMING_STANDBY_PHASE|TIMING_MAIN_END|TIMINGS_CHECK_MONSTER_E)
18+
e1:SetTarget(s.destg)
19+
e1:SetOperation(s.desop)
1320
c:RegisterEffect(e1)
14-
--Destroy 1 Machine monster you control and all monsters your opponent controls with ATK less than or equal to it
21+
--Special Summon this card
1522
local e2=Effect.CreateEffect(c)
16-
e2:SetDescription(aux.Stringid(id,0))
17-
e2:SetCategory(CATEGORY_DESTROY)
18-
e2:SetHintTiming(TIMINGS_CHECK_MONSTER|TIMING_BATTLE_START)
19-
e2:SetType(EFFECT_TYPE_QUICK_O)
20-
e2:SetCode(EVENT_FREE_CHAIN)
21-
e2:SetRange(LOCATION_MZONE)
22-
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
23-
e2:SetCountLimit(1,id)
24-
e2:SetTarget(s.destg)
25-
e2:SetOperation(s.desop)
23+
e2:SetDescription(aux.Stringid(id,1))
24+
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
25+
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
26+
e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP,EFFECT_FLAG2_CHECK_SIMULTANEOUS)
27+
e2:SetCode(EVENT_DESTROYED)
28+
e2:SetRange(LOCATION_GRAVE)
29+
e2:SetCountLimit(1,{id,1})
30+
e2:SetCondition(s.spcon)
31+
e2:SetTarget(s.sptg)
32+
e2:SetOperation(s.spop)
2633
c:RegisterEffect(e2)
27-
--Special Summon this card from your GY
28-
local e3=Effect.CreateEffect(c)
29-
e3:SetDescription(aux.Stringid(id,1))
30-
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
31-
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
32-
e3:SetCode(EVENT_DESTROYED)
33-
e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
34-
e3:SetRange(LOCATION_GRAVE)
35-
e3:SetCountLimit(1,{id,1})
36-
e3:SetCondition(s.spcon)
37-
e3:SetTarget(s.sptg)
38-
e3:SetOperation(s.spop)
39-
c:RegisterEffect(e3)
4034
end
4135
s.listed_names={id}
42-
function s.splimit(e,se,sp,st)
43-
return se:IsHasType(EFFECT_TYPE_ACTIONS)
44-
end
45-
function s.tgfilter(c,tp)
46-
return c:IsFaceup() and c:IsRace(RACE_MACHINE)
47-
and Duel.IsExistingMatchingCard(aux.FaceupFilter(Card.IsAttackBelow,c:GetAttack()),tp,0,LOCATION_MZONE,1,nil)
36+
function s.desfilter(c,tp)
37+
return c:IsRace(RACE_MACHINE) and c:IsFaceup() and Duel.IsExistingMatchingCard(aux.FaceupFilter(Card.IsAttackBelow,c:GetAttack()),tp,0,LOCATION_MZONE,1,nil)
4838
end
4939
function s.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
50-
local c=e:GetHandler()
51-
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.tgfilter(chkc,tp) end
52-
if chk==0 then return Duel.IsExistingTarget(s.tgfilter,tp,LOCATION_MZONE,0,1,nil,tp) end
40+
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.desfilter(chkc,tp) end
41+
if chk==0 then return Duel.IsExistingTarget(s.desfilter,tp,LOCATION_MZONE,0,1,nil,tp) end
5342
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
54-
local tc=Duel.SelectTarget(tp,s.tgfilter,tp,LOCATION_MZONE,0,1,1,nil,tp):GetFirst()
55-
local dg=Duel.GetMatchingGroup(aux.FaceupFilter(Card.IsAttackBelow,tc:GetAttack()),tp,0,LOCATION_MZONE,nil)
56-
dg:AddCard(tc)
57-
Duel.SetOperationInfo(0,CATEGORY_DESTROY,dg,#dg,PLAYER_ALL,0)
43+
local tc=Duel.SelectTarget(tp,s.desfilter,tp,LOCATION_MZONE,0,1,1,nil,tp):GetFirst()
44+
local dg=tc+Duel.GetMatchingGroup(aux.FaceupFilter(Card.IsAttackBelow,tc:GetAttack()),tp,0,LOCATION_MZONE,nil)
45+
Duel.SetOperationInfo(0,CATEGORY_DESTROY,dg,#dg,tp,0)
5846
end
5947
function s.desop(e,tp,eg,ep,ev,re,r,rp)
6048
local tc=Duel.GetFirstTarget()
61-
if not tc:IsRelateToEffect(e) or not s.tgfilter(tc,tp) then return end
62-
local g=Duel.GetMatchingGroup(aux.FaceupFilter(Card.IsAttackBelow,tc:GetAttack()),tp,0,LOCATION_MZONE,nil)
63-
if #g>0 then
64-
g:AddCard(tc)
65-
Duel.Destroy(g,REASON_EFFECT)
49+
if tc:IsRelateToEffect(e) and tc:IsRace(RACE_MACHINE) and tc:IsFaceup() then
50+
local g=Duel.GetMatchingGroup(aux.FaceupFilter(Card.IsAttackBelow,tc:GetAttack()),tp,0,LOCATION_MZONE,nil)
51+
if #g>0 then
52+
Duel.Destroy(g+tc,REASON_EFFECT)
53+
end
6654
end
6755
end
68-
function s.spcfilter(c,tp)
69-
return c:IsReason(REASON_BATTLE|REASON_EFFECT)
70-
and c:IsPreviousControler(tp) and c:IsPreviousLocation(LOCATION_MZONE)
71-
and c:IsPreviousPosition(POS_FACEUP) and (c:GetPreviousAttributeOnField()&ATTRIBUTE_EARTH)==ATTRIBUTE_EARTH
72-
and (c:GetPreviousRaceOnField()&RACE_MACHINE)==RACE_MACHINE and not c:IsCode(id)
56+
function s.spconfilter(c,tp)
57+
return c:IsPreviousAttributeOnField(ATTRIBUTE_EARTH) and c:IsPreviousRaceOnField(RACE_MACHINE) and c:IsPreviousPosition(POS_FACEUP)
58+
and c:IsPreviousControler(tp) and c:IsPreviousLocation(LOCATION_MZONE) and not c:IsPreviousCodeOnField(id)
59+
and c:IsReason(REASON_BATTLE|REASON_EFFECT)
7360
end
7461
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
75-
return eg:IsExists(s.spcfilter,1,e:GetHandler(),tp) and not eg:IsContains(e:GetHandler())
62+
return not eg:IsContains(e:GetHandler()) and eg:IsExists(s.spconfilter,1,nil,tp)
7663
end
7764
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
7865
local c=e:GetHandler()
7966
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
8067
and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end
81-
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,LOCATION_GRAVE)
68+
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,tp,0)
8269
end
8370
function s.spop(e,tp,eg,ep,ev,re,r,rp)
8471
local c=e:GetHandler()
8572
if c:IsRelateToEffect(e) then
8673
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
8774
end
88-
end
75+
end

0 commit comments

Comments
 (0)