From cf58dba26e5d52e46034e49d10f0dfd0f63386b7 Mon Sep 17 00:00:00 2001 From: When <104731682+idk-what-to-name-here@users.noreply.github.com> Date: Tue, 25 Jul 2023 14:58:33 -0700 Subject: [PATCH 1/3] Add files via upload --- unofficial/c511027621.lua | 56 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 unofficial/c511027621.lua diff --git a/unofficial/c511027621.lua b/unofficial/c511027621.lua new file mode 100644 index 0000000000..5459aea6e6 --- /dev/null +++ b/unofficial/c511027621.lua @@ -0,0 +1,56 @@ +--逆襲! +--Counterattack! +--Made by When +local s,id=GetID() +function s.initial_effect(c) + --Force a Battle + local e1=Effect.CreateEffect(c) + e1:SetType(EFFECT_TYPE_ACTIVATE) + e1:SetCode(EVENT_FREE_CHAIN) + e1:SetCondition(s.condition) + e1:SetTarget(s.target) + e1:SetOperation(s.activate) + c:RegisterEffect(e1) + aux.GlobalCheck(s,function() + s[0]=true + s[1]=true + local ge1=Effect.CreateEffect(c) + ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) + ge1:SetCode(EVENT_DAMAGE_STEP_END) + ge1:SetOperation(s.checkop) + Duel.RegisterEffect(ge1,0) + local ge2=Effect.CreateEffect(c) + ge2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) + ge2:SetCode(EVENT_ADJUST) + ge2:SetCountLimit(1) + ge2:SetOperation(s.clear) + Duel.RegisterEffect(ge2,0) + end) +end +function s.checkop(e,tp,eg,ep,ev,re,r,rp) + local at=Duel.GetAttackTarget() + if at and at:IsRelateToBattle() then + s[at:GetControler()]=true + end +end +function s.clear(e,tp,eg,ep,ev,re,r,rp) + s[0]=false + s[1]=false +end +function s.condition(e,tp,eg,ep,ev,re,r,rp) + local ph=Duel.GetCurrentPhase() + return ph>=0x08 and ph<=0x20 and Duel.GetTurnPlayer()~=tp and s[tp] +end +function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) + if chk==0 then return Duel.IsExistingMatchingCard(Card.IsMonster,tp,0,LOCATION_MZONE,1,nil) and Duel.IsExistingMatchingCard(Card.IsMonster,tp,LOCATION_MZONE,0,1,nil) end +end +function s.activate(e,tp,eg,ep,ev,re,r,rp) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) + local g1=Duel.SelectMatchingCard(tp,Card.IsMonster,tp,0,LOCATION_MZONE,1,1,nil) + local g2=Duel.SelectMatchingCard(tp,Card.IsMonster,tp,LOCATION_MZONE,0,1,1,nil) + local tc1=g1:GetFirst() + local tc2=g2:GetFirst() + if tc1:IsPosition(POS_FACEUP_ATTACK) or tc2:IsPosition(POS_FACEUP_ATTACK) and tc1 and tc2 then + Duel.CalculateDamage(tc1,tc2) + end +end \ No newline at end of file From f760e7bb4102973a229971afd4530904b416781d Mon Sep 17 00:00:00 2001 From: When <104731682+idk-what-to-name-here@users.noreply.github.com> Date: Wed, 26 Jul 2023 03:06:01 -0700 Subject: [PATCH 2/3] Update c511027621.lua --- unofficial/c511027621.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/unofficial/c511027621.lua b/unofficial/c511027621.lua index 5459aea6e6..c9f2e7d270 100644 --- a/unofficial/c511027621.lua +++ b/unofficial/c511027621.lua @@ -16,7 +16,7 @@ function s.initial_effect(c) s[1]=true local ge1=Effect.CreateEffect(c) ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) - ge1:SetCode(EVENT_DAMAGE_STEP_END) + ge1:SetCode(EVENT_BATTLED) ge1:SetOperation(s.checkop) Duel.RegisterEffect(ge1,0) local ge2=Effect.CreateEffect(c) @@ -38,11 +38,10 @@ function s.clear(e,tp,eg,ep,ev,re,r,rp) s[1]=false end function s.condition(e,tp,eg,ep,ev,re,r,rp) - local ph=Duel.GetCurrentPhase() - return ph>=0x08 and ph<=0x20 and Duel.GetTurnPlayer()~=tp and s[tp] + return tp~=Duel.GetTurnPlayer() and Duel.GetCurrentPhase()>=PHASE_BATTLE_START and Duel.GetCurrentPhase()<=PHASE_BATTLE and s[tp] end function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) - if chk==0 then return Duel.IsExistingMatchingCard(Card.IsMonster,tp,0,LOCATION_MZONE,1,nil) and Duel.IsExistingMatchingCard(Card.IsMonster,tp,LOCATION_MZONE,0,1,nil) end + if chk==0 then return Duel.IsExistingMatchingCard(Card.IsMonster,tp,0,LOCATION_MZONE,1,nil) and Duel.IsExistingMatchingCard(Card.IsMonster,tp,LOCATION_MZONE,0,1,nil) and Duel.IsExistingMatchingCard(Card.IsPosition,tp,LOCATION_MZONE,0,1,nil,POS_FACEUP_ATTACK) or Duel.IsExistingMatchingCard(Card.IsPosition,tp,0,LOCATION_MZONE,1,nil,POS_FACEUP_ATTACK) end end function s.activate(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) @@ -53,4 +52,4 @@ function s.activate(e,tp,eg,ep,ev,re,r,rp) if tc1:IsPosition(POS_FACEUP_ATTACK) or tc2:IsPosition(POS_FACEUP_ATTACK) and tc1 and tc2 then Duel.CalculateDamage(tc1,tc2) end -end \ No newline at end of file +end From aa9220ba3bd73f09755961f3abcfcfbaa8292446 Mon Sep 17 00:00:00 2001 From: When <104731682+idk-what-to-name-here@users.noreply.github.com> Date: Wed, 26 Jul 2023 04:27:05 -0700 Subject: [PATCH 3/3] Update c511027621.lua --- unofficial/c511027621.lua | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/unofficial/c511027621.lua b/unofficial/c511027621.lua index c9f2e7d270..7bf651f5d4 100644 --- a/unofficial/c511027621.lua +++ b/unofficial/c511027621.lua @@ -44,12 +44,22 @@ function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsMonster,tp,0,LOCATION_MZONE,1,nil) and Duel.IsExistingMatchingCard(Card.IsMonster,tp,LOCATION_MZONE,0,1,nil) and Duel.IsExistingMatchingCard(Card.IsPosition,tp,LOCATION_MZONE,0,1,nil,POS_FACEUP_ATTACK) or Duel.IsExistingMatchingCard(Card.IsPosition,tp,0,LOCATION_MZONE,1,nil,POS_FACEUP_ATTACK) end end function s.activate(e,tp,eg,ep,ev,re,r,rp) + local g2=Duel.SelectMatchingCard(tp,Card.IsMonster,tp,LOCATION_MZONE,0,1,1,nil):GetFirst() + local g1=Duel.SelectMatchingCard(tp,Card.IsMonster,tp,0,LOCATION_MZONE,1,1,nil):GetFirst() + if g1:IsPosition(POS_FACEUP_DEFENSE) or g1:IsPosition(POS_FACEDOWN_DEFENSE) then + g2=Duel.SelectMatchingCard(tp,Card.IsPosition,tp,LOCATION_MZONE,0,1,1,nil,POS_FACEUP_ATTACK):GetFirst() + elseif g2:IsPosition(POS_FACEUP_DEFENSE) or g2:IsPosition(POS_FACEDOWN_DEFENSE) then + g1=Duel.SelectMatchingCard(tp,Card.IsPosition,tp,0,LOCATION_MZONE,1,1,nil,POS_FACEUP_ATTACK):GetFirst() + else + g2=Duel.SelectMatchingCard(tp,Card.IsMonster,tp,LOCATION_MZONE,0,1,1,nil):GetFirst() + g1=Duel.SelectMatchingCard(tp,Card.IsMonster,tp,0,LOCATION_MZONE,1,1,nil):GetFirst() + end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) - local g1=Duel.SelectMatchingCard(tp,Card.IsMonster,tp,0,LOCATION_MZONE,1,1,nil) - local g2=Duel.SelectMatchingCard(tp,Card.IsMonster,tp,LOCATION_MZONE,0,1,1,nil) - local tc1=g1:GetFirst() - local tc2=g2:GetFirst() - if tc1:IsPosition(POS_FACEUP_ATTACK) or tc2:IsPosition(POS_FACEUP_ATTACK) and tc1 and tc2 then - Duel.CalculateDamage(tc1,tc2) + if g1:IsPosition(POS_FACEUP_DEFENSE) or g1:IsPosition(POS_FACEDOWN_DEFENSE) and g2:IsPosition(POS_FACEUP_ATTACK) and g1 and g2 then + Duel.CalculateDamage(g2,g1) + elseif g2:IsPosition(POS_FACEUP_DEFENSE) or g2:IsPosition(POS_FACEDOWN_DEFENSE) and g1:IsPosition(POS_FACEUP_ATTACK) and g1 and g2 then + Duel.CalculateDamage(g1,g2) + else + Duel.CalculateDamage(g2,g1) end end