Skip to content

Commit 8b87576

Browse files
authored
fix "Ehther the Heavenly Monarch"
- should not attempt to Special Summon on resolution if there is no available zone - modernized script
1 parent 3b7370c commit 8b87576

File tree

1 file changed

+45
-87
lines changed

1 file changed

+45
-87
lines changed

official/c96570609.lua

Lines changed: 45 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,42 @@
22
--Ehther the Heavenly Monarch
33
local s,id=GetID()
44
function s.initial_effect(c)
5-
--summon with 1 tribute
6-
local e1=aux.AddNormalSummonProcedure(c,true,true,1,1,SUMMON_TYPE_TRIBUTE,aux.Stringid(id,0),s.otfilter)
7-
local e2=aux.AddNormalSetProcedure(c,true,true,1,1,SUMMON_TYPE_TRIBUTE,aux.Stringid(id,0),s.otfilter)
8-
--spsummon
9-
local e3=Effect.CreateEffect(c)
10-
e3:SetDescription(aux.Stringid(id,1))
11-
e3:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOGRAVE)
12-
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
13-
e3:SetCode(EVENT_SUMMON_SUCCESS)
14-
e3:SetProperty(EFFECT_FLAG_DELAY)
15-
e3:SetCondition(s.spcon)
16-
e3:SetTarget(s.sptg)
17-
e3:SetOperation(s.spop)
18-
c:RegisterEffect(e3)
19-
--summon
20-
local e4=Effect.CreateEffect(c)
21-
e4:SetDescription(aux.Stringid(id,2))
22-
e4:SetCategory(CATEGORY_SUMMON)
23-
e4:SetType(EFFECT_TYPE_QUICK_O)
24-
e4:SetRange(LOCATION_HAND)
25-
e4:SetCode(EVENT_FREE_CHAIN)
26-
e4:SetHintTiming(0,TIMINGS_CHECK_MONSTER|TIMING_MAIN_END)
27-
e4:SetCondition(s.sumcon)
28-
e4:SetCost(s.sumcost)
29-
e4:SetTarget(s.sumtg)
30-
e4:SetOperation(s.sumop)
31-
c:RegisterEffect(e4)
5+
--You can Tribute Summon this card by Tributing 1 Tribute Summoned monster
6+
local e1=aux.AddNormalSummonProcedure(c,true,true,1,1,SUMMON_TYPE_TRIBUTE,aux.Stringid(id,0),Card.IsTributeSummoned)
7+
local e2=aux.AddNormalSetProcedure(c,true,true,1,1,SUMMON_TYPE_TRIBUTE,aux.Stringid(id,0),Card.IsTributeSummoned)
8+
--Send 2 "Monarch" Spells/Traps with different names from your hand and/or Deck to the GY, and if you do, Special Summon 1 monster with 2400 or more ATK and 1000 DEF from your Deck
9+
local e1=Effect.CreateEffect(c)
10+
e1:SetDescription(aux.Stringid(id,1))
11+
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOGRAVE)
12+
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
13+
e1:SetProperty(EFFECT_FLAG_DELAY)
14+
e1:SetCode(EVENT_SUMMON_SUCCESS)
15+
e1:SetCondition(function(e) return e:GetHandler():IsTributeSummoned() end)
16+
e1:SetTarget(s.tgtg)
17+
e1:SetOperation(s.tgop)
18+
c:RegisterEffect(e1)
19+
--Tribute Summon this card
20+
local e2=Effect.CreateEffect(c)
21+
e2:SetDescription(aux.Stringid(id,2))
22+
e2:SetCategory(CATEGORY_SUMMON)
23+
e2:SetType(EFFECT_TYPE_QUICK_O)
24+
e2:SetCode(EVENT_FREE_CHAIN)
25+
e2:SetRange(LOCATION_HAND)
26+
e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER|TIMING_MAIN_END)
27+
e2:SetCondition(function(e,tp) return Duel.IsTurnPlayer(1-tp) and Duel.IsMainPhase() end)
28+
e2:SetCost(Cost.AND(Cost.SoftOncePerChain(id),s.sumcost))
29+
e2:SetTarget(s.sumtg)
30+
e2:SetOperation(s.sumop)
31+
c:RegisterEffect(e2)
3232
end
3333
s.listed_series={SET_MONARCH}
34-
function s.otfilter(c)
35-
return c:IsTributeSummoned()
36-
end
37-
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
38-
return e:GetHandler():IsTributeSummoned()
39-
end
4034
function s.tgfilter(c)
4135
return c:IsSetCard(SET_MONARCH) and c:IsSpellTrap() and c:IsAbleToGrave()
4236
end
4337
function s.spfilter(c,e,tp)
44-
return c:IsAttackAbove(2400) and c:GetDefense()==1000 and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
38+
return c:IsAttackAbove(2400) and c:IsDefense(1000) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
4539
end
46-
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
40+
function s.tgtg(e,tp,eg,ep,ev,re,r,rp,chk)
4741
if chk==0 then
4842
local g=Duel.GetMatchingGroup(s.tgfilter,tp,LOCATION_HAND|LOCATION_DECK,0,nil)
4943
return g:GetClassCount(Card.GetCode)>1
@@ -53,72 +47,36 @@ function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
5347
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,2,tp,LOCATION_DECK)
5448
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
5549
end
56-
function s.spop(e,tp,eg,ep,ev,re,r,rp)
50+
function s.tgop(e,tp,eg,ep,ev,re,r,rp)
5751
local g=Duel.GetMatchingGroup(s.tgfilter,tp,LOCATION_HAND|LOCATION_DECK,0,nil)
58-
if g:GetClassCount(Card.GetCode)<2 then return end
5952
local tg=aux.SelectUnselectGroup(g,e,tp,2,2,aux.dncheck,1,tp,HINTMSG_TOGRAVE)
60-
if Duel.SendtoGrave(tg,REASON_EFFECT)~=0 and tg:IsExists(Card.IsLocation,2,nil,LOCATION_GRAVE) then
61-
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
62-
local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
63-
local tc=g:GetFirst()
64-
if tc then
65-
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
66-
local fid=e:GetHandler():GetFieldID()
67-
tc:RegisterFlagEffect(id,RESET_EVENT|RESETS_STANDARD,0,1,fid)
68-
local e1=Effect.CreateEffect(e:GetHandler())
69-
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
70-
e1:SetCode(EVENT_PHASE+PHASE_END)
71-
e1:SetCountLimit(1)
72-
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
73-
e1:SetLabel(fid)
74-
e1:SetLabelObject(tc)
75-
e1:SetCondition(s.thcon)
76-
e1:SetOperation(s.thop)
77-
Duel.RegisterEffect(e1,tp)
78-
end
53+
if #tg~=2 or Duel.SendtoGrave(tg,REASON_EFFECT)==0
54+
or not tg:IsExists(Card.IsLocation,2,nil,LOCATION_GRAVE)
55+
or Duel.GetLocationCount(tp,LOCATION_MZONE)==0 then return end
56+
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
57+
local tc=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp):GetFirst()
58+
if tc and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)>0 then
59+
--Return it to the hand during the End Phase
60+
aux.DelayedOperation(tc,PHASE_END,id,e,tp,function(ag) Duel.SendtoHand(ag,nil,REASON_EFFECT) end,nil,0,0,aux.Stringid(id,3))
7961
end
8062
end
81-
function s.thcon(e,tp,eg,ep,ev,re,r,rp)
82-
local tc=e:GetLabelObject()
83-
if tc:GetFlagEffectLabel(id)~=e:GetLabel() then
84-
e:Reset()
85-
return false
86-
else return true end
87-
end
88-
function s.thop(e,tp,eg,ep,ev,re,r,rp)
89-
Duel.SendtoHand(e:GetLabelObject(),nil,REASON_EFFECT)
90-
end
91-
function s.sumcon(e,tp,eg,ep,ev,re,r,rp)
92-
local ph=Duel.GetCurrentPhase()
93-
return Duel.IsTurnPlayer(1-tp) and (Duel.IsMainPhase())
94-
end
95-
function s.cfilter(c)
63+
function s.sumcostfilter(c)
9664
return c:IsSetCard(SET_MONARCH) and c:IsSpellTrap() and c:IsAbleToRemoveAsCost()
9765
end
9866
function s.sumcost(e,tp,eg,ep,ev,re,r,rp,chk)
99-
local c=e:GetHandler()
100-
if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_GRAVE,0,1,nil)
101-
and c:GetFlagEffect(id)==0 end
67+
if chk==0 then return Duel.IsExistingMatchingCard(s.sumcostfilter,tp,LOCATION_GRAVE,0,1,nil) end
10268
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
103-
local g=Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_GRAVE,0,1,1,nil)
69+
local g=Duel.SelectMatchingCard(tp,s.sumcostfilter,tp,LOCATION_GRAVE,0,1,1,nil)
10470
Duel.Remove(g,POS_FACEUP,REASON_COST)
105-
c:RegisterFlagEffect(id,RESET_CHAIN,0,1)
10671
end
10772
function s.sumtg(e,tp,eg,ep,ev,re,r,rp,chk)
10873
local c=e:GetHandler()
109-
if chk==0 then return c:IsSummonable(true,nil,1) or c:IsMSetable(true,nil,1) end
74+
if chk==0 then return c:CanSummonOrSet(true,nil,1) end
11075
Duel.SetOperationInfo(0,CATEGORY_SUMMON,c,1,0,0)
11176
end
11277
function s.sumop(e,tp,eg,ep,ev,re,r,rp)
11378
local c=e:GetHandler()
114-
if not c:IsRelateToEffect(e) then return end
115-
local pos=0
116-
if c:IsSummonable(true,nil,1) then pos=pos+POS_FACEUP_ATTACK end
117-
if c:IsMSetable(true,nil,1) then pos=pos+POS_FACEDOWN_DEFENSE end
118-
if pos==0 then return end
119-
if Duel.SelectPosition(tp,c,pos)==POS_FACEUP_ATTACK then
120-
Duel.Summon(tp,c,true,nil,1)
121-
else
122-
Duel.MSet(tp,c,true,nil,1)
79+
if c:IsRelateToEffect(e) then
80+
Duel.SummonOrSet(tp,c,true,nil,1)
12381
end
124-
end
82+
end

0 commit comments

Comments
 (0)