From 2513a689973f56bf735adc169fb40434d57f2446 Mon Sep 17 00:00:00 2001 From: mercury233 Date: Sat, 18 May 2024 10:35:12 +0800 Subject: [PATCH] add Auxiliary.AddPlaceToPZoneIfDestroyEffect part 1 --- c13331639.lua | 23 +---------------------- c18897163.lua | 23 +---------------------- c22070401.lua | 23 +---------------------- c22211622.lua | 23 +---------------------- c24070330.lua | 23 +---------------------- c24087580.lua | 26 ++------------------------ c26435595.lua | 23 +---------------------- c30095833.lua | 23 +---------------------- c37491810.lua | 23 +---------------------- c6218704.lua | 23 +---------------------- utility.lua | 34 ++++++++++++++++++++++++++++++++++ 11 files changed, 45 insertions(+), 222 deletions(-) diff --git a/c13331639.lua b/c13331639.lua index fd4cea49a3..9f78df1252 100644 --- a/c13331639.lua +++ b/c13331639.lua @@ -63,15 +63,7 @@ function c13331639.initial_effect(c) e7:SetOperation(c13331639.spop) c:RegisterEffect(e7) --pendulum - local e8=Effect.CreateEffect(c) - e8:SetDescription(aux.Stringid(13331639,3)) - e8:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) - e8:SetCode(EVENT_DESTROYED) - e8:SetProperty(EFFECT_FLAG_DELAY) - e8:SetCondition(c13331639.pencon) - e8:SetTarget(c13331639.pentg) - e8:SetOperation(c13331639.penop) - c:RegisterEffect(e8) + aux.AddPlaceToPZoneIfDestroyEffect(c) end c13331639.material_type=TYPE_SYNCHRO function c13331639.fusfilter1(c) @@ -135,16 +127,3 @@ function c13331639.spop(e,tp,eg,ep,ev,re,r,rp) Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end -function c13331639.pencon(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - return c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() -end -function c13331639.pentg(e,tp,eg,ep,ev,re,r,rp,chk) - if chk==0 then return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) end -end -function c13331639.penop(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - if c:IsRelateToEffect(e) then - Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) - end -end diff --git a/c18897163.lua b/c18897163.lua index 36bc36b320..8715eea4a0 100644 --- a/c18897163.lua +++ b/c18897163.lua @@ -45,15 +45,7 @@ function c18897163.initial_effect(c) e4:SetOperation(c18897163.desop) c:RegisterEffect(e4) --pendulum - local e6=Effect.CreateEffect(c) - e6:SetDescription(aux.Stringid(18897163,3)) - e6:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) - e6:SetCode(EVENT_DESTROYED) - e6:SetProperty(EFFECT_FLAG_DELAY) - e6:SetCondition(c18897163.pencon) - e6:SetTarget(c18897163.pentg) - e6:SetOperation(c18897163.penop) - c:RegisterEffect(e6) + aux.AddPlaceToPZoneIfDestroyEffect(c) end function c18897163.spcon(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(Card.IsSetCard,tp,LOCATION_PZONE,0,1,e:GetHandler(),0xaf) @@ -113,16 +105,3 @@ function c18897163.desop(e,tp,eg,ep,ev,re,r,rp) Duel.Destroy(g,REASON_EFFECT) end end -function c18897163.pencon(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - return c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() -end -function c18897163.pentg(e,tp,eg,ep,ev,re,r,rp,chk) - if chk==0 then return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) end -end -function c18897163.penop(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - if c:IsRelateToEffect(e) then - Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) - end -end diff --git a/c22070401.lua b/c22070401.lua index 6704020115..fc3d9c9fb4 100644 --- a/c22070401.lua +++ b/c22070401.lua @@ -43,15 +43,7 @@ function c22070401.initial_effect(c) e5:SetOperation(c22070401.operation) c:RegisterEffect(e5) --pendulum - local e6=Effect.CreateEffect(c) - e6:SetDescription(aux.Stringid(22070401,2)) - e6:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) - e6:SetCode(EVENT_DESTROYED) - e6:SetProperty(EFFECT_FLAG_DELAY) - e6:SetCondition(c22070401.pencon) - e6:SetTarget(c22070401.pentg) - e6:SetOperation(c22070401.penop) - c:RegisterEffect(e6) + aux.AddPlaceToPZoneIfDestroyEffect(c) end function c22070401.ffilter(c) return c:IsFusionAttribute(ATTRIBUTE_DARK) and c:IsFusionType(TYPE_PENDULUM) @@ -110,16 +102,3 @@ function c22070401.operation(e,tp,eg,ep,ev,re,r,rp) tc=g:GetNext() end end -function c22070401.pencon(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - return bit.band(r,REASON_EFFECT+REASON_BATTLE)~=0 and c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() -end -function c22070401.pentg(e,tp,eg,ep,ev,re,r,rp,chk) - if chk==0 then return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) end -end -function c22070401.penop(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - if c:IsRelateToEffect(e) then - Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) - end -end diff --git a/c22211622.lua b/c22211622.lua index 0a317d2bd2..038a7b8dc1 100644 --- a/c22211622.lua +++ b/c22211622.lua @@ -36,15 +36,7 @@ function c22211622.initial_effect(c) e3:SetOperation(c22211622.spop) c:RegisterEffect(e3) --pendulum - local e4=Effect.CreateEffect(c) - e4:SetDescription(aux.Stringid(22211622,2)) - e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) - e4:SetCode(EVENT_DESTROYED) - e4:SetProperty(EFFECT_FLAG_DELAY) - e4:SetCondition(c22211622.pencon) - e4:SetTarget(c22211622.pentg) - e4:SetOperation(c22211622.penop) - c:RegisterEffect(e4) + aux.AddPlaceToPZoneIfDestroyEffect(c) end function c22211622.splimcon(e) return Duel.GetFieldGroupCount(e:GetHandlerPlayer(),LOCATION_MZONE,0)>0 @@ -133,16 +125,3 @@ function c22211622.spop(e,tp,eg,ep,ev,re,r,rp) Duel.SpecialSummonComplete() end end -function c22211622.pencon(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - return c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() -end -function c22211622.pentg(e,tp,eg,ep,ev,re,r,rp,chk) - if chk==0 then return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) end -end -function c22211622.penop(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - if c:IsRelateToEffect(e) then - Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) - end -end diff --git a/c24070330.lua b/c24070330.lua index dbe2f85a41..0035e04e57 100644 --- a/c24070330.lua +++ b/c24070330.lua @@ -52,15 +52,7 @@ function c24070330.initial_effect(c) e4:SetOperation(c24070330.desop) c:RegisterEffect(e4) --pendulum - local e5=Effect.CreateEffect(c) - e5:SetDescription(aux.Stringid(24070330,4)) - e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) - e5:SetCode(EVENT_DESTROYED) - e5:SetProperty(EFFECT_FLAG_DELAY) - e5:SetCondition(c24070330.pencon) - e5:SetTarget(c24070330.pentg) - e5:SetOperation(c24070330.penop) - c:RegisterEffect(e5) + aux.AddPlaceToPZoneIfDestroyEffect(c) end function c24070330.thfilter(c) return c:IsFaceup() and c:IsType(TYPE_PENDULUM) and c:IsAbleToHand() @@ -109,16 +101,3 @@ function c24070330.desop(e,tp,eg,ep,ev,re,r,rp) Duel.Destroy(g,REASON_EFFECT) end end -function c24070330.pencon(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - return c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() -end -function c24070330.pentg(e,tp,eg,ep,ev,re,r,rp,chk) - if chk==0 then return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) end -end -function c24070330.penop(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - if c:IsRelateToEffect(e) then - Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) - end -end diff --git a/c24087580.lua b/c24087580.lua index e3275f9897..5c907d6ec9 100644 --- a/c24087580.lua +++ b/c24087580.lua @@ -24,16 +24,8 @@ function c24087580.initial_effect(c) e2:SetOperation(c24087580.thop) c:RegisterEffect(e2) --pendulum - local e3=Effect.CreateEffect(c) - e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) - e3:SetCode(EVENT_DESTROYED) - e3:SetProperty(EFFECT_FLAG_DELAY) - e3:SetCountLimit(1,24087581) - e3:SetCondition(c24087580.pencon) - e3:SetTarget(c24087580.pentg) - e3:SetOperation(c24087580.penop) - c:RegisterEffect(e3) - --pendulem + aux.AddPlaceToPZoneIfDestroyEffect(c) + --pendulum local e4=Effect.CreateEffect(c) e4:SetCategory(CATEGORY_LEAVE_GRAVE) e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) @@ -69,20 +61,6 @@ function c24087580.thop(e,tp,eg,ep,ev,re,r,rp) Duel.SendtoHand(tc,nil,REASON_EFFECT) end end -function c24087580.pencon(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - return c:IsReason(REASON_BATTLE+REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() -end -function c24087580.pentg(e,tp,eg,ep,ev,re,r,rp,chk) - if chk==0 then return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) end -end -function c24087580.penop(e,tp,eg,ep,ev,re,r,rp) - if not Duel.CheckLocation(tp,LOCATION_PZONE,0) and not Duel.CheckLocation(tp,LOCATION_PZONE,1) then return end - local c=e:GetHandler() - if c:IsRelateToEffect(e) then - Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) - end -end function c24087580.penfilter(c,tp) return c:IsSetCard(0x4) and c:IsControler(tp) end diff --git a/c26435595.lua b/c26435595.lua index 9f6e324451..fcd8c18222 100644 --- a/c26435595.lua +++ b/c26435595.lua @@ -13,15 +13,7 @@ function c26435595.initial_effect(c) e1:SetOperation(c26435595.pcop) c:RegisterEffect(e1) --pendulum - local e2=Effect.CreateEffect(c) - e2:SetDescription(aux.Stringid(26435595,1)) - e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) - e2:SetCode(EVENT_DESTROYED) - e2:SetProperty(EFFECT_FLAG_DELAY) - e2:SetCondition(c26435595.pencon) - e2:SetTarget(c26435595.pentg) - e2:SetOperation(c26435595.penop) - c:RegisterEffect(e2) + aux.AddPlaceToPZoneIfDestroyEffect(c) end function c26435595.pcfilter(c,tp) return c:IsFaceup() and c:IsType(TYPE_PENDULUM) and not c:IsForbidden() and c:CheckUniqueOnField(tp,LOCATION_SZONE) @@ -38,16 +30,3 @@ function c26435595.pcop(e,tp,eg,ep,ev,re,r,rp) Duel.MoveToField(g:GetFirst(),tp,tp,LOCATION_PZONE,POS_FACEUP,true) end end -function c26435595.pencon(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - return c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() -end -function c26435595.pentg(e,tp,eg,ep,ev,re,r,rp,chk) - if chk==0 then return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) end -end -function c26435595.penop(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - if c:IsRelateToEffect(e) then - Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) - end -end diff --git a/c30095833.lua b/c30095833.lua index d7a8210571..4fb4506133 100644 --- a/c30095833.lua +++ b/c30095833.lua @@ -35,15 +35,7 @@ function c30095833.initial_effect(c) e2:SetOperation(c30095833.desop) c:RegisterEffect(e2) --pendulum move - local e3=Effect.CreateEffect(c) - e3:SetDescription(aux.Stringid(30095833,1)) - e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) - e3:SetCode(EVENT_DESTROYED) - e3:SetProperty(EFFECT_FLAG_DELAY) - e3:SetCondition(c30095833.pencon) - e3:SetTarget(c30095833.pentg) - e3:SetOperation(c30095833.penop) - c:RegisterEffect(e3) + aux.AddPlaceToPZoneIfDestroyEffect(c) end c30095833.pendulum_level=7 function c30095833.xyzcon(e) @@ -90,16 +82,3 @@ function c30095833.desop(e,tp,eg,ep,ev,re,r,rp) Duel.Destroy(tg,REASON_EFFECT) end end -function c30095833.pencon(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - return c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() -end -function c30095833.pentg(e,tp,eg,ep,ev,re,r,rp,chk) - if chk==0 then return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) end -end -function c30095833.penop(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - if c:IsRelateToEffect(e) then - Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) - end -end \ No newline at end of file diff --git a/c37491810.lua b/c37491810.lua index 3dd0e50b28..bbd4bd29f4 100644 --- a/c37491810.lua +++ b/c37491810.lua @@ -29,15 +29,7 @@ function c37491810.initial_effect(c) e2:SetOperation(c37491810.desmop) c:RegisterEffect(e2) --pendulum - local e5=Effect.CreateEffect(c) - e5:SetDescription(aux.Stringid(98452268,2)) - e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) - e5:SetCode(EVENT_DESTROYED) - e5:SetProperty(EFFECT_FLAG_DELAY) - e5:SetCondition(c37491810.pencon) - e5:SetTarget(c37491810.pentg) - e5:SetOperation(c37491810.penop) - c:RegisterEffect(e5) + aux.AddPlaceToPZoneIfDestroyEffect(c) end function c37491810.filter(c,tp) return c:IsReason(REASON_EFFECT) and c:IsPreviousSetCard(0xe1) @@ -82,16 +74,3 @@ function c37491810.desmop(e,tp,eg,ep,ev,re,r,rp) Duel.Destroy(tc,REASON_EFFECT) end end -function c37491810.pencon(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - return c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() -end -function c37491810.pentg(e,tp,eg,ep,ev,re,r,rp,chk) - if chk==0 then return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) end -end -function c37491810.penop(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - if c:IsRelateToEffect(e) then - Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) - end -end diff --git a/c6218704.lua b/c6218704.lua index 7126d3e2ab..e047c5825f 100644 --- a/c6218704.lua +++ b/c6218704.lua @@ -45,15 +45,7 @@ function c6218704.initial_effect(c) e4:SetOperation(c6218704.setop) c:RegisterEffect(e4) --pendulum - local e5=Effect.CreateEffect(c) - e5:SetDescription(aux.Stringid(6218704,4)) - e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) - e5:SetCode(EVENT_DESTROYED) - e5:SetProperty(EFFECT_FLAG_DELAY) - e5:SetCondition(c6218704.pencon) - e5:SetTarget(c6218704.pentg) - e5:SetOperation(c6218704.penop) - c:RegisterEffect(e5) + aux.AddPlaceToPZoneIfDestroyEffect(c) end c6218704.material_type=TYPE_SYNCHRO function c6218704.fusfilter1(c) @@ -139,16 +131,3 @@ function c6218704.setop(e,tp,eg,ep,ev,re,r,rp) tc:SetStatus(STATUS_EFFECT_ENABLED,true) end end -function c6218704.pencon(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - return c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() -end -function c6218704.pentg(e,tp,eg,ep,ev,re,r,rp,chk) - if chk==0 then return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) end -end -function c6218704.penop(e,tp,eg,ep,ev,re,r,rp) - local c=e:GetHandler() - if c:IsRelateToEffect(e) then - Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) - end -end diff --git a/utility.lua b/utility.lua index a8d02ada90..51e4a9adba 100644 --- a/utility.lua +++ b/utility.lua @@ -1598,3 +1598,37 @@ end function Auxiliary.BanishRedirectCondition(e) return e:GetHandler():IsFaceup() end +---If this card in the Monster Zone is destroyed by battle or card effect: You can place this card in your Pendulum Zone. +function Auxiliary.AddPlaceToPZoneIfDestroyEffect(c) + local e1=Effect.CreateEffect(c) + e1:SetDescription(1170) + e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) + e1:SetCode(EVENT_DESTROYED) + e1:SetProperty(EFFECT_FLAG_DELAY) + e1:SetCondition(Auxiliary.PlaceToPZoneCondition) + e1:SetTarget(Auxiliary.PlaceToPZoneTarget) + e1:SetOperation(Auxiliary.PlaceToPZoneOperation) + c:RegisterEffect(e1) + return e1 +end +---Check whether the player has a Pendulum Zone available +function Auxiliary.CheckPendulumLocation(tp) + return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1) +end +function Auxiliary.PlaceToPZoneCondition(e,tp,eg,ep,ev,re,r,rp) + local c=e:GetHandler() + return c:IsPreviousLocation(LOCATION_MZONE) and c:IsFaceup() and c:IsReason(REASON_BATTLE+REASON_EFFECT) +end +function Auxiliary.PlaceToPZoneTarget(e,tp,eg,ep,ev,re,r,rp,chk) + if chk==0 then return Auxiliary.CheckPendulumLocation(tp) end + local c=e:GetHandler() + if c:IsLocation(LOCATION_GRAVE) then + Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,c,1,0,0) + end +end +function Auxiliary.PlaceToPZoneOperation(e,tp,eg,ep,ev,re,r,rp) + local c=e:GetHandler() + if c:IsRelateToEffect(e) then + Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) + end +end