Commit d6eb54c1 authored by Nemo Ma's avatar Nemo Ma

maint

parent f064b2fd
...@@ -1534,6 +1534,24 @@ ...@@ -1534,6 +1534,24 @@
31403102 0 31403102 0
31403103 0 31403103 0
31403104 0 31403104 0
#「机骸」系列 - 修女鱼
31200010 0
31200038 0
31200036 0
31200034 0
31200032 0
31200030 0
31200028 0
31200026 0
31200024 0
31200022 0
31200020 0
31200018 0
31200016 0
31200014 0
31200012 0
#230618
53796103 0
#230611 #230611
30005508 0 30005508 0
11451703 1 11451703 1
......
No preview for this file type
...@@ -91,7 +91,7 @@ function cm.sptg(e,tp,eg,ep,ev,re,r,rp,chk) ...@@ -91,7 +91,7 @@ function cm.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler() local c=e:GetHandler()
local tp=c:GetControler() local tp=c:GetControler()
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsPlayerCanSpecialSummonMonster(tp,29010023,nil,0x4011,1500,1500,1,RACE_AQUA,ATTRIBUTE_WATER) and Duel.IsPlayerCanSpecialSummonMonster(tp,29098632,nil,0x4011,1500,1500,1,RACE_AQUA,ATTRIBUTE_WATER)
and not Duel.IsExistingMatchingCard(Card.IsType,tp,LOCATION_MZONE,0,1,nil,TYPE_TOKEN) end and not Duel.IsExistingMatchingCard(Card.IsType,tp,LOCATION_MZONE,0,1,nil,TYPE_TOKEN) end
Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,0) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,0)
...@@ -100,8 +100,8 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp) ...@@ -100,8 +100,8 @@ function cm.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler() local c=e:GetHandler()
local tp=c:GetControler() local tp=c:GetControler()
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
if not Duel.IsPlayerCanSpecialSummonMonster(tp,29010023,nil,0x4011,1500,1500,1,RACE_AQUA,ATTRIBUTE_WATER) then return end if not Duel.IsPlayerCanSpecialSummonMonster(tp,29098632,nil,0x4011,1500,1500,1,RACE_AQUA,ATTRIBUTE_WATER) then return end
local token=Duel.CreateToken(tp,29010023) local token=Duel.CreateToken(tp,29098632)
local fid=e:GetHandler():GetFieldID() local fid=e:GetHandler():GetFieldID()
local g=Group.CreateGroup() local g=Group.CreateGroup()
if Duel.SpecialSummonStep(token,0,tp,tp,false,false,POS_FACEUP) then if Duel.SpecialSummonStep(token,0,tp,tp,false,false,POS_FACEUP) then
...@@ -183,14 +183,14 @@ function cm.efilter(c,sc,seq,tp) ...@@ -183,14 +183,14 @@ function cm.efilter(c,sc,seq,tp)
end end
end end
return b and c:IsCode(29010023) and sc:GetControler()==tp return b and c:IsCode(29098632) and sc:GetControler()==tp
end end
function cm.eftg(e,c) function cm.eftg(e,c)
local seq=c:GetSequence() local seq=c:GetSequence()
return c:IsType(TYPE_EFFECT) and ((seq<5 and math.abs(e:GetHandler():GetSequence()-seq)<=1) or (Duel.IsExistingMatchingCard(cm.efilter,e:GetHandlerPlayer(),LOCATION_ONFIELD,LOCATION_MZONE,1,nil,c,seq,e:GetHandlerPlayer()))) return c:IsType(TYPE_EFFECT) and ((seq<5 and math.abs(e:GetHandler():GetSequence()-seq)<=1) or (Duel.IsExistingMatchingCard(cm.efilter,e:GetHandlerPlayer(),LOCATION_ONFIELD,LOCATION_MZONE,1,nil,c,seq,e:GetHandlerPlayer())))
end end
function cm.repfilter(c,e) function cm.repfilter(c,e)
return c:IsFaceup() and (c:IsCode(29010023) or c:IsCode(15000181)) return c:IsFaceup() and (c:IsCode(29098632) or c:IsCode(15000181))
and c:IsDestructable(e) and not c:IsStatus(STATUS_DESTROY_CONFIRMED) and c:IsDestructable(e) and not c:IsStatus(STATUS_DESTROY_CONFIRMED)
end end
function cm.reptg(e,tp,eg,ep,ev,re,r,rp,chk) function cm.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
...@@ -219,7 +219,7 @@ end ...@@ -219,7 +219,7 @@ end
function cm.cdcon1(e,tp,eg,ep,ev,re,r,rp) function cm.cdcon1(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler() local c=e:GetHandler()
local tp=c:GetControler() local tp=c:GetControler()
return Duel.GetFlagEffect(tp,15000181)==0 and ((c:IsLocation(LOCATION_ONFIELD) and c:IsFaceup() and eg:FilterCount(Card.IsReason,nil,REASON_DESTROY)==eg:GetCount() and not Duel.IsExistingMatchingCard(Card.IsFaceup,tp,LOCATION_ONFIELD,0,1,c)) or (eg:IsContains(c) and c:IsReason(REASON_REPLACE)) or (c:IsLocation(LOCATION_ONFIELD) and c:IsFaceup() and eg:GetFirst():IsReason(REASON_DESTROY) and eg:GetCount()==1 and eg:GetFirst():GetPreviousControler()==1-tp and (Duel.GetAttacker():IsCode(29010023) or (Duel.GetAttackTarget() and Duel.GetAttackTarget():IsCode(29010023))))) return Duel.GetFlagEffect(tp,15000181)==0 and ((c:IsLocation(LOCATION_ONFIELD) and c:IsFaceup() and eg:FilterCount(Card.IsReason,nil,REASON_DESTROY)==eg:GetCount() and not Duel.IsExistingMatchingCard(Card.IsFaceup,tp,LOCATION_ONFIELD,0,1,c)) or (eg:IsContains(c) and c:IsReason(REASON_REPLACE)) or (c:IsLocation(LOCATION_ONFIELD) and c:IsFaceup() and eg:GetFirst():IsReason(REASON_DESTROY) and eg:GetCount()==1 and eg:GetFirst():GetPreviousControler()==1-tp and (Duel.GetAttacker():IsCode(29098632) or (Duel.GetAttackTarget() and Duel.GetAttackTarget():IsCode(29098632)))))
end end
function cm.cdop1(e,tp,eg,ep,ev,re,r,rp) function cm.cdop1(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler() local c=e:GetHandler()
...@@ -229,7 +229,7 @@ function cm.cdop1(e,tp,eg,ep,ev,re,r,rp) ...@@ -229,7 +229,7 @@ function cm.cdop1(e,tp,eg,ep,ev,re,r,rp)
Duel.SelectYesNo(tp,aux.Stringid(m,0)) Duel.SelectYesNo(tp,aux.Stringid(m,0))
elseif eg:IsContains(c) and c:IsReason(REASON_REPLACE) then elseif eg:IsContains(c) and c:IsReason(REASON_REPLACE) then
Duel.SelectYesNo(tp,aux.Stringid(m,1)) Duel.SelectYesNo(tp,aux.Stringid(m,1))
elseif c:IsLocation(LOCATION_ONFIELD) and c:IsFaceup() and eg:GetFirst():IsReason(REASON_DESTROY) and eg:GetCount()==1 and eg:GetFirst():GetPreviousControler()==1-tp and (Duel.GetAttacker():IsCode(29010023) or (Duel.GetAttackTarget() and Duel.GetAttackTarget():IsCode(29010023))) then elseif c:IsLocation(LOCATION_ONFIELD) and c:IsFaceup() and eg:GetFirst():IsReason(REASON_DESTROY) and eg:GetCount()==1 and eg:GetFirst():GetPreviousControler()==1-tp and (Duel.GetAttacker():IsCode(29098632) or (Duel.GetAttackTarget() and Duel.GetAttackTarget():IsCode(29098632))) then
Duel.SelectYesNo(tp,aux.Stringid(m,2)) Duel.SelectYesNo(tp,aux.Stringid(m,2))
end end
Duel.RegisterFlagEffect(tp,15000181,RESET_PHASE+PHASE_END,0,99) Duel.RegisterFlagEffect(tp,15000181,RESET_PHASE+PHASE_END,0,99)
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
local s,id=GetID() local s,id=GetID()
xpcall(function() require("expansions/script/glitchylib_vsnemo") end,function() require("script/glitchylib_vsnemo") end) xpcall(function() require("expansions/script/glitchylib_vsnemo") end,function() require("script/glitchylib_vsnemo") end)
xpcall(function() require("expansions/script/utterconfusionlib") end,function() require("script/utterconfusionlib") end)
function s.initial_effect(c) function s.initial_effect(c)
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
......
--慈英州対張銅羅
--Duel of the Walkers || Duello dei Camminatori
--Scripted by: XGlitchy30
xpcall(function() require("expansions/script/glitchylib_vsnemo") end,function() require("script/glitchylib_vsnemo") end)
local s,id,o=GetID()
function s.initial_effect(c)
Duel.EnableGlobalFlag(GLOBALFLAG_SELF_TOGRAVE)
--Counter Permit workaround for placing counters at activation (do NOT assign the EFFECT_FLAG_SINGLE_RANGE property)
local ct=Effect.CreateEffect(c)
ct:SetType(EFFECT_TYPE_SINGLE)
ct:SetRange(LOCATION_FZONE)
ct:SetCode(EFFECT_COUNTER_PERMIT|0x46c)
c:RegisterEffect(ct)
--[[Activate this card by paying half of your LP. If you do, when this card resolves, place 1 Life Counter on this card for every 400 LP you paid this way (rounded up).]]
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCost(s.cost)
c:RegisterEffect(e1)
--[[Monsters cannot activate their effects or declare an attack, during the turn they were Normal Summoned/Set.]]
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_CANNOT_ACTIVATE)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetRange(LOCATION_FZONE)
e2:SetTargetRange(1,1)
e2:SetValue(s.aclimit)
c:RegisterEffect(e2)
local e2x=Effect.CreateEffect(c)
e2x:SetType(EFFECT_TYPE_FIELD)
e2x:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
e2x:SetRange(LOCATION_FZONE)
e2x:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e2x:SetTarget(aux.TargetBoolFunction(Card.HasFlagEffect,id))
c:RegisterEffect(e2x)
--[[You choose the attack targets for your opponent's attacks, also you can make them direct attacks.]]
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e3:SetCode(EFFECT_PATRICIAN_OF_DARKNESS)
e3:SetRange(LOCATION_FZONE)
e3:SetTargetRange(0,1)
c:RegisterEffect(e3)
local e3x=Effect.CreateEffect(c)
e3x:SetType(EFFECT_TYPE_FIELD)
e3x:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e3x:SetCode(EFFECT_DIRECT_ATTACK)
e3x:SetRange(LOCATION_FZONE)
e3x:SetTargetRange(0,LOCATION_MZONE)
c:RegisterEffect(e3x)
--[[If you would gain LP, place 1 Life Counter on this card for each 400 LP you would have gained, instead.]]
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_FIELD)
e4:SetCode(EFFECT_CHANGE_RECOVER)
e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e4:SetRange(LOCATION_FZONE)
e4:SetTargetRange(1,0)
e4:SetValue(s.recval)
c:RegisterEffect(e4)
local e4x=Effect.CreateEffect(c)
e4x:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_CONTINUOUS)
e4x:SetCode(EVENT_PRE_BATTLE_DAMAGE)
e4x:SetRange(LOCATION_FZONE)
e4x:SetCondition(s.bdcon)
e4x:SetOperation(s.bdop)
c:RegisterEffect(e4x)
--[[If you would take damage, remove 1 Life Counter from this card for each 400 damage you would have taken, instead.]]
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_FIELD)
e5:SetCode(EFFECT_CHANGE_DAMAGE)
e5:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e5:SetRange(LOCATION_FZONE)
e5:SetTargetRange(1,0)
e5:SetValue(s.damval)
c:RegisterEffect(e5)
local e5x=e5:Clone()
e5x:SetCode(EFFECT_NO_EFFECT_DAMAGE)
e5x:SetValue(s.CheckProtectionApplicability)
c:RegisterEffect(e5x)
--[[If there are no Life Counters on this card, send it to the GY.]]
local e6=Effect.CreateEffect(c)
e6:SetType(EFFECT_TYPE_SINGLE)
e6:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e6:SetCode(EFFECT_SELF_TOGRAVE)
e6:SetRange(LOCATION_FZONE)
e6:SetCondition(s.selftg)
c:RegisterEffect(e6)
--[[If this card leaves the field: Halve your LP.]]
local e7=Effect.CreateEffect(c)
e7:SetDescription(aux.Stringid(id,1))
e7:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_F)
e7:SetCode(EVENT_LEAVE_FIELD)
e7:SetOperation(s.hlop)
c:RegisterEffect(e7)
--
if not s.global_check then
s.global_check=true
local ge1=Effect.CreateEffect(c)
ge1:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_CONTINUOUS)
ge1:SetCode(EVENT_SUMMON_SUCCESS)
ge1:SetOperation(s.regsum)
Duel.RegisterEffect(ge1,0)
end
end
function s.regsum(e,tp,eg,ep,ev,re,r,rp)
for tc in aux.Next(eg) do
tc:RegisterFlagEffect(id,RESET_EVENT|(RESETS_STANDARD&(~(RESET_TEMP_REMOVE|RESET_TURN_SET)))|RESET_PHASE|PHASE_END,EFFECT_FLAG_SET_AVAILABLE,1)
end
end
--E1
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
local cost=math.floor(Duel.GetLP(tp)/2)
if chk==0 then return c:IsCanAddCounter(0x46c,math.ceil(cost/400),false,LOCATION_FZONE) end
Duel.PayLPCost(tp,cost)
e:SetLabel(math.ceil(cost/400))
c:AddCounter(0x46c,math.ceil(cost/400))
end
--E2
function s.aclimit(e,re,tp)
local tc=re:GetHandler()
return tc:IsLocation(LOCATION_MZONE) and tc:IsFaceup() and re:IsActiveType(TYPE_MONSTER) and tc:HasFlagEffect(id)
end
--E4
function s.recval(e,r,val)
local c=e:GetHandler()
local ct=math.floor(val/400)
if ct>0 and c:IsCanAddCounter(0x46c,ct) then
c:AddCounter(0x46c,ct)
end
return 0
end
--E4X
function s.bdcon(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetBattleDamage(tp)<=0 or Duel.IsPlayerAffectedByEffect(tp,EFFECT_AVOID_BATTLE_DAMAGE) then return false end
local DamageWillBeReversed=false
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_REVERSE_DAMAGE)}) do
local val=ce:GetValue()
local rc = (re and re&REASON_EFFECT==REASON_EFFECT) and re:GetHandler() or Duel.GetAttacker()
if not val or (type(val)=="number" and val~=0) or val(ce,re,r|REASON_BATTLE,rp,rc) then
DamageWillBeReversed=true
break
end
end
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_REVERSE_RECOVER)}) do
local val=ce:GetValue()
if not val or (type(val)=="number" and val~=0) or val(ce,re,r|REASON_BATTLE,rp) then
DamageWillBeReversed=false
break
end
end
return DamageWillBeReversed
end
function s.bdop(e,tp,eg,ep,ev,re,r,rp)
if Duel.PlayerHasFlagEffect(tp,id) then return end
local c=e:GetHandler()
local ct=math.floor(Duel.GetBattleDamage(tp)/400)
if ct>0 and c:IsCanAddCounter(0x46c,ct) then
c:AddCounter(0x46c,ct)
Duel.RegisterFlagEffect(tp,id,RESET_PHASE|PHASE_DAMAGE,0,1)
Duel.ChangeBattleDamage(tp,0)
end
end
--E5
function s.damval(e,re,val,r,rp,rc)
local c=e:GetHandler()
local tp=e:GetHandlerPlayer()
local ct=math.floor(val/400)
if ct>0 and c:IsCanRemoveCounter(tp,0x46c,ct,REASON_EFFECT) then
Duel.IgnoreActionCheck(Card.RemoveCounter,c,tp,0x46c,ct,REASON_EFFECT)
return 0
end
return ev
end
--E5X
function s.CheckProtectionApplicability(e,dam)
return dam>=400
end
--E6
function s.selftg(e)
return e:GetHandler():GetCounter(0x46c)==0
end
--E7
function s.hlop(e,tp,eg,ep,ev,re,r,rp)
Duel.SetLP(tp,math.ceil(Duel.GetLP(tp)/2))
end
\ No newline at end of file
--无声交流
--Expression in Silence || Espressione nel Silenzio
--Scripted by: XGlitchy30
xpcall(function() require("expansions/script/glitchylib_vsnemo") end,function() require("script/glitchylib_vsnemo") end)
local s,id,o=GetID()
function s.initial_effect(c)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--[[While this card is on the field, you skip your Draw Phase.]]
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetRange(LOCATION_SZONE)
e2:SetTargetRange(1,0)
e2:SetCode(EFFECT_SKIP_DP)
c:RegisterEffect(e2)
--[[During your Standby Phase: Look at the top 3 cards of your Deck, place 1 of them on the bottom of the Deck, and if you do,
add 1 of them to your hand, and keep it revealed as long as it remains in your hand, then add the remaining card to your hand.]]
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetCategory(CATEGORIES_SEARCH)
e3:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_TRIGGER_F)
e3:SetCode(EVENT_PHASE|PHASE_STANDBY)
e3:SetRange(LOCATION_SZONE)
e3:SetCountLimit(1)
e3:SetCondition(aux.TurnPlayerCond(0))
e3:SetOperation(s.thop)
c:RegisterEffect(e3)
--[[Once per turn, during the End Phase: Banish, face-down, all revealed cards in your hand that were revealed by this card's effect.]]
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,3))
e4:SetCategory(CATEGORY_REMOVE)
e4:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_TRIGGER_F)
e4:SetCode(EVENT_PHASE|PHASE_END)
e4:SetRange(LOCATION_SZONE)
e4:SetCountLimit(1)
e4:SetTarget(s.rmtg)
e4:SetOperation(s.rmop)
c:RegisterEffect(e4)
--[[When your opponent activates a card or effect, while this card is in the GY: You can banish this card and 1 card with the same name from your GY, face-down, and if you do, negate that effect.]]
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(id,4))
e5:SetCategory(CATEGORY_DISABLE|CATEGORY_REMOVE)
e5:SetType(EFFECT_TYPE_QUICK_O)
e5:SetCode(EVENT_CHAINING)
e5:SetRange(LOCATION_GRAVE)
e5:SetCondition(s.discon)
e5:SetTarget(s.distg)
e5:SetOperation(s.disop)
c:RegisterEffect(e5)
end
--E3
function s.thop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)<3 then return end
local g=Duel.GetDecktopGroup(tp,3)
Duel.ConfirmCards(tp,g)
local bg=g:Select(tp,1,1,nil)
if #bg>0 then
local bc=bg:GetFirst()
Duel.MoveSequence(bc,1)
if bc:IsLocation(LOCATION_DECK) and bc:GetSequence()==0 then
g:RemoveCard(bc)
local sg=g:Filter(Card.IsAbleToHand,nil)
if #sg>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local sg1=sg:Select(tp,1,1,nil)
if #sg1>0 then
Duel.DisableShuffleCheck()
if Duel.SendtoHand(sg1,nil,REASON_EFFECT)>0 and aux.PLChk(sg1,tp,LOCATION_HAND) then
Duel.ConfirmCards(1-tp,sg1)
local sc1=sg1:GetFirst()
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_PUBLIC)
e1:SetLabel(tp)
e1:SetCondition(s.resetcon)
e1:SetReset(RESET_EVENT|RESETS_STANDARD)
sc1:RegisterEffect(e1)
sc1:RegisterFlagEffect(id,RESET_EVENT|RESETS_STANDARD,EFFECT_FLAG_IGNORE_IMMUNE|EFFECT_FLAG_CLIENT_HINT,1,0,aux.Stringid(id,2))
sg:RemoveCard(sc1)
if #sg>0 then
Duel.BreakEffect()
Duel.SendtoHand(sg,nil,REASON_EFFECT)
end
end
Duel.ShuffleHand(tp)
end
end
end
end
end
function s.resetcon(e)
local c=e:GetHandler()
if c:GetControler()~=e:GetLabel() then
e:ResetFlagEffect(id)
e:Reset()
return false
end
return true
end
--FILTERS E4
function s.revfilter(c,tp)
return c:IsPublic() and c:HasFlagEffect(id) and c:IsAbleToRemove(tp,POS_FACEDOWN)
end
--E4
function s.rmtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local g=Duel.Group(s.revfilter,tp,LOCATION_HAND,0,nil,tp)
if #g>0 then
Duel.SetCardOperationInfo(g,CATEGORY_REMOVE)
end
end
function s.rmop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.Group(s.revfilter,tp,LOCATION_HAND,0,nil,tp)
if #g>0 then
Duel.Banish(g,POS_FACEDOWN)
end
end
--FILTERS E5
function s.rmfilter(c,tp,code1,code2)
return c:IsCode(code1,code2) and c:IsAbleToRemove(tp,POS_FACEDOWN)
end
--E5
function s.discon(e,tp,eg,ep,ev,re,r,rp)
if rp==tp or not Duel.IsChainDisablable(ev) then return false end
return true
end
function s.distg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
local code1,code2=Duel.GetChainInfo(ev,CHAININFO_TRIGGERING_CODE,CHAININFO_TRIGGERING_CODE2)
if chk==0 then
return not re:GetHandler():IsStatus(STATUS_DISABLED) and c:IsAbleToRemove(tp,POS_FACEDOWN) and Duel.IsExistingMatchingCard(s.rmfilter,tp,LOCATION_GRAVE,0,1,c,tp,code1,code2)
end
Duel.SetOperationInfo(0,CATEGORY_DISABLE,eg,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,c,2,tp,LOCATION_GRAVE)
end
function s.disop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToChain() then return end
local code1,code2=Duel.GetChainInfo(ev,CHAININFO_TRIGGERING_CODE,CHAININFO_TRIGGERING_CODE2)
local g=Duel.Select(HINTMSG_REMOVE,false,tp,aux.Necro(s.rmfilter),tp,LOCATION_GRAVE,0,1,1,c,tp,code1,code2)
if not c:IsHasEffect(EFFECT_NECRO_VALLEY) and c:IsAbleToRemove(tp,POS_FACEDOWN) then
g:AddCard(c)
end
if #g>0 then
Duel.HintSelection(g)
if Duel.Banish(g,POS_FACEDOWN)>0 then
Duel.NegateEffect(ev)
end
end
end
\ No newline at end of file
--无尽的重担 ~月童~
--Timeless Burden - Tsukiwarawa- || Fardello senza Tempo - Tsukiwarawa-
--Scripted by: XGlitchy30
xpcall(function() require("expansions/script/glitchylib_vsnemo") end,function() require("script/glitchylib_vsnemo") end)
local s,id,o=GetID()
function s.initial_effect(c)
c:SetUniqueOnField(1,0,id)
c:EnableCounterPermit(0x46d)
--[[If this is your first turn of the Duel, you can activate this card from your hand.]]
local e0=Effect.CreateEffect(c)
e0:SetDescription(aux.Stringid(id,0))
e0:SetType(EFFECT_TYPE_SINGLE)
e0:SetCode(EFFECT_TRAP_ACT_IN_HAND)
e0:SetCondition(s.handcon)
c:RegisterEffect(e0)
--[[When this card is activated: You lose 2000 LP, also until the End Phase of your opponent's next turn, all damage you would take becomes 0.]]
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,1))
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCondition(s.condition)
e1:SetOperation(s.operation)
c:RegisterEffect(e1)
--[[Cannot be destroyed by other card effects.]]
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e2:SetRange(LOCATION_SZONE)
e2:SetValue(s.efilter)
c:RegisterEffect(e2)
--[[Once per turn, during your Main Phase: You can place 1 counter on this card, and if you do, draw cards equal to the number of counters on this card (if any).]]
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,3))
e3:SetCategory(CATEGORY_COUNTER|CATEGORY_DRAW)
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetCode(EVENT_FREE_CHAIN)
e3:SetRange(LOCATION_SZONE)
e3:SetCountLimit(1)
e3:SetHintTiming(0,RELEVANT_TIMINGS)
e3:SetCondition(aux.MainPhaseCond(0))
e3:SetTarget(s.cttg)
e3:SetOperation(s.ctop)
c:RegisterEffect(e3)
--[[During the Standby Phase: You take damage equal to the number of counters on this card x 400.]]
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,4))
e4:SetCategory(CATEGORY_DAMAGE)
e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e4:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_TRIGGER_F)
e4:SetCode(EVENT_PHASE|PHASE_STANDBY)
e4:SetRange(LOCATION_SZONE)
e4:SetCountLimit(1)
e4:SetTarget(s.damtg)
e4:SetOperation(s.damop)
c:RegisterEffect(e4)
--[[If you have 6 or more cards in your hand, destroy this card.]]
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_SINGLE)
e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e5:SetRange(LOCATION_SZONE)
e5:SetCode(EFFECT_SELF_DESTROY)
e5:SetCondition(s.descon)
c:RegisterEffect(e5)
--[[If this card leaves the field: You lose LP equal to the number of counters that were on it x 2000.]]
local e6=Effect.CreateEffect(c)
e6:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_CONTINUOUS)
e6:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e6:SetCode(EVENT_LEAVE_FIELD_P)
e6:SetOperation(s.regop)
c:RegisterEffect(e6)
local e7=Effect.CreateEffect(c)
e7:SetDescription(aux.Stringid(id,5))
e7:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_F)
e7:SetCode(EVENT_LEAVE_FIELD)
e7:SetLabelObject(e6)
e7:SetCondition(s.lpcon)
e7:SetOperation(s.lpop)
c:RegisterEffect(e7)
if not s.global_check then
s.global_check=true
s[0]=0
s[1]=0
local ge1=Effect.CreateEffect(c)
ge1:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_CONTINUOUS)
ge1:SetCode(EVENT_PHASE_START|PHASE_DRAW)
ge1:SetCountLimit(1,id)
ge1:SetOperation(s.regturn)
Duel.RegisterEffect(ge1,0)
local ge2=ge1:Clone()
ge2:SetCode(EVENT_PHASE_START|PHASE_STANDBY)
Duel.RegisterEffect(ge2,0)
local ge3=ge1:Clone()
ge3:SetCode(EVENT_PHASE_START|PHASE_MAIN1)
Duel.RegisterEffect(ge3,0)
local ge4=ge1:Clone()
ge4:SetCode(EVENT_PHASE_START|PHASE_BATTLE_START)
Duel.RegisterEffect(ge4,0)
local ge5=ge1:Clone()
ge5:SetCode(EVENT_PHASE_START|PHASE_MAIN2)
Duel.RegisterEffect(ge5,0)
local ge6=ge1:Clone()
ge6:SetCode(EVENT_PHASE_START|PHASE_END)
Duel.RegisterEffect(ge6,0)
end
end
function s.regturn(e,tp,eg,ep,ev,re,r,rp)
local p=Duel.GetTurnPlayer()
s[p]=s[p]+1
end
--E0
function s.handcon(e)
return s[e:GetHandlerPlayer()]==1
end
--E1
function s.condition(e,tp,eg,ep,ev,re,r,rp)
return not Duel.IsExistingMatchingCard(Card.IsSpellTrapOnField,tp,LOCATION_ONFIELD,0,1,e:GetHandler())
end
function s.operation(e,tp,eg,ep,ev,re,r,rp)
Duel.LoseLP(tp,2000)
local c=e:GetHandler()
local rct = (Duel.GetTurnPlayer()==tp and 1 or 2)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,2))
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_CLIENT_HINT|EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EFFECT_CHANGE_DAMAGE)
e1:SetTargetRange(1,0)
e1:SetValue(0)
e1:SetReset(RESET_PHASE|PHASE_END|RESET_TURN_OPPO,rct)
Duel.RegisterEffect(e1,tp)
local e2=e1:Clone()
e2:SetCode(EFFECT_NO_EFFECT_DAMAGE)
e2:SetReset(RESET_PHASE|PHASE_END|RESET_TURN_OPPO,rct)
Duel.RegisterEffect(e2,tp)
end
--E2
function s.efilter(e,te)
return te:GetOwner()~=e:GetOwner()
end
--E3
function s.cttg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
local ct=c:GetCounter(0x46d)+1
if chk==0 then return c:IsCanAddCounter(0x46d,1) and Duel.IsPlayerCanDraw(tp,ct) end
Duel.SetOperationInfo(0,CATEGORY_COUNTER,nil,1,0,0x46d)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,ct)
end
function s.ctop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not (c:IsRelateToChain() and c:IsFaceup() and c:AddCounter(0x46d,1)) then return end
local ct=c:GetCounter(0x46d)
if ct>0 then
Duel.Draw(tp,ct,REASON_EFFECT)
end
end
--E4
function s.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local ct=e:GetHandler():GetCounter(0x46d)
Duel.SetTargetPlayer(tp)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,tp,ct*400)
end
function s.damop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToChain() then
local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER)
local ct=math.max(0,c:GetCounter(0x46d))
Duel.Damage(p,ct*400,REASON_EFFECT)
end
end
--E5
function s.descon(e)
return Duel.GetHandCount(e:GetHandlerPlayer())>=116
end
--E6 and E7
function s.regop(e,tp,eg,ep,ev,re,r,rp)
local ct=e:GetHandler():GetCounter(0x46d)
e:SetLabel(ct)
end
function s.lpcon(e,tp,eg,ep,ev,re,r,rp)
local ct=e:GetLabelObject():GetLabel()
e:SetLabel(ct)
return ct>0
end
function s.lpop(e,tp,eg,ep,ev,re,r,rp)
Duel.LoseLP(tp,e:GetLabel()*2000)
end
\ No newline at end of file
--直面光明
--Facing the Light || Affrontare la Luce
--Scripted by: XGlitchy30
xpcall(function() require("expansions/script/glitchylib_vsnemo") end,function() require("script/glitchylib_vsnemo") end)
local s,id,o=GetID()
function s.initial_effect(c)
--[[Banish, from your hand, field, and/or Extra Deck, LIGHT monsters with a total Level of 50 or more,
and if you do, your opponent sends to the GY, 1 monster they control, 1 card in their Spell & Trap Card Zones, and 1 card in their hand,
and if less than 3 cards are sent to the GY by this effect, inflict damage to your opponent equal to the difference x 800.
If this card is activated on or after the 5th turn of this Duel, you can also banish cards from your GY.]]
local e1=Effect.CreateEffect(c)
e1:Desc(0)
e1:SetCategory(CATEGORY_REMOVE|CATEGORY_TOGRAVE|CATEGORY_DAMAGE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:HOPT(true)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1)
end
--FILTERS E1
function s.rmfilter(c)
return (not c:IsOnField() or c:IsFaceup()) and c:IsMonster() and c:IsAttribute(ATTRIBUTE_LIGHT) and c:HasLevel() and c:IsAbleToRemove()
end
function s.gcheck(g)
Duel.SetSelectedCard(g)
return g:CheckWithSumGreater(Card.GetLevel,50)
end
function s.tgfilter(c,tp)
return (not c:IsLocation(LOCATION_SZONE) or c:GetSequence()<5) and Duel.IsPlayerCanSendtoGrave(1-tp,c)
end
function s.tgcheck(g)
return g:GetClassCount(Card.GetLocation)==#g
end
--E1
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
local loc=LOCATION_HAND|LOCATION_MZONE|LOCATION_EXTRA
if Duel.GetTurnCount()>=5 then
loc=loc|LOCATION_GRAVE
end
if chk==0 then
local g=Duel.Group(s.rmfilter,tp,loc,0,nil)
return #g>0 and g:CheckWithSumGreater(Card.GetLevel,50)
end
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,loc)
end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
local loc=LOCATION_HAND|LOCATION_MZONE|LOCATION_EXTRA
if Duel.GetTurnCount()>=5 then
loc=loc|LOCATION_GRAVE
end
local g=Duel.Group(aux.Necro(s.rmfilter),tp,loc,0,nil)
if #g>0 and g:CheckWithSumGreater(Card.GetLevel,50) then
Duel.HintMessage(tp,HINTMSG_REMOVE)
local rg=g:SelectWithSumGreater(tp,Card.GetLevel,50)
if #rg>0 and Duel.Banish(rg)>0 then
local ct=3
local sg=Duel.Group(s.tgfilter,tp,0,LOCATION_HAND|LOCATION_MZONE|LOCATION_SZONE,nil,tp)
if #sg>0 then
local min=3
local loclist={LOCATION_HAND,LOCATION_MZONE,LOCATION_SZONE}
for i=1,3 do
if not sg:IsExists(Card.IsLocation,1,nil,loclist[i]) then
min=min-1
if min==1 then
break
end
end
end
Duel.HintMessage(1-tp,HINTMSG_TOGRAVE)
aux.GCheckAdditional=s.tgcheck
local tg=sg:SelectSubGroup(1-tp,aux.TRUE,false,min,min)
aux.GCheckAdditional=nil
if #tg>0 and Duel.SendtoGrave(tg,REASON_RULE)>0 then
local oct=Duel.GetOperatedGroup():FilterCount(Card.IsLocation,nil,LOCATION_GRAVE)
ct=3-oct
end
end
if ct>0 then
Duel.Damage(1-tp,ct*800,REASON_EFFECT)
end
end
end
end
\ No newline at end of file
--电脑童
--Brilliant Program & Genius Kid || Programma Brillante & Bambino Geniale
--Scripted by: XGlitchy30
xpcall(function() require("expansions/script/glitchylib_vsnemo") end,function() require("script/glitchylib_vsnemo") end)
local s,id,o=GetID()
function s.initial_effect(c)
--[[(Quick Effect): You can send this card from your hand or field to the GY; reveal 1 monster in your Extra Deck, then banish it face-down, and if you do, choose up to 2 of the below values. For the rest of this turn, the chosen values of all face-up monster on the field become the respective original values of the monster banished by this card's effect.
● ATK
● DEF
● Type
● Attribute.]]
local e1=Effect.CreateEffect(c)
e1:Desc(0)
e1:SetCategory(CATEGORY_REMOVE)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(LOCATION_HAND|LOCATION_MZONE)
e1:SetHintTiming(0,RELEVANT_TIMINGS)
e1:SetCost(s.cost)
e1:SetTarget(s.target)
e1:SetOperation(s.operation)
c:RegisterEffect(e1)
end
--FILTERS E1
function s.rmfilter(c,tp)
return not c:IsPublic() and c:IsMonster() and c:IsAbleToRemove(tp,POS_FACEDOWN)
end
--E1
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsAbleToGraveAsCost() end
Duel.SendtoGrave(c,REASON_COST)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
return Duel.IsExistingMatchingCard(s.rmfilter,tp,LOCATION_EXTRA,0,1,nil,tp)
end
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_EXTRA)
end
function s.operation(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.Select(HINTMSG_CONFIRM,false,tp,s.rmfilter,tp,LOCATION_EXTRA,0,1,1,nil,tp)
if #g>0 then
Duel.ConfirmCards(1-tp,g)
local tc=g:GetFirst()
local atk,def,type,attr = tc:GetTextAttack(),tc:GetTextDefense(),tc:GetOriginalRace(),tc:GetOriginalAttribute()
local hasdef = not tc:IsType(TYPE_LINK)
Duel.BreakEffect()
if Duel.Banish(g,POS_FACEDOWN)>0 then
local val=0
for i=1,2 do
local b1 = val&0x1==0
local b2 = val&0x2==0 and hasdef
local b3 = val&0x4==0
local b4 = val&0x8==0
local opt=aux.Option(tp,id,1,b1,b2,b3,b4)
val = val|(2^opt)
end
if val~=0 then
local c=e:GetHandler()
if val&0x1==0x1 then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(0,EFFECT_FLAG2_WICKED)
e1:SetCode(EFFECT_SET_ATTACK_FINAL)
e1:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e1:SetValue(atk)
e1:SetReset(RESET_PHASE|PHASE_END)
Duel.RegisterEffect(e1,tp)
end
if val&0x2==0x2 then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(0,EFFECT_FLAG2_WICKED)
e1:SetCode(EFFECT_SET_DEFENSE_FINAL)
e1:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e1:SetValue(def)
e1:SetReset(RESET_PHASE|PHASE_END)
Duel.RegisterEffect(e1,tp)
end
if val&0x4==0x4 then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CHANGE_RACE)
e1:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e1:SetValue(type)
e1:SetReset(RESET_PHASE|PHASE_END)
Duel.RegisterEffect(e1,tp)
end
if val&0x8==0x8 then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CHANGE_ATTRIBUTE)
e1:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e1:SetValue(attr)
e1:SetReset(RESET_PHASE|PHASE_END)
Duel.RegisterEffect(e1,tp)
end
end
end
end
end
\ No newline at end of file
...@@ -41,7 +41,7 @@ function cm.dfilter(c) ...@@ -41,7 +41,7 @@ function cm.dfilter(c)
end end
function cm.actcon(e,tp,eg,ep,ev,re,r,rp) function cm.actcon(e,tp,eg,ep,ev,re,r,rp)
local tp=e:GetHandlerPlayer() local tp=e:GetHandlerPlayer()
return Duel.GetFlagEffect(tp,40009560)>0 or Duel.IsExistingMatchingCard(cm.dfilter,tp,LOCATION_MZONE,0,1,nil) return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 and Duel.GetFlagEffect(tp,40009560)>0 or Duel.IsExistingMatchingCard(cm.dfilter,tp,LOCATION_MZONE,0,1,nil)
end end
function cm.cfilter(c) function cm.cfilter(c)
return c:IsRace(RACE_FIEND) and c:IsAbleToGraveAsCost() return c:IsRace(RACE_FIEND) and c:IsAbleToGraveAsCost()
......
...@@ -40,7 +40,7 @@ function cm.dfilter(c) ...@@ -40,7 +40,7 @@ function cm.dfilter(c)
end end
function cm.actcon(e,tp,eg,ep,ev,re,r,rp) function cm.actcon(e,tp,eg,ep,ev,re,r,rp)
local tp=e:GetHandlerPlayer() local tp=e:GetHandlerPlayer()
return Duel.GetFlagEffect(tp,40009560)>0 or Duel.IsExistingMatchingCard(cm.dfilter,tp,LOCATION_MZONE,0,1,nil) return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 and Duel.GetFlagEffect(tp,40009560)>0 or Duel.IsExistingMatchingCard(cm.dfilter,tp,LOCATION_MZONE,0,1,nil)
end end
function cm.cfilter(c) function cm.cfilter(c)
return c:IsRace(RACE_FIEND) and c:IsAbleToGraveAsCost() return c:IsRace(RACE_FIEND) and c:IsAbleToGraveAsCost()
......
...@@ -39,7 +39,7 @@ function cm.dfilter(c) ...@@ -39,7 +39,7 @@ function cm.dfilter(c)
end end
function cm.actcon(e,tp,eg,ep,ev,re,r,rp) function cm.actcon(e,tp,eg,ep,ev,re,r,rp)
local tp=e:GetHandlerPlayer() local tp=e:GetHandlerPlayer()
return Duel.GetFlagEffect(tp,40009560)>0 or Duel.IsExistingMatchingCard(cm.dfilter,tp,LOCATION_MZONE,0,1,nil) return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 and Duel.GetFlagEffect(tp,40009560)>0 or Duel.IsExistingMatchingCard(cm.dfilter,tp,LOCATION_MZONE,0,1,nil)
end end
function cm.tfilter(c,tp) function cm.tfilter(c,tp)
return ((c:IsLocation(LOCATION_ONFIELD) and c:IsFaceup() and c:IsControler(tp)) or c:IsLocation(LOCATION_GRAVE)) and cm.Diablotherhood(c) return ((c:IsLocation(LOCATION_ONFIELD) and c:IsFaceup() and c:IsControler(tp)) or c:IsLocation(LOCATION_GRAVE)) and cm.Diablotherhood(c)
......
...@@ -87,13 +87,9 @@ end ...@@ -87,13 +87,9 @@ end
function cm.discon(e,tp,eg,ep,ev,re,r,rp) function cm.discon(e,tp,eg,ep,ev,re,r,rp)
return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev) return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev)
end end
function cm.cfilter(c,ft,tp)
return c:IsCode(40009699)
and (ft>0 or (c:IsControler(tp) and c:GetSequence()<5)) and (c:IsControler(tp) or c:IsFaceup())
end
function cm.discost(e,tp,eg,ep,ev,re,r,rp,chk) function cm.discost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,cm.cfilter,3,nil) end if chk==0 then return Duel.CheckReleaseGroup(tp,Card.IsCode,3,nil,40009699) end
local g=Duel.SelectReleaseGroup(tp,cm.cfilter,3,3,nil) local g=Duel.SelectReleaseGroup(tp,Card.IsCode,3,3,nil,40009699)
Duel.Release(g,REASON_COST) Duel.Release(g,REASON_COST)
end end
function cm.distg(e,tp,eg,ep,ev,re,r,rp,chk) function cm.distg(e,tp,eg,ep,ev,re,r,rp,chk)
......
...@@ -55,6 +55,17 @@ function cm.initial_effect(c) ...@@ -55,6 +55,17 @@ function cm.initial_effect(c)
sg:KeepAlive() sg:KeepAlive()
e4:SetLabelObject(sg) e4:SetLabelObject(sg)
e5:SetLabelObject(e4) e5:SetLabelObject(e4)
if not cm.global_check then
cm.global_check=true
cm[0]=Card.GetType
Card.GetType=function(tc)
if tc:GetFlagEffect(m)>0 then
return TYPE_SPELL
else
return cm[0](tc)
end
end
end
end end
function cm.etg(e,c) function cm.etg(e,c)
return e:GetHandler():GetEquipGroup():IsContains(c) return e:GetHandler():GetEquipGroup():IsContains(c)
...@@ -102,12 +113,6 @@ function cm.eqop(e,tp,eg,ep,ev,re,r,rp) ...@@ -102,12 +113,6 @@ function cm.eqop(e,tp,eg,ep,ev,re,r,rp)
e2:SetReset(RESET_EVENT+RESETS_STANDARD) e2:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e2) tc:RegisterEffect(e2)
tc:RegisterFlagEffect(m,RESET_EVENT+RESETS_STANDARD,0,1) tc:RegisterFlagEffect(m,RESET_EVENT+RESETS_STANDARD,0,1)
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_REMOVE_TYPE)
e3:SetValue(TYPE_EQUIP)
e3:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e3)
end end
end end
function cm.eqlimit(e,c) function cm.eqlimit(e,c)
......
...@@ -83,6 +83,7 @@ function cm.penop(e,tp,eg,ep,ev,re,r,rp) ...@@ -83,6 +83,7 @@ function cm.penop(e,tp,eg,ep,ev,re,r,rp)
e2:SetCode(EFFECT_EXTRA_PENDULUM_SUMMON) e2:SetCode(EFFECT_EXTRA_PENDULUM_SUMMON)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetTargetRange(1,0) e2:SetTargetRange(1,0)
e2:SetCountLimit(1,29432356)
e2:SetValue(cm.pendvalue) e2:SetValue(cm.pendvalue)
e2:SetReset(RESET_PHASE+PHASE_END) e2:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e2,tp) Duel.RegisterEffect(e2,tp)
......
--核成将军
function c98920240.initial_effect(c)
--xyz summon
aux.AddXyzProcedure(c,nil,4,2)
c:EnableReviveLimit()
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(98920240,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetCountLimit(1,98920240)
e1:SetCondition(c98920240.spcon)
e1:SetTarget(c98920240.sptg)
e1:SetOperation(c98920240.spop)
c:RegisterEffect(e1)
--destroy replace
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_DESTROY_REPLACE)
e2:SetRange(LOCATION_MZONE)
e2:SetTarget(c98920240.desreptg)
e2:SetValue(c98920240.desrepval)
e2:SetOperation(c98920240.desrepop)
c:RegisterEffect(e2)
end
function c98920240.spcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
end
function c98920240.spfilter(c,e,tp)
return c:IsSetCard(0x1d) and c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c98920240.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c98920240.spfilter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c98920240.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c98920240.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c98920240.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
function c98920240.repfilter(c,tp)
return c:IsFaceup() and c:IsControler(tp) and c:IsOnField() and not c:IsReason(REASON_REPLACE) and c:IsSetCard(0x1d)
end
function c98920240.desreptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return eg:IsExists(c98920240.repfilter,1,nil,tp)
and c:CheckRemoveOverlayCard(tp,1,REASON_EFFECT) end
return Duel.SelectEffectYesNo(tp,c,96)
end
function c98920240.desrepval(e,c)
return c98920240.repfilter(c,e:GetHandlerPlayer())
end
function c98920240.desrepop(e,tp,eg,ep,ev,re,r,rp)
e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_EFFECT)
Duel.Hint(HINT_CARD,0,98920240)
end
\ No newline at end of file
...@@ -11,6 +11,7 @@ function c98920338.initial_effect(c) ...@@ -11,6 +11,7 @@ function c98920338.initial_effect(c)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetRange(LOCATION_MZONE) e1:SetRange(LOCATION_MZONE)
e1:SetTargetRange(1,0) e1:SetTargetRange(1,0)
e1:SetCountLimit(1,29432356)
e1:SetCondition(c98920338.excon) e1:SetCondition(c98920338.excon)
e1:SetValue(c98920338.pendvalue) e1:SetValue(c98920338.pendvalue)
c:RegisterEffect(e1) c:RegisterEffect(e1)
......
Glitchy = Glitchy or {}
self_reference_effect = nil self_reference_effect = nil
self_reference_tp = nil self_reference_tp = nil
LOCATION_ALL = LOCATION_DECK+LOCATION_HAND+LOCATION_MZONE+LOCATION_SZONE+LOCATION_GRAVE+LOCATION_REMOVED+LOCATION_EXTRA --Modified functions
local duel_recover, duel_damage, aux_damcon1 = Duel.Recover, Duel.Damage, Auxiliary.damcon1
Duel.Recover = function(p,v,r,...)
if Duel.IsPlayerAffectedByEffect(p,EFFECT_CHANGE_RECOVER) then
for _,e in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_CHANGE_RECOVER)}) do
local val=e:GetValue()
if val and (aux.GetValueType(val)=="number" or val(e,r,v)) then
if aux.GetValueType(val)~="number" then
val=val(e,r,v)
end
return duel_recover(p,val,r,...)
end
end
else
return duel_recover(p,v,r,...)
end
end
Duel.Damage = function(p,v,r,...)
if Duel.IsPlayerAffectedByEffect(p,EFFECT_REVERSE_DAMAGE) and Duel.IsPlayerAffectedByEffect(p,EFFECT_CHANGE_RECOVER) then
for _,e in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_CHANGE_RECOVER)}) do
local val=e:GetValue()
if val and (aux.GetValueType(val)=="number" or val(e,r|REASON_RDAMAGE,v)) then
if aux.GetValueType(val)~="number" then
val=val(e,r|REASON_RDAMAGE,v)
end
return duel_damage(p,val,r,...)
end
end
else
return duel_damage(p,v,r,...)
end
end
Auxiliary.damcon1 = function(e,tp,eg,ep,ev,re,r,rp)
local e1=Duel.IsPlayerAffectedByEffect(tp,EFFECT_REVERSE_DAMAGE)
local e2=Duel.IsPlayerAffectedByEffect(tp,EFFECT_REVERSE_RECOVER)
local rd=e1 and not e2
local rr=not e1 and e2
local ex,cg,ct,cp,cv=Duel.GetOperationInfo(ev,CATEGORY_DAMAGE)
local takedamcheck=true
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_NO_EFFECT_DAMAGE)}) do
local value=ce:GetValue()
if not value or value(ce,cv) then
takedamcheck=false
break
end
end
if ex and (cp==tp or cp==PLAYER_ALL) and not rd and takedamcheck then
return true
end
ex,cg,ct,cp,cv=Duel.GetOperationInfo(ev,CATEGORY_RECOVER)
return ex and (cp==tp or cp==PLAYER_ALL) and rr and takedamcheck
end
--Glitchylib imports
EFFECT_CHANGE_RECOVER = 1508
EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER = 33720071 --Rating types
EFFECT_UTTER_CONFUSION_CONFIDENCE = 33720072 RATING_LEVEL = 0x1
RATING_RANK = 0x2
RATING_LINK = 0x4
Glitchy.EnableTestChamber = false --Stat types
Glitchy.TestChamberResult = 0 STAT_ATTACK = 0x1
Glitchy.TestChamberResultGroup = {} STAT_DEFENSE = 0x2
Glitchy.UndefinedActionWarning = false
GLITCHY_ENABLE_TEST_CHAMBER = 33720071 --COIN RESULTS
TEST_CHAMBER_TARGET = 0x1 COIN_HEADS = 1
TEST_CHAMBER_TOHAND = 0x2 COIN_TAILS = 0
--Internal Archetypes --Effects
ARCHE_UTTER_CONFUSION = {33720051,33720052,33720053,33720070,33720071,33720072,33720073,33720074} GLOBAL_EFFECT_RESET = 10203040
--TEST CHAMBER MECHANIC (necessary for UTTER CONFUSION - CONFIDENCE) --Properties
local _Hint, _IsCanBeEffectTarget, _IsAbleToHand, _IsAbleToHandAsCost, _SelectMatchingCard, _SelectTarget, _GetMatchingGroup, _GroupFilter, _GroupSelect, _FilterSelect, _SelectUnselect, _GroupMerge, _GroupClone, _SelectSubGroup, EFFECT_FLAG_DD = EFFECT_FLAG_DAMAGE_STEP|EFFECT_FLAG_DAMAGE_CAL
_SelectSubGroupEach, _SelectWithSumEqual, _SelectWithSumGreater = EFFECT_FLAG_DDD = EFFECT_FLAG_DELAY|EFFECT_FLAG_DAMAGE_STEP|EFFECT_FLAG_DAMAGE_CAL
Duel.Hint, Card.IsCanBeEffectTarget, Card.IsAbleToHand, Card.IsAbleToHandAsCost, Duel.SelectMatchingCard, Duel.SelectTarget, Duel.GetMatchingGroup, Group.Filter, Group.Select, Group.FilterSelect, Group.SelectUnselect, Group.Merge, Group.Clone,
Group.SelectSubGroup, Group.SelectSubGroupEach, Group.SelectWithSumEqual, Group.SelectWithSumGreater
Duel.Hint = function(hinttype,p,hint) --zone constants
if hint==HINTMSG_OPERATECARD then EXTRA_MONSTER_ZONE=0x60
Glitchy.UndefinedActionWarning = true
end --resets
return _Hint(hinttype,p,hint) RESETS_REDIRECT_FIELD = 0x047e0000
RESETS_STANDARD_UNION = RESETS_STANDARD&(~(RESET_TOFIELD|RESET_LEAVE))
RESETS_STANDARD_TOFIELD = RESETS_STANDARD&(~(RESET_TOFIELD))
RESETS_STANDARD_EXC_GRAVE = RESETS_STANDARD&~(RESET_LEAVE|RESET_TOGRAVE)
--timings
RELEVANT_TIMINGS = TIMINGS_CHECK_MONSTER|TIMING_MAIN_END|TIMING_END_PHASE
--win
WIN_REASON_CUSTOM = 0xff
--constants aliases
TYPE_ST = TYPE_SPELL|TYPE_TRAP
RACES_BEASTS = RACE_BEAST|RACE_BEASTWARRIOR|RACE_WINDBEAST
ARCHE_FUSION = 0x46
LOCATION_ALL = LOCATION_DECK|LOCATION_HAND|LOCATION_MZONE|LOCATION_SZONE|LOCATION_GRAVE|LOCATION_REMOVED|LOCATION_EXTRA
LOCATION_GB = LOCATION_GRAVE|LOCATION_REMOVED
MAX_RATING = 14
REASON_EXCAVATE = REASON_REVEAL
RESET_TURN_SELF = RESET_SELF_TURN
RESET_TURN_OPPO = RESET_OPPO_TURN
--Shortcuts
function Duel.IsExists(target,f,tp,loc1,loc2,min,exc,...)
if aux.GetValueType(target)~="boolean" then return false end
local func = (target==true) and Duel.IsExistingTarget or Duel.IsExistingMatchingCard
return func(f,tp,loc1,loc2,min,exc,...)
end end
Card.IsCanBeEffectTarget = function(c,e) function Duel.Select(hint,target,tp,f,pov,loc1,loc2,min,max,exc,...)
if Glitchy.EnableTestChamber and Glitchy.TestChamberResult&TEST_CHAMBER_TARGET==0 then if aux.GetValueType(target)~="boolean" then return false end
Glitchy.TestChamberResult = Glitchy.TestChamberResult | TEST_CHAMBER_TARGET local func = (target==true) and Duel.SelectTarget or Duel.SelectMatchingCard
end local hint = hint or HINTMSG_TARGET
return _IsCanBeEffectTarget(c,e)
Duel.Hint(HINT_SELECTMSG,tp,hint)
local g=func(tp,f,pov,loc1,loc2,min,max,exc,...)
return g
end end
Card.IsAbleToHand = function(c,...) function Duel.Group(f,tp,loc1,loc2,exc,...)
local x = {...} local g=Duel.GetMatchingGroup(f,tp,loc1,loc2,exc,...)
local p = x[1] return g
if Glitchy.EnableTestChamber and Glitchy.TestChamberResult&TEST_CHAMBER_TOHAND==0 and (not p or p==self_reference_effect) then end
Glitchy.TestChamberResult = Glitchy.TestChamberResult | TEST_CHAMBER_TOHAND function Duel.HintMessage(tp,msg)
end return Duel.Hint(HINT_SELECTMSG,tp,msg)
return _IsAbleToHand(c,...)
end end
Card.IsAbleToHandAsCost = function(c) function Auxiliary.Necro(f)
if Glitchy.EnableTestChamber and Glitchy.TestChamberResult&TEST_CHAMBER_TOHAND==0 then return aux.NecroValleyFilter(f)
Glitchy.TestChamberResult = Glitchy.TestChamberResult | TEST_CHAMBER_TOHAND end
function Card.Activation(c,oath)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
if oath then
e1:HOPT(true)
end
c:RegisterEffect(e1)
return e1
end
--Custom Categories
if not global_effect_category_table_global_check then
global_effect_category_table_global_check=true
global_effect_category_table={}
global_effect_info_table={}
end
function Effect.SetCustomCategory(e,cat,flags)
if not cat then cat=0 end
if not flags then flags=0 end
if not global_effect_category_table[e] then global_effect_category_table[e]={} end
global_effect_category_table[e][1]=cat
global_effect_category_table[e][2]=flags
end
function Effect.GetCustomCategory(e)
if not global_effect_category_table[e] then return 0,0 end
return global_effect_category_table[e][1], global_effect_category_table[e][2]
end
function Effect.IsHasCustomCategory(e,cat1,cat2)
local ocat1,ocat2=e:GetCustomCategory()
return (cat1 and ocat1&cat1>0) or (cat2 and ocat2&cat2>0)
end
function Duel.SetCustomOperationInfo(ch,cat,g,ct,p,val,...)
local extra={...}
if not global_effect_info_table[ch+1] or #global_effect_info_table[ch+1]>0 then
global_effect_info_table[ch+1]={}
end end
return _IsAbleToHandAsCost(c) table.insert(global_effect_info_table[ch+1],{cat,g,ct,p,val,table.unpack(extra)})
end end
Duel.SelectMatchingCard = function(p,f,pov,loc1,loc2,min,max,exc,...) --Card Actions
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then function Duel.Attach(c,xyz)
local test_chamber = _GetMatchingGroup(f,pov,loc1,loc2,exc,...) if aux.GetValueType(c)=="Card" then
Glitchy.EnableTestChamber = true local og=c:GetOverlayGroup()
Glitchy.TestChamberResult = 0 if og:GetCount()>0 then
for tc in aux.Next(test_chamber) do Duel.SendtoGrave(og,REASON_RULE)
f(tc,...)
end end
Glitchy.EnableTestChamber = false Duel.Overlay(xyz,Group.FromCards(c))
local result = Glitchy.TestChamberResult return xyz:GetOverlayGroup():IsContains(c)
Glitchy.TestChamberResult = 0
local player = p elseif aux.GetValueType(c)=="Group" then
local nloc1,nloc2 = loc1,loc2 for tc in aux.Next(c) do
if p==self_reference_effect:GetHandlerPlayer() then local og=tc:GetOverlayGroup()
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then if og:GetCount()>0 then
player = 1-p Duel.SendtoGrave(og,REASON_RULE)
end
end
Duel.Overlay(xyz,c)
return c:FilterCount(function (card,group) return group:IsContains(card) end, nil, xyz:GetOverlayGroup())
end
end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then function Duel.Banish(g,pos,r)
if loc1&~(LOCATION_DECK+LOCATION_GRAVE)==0 and loc2==0 then if not pos then pos=POS_FACEUP end
player = 1-p if not r then r=REASON_EFFECT end
return Duel.Remove(g,pos,r)
end
function Duel.BanishUntil(g,pos,phase,id,phasect,phasenext,rc,r)
local e, tp = self_reference_effect, current_triggering_player
if aux.GetValueType(g)=="Card" then g=Group.FromCards(g) end
if not phase then phase=PHASE_END end
if not phasect then phasect=1 end
if not rc then rc=e:GetHandler() end
if not r then r=REASON_EFFECT end
local ct=Duel.Remove(g,pos,r|REASON_TEMPORARY)
if ct>0 then
local og=g:Filter(Card.IsLocation,nil,LOCATION_REMOVED)
if #og>0 then
og:KeepAlive()
local turnct,turnct2=0,phasect
local ph = phase&(PHASE_DRAW|PHASE_STANDBY|PHASE_MAIN1|PHASE_BATTLE_START|PHASE_BATTLE_STEP|PHASE_DAMAGE|PHASE_DAMAGE_CAL|PHASE_BATTLE|PHASE_MAIN2|PHASE_END)
local player = phase&(RESET_SELF_TURN|RESET_OPPO_TURN)
if (player==RESET_SELF_TURN and Duel.GetTurnPlayer()~=tp) or (player==RESET_OPPO_TURN and Duel.GetTurnPlayer()~=1-tp) then
turnct=1
elseif Duel.GetCurrentPhase()>ph then
turnct=1
end
if phasenext then
if Duel.GetCurrentPhase()==phase
and (player==0 or (player==RESET_SELF_TURN and Duel.GetTurnPlayer()==tp) or (player==RESET_OPPO_TURN and Duel.GetTurnPlayer()==1-tp)) then
turnct=turnct+1
turnct2=turnct2+1
end
end
for tc in aux.Next(og) do
tc:RegisterFlagEffect(id,RESET_EVENT|RESETS_STANDARD|RESET_PHASE|phase,EFFECT_FLAG_SET_AVAILABLE|EFFECT_FLAG_CLIENT_HINT,turnct2,0,STRING_TEMPORARILY_BANISHED)
end
local e1=Effect.CreateEffect(rc)
e1:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_PHASE|phase)
e1:SetReset(RESET_PHASE|phase,phasect)
e1:SetCountLimit(1)
e1:SetLabel(Duel.GetTurnCount()+turnct*phasect)
e1:SetLabelObject(og)
e1:SetCondition(aux.TimingCondition(ph,player))
e1:SetOperation(aux.ReturnLabelObjectToFieldOp(id))
Duel.RegisterEffect(e1,tp)
end
end
return ct
end
function Auxiliary.TimingCondition(phase,player)
return function(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()==phase and (player==0 or (player==RESET_SELF_TURN and Duel.GetTurnPlayer()==tp) or (player==RESET_OPPO_TURN and Duel.GetTurnPlayer()==1-tp))
and Duel.GetTurnCount()==e:GetLabel()
end
end
function Auxiliary.ReturnLabelObjectToFieldOp(id)
return function(e,tp,eg,ep,ev,re,r,rp)
local g=e:GetLabelObject()
local sg=g:Filter(Card.HasFlagEffect,nil,id)
local rg=Group.CreateGroup()
for p=tp,1-tp,1-2*tp do
local sg1=sg:Filter(Card.IsPreviousControler,nil,p)
if #sg1>0 then
local ft=Duel.GetLocationCount(p,LOCATION_MZONE)
if ft>0 then
if ft<#sg1 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD)
local tg=sg1:Select(tp,ft,ft,nil)
if #tg>0 then
rg:Merge(tg)
end
else else
local opt = loc1&(LOCATION_DECK+LOCATION_GRAVE)==0 and 2 or Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1)) rg:Merge(sg1)
if opt==0 then end
player = 1-p end
nloc1=nloc1&(LOCATION_DECK+LOCATION_GRAVE)
nloc2=0
elseif opt==1 then
nloc1 = nloc1&~(LOCATION_DECK+LOCATION_GRAVE)
end end
end end
if #rg>0 then
for tc in aux.Next(rg) do
Duel.ReturnToField(tc)
end end
end end
if Glitchy.UndefinedActionWarning then g:DeleteGroup()
Glitchy.UndefinedActionWarning = false
end end
end
return _SelectMatchingCard(player,f,pov,nloc1,nloc2,min,max,exc,...) function Duel.EquipAndRegisterLimit(p,be_equip,equip_to,...)
local res=Duel.Equip(p,be_equip,equip_to,...)
if res and equip_to:GetEquipGroup():IsContains(be_equip) then
local e1=Effect.CreateEffect(equip_to)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_OWNER_RELATE)
e1:SetCode(EFFECT_EQUIP_LIMIT)
e1:SetReset(RESET_EVENT|RESETS_STANDARD)
e1:SetValue(function(e,c)
return e:GetOwner()==c
end
)
be_equip:RegisterEffect(e1)
end
return res and equip_to:GetEquipGroup():IsContains(be_equip)
end
function Duel.EquipAndRegisterCustomLimit(f,p,be_equip,equip_to,...)
local res=Duel.Equip(p,be_equip,equip_to,...)
if res and equip_to:GetEquipGroup():IsContains(be_equip) then
local e1=Effect.CreateEffect(equip_to)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_OWNER_RELATE)
e1:SetCode(EFFECT_EQUIP_LIMIT)
e1:SetReset(RESET_EVENT|RESETS_STANDARD)
e1:SetValue(f)
be_equip:RegisterEffect(e1)
end
return res and equip_to:GetEquipGroup():IsContains(be_equip)
end
else function Card.Recreate(c,...)
return _SelectMatchingCard(p,f,pov,loc1,loc2,min,max,exc,...) local x={...}
if #x==0 then return end
local datalist={CARDDATA_CODE,CARDDATA_ALIAS,CARDDATA_SETCODE,CARDDATA_TYPE,CARDDATA_LEVEL,CARDDATA_ATTRIBUTE,CARDDATA_RACE,CARDDATA_ATTACK,CARDDATA_DEFENSE,CARDDATA_LSCALE,CARDDATA_RSCALE}
for i,newval in ipairs(x) do
if newval then
c:SetCardData(datalist[i],newval)
end
end end
end end
Duel.GetMatchingGroup = function(f,pov,loc1,loc2,exc,...) function Card.CheckNegateConjunction(c,e1,e2,e3)
local g = _GetMatchingGroup(f,pov,loc1,loc2,exc,...) return not c:IsImmuneToEffect(e1) and not c:IsImmuneToEffect(e2) and (not e3 or not c:IsImmuneToEffect(e3))
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then end
Glitchy.EnableTestChamber = true function Duel.Negate(tc,e,reset,notfield,forced)
Glitchy.TestChamberResult = 0 local rct=1
for tc in aux.Next(g) do if not reset then
f(tc,...) reset=0
elseif type(reset)=="table" then
rct=reset[2]
reset=reset[1]
end end
Glitchy.EnableTestChamber = false Duel.NegateRelatedChain(tc,RESET_TURN_SET)
Glitchy.TestChamberResultGroup[g] = Glitchy.TestChamberResult local e1=Effect.CreateEffect(e:GetHandler())
Glitchy.TestChamberResult = 0 e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_DISABLE)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+reset,rct)
tc:RegisterEffect(e1,forced)
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCode(EFFECT_DISABLE_EFFECT)
if not notfield then
e2:SetValue(RESET_TURN_SET)
end end
return g e2:SetReset(RESET_EVENT+RESETS_STANDARD+reset,rct)
tc:RegisterEffect(e2,forced)
if not notfield and tc:IsType(TYPE_TRAPMONSTER) then
local e3=Effect.CreateEffect(e:GetHandler())
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e3:SetCode(EFFECT_DISABLE_TRAPMONSTER)
e3:SetReset(RESET_EVENT+RESETS_STANDARD+reset,rct)
tc:RegisterEffect(e3,forced)
local res=tc:CheckNegateConjunction(e1,e2,e3)
if res then
Duel.AdjustInstantly(tc)
end
return e1,e2,e3,res
end
local res=tc:CheckNegateConjunction(e1,e2)
if res then
Duel.AdjustInstantly(tc)
end
return e1,e2,res
end
function Duel.NegateInGY(tc,e,reset)
if not reset then reset=0 end
Duel.NegateRelatedChain(tc,RESET_TURN_SET)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_DISABLE)
e1:SetReset(RESET_EVENT+RESETS_STANDARD_EXC_GRAVE+reset)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCode(EFFECT_DISABLE_EFFECT)
e2:SetReset(RESET_EVENT+RESETS_STANDARD_EXC_GRAVE+reset)
tc:RegisterEffect(e2)
return e1,e2
end
function Duel.PositionChange(c)
return Duel.ChangePosition(c,POS_FACEUP_DEFENSE,POS_FACEDOWN_DEFENSE,POS_FACEUP_ATTACK,POS_FACEUP_ATTACK)
end
function Duel.Search(g,tp,p)
if aux.GetValueType(g)=="Card" then g=Group.FromCards(g) end
local ct=Duel.SendtoHand(g,p,REASON_EFFECT)
local cg=g:Filter(aux.PLChk,nil,tp,LOCATION_HAND)
if #cg>0 then
Duel.ConfirmCards(1-tp,cg)
end
return ct,#cg,cg
end
function Duel.Bounce(g)
if aux.GetValueType(g)=="Card" then g=Group.FromCards(g) end
local ct=Duel.SendtoHand(g,nil,REASON_EFFECT)
local cg=g:Filter(aux.PLChk,nil,nil,LOCATION_HAND)
return ct,#cg,cg
end end
Group.Filter = function(g,f,exc,...) function Duel.ShuffleIntoDeck(g,p)
local new_g = _GroupFilter(g,f,exc,...) local ct=Duel.SendtoDeck(g,p,SEQ_DECKSHUFFLE,REASON_EFFECT)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then if ct>0 then
Glitchy.EnableTestChamber = true aux.AfterShuffle(g)
Glitchy.TestChamberResult = 0 if aux.GetValueType(g)=="Card" and aux.PLChk(g,p,LOCATION_DECK+LOCATION_EXTRA) then
for tc in aux.Next(g) do return 1
f(tc,...) elseif aux.GetValueType(g)=="Group" then
end return g:FilterCount(aux.PLChk,nil,p,LOCATION_DECK+LOCATION_EXTRA)
Glitchy.EnableTestChamber = false
Glitchy.TestChamberResultGroup[new_g] = Glitchy.TestChamberResult
if type(Glitchy.TestChamberResultGroup[g])=="number" then
Glitchy.TestChamberResultGroup[new_g] = Glitchy.TestChamberResultGroup[new_g] | Glitchy.TestChamberResultGroup[g]
end
Glitchy.TestChamberResult = 0
end
return new_g
end
Duel.SelectTarget = function(p,f,pov,loc1,loc2,min,max,exc,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then
local test_chamber = _GetMatchingGroup(f,pov,loc1,loc2,exc,...)
Glitchy.EnableTestChamber = true
Glitchy.TestChamberResult = 0
for tc in aux.Next(test_chamber) do
f(tc,...)
end
Glitchy.EnableTestChamber = false
local result = Glitchy.TestChamberResult
Glitchy.TestChamberResult = 0
local player = p
local nloc1,nloc2 = loc1,loc2
if p==self_reference_effect:GetHandlerPlayer() then
if Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then
local val=ce:GetValue()
if not val or val(ce,self_reference_effect,self_reference_tp) then
player = 1-p
break
end end
end end
return 0
end
function Duel.PlaceOnTopOfDeck(g,p)
local ct=Duel.SendtoDeck(g,p,SEQ_DECKTOP,REASON_EFFECT)
if ct>0 then
local og=g:Filter(Card.IsLocation,nil,LOCATION_DECK)
for pp=tp,1-tp,1-2*tp do
local dg=og:Filter(Card.IsControler,nil,pp)
if #dg>1 then
Duel.SortDecktop(p,pp,#dg)
end end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then
if loc1&~(LOCATION_DECK+LOCATION_GRAVE)==0 and loc2==0 then
player = 1-p
else
local opt = loc1&(LOCATION_DECK+LOCATION_GRAVE)==0 and 2 or Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1))
if opt==0 then
player = 1-p
nloc1=nloc1&(LOCATION_DECK+LOCATION_GRAVE)
nloc2=0
elseif opt==1 then
nloc1 = nloc1&~(LOCATION_DECK+LOCATION_GRAVE)
end end
return ct
end end
return 0
end
function Auxiliary.PLChk(c,p,loc,min)
if not min then min=1 end
if aux.GetValueType(c)=="Card" then
return (not p or c:IsControler(p)) and (not loc or c:IsLocation(loc))
elseif aux.GetValueType(c)=="Group" then
return c:IsExists(aux.PLChk,min,nil,p,loc)
else
return false
end end
end
function Auxiliary.AfterShuffle(g)
for p=0,1 do
if aux.PLChk(g,p,LOCATION_DECK) then
Duel.ShuffleDeck(p)
end end
if Glitchy.UndefinedActionWarning then
Glitchy.UndefinedActionWarning = false
end end
end
return _SelectTarget(player,f,pov,loc1,loc2,min,max,exc,...) --Battle Phase
function Card.IsCapableOfAttacking(c,tp)
if not tp then tp=Duel.GetTurnPlayer() end
return not c:IsForbidden() and not c:IsHasEffect(EFFECT_CANNOT_ATTACK) and not c:IsHasEffect(EFFECT_ATTACK_DISABLED) and not Duel.IsPlayerAffectedByEffect(tp,EFFECT_SKIP_BP)
end
else --Card Filters
return _SelectTarget(p,f,pov,loc1,loc2,min,max,exc,...) function Card.IsMonster(c,typ)
return c:IsType(TYPE_MONSTER) and (aux.GetValueType(typ)~="number" or c:IsType(typ))
end
function Card.IsSpell(c,typ)
return c:IsType(TYPE_SPELL) and (aux.GetValueType(typ)~="number" or c:IsType(typ))
end
function Card.IsTrap(c,typ)
return c:IsType(TYPE_TRAP) and (aux.GetValueType(typ)~="number" or c:IsType(typ))
end
function Card.IsNormalSpell(c)
return c:GetType()&(TYPE_SPELL|TYPE_CONTINUOUS|TYPE_RITUAL|TYPE_EQUIP|TYPE_QUICKPLAY|TYPE_FIELD)==TYPE_SPELL
end
function Card.IsNormalTrap(c)
return c:GetType()&(TYPE_TRAP|TYPE_CONTINUOUS|TYPE_COUNTER)==TYPE_TRAP
end
function Card.IsST(c,typ)
return c:IsType(TYPE_ST) and (aux.GetValueType(typ)~="number" or c:IsType(typ))
end
function Card.MonsterOrFacedown(c)
return c:IsMonster() or c:IsFacedown()
end
function Card.IsAppropriateEquipSpell(c,ec,tp)
return c:IsSpell(TYPE_EQUIP) and c:CheckEquipTarget(ec) and c:CheckUniqueOnField(tp) and not c:IsForbidden()
end
function Card.HasAttack(c)
return true
end
function Card.HasDefense(c)
return not c:IsOriginalType(TYPE_LINK)
end
function Card.HasHighest(c,stat,g,f)
if not g then g=Duel.GetFieldGroup(0,LOCATION_MZONE,LOCATION_MZONE):Filter(Card.IsFaceup,nil) end
local func = function(tc,val,fil)
return stat(tc)>val and (not fil or fil(tc))
end end
return not g:IsExists(func,1,c,stat(c),f)
end
function Card.HasLowest(c,stat,g,f)
if not g then g=Duel.GetFieldGroup(0,LOCATION_MZONE,LOCATION_MZONE):Filter(Card.IsFaceup,nil) end
local func = function(tc,val,fil)
return stat(tc)<val and (not fil or fil(tc))
end
return not g:IsExists(func,1,c,stat(c),f)
end
function Card.HasHighestATK(c,g,f)
return c:HasHighest(Card.GetAttack,g,f)
end
function Card.HasLowestATK(c,g,f)
return c:HasLowest(Card.GetAttack,g,f)
end
function Card.HasHighestDEF(c,g,f)
return c:HasHighest(Card.GetDefense,g,f)
end
function Card.HasLowestDEF(c,g,f)
return c:HasLowest(Card.GetDefense,g,f)
end end
Group.Select = function(g,p,min,max,exc) function Card.HasOriginalLevel(c)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and type(Glitchy.TestChamberResultGroup[g])=="number" then return not c:IsOriginalType(TYPE_XYZ+TYPE_LINK)
local result = Glitchy.TestChamberResultGroup[g] end
local player = p function Card.IsOriginalType(c,typ)
if p==self_reference_effect:GetHandlerPlayer() then return c:GetOriginalType()&typ>0
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then end
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do function Card.IsOriginalRace(c,rc)
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then return c:GetOriginalRace()&rc>0
local val=ce:GetValue() end
if not val or val(ce,self_reference_effect,self_reference_tp) then
player = 1-p function Card.HasRank(c)
break return c:IsType(TYPE_XYZ) or c:IsOriginalType(TYPE_XYZ) or c:IsHasEffect(EFFECT_ORIGINAL_LEVEL_RANK_DUALITY)
end
function Card.GetRating(c)
local list={false,false,false,false}
if c:HasLevel() then
list[1]=c:GetLevel()
end end
if c:IsOriginalType(TYPE_XYZ) then
list[2]=c:GetRank()
end end
if c:IsOriginalType(TYPE_LINK) then
list[3]=c:GetLink()
end end
if c:IsOriginalType(TYPE_TIMELEAP) then
list[4]=c:GetFuture()
end
return list
end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then function Card.IsRating(c,rtyp,...)
if not g:IsExists(function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,1,nil,p) then local x={...}
player = 1-p local lv=rtyp&RATING_LEVEL>0
else local rk=rtyp&RATING_RANK>0
local opt=Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1)) local link=rtyp&RATING_LINK>0
if opt==0 then local fut=rtyp&RATING_FUTURE>0
player = 1-p for i,n in ipairs(x) do
g = _GroupFilter(g,function(card,tp) return card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) and card:IsControler(tp) end,nil,p) if (lv and c:HasLevel() and c:IsLevel(n)) or (rk and c:HasRank() and c:IsRank(n)) or (link and c:IsOriginalType(TYPE_LINK) and c:IsLink(n))
else or (fut and c:IsOriginalType(TYPE_TIMELEAP) and c:IsFuture(n)) then
g = _GroupFilter(g,function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,nil,p) return true
end end
end end
return false
end
function Card.IsRatingAbove(c,rtyp,...)
local x={...}
local lv=rtyp&RATING_LEVEL>0
local rk=rtyp&RATING_RANK>0
local link=rtyp&RATING_LINK>0
local fut=rtyp&RATING_FUTURE>0
for i,n in ipairs(x) do
if (lv and c:HasLevel() and c:IsLevelAbove(n)) or (rk and c:HasRank() and c:IsRankAbove(n)) or (link and c:IsOriginalType(TYPE_LINK) and c:IsLinkAbove(n))
or (fut and c:IsOriginalType(TYPE_TIMELEAP) and c:IsFutureAbove(n)) then
return true
end end
end end
if Glitchy.UndefinedActionWarning then end
Glitchy.UndefinedActionWarning = false function Card.IsRatingBelow(c,rtyp,...)
local x={...}
local lv=rtyp&RATING_LEVEL>0
local rk=rtyp&RATING_RANK>0
local link=rtyp&RATING_LINK>0
local fut=rtyp&RATING_FUTURE>0
for i,n in ipairs(x) do
if (lv and c:HasLevel() and c:IsLevelBelow(n)) or (rk and c:HasRank() and c:IsRankBelow(n)) or (link and c:IsOriginalType(TYPE_LINK) and c:IsLinkBelow(n))
or (fut and c:IsOriginalType(TYPE_TIMELEAP) and c:IsFutureBelow(n)) then
return true
end end
return _GroupSelect(g,player,min,max,exc)
else
return _GroupSelect(g,p,min,max,exc)
end end
end end
Group.FilterSelect = function(g,p,f,min,max,exc,...) function Card.IsStat(c,rtyp,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then local x={...}
Glitchy.EnableTestChamber = true local atk=rtyp&STAT_ATTACK>0
Glitchy.TestChamberResult = 0 local def=rtyp&STAT_DEFENSE>0
for tc in aux.Next(g) do for i,n in ipairs(x) do
f(tc,...) if (not atk or (c:HasAttack() and c:IsAttack(n))) and (not def or (c:HasDefense() and c:IsDefense(n))) then
return true
end
end
return false
end
function Card.IsStatBelow(c,rtyp,...)
local x={...}
local atk=rtyp&STAT_ATTACK>0
local def=rtyp&STAT_DEFENSE>0
for i,n in ipairs(x) do
if (not atk or (c:HasAttack() and c:IsAttackBelow(n))) or (not def or (c:HasDefense() and c:IsDefenseBelow(n))) then
return true
end
end
return false
end
function Card.IsStatAbove(c,rtyp,...)
local x={...}
local atk=rtyp&STAT_ATTACK>0
local def=rtyp&STAT_DEFENSE>0
for i,n in ipairs(x) do
if (not atk or (c:HasAttack() and c:IsAttackAbove(n))) or (not def or (c:HasDefense() and c:IsDefenseAbove(n))) then
return true
end end
Glitchy.EnableTestChamber = false
if type(Glitchy.TestChamberResultGroup[g])=="number" then
Glitchy.TestChamberResult = Glitchy.TestChamberResult | Glitchy.TestChamberResultGroup[g]
end end
local result = Glitchy.TestChamberResult return false
Glitchy.TestChamberResult = 0 end
local player = p function Card.ByBattleOrEffect(c,f,p)
if p==self_reference_effect:GetHandlerPlayer() then return function(e,tp,eg,ep,ev,re,r,rp)
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then return c:IsReason(REASON_BATTLE) or c:IsReason(REASON_EFFECT) and (not f or re and f(re:GetHandler(),e,tp,eg,ep,ev,re,r,rp)) and (not p or rp~=(1-p))
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then
local val=ce:GetValue()
if not val or val(ce,self_reference_effect,self_reference_tp) then
player = 1-p
break
end end
end
function Card.IsContained(c,g,exc)
return g:IsContains(c) and (not exc or not exc:IsContains(c))
end
--Chain Info
function Duel.GetTargetParam()
return Duel.GetChainInfo(0,CHAININFO_TARGET_PARAM)
end
--Cloned Effects
function Effect.SpecialSummonEventClone(e,c,notreg)
local ex=e:Clone()
ex:SetCode(EVENT_SPSUMMON_SUCCESS)
if not notreg then
c:RegisterEffect(ex)
end
return ex
end
function Effect.FlipSummonEventClone(e,c,notreg)
local ex=e:Clone()
ex:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
if not notreg then
c:RegisterEffect(ex)
end end
return ex
end
function Effect.UpdateDefenseClone(e,c,notreg)
local ex=e:Clone()
ex:SetCode(EFFECT_UPDATE_DEFENSE)
if not notreg then
c:RegisterEffect(ex)
end end
return ex
end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then --Columns
if not g:IsExists(function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,1,nil,p) then function Card.GlitchyGetColumnGroup(c,left,right,without_center)
player = 1-p local left = (left and aux.GetValueType(left)=="number" and left>=0) and left or 0
local right = (right and aux.GetValueType(right)=="number" and right>=0) and right or 0
if left==0 and right==0 then
return c:GetColumnGroup()
else else
local opt=Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1)) local f = function(card,refc,val)
if opt==0 then local refseq
player = 1-p if refc:GetSequence()<5 then
g = _GroupFilter(g,function(card,tp) return card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) and card:IsControler(tp) end,nil,p) refseq=refc:GetSequence()
else else
g = _GroupFilter(g,function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,nil,p) if refc:GetSequence()==5 then
refseq = 1
elseif refc:GetSequence()==6 then
refseq = 3
end end
end end
if card:GetSequence()<5 then
if card:IsControler(refc:GetControler()) then
return math.abs(refseq-card:GetSequence())==val
else
return math.abs(refseq+card:GetSequence()-4)==val
end end
elseif card:GetSequence()==5 then
local seq = card:IsControler(refc:GetControler()) and 1 or 3
return math.abs(refseq-seq)==val
elseif card:GetSequence()==6 then
local seq = card:IsControler(refc:GetControler()) and 3 or 1
return math.abs(refseq-seq)==val
end end
if Glitchy.UndefinedActionWarning then
Glitchy.UndefinedActionWarning = false
end end
return _FilterSelect(g,player,f,min,max,exc,...) local lg=Duel.Group(f,c:GetControler(),LOCATION_MZONE+LOCATION_SZONE,LOCATION_MZONE+LOCATION_SZONE,nil,c,left)
local cg = without_center and Group.CreateGroup() or c:GetColumnGroup()
local rg=Duel.Group(f,c:GetControler(),LOCATION_MZONE+LOCATION_SZONE,LOCATION_MZONE+LOCATION_SZONE,nil,c,right)
cg:Merge(lg)
cg:Merge(rg)
return cg
end
end
--Exception
function Auxiliary.ActivateException(e,chk)
local c=e:GetHandler()
if c and e:IsHasType(EFFECT_TYPE_ACTIVATE) and not c:IsType(TYPE_CONTINUOUS+TYPE_FIELD+TYPE_EQUIP) and not c:IsHasEffect(EFFECT_REMAIN_FIELD) and (chk or c:IsRelateToChain(0)) then
return c
else else
return _FilterSelect(g,p,f,min,max,exc,...) return nil
end end
end end
function Auxiliary.ExceptThis(c)
if aux.GetValueType(c)=="Effect" then c=c:GetHandler() end
if c:IsRelateToChain() then return c else return nil end
end
Group.SelectUnselect = function(g,ug,p,...) --Descriptions
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and type(Glitchy.TestChamberResultGroup[g])=="number" then function Effect.Desc(e,id,...)
local result = Glitchy.TestChamberResultGroup[g] local x = {...}
local code = #x>0 and x[1] or e:GetOwner():GetOriginalCode()
return e:SetDescription(aux.Stringid(code,id))
end
function Card.AskPlayer(c,tp,desc)
local string = desc<=15 and aux.Stringid(c:GetOriginalCode(),desc) or desc
return Duel.SelectYesNo(tp,string)
end
local player = p function Auxiliary.Option(id,tp,desc,...)
if p==self_reference_effect:GetHandlerPlayer() then if id<2 then
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then id,tp=tp,id
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then
local val=ce:GetValue()
if not val or val(ce,self_reference_effect,self_reference_tp) then
player = 1-p
break
end
end
end end
local list={...}
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then local off=1
if not g:IsExists(function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,1,nil,p) then local ops={}
player = 1-p local opval={}
else local truect=1
local opt=Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1)) for ct,b in ipairs(list) do
if opt==0 then local check=b
player = 1-p local localid
g = _GroupFilter(g,function(card,tp) return card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) and card:IsControler(tp) end,nil,p) local localdesc
if aux.GetValueType(b)=="table" then
check=b[1]
if #b==3 then
localid=b[2]
localdesc=b[3]
else else
g = _GroupFilter(g,function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,nil,p) localid=false
end localdesc=b[2]
end end
else
localid=id
localdesc=desc+truect-1
truect=truect+1
end end
if check==true then
if localid then
ops[off]=aux.Stringid(localid,localdesc)
else
ops[off]=localdesc
end end
if Glitchy.UndefinedActionWarning then opval[off]=ct-1
Glitchy.UndefinedActionWarning = false off=off+1
end end
return _SelectUnselect(g,ug,player,...)
else
return _SelectUnselect(g,ug,p,...)
end end
local op=Duel.SelectOption(tp,table.unpack(ops))+1
local sel=opval[op]
Duel.Hint(HINT_OPSELECTED,1-tp,ops[op])
return sel
end end
Group.Merge = function(g,c) function Duel.RegisterHint(p,flag,reset,rct,id,desc)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and aux.GetValueType(c)=="Group" and type(Glitchy.TestChamberResultGroup[c])=="number" then if not reset then reset=PHASE_END end
if type(Glitchy.TestChamberResultGroup[g])~="number" then Glitchy.TestChamberResultGroup[g] = 0 end if not rct then rct=1 end
Glitchy.TestChamberResultGroup[g] = Glitchy.TestChamberResultGroup[g] + Glitchy.TestChamberResultGroup[c] return Duel.RegisterFlagEffect(p,flag,RESET_PHASE+reset,EFFECT_FLAG_CLIENT_HINT,rct,0,aux.Stringid(id,desc))
end
return _GroupMerge(g,c)
end end
Group.Clone = function(g,g2) --Excavate
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and type(Glitchy.TestChamberResultGroup[g2])=="number" then function Duel.IsPlayerCanExcavateAndSpecialSummon(tp)
if type(Glitchy.TestChamberResultGroup[g])~="number" then Glitchy.TestChamberResultGroup[g] = 0 end return Duel.IsPlayerCanSpecialSummon(tp) and not Duel.IsPlayerAffectedByEffect(tp,CARD_EHERO_BLAZEMAN)
Glitchy.TestChamberResultGroup[g] = Glitchy.TestChamberResultGroup[g] + Glitchy.TestChamberResultGroup[g2]
end
return _GroupClone(g,g2)
end end
Group.SelectSubGroup = function(g,tp,f,cancelable,min,max,...) --Filters
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then function Auxiliary.Filter(f,...)
Auxiliary.SubGroupCaptured=Group.CreateGroup()
local min=min or 1
local max=max or #g
local ext_params={...} local ext_params={...}
local sg=Group.CreateGroup() return aux.FilterBoolFunction(f,table.unpack(ext_params))
local fg=Duel.GrabSelectedCard() end
if #fg>max or min>max or #(g+fg)<min then return nil end function Auxiliary.BuildFilter(f,...)
for tc in aux.Next(fg) do local ext_params={...}
if type(Glitchy.TestChamberResultGroup[g])=="number" then return function(c)
Glitchy.TestChamberResultGroup[fg] = Glitchy.TestChamberResultGroup[g] for _,func in ipairs(ext_params) do
end if type(func)=="function" then
fg:SelectUnselect(sg,tp,false,false,min,max) if not func(c) then
end return false
sg:Merge(fg)
local finish=(#sg>=min and #sg<=max and f(sg,...))
while #sg<max do
local cg=Group.CreateGroup()
local eg=g:Clone()
for c in aux.Next(g-sg) do
if not cg:IsContains(c) then
if Auxiliary.CheckGroupRecursiveCapture(c,sg,eg,f,min,max,ext_params) then
cg:Merge(Auxiliary.SubGroupCaptured)
else
eg:RemoveCard(c)
end end
elseif type(func)=="table" then
if not func[1](c,func[2]) then
return false
end end
end end
cg:Sub(sg)
finish=(#sg>=min and #sg<=max and f(sg,...))
if #cg==0 then break end
local cancel=not finish and cancelable
if type(Glitchy.TestChamberResultGroup[g])=="number" then
Glitchy.TestChamberResultGroup[cg] = Glitchy.TestChamberResultGroup[g]
end end
local tc=cg:SelectUnselect(sg,tp,finish,cancel,min,max) return true
if not tc then break end
if not fg:IsContains(tc) then
if not sg:IsContains(tc) then
sg:AddCard(tc)
if #sg==max then finish=true end
else
sg:RemoveCard(tc)
end end
elseif cancelable then
return nil end
function Auxiliary.Faceup(f)
return function(c,...)
return (not f or f(c,...)) and c:IsFaceup()
end end
end
function Auxiliary.Facedown(f)
return function(c,...)
return (not f or f(c,...)) and c:IsFacedown()
end end
if finish then end
return sg function Auxiliary.FaceupFilter(f,...)
else local ext_params={...}
return nil return function(target)
return target:IsFaceup() and f(target,table.unpack(ext_params))
end end
else end
return _SelectSubGroup(g,tp,f,cancelable,min,max,...) function Auxiliary.ArchetypeFilter(set,f,...)
local ext_params={...}
return function(target)
return target:IsSetCard(set) and (not f or f(target,table.unpack(ext_params)))
end end
end end
function Auxiliary.MonsterFilter(typ,f,...)
Group.SelectSubGroupEach = function(g,tp,checks,cancelable,f,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then
if cancelable==nil then cancelable=false end
if f==nil then f=Auxiliary.TRUE end
local ct=#checks
local ext_params={...} local ext_params={...}
local sg=Group.CreateGroup() if type(typ)=="function" then
local finish=false if type(f)~="nil" then
while #sg<ct do table.insert(ext_params,1,f)
local cg=g:Filter(Auxiliary.CheckGroupRecursiveEach,sg,sg,g,f,checks,ext_params)
if #cg==0 then break end
if type(Glitchy.TestChamberResultGroup[g])=="number" then
Glitchy.TestChamberResultGroup[cg] = Glitchy.TestChamberResultGroup[g]
end
local tc=cg:SelectUnselect(sg,tp,false,cancelable,ct,ct)
if not tc then break end
if not sg:IsContains(tc) then
sg:AddCard(tc)
if #sg==ct then finish=true end
else
sg:Clear()
end end
f=typ
typ=nil
end end
if finish then return function(target)
return sg return target:IsMonster(typ) and (not f or f(target,table.unpack(ext_params)))
else
return nil
end end
end
else function Auxiliary.RaceFilter(race,f,...)
return _SelectSubGroupEach(g,tp,checks,cancelable,f,...) local ext_params={...}
return function(target)
return target:IsRace(race) and (not f or f(target,table.unpack(ext_params)))
end
end
function Auxiliary.STFilter(f,...)
local ext_params={...}
return function(target)
return target:IsST() and (not f or f(target,table.unpack(ext_params)))
end end
end end
Group.SelectWithSumEqual = function(g,p,f,acc,min,max,...) --Flag Effects
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and type(Glitchy.TestChamberResultGroup[g])=="number" then function Card.HasFlagEffect(c,id,...)
local result = Glitchy.TestChamberResultGroup[g] local flags={...}
if id then
table.insert(flags,id)
end
for _,flag in ipairs(flags) do
if c:GetFlagEffect(flag)>0 then
return true
end
end
local player = p return false
if p==self_reference_effect:GetHandlerPlayer() then end
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then function Duel.PlayerHasFlagEffect(p,id,...)
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do local flags={...}
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then if id then
local val=ce:GetValue() table.insert(flags,id)
if not val or val(ce,self_reference_effect,self_reference_tp) then
player = 1-p
break
end end
for _,flag in ipairs(flags) do
if Duel.GetFlagEffect(p,flag)>0 then
return true
end end
end end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then return false
if not g:IsExists(function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,1,nil,p) then end
player = 1-p function Card.UpdateFlagEffectLabel(c,id,ct)
else if not ct then ct=1 end
local opt=Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1)) return c:SetFlagEffectLabel(id,c:GetFlagEffectLabel(id)+ct)
if opt==0 then end
player = 1-p function Duel.UpdateFlagEffectLabel(p,id,ct)
g = _GroupFilter(g,function(card,tp) return card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) and card:IsControler(tp) end,nil,p) if not ct then ct=1 end
else return Duel.SetFlagEffectLabel(p,id,Duel.GetFlagEffectLabel(p,id)+ct)
g = _GroupFilter(g,function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,nil,p) end
function Card.HasFlagEffectLabel(c,id,val)
if not c:HasFlagEffect(id) then return false end
for _,label in ipairs({c:GetFlagEffectLabel(id)}) do
if label==val then
return true
end
end
return false
end
function Card.HasFlagEffectLabelLower(c,id,val)
if not c:HasFlagEffect(id) then return false end
for _,label in ipairs({c:GetFlagEffectLabel(id)}) do
if label<val then
return true
end end
end end
return false
end
function Card.HasFlagEffectLabelHigher(c,id,val)
if not c:HasFlagEffect(id) then return false end
for _,label in ipairs({c:GetFlagEffectLabel(id)}) do
if label>val then
return true
end end
end end
if Glitchy.UndefinedActionWarning then return false
Glitchy.UndefinedActionWarning = false end
function Duel.PlayerHasFlagEffectLabel(tp,id,val)
if Duel.GetFlagEffect(tp,id)==0 then return false end
for _,label in ipairs({Duel.GetFlagEffectLabel(tp,id)}) do
if label==val then
return true
end
end end
return false
end
return _SelectWithSumEqual(g,player,f,acc,min,max,...)
--Gain Effect
function Auxiliary.GainEffectType(c,oc,reset)
if not oc then oc=c end
if not reset then reset=0 end
if not c:IsType(TYPE_EFFECT) then
local e=Effect.CreateEffect(oc)
e:SetType(EFFECT_TYPE_SINGLE)
e:SetCode(EFFECT_ADD_TYPE)
e:SetValue(TYPE_EFFECT)
e:SetReset(RESET_EVENT+RESETS_STANDARD+reset)
c:RegisterEffect(e,true)
end
end
--Labels
function Effect.SetLabelPair(e,l1,l2)
if l1 and l2 then
e:SetLabel(l1,l2)
elseif l1 then
local _,o2=e:GetLabel()
e:SetLabel(l1,o2)
else else
return _SelectWithSumEqual(g,p,f,acc,min,max,...) local o1,_=e:GetLabel()
e:SetLabel(o1,l2)
end end
end end
function Effect.GetSpecificLabel(e,pos)
if not pos then pos=1 end
local tab={e:GetLabel()}
if #tab<pos then return end
return tab[pos]
end
Group.SelectWithSumGreater = function(g,p,f,acc,...) --LP
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and type(Glitchy.TestChamberResultGroup[g])=="number" then function Duel.LoseLP(p,val)
local result = Glitchy.TestChamberResultGroup[g] return Duel.SetLP(tp,Duel.GetLP(tp)-math.abs(val))
end
local player = p --Locations
if p==self_reference_effect:GetHandlerPlayer() then function Card.IsBanished(c,pos)
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then return c:IsLocation(LOCATION_REMOVED) and (not pos or c:IsPosition(pos))
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do end
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then function Card.IsInExtra(c,fu)
local val=ce:GetValue() return c:IsLocation(LOCATION_EXTRA) and (fu==nil or fu and c:IsFaceup() or not fu and c:IsFacedown())
if not val or val(ce,self_reference_effect,self_reference_tp) then end
player = 1-p function Card.IsInGY(c)
break return c:IsLocation(LOCATION_GRAVE)
end end
function Card.IsInMMZ(c)
return c:IsLocation(LOCATION_MZONE) and c:GetSequence()<5
end
function Card.IsInEMZ(c)
return c:IsLocation(LOCATION_MZONE) and c:GetSequence()>=5
end
function Card.IsInBackrow(c)
return c:IsLocation(LOCATION_SZONE) and c:GetSequence()<5
end
function Card.IsSequence(c,seq)
return c:GetSequence()==seq
end
function Card.IsSequenceBelow(c,seq)
return c:GetSequence()<=seq
end
function Card.IsSequenceAbove(c,seq)
return c:GetSequence()>=seq
end
function Card.IsInMainSequence(c)
return c:IsSequenceBelow(4)
end
function Card.IsSpellTrapOnField(c)
return not c:IsLocation(LOCATION_MZONE) or (c:IsFaceup() and c:IsST())
end
function Card.NotOnFieldOrFaceup(c)
return not c:IsOnField() or c:IsFaceup()
end
function Card.NotBanishedOrFaceup(c)
return not c:IsLocation(LOCATION_REMOVED) or c:IsFaceup()
end
function Card.NotInExtraOrFaceup(c)
return not c:IsLocation(LOCATION_EXTRA) or c:IsFaceup()
end
function Card.IsFusionSummoned(c)
return c:IsSummonType(SUMMON_TYPE_FUSION)
end
function Card.IsRitualSummoned(c)
return c:IsSummonType(SUMMON_TYPE_RITUAL)
end
function Card.IsSynchroSummoned(c)
return c:IsSummonType(SUMMON_TYPE_SYNCHRO)
end
function Card.IsXyzSummoned(c)
return c:IsSummonType(SUMMON_TYPE_XYZ)
end
function Card.IsPendulumSummoned(c)
return c:IsSummonType(SUMMON_TYPE_PENDULUM)
end
function Card.IsLinkSummoned(c)
return c:IsSummonType(SUMMON_TYPE_LINK)
end
function Card.IsPandemoniumSummoned(c)
return c:IsSummonType(SUMMON_TYPE_PANDEMONIUM)
end
function Card.IsTimeleapSummoned(c)
return c:IsSummonType(SUMMON_TYPE_TIMELEAP)
end
function Card.IsBigbangSummoned(c)
return c:IsSummonType(SUMMON_TYPE_BIGBANG)
end
function Card.IsDriveSummoned(c)
return c:IsSummonType(SUMMON_TYPE_DRIVE)
end
function Card.IsSelfSummoned(c)
return c:IsSummonType(SUMMON_TYPE_SPECIAL+1)
end
function Card.GetZone(c,tp)
local rzone = c:IsControler(tp) and (1 <<c:GetSequence()) or (1 << (16+c:GetSequence()))
if c:IsSequence(5,6) then
rzone = rzone | (c:IsControler(tp) and (1 << (16 + 11 - c:GetSequence())) or (1 << (11 - c:GetSequence())))
end end
return rzone
end
function Card.GetPreviousZone(c,tp)
local rzone = c:IsControler(tp) and (1 <<c:GetPreviousSequence()) or (1 << (16+c:GetPreviousSequence()))
if c:GetPreviousSequence()==5 or c:GetPreviousSequence()==6 then
rzone = rzone | (c:IsControler(tp) and (1 << (16 + 11 - c:GetPreviousSequence())) or (1 << (11 - c:GetPreviousSequence())))
end end
return rzone
end
function Duel.CheckPendulumZones(tp)
return Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1)
end
function Card.IsInLinkedZone(c,cc)
return cc:GetLinkedGroup():IsContains(c)
end
function Card.WasInLinkedZone(c,cc)
return cc:GetLinkedZone(c:GetPreviousControler())&c:GetPreviousZone()~=0
end
function Card.HasBeenInLinkedZone(c,cc)
return cc:GetLinkedGroup():IsContains(c) or (not c:IsLocation(LOCATION_MZONE) and cc:GetLinkedZone(c:GetPreviousControler())&c:GetPreviousZone()~=0)
end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then --Location Groups
if not g:IsExists(function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,1,nil,p) then function Duel.GetHand(p)
player = 1-p return Duel.GetFieldGroup(p,LOCATION_HAND,0)
else end
local opt=Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1)) function Duel.GetHandCount(p)
if opt==0 then return Duel.GetFieldGroupCount(p,LOCATION_HAND,0)
player = 1-p end
g = _GroupFilter(g,function(card,tp) return card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) and card:IsControler(tp) end,nil,p) function Duel.GetDeck(p)
return Duel.GetFieldGroup(p,LOCATION_DECK,0)
end
function Duel.GetDeckCount(p)
return Duel.GetFieldGroupCount(p,LOCATION_DECK,0)
end
function Duel.GetGY(p)
return Duel.GetFieldGroup(p,LOCATION_GY,0)
end
function Duel.GetGYCount(p)
return Duel.GetFieldGroupCount(p,LOCATION_GY,0)
end
function Duel.GetExtraDeck(p)
return Duel.GetFieldGroup(p,LOCATION_EXTRA,0)
end
function Duel.GetExtraDeckCount(p)
return Duel.GetFieldGroupCount(p,LOCATION_EXTRA,0)
end
function Duel.GetPendulums(p)
return Duel.GetFieldGroup(p,LOCATION_PZONE,0)
end
function Duel.GetPendulumsCount(p)
return Duel.GetFieldGroupCount(p,LOCATION_PZONE,0)
end
--Materials
function Auxiliary.GetMustMaterialGroup(p,eff)
return Duel.GetMustMaterial(p,eff)
end
--Normal Summon/set
function Card.IsSummonableOrSettable(c)
return c:IsSummonable(true,nil) or c:IsMSetable(true,nil)
end
function Duel.SummonOrSet(tp,tc,ignore_limit,min)
if not ignore_limit then ignore_limit=true end
if tc:IsSummonable(ignore_limit,min) and (not tc:IsMSetable(ignore_limit,min) or Duel.SelectPosition(tp,tc,POS_FACEUP_ATTACK|POS_FACEDOWN_DEFENSE)==POS_FACEUP_ATTACK) then
Duel.Summon(tp,tc,ignore_limit,min)
else else
g = _GroupFilter(g,function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,nil,p) Duel.MSet(tp,tc,ignore_limit,min)
end
end
--Set Monster/Spell/Trap
function Card.IsCanBeSet(c,e,tp,ignore_mzone,ignore_szone)
if c:IsMonster() then
return c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEDOWN_DEFENSE) and (not ignore_mzone or Duel.GetMZoneCount(tp)>0)
elseif c:IsST() then
return c:IsSSetable(ignore_szone)
end
end
function Duel.Set(tp,g)
if aux.GetValueType(g)=="Card" then g=Group.FromCards(g) end
local ct=0
local mg=g:Filter(Card.IsMonster,nil)
if #mg>0 and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then
for tc in aux.Next(mg) do
if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEDOWN_DEFENSE) then
Duel.ConfirmCards(1-tp,tc)
end end
end end
end end
local sg=g:Filter(Card.IsST,nil)
if #sg>0 then
for tc in aux.Next(sg) do
if tc:IsType(TYPE_FIELD) or Duel.GetLocationCount(tp,LOCATION_SZONE)>0 then
ct=ct+Duel.SSet(tp,tc)
end end
if Glitchy.UndefinedActionWarning then
Glitchy.UndefinedActionWarning = false
end end
end
ct=ct+Duel.SpecialSummonComplete()
return ct
end
return _SelectWithSumGreater(g,player,f,acc,...) --Once per turn
function Effect.OPT(e,ct)
if not ct then ct=1 end
return e:SetCountLimit(ct)
end
else if not Auxiliary.HOPTTracker then
return _SelectWithSumGreater(g,p,f,acc,...) Auxiliary.HOPTTracker={}
end
end end
function Effect.HOPT(e,oath)
if not e:GetOwner() then return end
local c=e:GetOwner()
local cid=c:GetOriginalCode()
if not aux.HOPTTracker[c] then
aux.HOPTTracker[c]=-1
end
aux.HOPTTracker[c]=aux.HOPTTracker[c]+1
if type(aux.HOPTTracker[c])=="number" then
cid=cid+aux.HOPTTracker[c]*100
end
local flag=0
if oath then
flag=flag|EFFECT_COUNT_CODE_OATH
end
--Glitchylib imports return e:SetCountLimit(1,cid+flag)
function Auxiliary.Option(id,tp,desc,...) end
local list={...} function Effect.SHOPT(e,oath)
local off=1 if not e:GetOwner() then return end
local ops={} local c=e:GetOwner()
local opval={} local cid=c:GetOriginalCode()
local truect=1 if not aux.HOPTTracker[c] then
for ct,b in ipairs(list) do aux.HOPTTracker[c]=0
local check=b
local localid=id
local localdesc=desc+truect-1
if aux.GetValueType(b)=="table" then
check=b[1]
localid=b[2]
localdesc=b[3]
else
truect=truect+1
end end
if check==true then if type(aux.HOPTTracker[c])=="number" then
ops[off]=aux.Stringid(localid,localdesc) cid=cid+aux.HOPTTracker[c]*100
opval[off]=ct-1
off=off+1
end end
local flag=0
if oath then
flag=flag|EFFECT_COUNT_CODE_OATH
end end
local op=Duel.SelectOption(tp,table.unpack(ops))+1
local sel=opval[op] return e:SetCountLimit(1,cid+flag)
Duel.Hint(HINT_OPSELECTED,1-tp,ops[op])
return sel
end end
function Duel.Attach(c,xyz) --Phases
if aux.GetValueType(c)=="Card" then function Duel.IsDrawPhase(tp)
local og=c:GetOverlayGroup() return (not tp or Duel.GetTurnPlayer()==tp) and Duel.GetCurrentPhase()==PHASE_DRAW
if og:GetCount()>0 then end
Duel.SendtoGrave(og,REASON_RULE) function Duel.IsStandbyPhase(tp)
return (not tp or Duel.GetTurnPlayer()==tp) and Duel.GetCurrentPhase()==PHASE_STANDBY
end
function Duel.IsMainPhase(tp,ct)
return (not tp or Duel.GetTurnPlayer()==tp)
and (not ct and (Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2) or ct==1 and Duel.GetCurrentPhase()==PHASE_MAIN1 or ct==2 and Duel.GetCurrentPhase()==PHASE_MAIN2)
end
function Duel.IsBattlePhase(tp)
local ph=Duel.GetCurrentPhase()
return (not tp or Duel.GetTurnPlayer()==tp) and ph>=PHASE_BATTLE_START and ph<=PHASE_BATTLE
end
function Duel.IsEndPhase(tp)
return (not tp or Duel.GetTurnPlayer()==tp) and Duel.GetCurrentPhase()==PHASE_END
end
--PositionChange
function Card.IsCanTurnSetGlitchy(c)
if c:IsPosition(POS_FACEDOWN_DEFENSE) then return false end
if not c:IsPosition(POS_FACEDOWN_ATTACK) then
return c:IsCanTurnSet()
else
return not c:IsType(TYPE_LINK|TYPE_TOKEN) and not c:IsHasEffect(EFFECT_CANNOT_TURN_SET) and not Duel.IsPlayerAffectedByEffect(tp,EFFECT_CANNOT_TURN_SET)
end end
Duel.Overlay(xyz,Group.FromCards(c)) end
return xyz:GetOverlayGroup():IsContains(c)
elseif aux.GetValueType(c)=="Group" then --Previous
for tc in aux.Next(c) do function Card.IsPreviousCodeOnField(c,code,...)
local og=tc:GetOverlayGroup() local codes={...}
if og:GetCount()>0 then table.insert(codes,1,code)
Duel.SendtoGrave(og,REASON_RULE) local precodes={c:GetPreviousCodeOnField()}
for _,prename in ipairs(precodes) do
for _,name in ipairs(codes) do
if prename==name then
return true
end end
end end
Duel.Overlay(xyz,c)
return c:FilterCount(function (card,group) return group:IsContains(card) end, nil, xyz:GetOverlayGroup())
end end
return false
end end
function Duel.Negate(tc,e,reset,notfield,forced) function Card.IsPreviousTypeOnField(c,typ)
if not reset then reset=0 end return c:GetPreviousTypeOnField()&typ==typ
Duel.NegateRelatedChain(tc,RESET_TURN_SET) end
local e1=Effect.CreateEffect(e:GetHandler()) function Card.IsPreviousLevelOnField(c,lv)
return c:GetPreviousLevelOnField()==lv
end
function Card.IsPreviousRankOnField(c,lv)
return c:GetPreviousRankOnField()==lv
end
function Card.IsPreviousAttributeOnField(c,att)
return c:GetPreviousAttributeOnField()&att==att
end
function Card.IsPreviousRaceOnField(c,rac)
return c:GetPreviousRaceOnField()&rac==rac
end
function Card.IsPreviousAttackOnField(c,atk)
return c:GetPreviousAttackOnField()==atk
end
function Card.IsPreviousDefenseOnField(c,def)
return c:GetPreviousDefenseOnField()==def
end
--Remain on field
function Auxiliary.RemainOnFieldCost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local c=e:GetHandler()
local cid=Duel.GetChainInfo(0,CHAININFO_CHAIN_ID)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE) e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_REMAIN_FIELD)
e1:SetProperty(EFFECT_FLAG_OATH)
e1:SetReset(RESET_CHAIN)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_CHAIN_DISABLED)
e2:SetOperation(aux.RemainOnFieldCostFunction)
e2:SetLabel(cid)
e2:SetReset(RESET_CHAIN)
Duel.RegisterEffect(e2,tp)
end
function Auxiliary.RemainOnFieldCostFunction(e,tp,eg,ep,ev,re,r,rp)
local cid=Duel.GetChainInfo(ev,CHAININFO_CHAIN_ID)
if cid~=e:GetLabel() then return end
if e:GetOwner():IsRelateToChain(ev) then
e:GetOwner():CancelToGrave(false)
end
end
--Location Check
function Auxiliary.AddThisCardBanishedAlreadyCheck(c)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_REMOVE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_DISABLE) e1:SetOperation(Auxiliary.ThisCardInGraveAlreadyCheckOperation)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+reset) c:RegisterEffect(e1)
tc:RegisterEffect(e1,forced) return e1
local e2=Effect.CreateEffect(e:GetHandler()) end
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) --Glitchylib_cond imports
e2:SetCode(EFFECT_DISABLE_EFFECT) --Turn/Phase Conditions
if not notfield then function Auxiliary.DrawPhaseCond(tp)
e2:SetValue(RESET_TURN_SET) return function(e,p)
local tp = (tp==0) and p or (tp==1) and 1-p or nil
return Duel.IsDrawPhase(tp)
end end
e2:SetReset(RESET_EVENT+RESETS_STANDARD+reset) end
tc:RegisterEffect(e2,forced) function Auxiliary.StandbyPhaseCond(tp)
if not notfield and tc:IsType(TYPE_TRAPMONSTER) then return function(e,p)
local e=Effect.CreateEffect(e:GetHandler()) local tp = (tp==0) and p or (tp==1) and 1-p or nil
e:SetType(EFFECT_TYPE_SINGLE) return Duel.IsStandbyPhase(tp)
e:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e:SetCode(EFFECT_DISABLE_TRAPMONSTER)
e:SetReset(RESET_EVENT+RESETS_STANDARD+reset)
tc:RegisterEffect(e,forced)
return e1,e2,e
end end
return e1,e2
end end
function Duel.UpdateFlagEffectLabel(p,id,ct) function Auxiliary.MainPhaseCond(tp,ct)
if not ct then ct=1 end return function(e,p)
return Duel.SetFlagEffectLabel(p,id,Duel.GetFlagEffectLabel(p,id)+ct) local tp = (tp==0) and p or (tp==1) and 1-p or nil
return Duel.IsMainPhase(tp,ct)
end
end
function Auxiliary.BattlePhaseCond(tp)
return function(e,p)
local tp = (tp==0) and p or (tp==1) and 1-p or nil
return Duel.IsBattlePhase(tp)
end
end
function Auxiliary.MainOrBattlePhaseCond(tp,ct)
return function(e,p)
local tp = (tp==0) and p or (tp==1) and 1-p or nil
return Duel.IsMainPhase(tp,ct) or Duel.IsBattlePhase(tp)
end
end
function Auxiliary.EndPhaseCond(tp)
return function(e,p)
local tp = (tp==0) and p or (tp==1) and 1-p or nil
return Duel.IsEndPhase(tp)
end
end
function Auxiliary.ExceptOnDamageStep()
return Auxiliary.ExceptOnDamageCalc()
end
function Auxiliary.ExceptOnDamageCalc()
return Duel.GetCurrentPhase()~=PHASE_DAMAGE or not Duel.IsDamageCalculated()
end
function Auxiliary.TurnPlayerCond(tp)
return function(e,p)
if not p then p=e:GetHandlerPlayer() end
local tp = (not tp or tp==0) and p or 1-p
return Duel.GetTurnPlayer()==tp
end
end
--Glitchylib_cost imports
function Auxiliary.LabelCost(e,tp,eg,ep,ev,re,r,rp,chk)
e:SetLabel(1)
if chk==0 then return true end
end end
--Other Imports --Other Imports
function Card.HasLevel(c) function Card.HasLevel(c,general)
if c:IsType(TYPE_MONSTER) then if c:IsType(TYPE_MONSTER) then
return (c:GetType()&TYPE_LINK~=TYPE_LINK and c:GetType()&TYPE_XYZ~=TYPE_XYZ) and not c:IsStatus(STATUS_NO_LEVEL) return ((c:GetType()&TYPE_LINK~=TYPE_LINK and c:GetType()&TYPE_XYZ~=TYPE_XYZ)) and not c:IsStatus(STATUS_NO_LEVEL)
elseif c:IsOriginalType(TYPE_MONSTER) then elseif general and c:IsOriginalType(TYPE_MONSTER) then
return not (c:IsOriginalType(TYPE_XYZ+TYPE_LINK) or c:IsStatus(STATUS_NO_LEVEL)) return not (c:IsOriginalType(TYPE_XYZ+TYPE_LINK) or c:IsStatus(STATUS_NO_LEVEL))
end end
return false return false
...@@ -608,6 +1379,20 @@ function Card.HasDefense(c) ...@@ -608,6 +1379,20 @@ function Card.HasDefense(c)
return not c:IsOriginalType(TYPE_LINK) return not c:IsOriginalType(TYPE_LINK)
end end
function Duel.IgnoreActionCheck(f,...)
Duel.DisableActionCheck(true)
local cr=coroutine.create(f)
local ret={}
while coroutine.status(cr)~="dead" do
local sret={coroutine.resume(cr,...)}
for i=2,#sret do
table.insert(ret,sret[i])
end
end
Duel.DisableActionCheck(false)
return table.unpack(ret)
end
--EFFECT TABLES --EFFECT TABLES
--Global Card Effect Table --Global Card Effect Table
if not global_card_effect_table_global_check then if not global_card_effect_table_global_check then
......
Glitchy = Glitchy or {}
EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER = 33720071
EFFECT_UTTER_CONFUSION_CONFIDENCE = 33720072
Glitchy.EnableTestChamber = false
Glitchy.TestChamberResult = 0
Glitchy.TestChamberResultGroup = {}
Glitchy.UndefinedActionWarning = false
GLITCHY_ENABLE_TEST_CHAMBER = 33720071
TEST_CHAMBER_TARGET = 0x1
TEST_CHAMBER_TOHAND = 0x2
--Internal Archetypes
ARCHE_UTTER_CONFUSION = {33720051,33720052,33720053,33720070,33720071,33720072,33720073,33720074}
--TEST CHAMBER MECHANIC (necessary for UTTER CONFUSION - CONFIDENCE)
local _Hint, _IsCanBeEffectTarget, _IsAbleToHand, _IsAbleToHandAsCost, _SelectMatchingCard, _SelectTarget, _GetMatchingGroup, _GroupFilter, _GroupSelect, _FilterSelect, _SelectUnselect, _GroupMerge, _GroupClone, _SelectSubGroup,
_SelectSubGroupEach, _SelectWithSumEqual, _SelectWithSumGreater =
Duel.Hint, Card.IsCanBeEffectTarget, Card.IsAbleToHand, Card.IsAbleToHandAsCost, Duel.SelectMatchingCard, Duel.SelectTarget, Duel.GetMatchingGroup, Group.Filter, Group.Select, Group.FilterSelect, Group.SelectUnselect, Group.Merge, Group.Clone,
Group.SelectSubGroup, Group.SelectSubGroupEach, Group.SelectWithSumEqual, Group.SelectWithSumGreater
Duel.Hint = function(hinttype,p,hint)
if hint==HINTMSG_OPERATECARD then
Glitchy.UndefinedActionWarning = true
end
return _Hint(hinttype,p,hint)
end
Card.IsCanBeEffectTarget = function(c,e)
if Glitchy.EnableTestChamber and Glitchy.TestChamberResult&TEST_CHAMBER_TARGET==0 then
Glitchy.TestChamberResult = Glitchy.TestChamberResult | TEST_CHAMBER_TARGET
end
return _IsCanBeEffectTarget(c,e)
end
Card.IsAbleToHand = function(c,...)
local x = {...}
local p = x[1]
if Glitchy.EnableTestChamber and Glitchy.TestChamberResult&TEST_CHAMBER_TOHAND==0 and (not p or p==self_reference_effect) then
Glitchy.TestChamberResult = Glitchy.TestChamberResult | TEST_CHAMBER_TOHAND
end
return _IsAbleToHand(c,...)
end
Card.IsAbleToHandAsCost = function(c)
if Glitchy.EnableTestChamber and Glitchy.TestChamberResult&TEST_CHAMBER_TOHAND==0 then
Glitchy.TestChamberResult = Glitchy.TestChamberResult | TEST_CHAMBER_TOHAND
end
return _IsAbleToHandAsCost(c)
end
Duel.SelectMatchingCard = function(p,f,pov,loc1,loc2,min,max,exc,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then
local test_chamber = _GetMatchingGroup(f,pov,loc1,loc2,exc,...)
Glitchy.EnableTestChamber = true
Glitchy.TestChamberResult = 0
for tc in aux.Next(test_chamber) do
f(tc,...)
end
Glitchy.EnableTestChamber = false
local result = Glitchy.TestChamberResult
Glitchy.TestChamberResult = 0
local player = p
local nloc1,nloc2 = loc1,loc2
if p==self_reference_effect:GetHandlerPlayer() then
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then
player = 1-p
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then
if loc1&~(LOCATION_DECK+LOCATION_GRAVE)==0 and loc2==0 then
player = 1-p
else
local opt = loc1&(LOCATION_DECK+LOCATION_GRAVE)==0 and 2 or Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1))
if opt==0 then
player = 1-p
nloc1=nloc1&(LOCATION_DECK+LOCATION_GRAVE)
nloc2=0
elseif opt==1 then
nloc1 = nloc1&~(LOCATION_DECK+LOCATION_GRAVE)
end
end
end
end
if Glitchy.UndefinedActionWarning then
Glitchy.UndefinedActionWarning = false
end
return _SelectMatchingCard(player,f,pov,nloc1,nloc2,min,max,exc,...)
else
return _SelectMatchingCard(p,f,pov,loc1,loc2,min,max,exc,...)
end
end
Duel.GetMatchingGroup = function(f,pov,loc1,loc2,exc,...)
local g = _GetMatchingGroup(f,pov,loc1,loc2,exc,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then
Glitchy.EnableTestChamber = true
Glitchy.TestChamberResult = 0
for tc in aux.Next(g) do
f(tc,...)
end
Glitchy.EnableTestChamber = false
Glitchy.TestChamberResultGroup[g] = Glitchy.TestChamberResult
Glitchy.TestChamberResult = 0
end
return g
end
Group.Filter = function(g,f,exc,...)
local new_g = _GroupFilter(g,f,exc,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then
Glitchy.EnableTestChamber = true
Glitchy.TestChamberResult = 0
for tc in aux.Next(g) do
f(tc,...)
end
Glitchy.EnableTestChamber = false
Glitchy.TestChamberResultGroup[new_g] = Glitchy.TestChamberResult
if type(Glitchy.TestChamberResultGroup[g])=="number" then
Glitchy.TestChamberResultGroup[new_g] = Glitchy.TestChamberResultGroup[new_g] | Glitchy.TestChamberResultGroup[g]
end
Glitchy.TestChamberResult = 0
end
return new_g
end
Duel.SelectTarget = function(p,f,pov,loc1,loc2,min,max,exc,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then
local test_chamber = _GetMatchingGroup(f,pov,loc1,loc2,exc,...)
Glitchy.EnableTestChamber = true
Glitchy.TestChamberResult = 0
for tc in aux.Next(test_chamber) do
f(tc,...)
end
Glitchy.EnableTestChamber = false
local result = Glitchy.TestChamberResult
Glitchy.TestChamberResult = 0
local player = p
local nloc1,nloc2 = loc1,loc2
if p==self_reference_effect:GetHandlerPlayer() then
if Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then
local val=ce:GetValue()
if not val or val(ce,self_reference_effect,self_reference_tp) then
player = 1-p
break
end
end
end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then
if loc1&~(LOCATION_DECK+LOCATION_GRAVE)==0 and loc2==0 then
player = 1-p
else
local opt = loc1&(LOCATION_DECK+LOCATION_GRAVE)==0 and 2 or Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1))
if opt==0 then
player = 1-p
nloc1=nloc1&(LOCATION_DECK+LOCATION_GRAVE)
nloc2=0
elseif opt==1 then
nloc1 = nloc1&~(LOCATION_DECK+LOCATION_GRAVE)
end
end
end
end
if Glitchy.UndefinedActionWarning then
Glitchy.UndefinedActionWarning = false
end
return _SelectTarget(player,f,pov,loc1,loc2,min,max,exc,...)
else
return _SelectTarget(p,f,pov,loc1,loc2,min,max,exc,...)
end
end
Group.Select = function(g,p,min,max,exc)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and type(Glitchy.TestChamberResultGroup[g])=="number" then
local result = Glitchy.TestChamberResultGroup[g]
local player = p
if p==self_reference_effect:GetHandlerPlayer() then
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then
local val=ce:GetValue()
if not val or val(ce,self_reference_effect,self_reference_tp) then
player = 1-p
break
end
end
end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then
if not g:IsExists(function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,1,nil,p) then
player = 1-p
else
local opt=Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1))
if opt==0 then
player = 1-p
g = _GroupFilter(g,function(card,tp) return card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) and card:IsControler(tp) end,nil,p)
else
g = _GroupFilter(g,function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,nil,p)
end
end
end
end
if Glitchy.UndefinedActionWarning then
Glitchy.UndefinedActionWarning = false
end
return _GroupSelect(g,player,min,max,exc)
else
return _GroupSelect(g,p,min,max,exc)
end
end
Group.FilterSelect = function(g,p,f,min,max,exc,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then
Glitchy.EnableTestChamber = true
Glitchy.TestChamberResult = 0
for tc in aux.Next(g) do
f(tc,...)
end
Glitchy.EnableTestChamber = false
if type(Glitchy.TestChamberResultGroup[g])=="number" then
Glitchy.TestChamberResult = Glitchy.TestChamberResult | Glitchy.TestChamberResultGroup[g]
end
local result = Glitchy.TestChamberResult
Glitchy.TestChamberResult = 0
local player = p
if p==self_reference_effect:GetHandlerPlayer() then
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then
local val=ce:GetValue()
if not val or val(ce,self_reference_effect,self_reference_tp) then
player = 1-p
break
end
end
end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then
if not g:IsExists(function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,1,nil,p) then
player = 1-p
else
local opt=Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1))
if opt==0 then
player = 1-p
g = _GroupFilter(g,function(card,tp) return card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) and card:IsControler(tp) end,nil,p)
else
g = _GroupFilter(g,function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,nil,p)
end
end
end
end
if Glitchy.UndefinedActionWarning then
Glitchy.UndefinedActionWarning = false
end
return _FilterSelect(g,player,f,min,max,exc,...)
else
return _FilterSelect(g,p,f,min,max,exc,...)
end
end
Group.SelectUnselect = function(g,ug,p,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and type(Glitchy.TestChamberResultGroup[g])=="number" then
local result = Glitchy.TestChamberResultGroup[g]
local player = p
if p==self_reference_effect:GetHandlerPlayer() then
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then
local val=ce:GetValue()
if not val or val(ce,self_reference_effect,self_reference_tp) then
player = 1-p
break
end
end
end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then
if not g:IsExists(function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,1,nil,p) then
player = 1-p
else
local opt=Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1))
if opt==0 then
player = 1-p
g = _GroupFilter(g,function(card,tp) return card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) and card:IsControler(tp) end,nil,p)
else
g = _GroupFilter(g,function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,nil,p)
end
end
end
end
if Glitchy.UndefinedActionWarning then
Glitchy.UndefinedActionWarning = false
end
return _SelectUnselect(g,ug,player,...)
else
return _SelectUnselect(g,ug,p,...)
end
end
Group.Merge = function(g,c)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and aux.GetValueType(c)=="Group" and type(Glitchy.TestChamberResultGroup[c])=="number" then
if type(Glitchy.TestChamberResultGroup[g])~="number" then Glitchy.TestChamberResultGroup[g] = 0 end
Glitchy.TestChamberResultGroup[g] = Glitchy.TestChamberResultGroup[g] + Glitchy.TestChamberResultGroup[c]
end
return _GroupMerge(g,c)
end
Group.Clone = function(g,g2)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and type(Glitchy.TestChamberResultGroup[g2])=="number" then
if type(Glitchy.TestChamberResultGroup[g])~="number" then Glitchy.TestChamberResultGroup[g] = 0 end
Glitchy.TestChamberResultGroup[g] = Glitchy.TestChamberResultGroup[g] + Glitchy.TestChamberResultGroup[g2]
end
return _GroupClone(g,g2)
end
Group.SelectSubGroup = function(g,tp,f,cancelable,min,max,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then
Auxiliary.SubGroupCaptured=Group.CreateGroup()
local min=min or 1
local max=max or #g
local ext_params={...}
local sg=Group.CreateGroup()
local fg=Duel.GrabSelectedCard()
if #fg>max or min>max or #(g+fg)<min then return nil end
for tc in aux.Next(fg) do
if type(Glitchy.TestChamberResultGroup[g])=="number" then
Glitchy.TestChamberResultGroup[fg] = Glitchy.TestChamberResultGroup[g]
end
fg:SelectUnselect(sg,tp,false,false,min,max)
end
sg:Merge(fg)
local finish=(#sg>=min and #sg<=max and f(sg,...))
while #sg<max do
local cg=Group.CreateGroup()
local eg=g:Clone()
for c in aux.Next(g-sg) do
if not cg:IsContains(c) then
if Auxiliary.CheckGroupRecursiveCapture(c,sg,eg,f,min,max,ext_params) then
cg:Merge(Auxiliary.SubGroupCaptured)
else
eg:RemoveCard(c)
end
end
end
cg:Sub(sg)
finish=(#sg>=min and #sg<=max and f(sg,...))
if #cg==0 then break end
local cancel=not finish and cancelable
if type(Glitchy.TestChamberResultGroup[g])=="number" then
Glitchy.TestChamberResultGroup[cg] = Glitchy.TestChamberResultGroup[g]
end
local tc=cg:SelectUnselect(sg,tp,finish,cancel,min,max)
if not tc then break end
if not fg:IsContains(tc) then
if not sg:IsContains(tc) then
sg:AddCard(tc)
if #sg==max then finish=true end
else
sg:RemoveCard(tc)
end
elseif cancelable then
return nil
end
end
if finish then
return sg
else
return nil
end
else
return _SelectSubGroup(g,tp,f,cancelable,min,max,...)
end
end
Group.SelectSubGroupEach = function(g,tp,checks,cancelable,f,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 then
if cancelable==nil then cancelable=false end
if f==nil then f=Auxiliary.TRUE end
local ct=#checks
local ext_params={...}
local sg=Group.CreateGroup()
local finish=false
while #sg<ct do
local cg=g:Filter(Auxiliary.CheckGroupRecursiveEach,sg,sg,g,f,checks,ext_params)
if #cg==0 then break end
if type(Glitchy.TestChamberResultGroup[g])=="number" then
Glitchy.TestChamberResultGroup[cg] = Glitchy.TestChamberResultGroup[g]
end
local tc=cg:SelectUnselect(sg,tp,false,cancelable,ct,ct)
if not tc then break end
if not sg:IsContains(tc) then
sg:AddCard(tc)
if #sg==ct then finish=true end
else
sg:Clear()
end
end
if finish then
return sg
else
return nil
end
else
return _SelectSubGroupEach(g,tp,checks,cancelable,f,...)
end
end
Group.SelectWithSumEqual = function(g,p,f,acc,min,max,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and type(Glitchy.TestChamberResultGroup[g])=="number" then
local result = Glitchy.TestChamberResultGroup[g]
local player = p
if p==self_reference_effect:GetHandlerPlayer() then
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then
local val=ce:GetValue()
if not val or val(ce,self_reference_effect,self_reference_tp) then
player = 1-p
break
end
end
end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then
if not g:IsExists(function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,1,nil,p) then
player = 1-p
else
local opt=Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1))
if opt==0 then
player = 1-p
g = _GroupFilter(g,function(card,tp) return card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) and card:IsControler(tp) end,nil,p)
else
g = _GroupFilter(g,function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,nil,p)
end
end
end
end
if Glitchy.UndefinedActionWarning then
Glitchy.UndefinedActionWarning = false
end
return _SelectWithSumEqual(g,player,f,acc,min,max,...)
else
return _SelectWithSumEqual(g,p,f,acc,min,max,...)
end
end
Group.SelectWithSumGreater = function(g,p,f,acc,...)
if Duel.GetFlagEffect(p,GLITCHY_ENABLE_TEST_CHAMBER)>0 and type(Glitchy.TestChamberResultGroup[g])=="number" then
local result = Glitchy.TestChamberResultGroup[g]
local player = p
if p==self_reference_effect:GetHandlerPlayer() then
if result&TEST_CHAMBER_TARGET>0 and Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER) then
for _,ce in ipairs({Duel.IsPlayerAffectedByEffect(p,EFFECT_GLITCHY_CHANGE_TARGETING_PLAYER)}) do
if ce and aux.GetValueType(ce)=="Effect" and ce.SetLabel then
local val=ce:GetValue()
if not val or val(ce,self_reference_effect,self_reference_tp) then
player = 1-p
break
end
end
end
elseif result&TEST_CHAMBER_TOHAND>0 and not Glitchy.UndefinedActionWarning and Duel.IsPlayerAffectedByEffect(p,EFFECT_UTTER_CONFUSION_CONFIDENCE) then
if not g:IsExists(function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,1,nil,p) then
player = 1-p
else
local opt=Duel.SelectOption(p,aux.Stringid(33720071,0),aux.Stringid(33720071,1))
if opt==0 then
player = 1-p
g = _GroupFilter(g,function(card,tp) return card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) and card:IsControler(tp) end,nil,p)
else
g = _GroupFilter(g,function(card,tp) return not card:IsLocation(LOCATION_DECK+LOCATION_GRAVE) or card:IsControler(1-tp) end,nil,p)
end
end
end
end
if Glitchy.UndefinedActionWarning then
Glitchy.UndefinedActionWarning = false
end
return _SelectWithSumGreater(g,player,f,acc,...)
else
return _SelectWithSumGreater(g,p,f,acc,...)
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment