Commit 4890b754 authored by JoyJ's avatar JoyJ

update srv5555 scripts

parent 5f7ede10
--村规决斗:水涨船高
--开局时,后攻方抽1张。
--所有怪兽得到以下效果:
--①:每次对方把效果发动,这张卡的攻击力·守备力上升300。
CUNGUI = {}
function Auxiliary.PreloadUds()
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetOperation(CUNGUI.AdjustOperation)
Duel.RegisterEffect(e1,0)
end
CUNGUI.RegisteredMonsters = Group.CreateGroup()
function CUNGUI.AdjustOperation(e,tp,eg,ep,ev,re,r,rp)
if not CUNGUI.DRAW then
CUNGUI.DRAW = true
Duel.Draw(1,1,REASON_RULE)
end
local g = Duel.GetMatchingGroup(Card.IsType,0,LOCATION_DECK+LOCATION_HAND+LOCATION_EXTRA,LOCATION_DECK+LOCATION_HAND+LOCATION_EXTRA,nil,TYPE_MONSTER)
g:ForEach(CUNGUI.RegisterMonsterSpecialEffects)
end
function CUNGUI.RegisterMonsterSpecialEffects(c)
if CUNGUI.RegisteredMonsters:IsContains(c) then return end
CUNGUI.RegisteredMonsters:AddCard(c)
--attack up
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_CHAINING)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_MZONE)
e1:SetOperation(aux.chainreg)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_CHAIN_SOLVED)
e2:SetRange(LOCATION_MZONE)
e2:SetOperation(CUNGUI.atkop)
c:RegisterEffect(e2)
end
function CUNGUI.atkop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if re:GetHandlerPlayer()~=tp and c:GetFlagEffect(1)>0 then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(300)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_DISABLE)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EFFECT_UPDATE_DEFENSE)
c:RegisterEffect(e2)
end
end
\ No newline at end of file
--村规决斗:乱打一气
--所有怪兽得到以下效果:
--①这张卡可以攻击的场合必须作出攻击。
--②这张卡可以向对方怪兽全部各作1次攻击。
--③这张卡的攻击宣言时发动。双方抽1张卡。
CUNGUI = {}
function Auxiliary.PreloadUds()
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetOperation(CUNGUI.AdjustOperation)
Duel.RegisterEffect(e1,0)
end
CUNGUI.RegisteredMonsters = Group.CreateGroup()
function CUNGUI.AdjustOperation(e,tp,eg,ep,ev,re,r,rp)
local g = Duel.GetMatchingGroup(Card.IsType,0,LOCATION_DECK+LOCATION_HAND+LOCATION_EXTRA,LOCATION_DECK+LOCATION_HAND+LOCATION_EXTRA,nil,TYPE_MONSTER)
g:ForEach(CUNGUI.RegisterMonsterSpecialEffects)
end
function CUNGUI.RegisterMonsterSpecialEffects(c)
if CUNGUI.RegisteredMonsters:IsContains(c) then return end
CUNGUI.RegisteredMonsters:AddCard(c)
--must attack
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_MUST_ATTACK)
c:RegisterEffect(e1)
--attack all
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_ATTACK_ALL)
e3:SetValue(1)
c:RegisterEffect(e3)
--draw
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(66666004,4))
e2:SetCategory(CATEGORY_DRAW)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetCode(EVENT_ATTACK_ANNOUNCE)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(CUNGUI.condition)
e2:SetTarget(CUNGUI.target)
e2:SetOperation(CUNGUI.operation)
c:RegisterEffect(e2)
end
function CUNGUI.condition(e,tp)
return Duel.GetAttacker()==e:GetHandler()
end
function CUNGUI.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,PLAYER_ALL,1)
end
function CUNGUI.operation(e,tp,eg,ep,ev,re,r,rp)
local d1=Duel.Draw(tp,1,REASON_EFFECT)
local d2=Duel.Draw(1-tp,1,REASON_EFFECT)
end
\ No newline at end of file
--村规决斗:拼多多多
--要支付Cost时,投1个骰子。
--不是1或6的场合,无需支付。
--是1或6的场合,需要支付2次。第2次支付失败的场合,发动无效。
local OrigRegister = Card.RegisterEffect
CUNGUI = {}
Card.RegisterEffect = function(c,e,b)
local f=e:GetCost()
if f then
e:SetCost(CUNGUI.CreateFunction(f))
end
return OrigRegister(c,e,b)
end
function Auxiliary.PreloadUds()
end
function CUNGUI.CreateFunction(f)
return function(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local dice = Duel.TossDice(tp,1)
if dice==1 or dice==6 then
f(e,tp,eg,ep,ev,re,r,rp)
if not f(e,tp,eg,ep,ev,re,r,rp,0) then
Duel.NegateActivation(0)
return false
else
f(e,tp,eg,ep,ev,re,r,rp,chk)
return true
end
else
return true
end
end
end
\ No newline at end of file
--村规决斗:莫误班车
--所有选发效果变为必发效果。
local OrigRegister = Card.RegisterEffect
CUNGUI = {}
Card.RegisterEffect = function(c,e,b)
local typ = e:GetType()
if (typ & 0x7d0)>0 and e:GetOperation()~=nil then
if (typ & EFFECT_TYPE_QUICK_O) > 0 then
typ = typ - EFFECT_TYPE_QUICK_O
typ = typ | EFFECT_TYPE_QUICK_F
end
if (typ & EFFECT_TYPE_TRIGGER_O) > 0 then
typ = typ - EFFECT_TYPE_TRIGGER_O
typ = typ | EFFECT_TYPE_TRIGGER_F
end
e:SetType(typ)
local p = e:GetProperty() or 0
p = p | EFFECT_FLAG_DELAY
e:SetProperty(p)
end
return OrigRegister(c,e,b)
end
function Auxiliary.PreloadUds()
end
--村规决斗:罪域骨王
--游戏开始时,各自从卡组外将1张【白骨王】加入双方手卡。
--除外的卡中有【白骨王】的场合(无论表侧还是里侧表示),那些【白骨王】回到墓地。
--所有怪兽得到以下效果:
--这张卡的卡名只要在墓地存在也当作「白骨」使用。
CUNGUI = {}
function Auxiliary.PreloadUds()
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetCountLimit(1)
e1:SetOperation(CUNGUI.AdjustOperation)
Duel.RegisterEffect(e1,0)
--return
local e2=Effect.GlobalEffect()
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e2:SetCode(EVENT_ADJUST)
e2:SetCountLimit(1)
e2:SetOperation(CUNGUI.AdjustOperation2)
Duel.RegisterEffect(e2,0)
end
CUNGUI.RegisteredMonsters = Group.CreateGroup()
function CUNGUI.AdjustOperation2(e,tp,eg,ep,ev,re,r,rp)
local g = Duel.GetMatchingGroup(Card.IsCode,0,LOCATION_REMOVED,LOCATION_REMOVED,nil,36021814)
if #g > 0 then
Duel.SendtoGrave(g,REASON_RULE+REASON_RETURN)
end
end
function CUNGUI.AdjustOperation(e,tp,eg,ep,ev,re,r,rp)
if not CUNGUI.INIT then
CUNGUI.INIT = true
local card1 = Duel.CreateToken(0,36021814)
local card2 = Duel.CreateToken(1,36021814)
CUNGUI.RegisteredMonsters:AddCard(card1)
CUNGUI.RegisteredMonsters:AddCard(card2)
Duel.SendtoHand(card1, nil, REASON_RULE)
Duel.SendtoHand(card2, nil, REASON_RULE)
end
local g = Duel.GetMatchingGroup(Card.IsType,0,LOCATION_DECK+LOCATION_HAND+LOCATION_EXTRA,LOCATION_DECK+LOCATION_HAND+LOCATION_EXTRA,nil,TYPE_MONSTER)
g:ForEach(CUNGUI.RegisterMonsterSpecialEffects)
end
function CUNGUI.RegisterMonsterSpecialEffects(c)
if CUNGUI.RegisteredMonsters:IsContains(c) then return end
CUNGUI.RegisteredMonsters:AddCard(c)
aux.EnableChangeCode(c,32274490,LOCATION_GRAVE)
end
\ No newline at end of file
--村规决斗:神陆零式
--双方场上的怪兽攻击力上升对方基本分一半的数值(向下取整)。
CUNGUI = {}
function CUNGUI.Init()
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e1:SetValue(CUNGUI.val)
Duel.RegisterEffect(e1,0)
end
function CUNGUI.filter(c,race)
return c:IsFaceup() and c:IsRace(race)
end
function CUNGUI.val(e,c)
return math.floor(Duel.GetLP(1-c:GetControler()) / 2)
end
function Auxiliary.PreloadUds()
-- one more draw
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetOperation(function(e)
CUNGUI.Init()
e:Reset()
end)
Duel.RegisterEffect(e1,0)
end
\ No newline at end of file
--村规决斗:天地创造
--开局时,双方将3张【贤者之石-萨巴希尔】(80831721)从卡组外表侧表示除外。
--这场决斗中这些卡不是表侧表示除外的场合,这张卡表侧表示除外。
--这些卡得到以下效果。
--这个效果的发动和效果不会被无效化。
--宣言1个卡名才能发动。
--这张卡撕碎,那个卡名的卡从卡组外加入手卡·额外卡组。
--这场决斗中,双方因这个效果加入的卡造成的效果伤害变为0。
--(即使发生过位置移动,也视为同一张卡)
CUNGUI = {}
local OrigAnnounceCard = Duel.AnnounceCard
Duel.AnnounceCard = function(...)
local id=80831721
while id==80831721 do
id=OrigAnnounceCard(...)
end
return id
end
function Auxiliary.PreloadUds()
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetOperation(CUNGUI.AdjustOperation)
Duel.RegisterEffect(e1,0)
end
function CUNGUI.AdjustOperation()
if not CUNGUI.INIT then
CUNGUI.INIT = true
CUNGUI.RegisterCardRule(0)
CUNGUI.RegisterCardRule(1)
end
for i=0,1 do
if CUNGUI.RuleCard[i] then Duel.Remove(CUNGUI.RuleCard[i],POS_FACEUP,REASON_RULE) end
end
end
CUNGUI.RuleCard={}
CUNGUI.RuleCard[0]=Group.CreateGroup()
CUNGUI.RuleCard[1]=Group.CreateGroup()
CUNGUI.CreatedCard={}
function CUNGUI.RegisterCardRule(tp)
for i=1,3 do
local c=Duel.CreateToken(tp,80831721)
Duel.Remove(c,POS_FACEUP,REASON_RULE)
CUNGUI.RuleCard[tp]:AddCard(c)
--forbid
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(66666004,4))
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg)
e1:SetOperation(CUNGUI.ruleop)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CHANGE_DAMAGE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(1,1)
e1:SetValue(CUNGUI.damval)
Duel.RegisterEffect(e1,0)
end
end
function CUNGUI.ruletg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
e:SetLabel(Duel.AnnounceCard(tp))
end
function CUNGUI.ruleop(e,tp,eg,ep,ev,re,r,rp)
local c=Duel.CreateToken(tp,e:GetLabel())
CUNGUI.RuleCard[tp]:RemoveCard(e:GetHandler())
Debug.Message(c)
CUNGUI.CreatedCard[c]=true
Duel.Exile(e:GetHandler(),REASON_RULE)
Duel.SendtoHand(c,nil,REASON_EFFECT)
end
function CUNGUI.damval(e,re,val,r,rp,rc)
if not re then return val end
local c=re:GetHandler()
if bit.band(r,REASON_EFFECT)~=0 and c and CUNGUI.CreatedCard[c] then return 0
else return val end
end
--村规决斗:按图索骥
--开局时,双方将1张大融合(7614732)从卡组外表侧表示除外。
--这场决斗中这张卡不是表侧表示除外的场合,这张卡表侧表示除外。
--这张卡得到以下效果。
--1回合1次,这张卡在除外的状态才能发动。这个效果的发动和效果不会被无效化。
--将1张随机融合怪兽卡从卡组外加入额外卡组,
--那张卡上记载的所有卡名的卡各1张
--和1张【融合】(24094653)从卡组外加入手卡·额外卡组。
CUNGUI = {}
function Auxiliary.PreloadUds()
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetOperation(CUNGUI.AdjustOperation)
Duel.RegisterEffect(e1,0)
end
function CUNGUI.AdjustOperation()
if not CUNGUI.INIT then
CUNGUI.INIT = true
CUNGUI.RegisterCardRule(0)
CUNGUI.RegisterCardRule(1)
Duel.LoadScript("random.lua")
math.randomseed(_G.RANDOMSEED)
for i=1,10 do math.random(1000) end
end
if CUNGUI.RuleCard[0] and (not CUNGUI.RuleCard[0]:IsLocation(LOCATION_REMOVED) or not CUNGUI.RuleCard[0]:IsFaceup()) then
Duel.Remove(CUNGUI.RuleCard[0],POS_FACEUP,REASON_RULE)
end
if CUNGUI.RuleCard[1] and (not CUNGUI.RuleCard[1]:IsLocation(LOCATION_REMOVED) or not CUNGUI.RuleCard[1]:IsFaceup()) then
Duel.Remove(CUNGUI.RuleCard[1],POS_FACEUP,REASON_RULE)
end
if CUNGUI.RuleCard[0] and not CUNGUI.RuleCard[0]:IsFaceup() then
Duel.ChangePosition(CUNGUI.RuleCard[0],POS_FACEUP)
end
if CUNGUI.RuleCard[1] and not CUNGUI.RuleCard[1]:IsFaceup() then
Duel.ChangePosition(CUNGUI.RuleCard[1],POS_FACEUP)
end
end
CUNGUI.RuleCard={}
CUNGUI.FusionCards={284224,464362,1412158,1516510,1546123,1546124,1561110,1641882,1906812,1945387,2111707,2129638,2504891,2519690,3113836,3366982,3410461,3544583,3642509,3779662,3897065,4167084,4591250,4628897,4688231,4796100,5128859,5368615,5600127,6150044,6150045,6182103,6602300,6840573,6855503,7243511,7631534,8198620,8327462,8463720,8692301,9293977,9603252,9653271,9910360,10040267,10248389,10365322,10383554,10526791,10817524,10920352,10960419,11039171,11270236,11321089,11443677,11502550,11901678,12015000,12307878,12652643,12678870,13108445,13293158,13331639,13529466,13722870,13735899,13756293,13803864,13857930,14017402,14225239,15237615,15291624,15661378,15989522,16006416,16114248,16304628,16507828,17032740,17412721,17745969,17881964,18313046,18386170,18514525,18666161,18832779,18967507,19066538,19261966,19355597,19747827,20366274,20366275,21113684,21140872,21175632,21225115,21947653,22061412,22070401,22093873,22160245,22638495,22804644,22900219,22908820,23204029,23995346,23995347,23995348,24550676,24672164,24799107,25119460,25366484,25586143,25655502,25793414,26273196,27134689,27346636,27873305,28016193,28593363,28677304,29095552,29343734,29357956,29455728,29929832,30086349,30757127,30864377,31111109,31339260,32355828,32485271,32615065,32751480,32752319,32775808,32828466,33026283,33129626,33250142,33574806,33652635,33691040,33964637,34848821,35187185,35752363,35809262,35877582,36256625,36841733,37057012,37261776,37421579,37440988,37491810,37542782,37663536,37678339,37818794,39512984,39915560,40080312,40101111,40173854,40391316,40418351,40636712,40854197,41209827,41209828,41232647,41373230,41436536,41462083,41462084,41517968,41544074,41578483,41685633,41721210,42166000,42717221,43228023,43378048,43387895,43892408,43892409,44146295,44373896,44509529,45014450,45170821,45231177,45231178,45349196,45655875,46354113,46696593,46759931,47611119,47737087,48063985,48156348,48424886,48791583,48832775,48996569,49161188,49352945,49513164,49597193,49820233,49868263,50237654,50282757,50608164,50855622,50907446,51570882,51777272,51788412,51828629,52031567,53262004,53315891,53539634,54401832,54541900,54622031,54702678,54752875,54757758,55171412,55615891,56413937,56532353,56655675,56907389,57157964,57477163,57594700,58147549,58293343,58332301,58468105,58481572,58528964,58601383,58859575,59036972,59255742,59531356,59642500,60110982,60237530,60461804,60493189,61204971,62111090,62624486,62873545,63519819,64463828,64599569,64655485,65029288,65172015,66235877,66309175,66889139,67985943,68507541,68745629,69394324,69946549,70219023,70534340,70681994,71159974,71616908,71628381,72064891,72272462,72378329,72664875,72869010,72926163,72959823,73285669,73452089,74009824,74157028,74506079,74583607,74703140,74711057,74822425,74889525,74936480,75286621,75380687,75906310,75923050,76263644,76614340,76815942,77693536,78084378,78512663,78734254,78778375,79194594,79206925,79229522,79864860,80071763,80516007,80532587,80727036,80889750,81003500,81197327,81566151,81612598,81997228,82315403,82734805,82956492,83121692,83340560,83656563,83743222,83866861,84058253,84243274,84433295,84569886,84687358,84988419,85059922,85507811,85545073,85684223,85908279,86099788,86164529,86165817,86240887,86274272,86346643,86520461,86676862,86805855,87116928,87182127,87746184,87751584,88305705,88753594,88820235,89112729,89870349,90050480,90140980,90307498,90555947,90579153,90660762,90957527,91034681,91272072,91998119,91998120,91998121,92798873,92892239,93379652,93657021,93729065,93877990,94566432,94905343,94977269,94977270,95144193,95463814,95486586,95793022,95952802,96220350,96334243,96897184,97165977,97300502,98502113,98502114,98502115,98927491,99267150,99267151,99551425,99724761,99916754}
function CUNGUI.RegisterCardRule(tp)
local c=Duel.CreateToken(tp,7614732)
Duel.Remove(c,POS_FACEUP,REASON_RULE)
CUNGUI.RuleCard[tp]=c
--forbid
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(66666004,4))
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetCountLimit(1)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetOperation(CUNGUI.ruleop)
c:RegisterEffect(e1)
end
function CUNGUI.ruleop(e,tp,eg,ep,ev,re,r,rp)
local index=#CUNGUI.FusionCards
local code=CUNGUI.FusionCards[math.random(index)]
local c=Duel.CreateToken(tp,code)
Duel.SendtoDeck(c,nil,2,REASON_EFFECT)
local fc=Duel.CreateToken(tp,24094653)
Duel.SendtoHand(fc,nil,REASON_EFFECT)
if not c.card_code_list then return end
for lcode,_ in pairs(c.card_code_list) do
local tc=Duel.CreateToken(tp,lcode)
Duel.SendtoHand(tc,tp,REASON_EFFECT)
end
end
--村规决斗:波动决斗
--所有怪兽得到以下效果:
--这张卡进行战斗后发动。
--这张卡的攻击力/守备力随机上升或下降。最少为-30%,最多为60%。
--这个效果上升和下降的攻击力不会被无效化,离场后仍然有效。
--具体规则:
--投一个硬币,如果是反面则下降,如果是正面则上升。
--再投一个骰子,如果是下降则按点数下降5%/10%/15%/20%/25%/30%,
--如果是上升则按点数上升10%/20%/30%/40%/50%/60%。
CUNGUI = {}
function Auxiliary.PreloadUds()
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetCountLimit(1)
e1:SetOperation(CUNGUI.AdjustOperation)
Duel.RegisterEffect(e1,0)
end
CUNGUI.RegisteredMonsters = Group.CreateGroup()
function CUNGUI.AdjustOperation(e,tp,eg,ep,ev,re,r,rp)
local g = Duel.GetMatchingGroup(Card.IsType,0,LOCATION_DECK+LOCATION_HAND+LOCATION_EXTRA+LOCATION_MZONE,LOCATION_DECK+LOCATION_HAND+LOCATION_EXTRA+LOCATION_MZONE,nil,TYPE_MONSTER)
g:ForEach(CUNGUI.RegisterMonsterSpecialEffects)
end
function CUNGUI.RegisterMonsterSpecialEffects(c)
if CUNGUI.RegisteredMonsters:IsContains(c) then return end
CUNGUI.RegisteredMonsters:AddCard(c)
--remove
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(1621413,0))
e1:SetCategory(CATEGORY_ATKCHANGE+CATEGORY_DEFCHANGE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetCode(EVENT_BATTLED)
e1:SetOperation(CUNGUI.operation)
c:RegisterEffect(e1)
end
function CUNGUI.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local coin=Duel.TossCoin(tp,1) * 2 - 1
local atk=Duel.TossDice(tp,1) * c:GetAttack() * 0.1
local def=Duel.TossDice(tp,1) * c:GetDefense() * 0.1
if coin < 0 then
atk = atk * 0.5
def = def * 0.5
end
atk = atk * coin
def = def * coin
atk = math.ceil(atk)
def = math.ceil(def)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(atk)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCode(EFFECT_UPDATE_DEFENSE)
e2:SetValue(def)
c:RegisterEffect(e2)
end
--村规决斗:汉诺之塔 Finale
--后攻玩家开局时抽1张卡;先攻第1回合可以进入战斗阶段。
--所有1速效果在自己·对方回合都能发动。
--※要把速攻魔法·灵摆卡以外的1速魔法在对方回合发动的场合,必须先在场上盖放。
--※并不意味着变成了2速,因此旋风可以直接按死想要发动的通常魔法卡。
--开局时,双方将1张神速召唤(55557574)从卡组外表侧表示除外。
--这场决斗中这张卡不是表侧表示除外的场合,这张卡表侧表示除外。
--这张卡得到以下效果。
--自己·对方回合,这张卡在除外的状态才能从下列效果中选1个发动。
--这个效果的发动和效果不会被无效化,同1个连锁只能发动1次。
--·进行1次同调召唤。
--·进行1次XYZ召唤。
--·进行1次连接召唤。
--·进行1次灵摆召唤。(注:需要消耗自己正常灵摆召唤的次数)
--·从自己的手卡将1只怪兽通常召唤(注:需要消耗自己的通常召唤次数)
--·履行特殊召唤的手续,将1只怪兽(如坏兽)从手卡特殊召唤。
--·从自己的手卡将任意数量的魔法·陷阱卡盖放。
CUNGUI = {}
CUNGUI.SPSummonProcs={}
CUNGUI.SPSummonProcTargetRanges={}
Debug.ReloadFieldBegin(DUEL_ATTACK_FIRST_TURN,5)
OrigTargetRange = Effect.SetTargetRange
Effect.SetTargetRange = function(e,s,o)
CUNGUI.SPSummonProcTargetRanges[e]={s,o}
OrigTargetRange(e,s,o)
end
Effect.GetTargetRange = function(e)
if not CUNGUI.SPSummonProcTargetRanges[e] then return nil,nil end
return CUNGUI.SPSummonProcTargetRanges[e][1],CUNGUI.SPSummonProcTargetRanges[e][2]
end
OrigRegister = Card.RegisterEffect
Card.RegisterEffect = function(c,e,forced)
local typ = e:GetType()
if typ and (typ & EFFECT_TYPE_IGNITION)>0 then
e:SetType(EFFECT_TYPE_QUICK_O)
e:SetCode(EVENT_FREE_CHAIN)
local cat = e:GetCategory()
if cat and (cat & (CATEGORY_ATKCHANGE+CATEGORY_DEFCHANGE+CATEGORY_NEGATE))>0 then
local prop = e:GetProperty()
if not prop then prop = 0 end
prop = prop | (EFFECT_FLAG_DAMAGE_CAL+EFFECT_FLAG_DAMAGE_STEP)
e:SetProperty(prop)
end
end
if typ and (typ & EFFECT_TYPE_ACTIVATE)>0 then
local prop = e:GetProperty()
if not prop then prop = 0 end
e:SetProperty(prop,EFFECT_FLAG2_COF)
local cond = e:GetCondition()
e:SetCondition(CUNGUI.ReworkSpellCondition(cond))
end
local code = e:GetCode()
if code == EFFECT_SPSUMMON_PROC then
if not CUNGUI.SPSummonProcs[c] then CUNGUI.SPSummonProcs[c] = {} end
table.insert(CUNGUI.SPSummonProcs[c],e)
end
return OrigRegister(c,e,forced)
end
function CUNGUI.ReworkSpellCondition(f)
return function(e,tp,eg,ep,ev,re,r,rp)
if not f then f=aux.TRUE end
local ot = e:GetHandler():GetOriginalType()
if (ot & TYPE_SPELL+TYPE_PENDULUM)==0 or (ot & TYPE_QUICKPLAY)>0 then return f(e,tp,eg,ep,ev,re,r,rp) end
return Duel.GetCurrentChain()<1 and f(e,tp,eg,ep,ev,re,r,rp)
end
end
function Auxiliary.PreloadUds()
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetOperation(CUNGUI.AdjustOperation)
Duel.RegisterEffect(e1,0)
end
CUNGUI.RegisteredCards = Group.CreateGroup()
function CUNGUI.AdjustOperation()
if not CUNGUI.INIT then
CUNGUI.INIT = true
CUNGUI.RegisterCardRule(0)
CUNGUI.RegisterCardRule(1)
Duel.Draw(1,1,REASON_RULE)
end
if CUNGUI.RuleCard[0] and (not CUNGUI.RuleCard[0]:IsLocation(LOCATION_REMOVED) or not CUNGUI.RuleCard[0]:IsFaceup()) then
Duel.Remove(CUNGUI.RuleCard[0],POS_FACEUP,REASON_RULE)
end
if CUNGUI.RuleCard[1] and (not CUNGUI.RuleCard[1]:IsLocation(LOCATION_REMOVED) or not CUNGUI.RuleCard[1]:IsFaceup()) then
Duel.Remove(CUNGUI.RuleCard[1],POS_FACEUP,REASON_RULE)
end
if CUNGUI.RuleCard[0] and not CUNGUI.RuleCard[0]:IsFaceup() then
Duel.ChangePosition(CUNGUI.RuleCard[0],POS_FACEUP)
end
if CUNGUI.RuleCard[1] and not CUNGUI.RuleCard[1]:IsFaceup() then
Duel.ChangePosition(CUNGUI.RuleCard[1],POS_FACEUP)
end
local g = Duel.GetMatchingGroup(Card.IsType,0,LOCATION_HAND,LOCATION_HAND,nil,TYPE_PENDULUM+TYPE_SPELL)
g:ForEach(CUNGUI.RegisterSpecialEffects)
end
function CUNGUI.RegisterSpecialEffects(c)
if CUNGUI.RegisteredCards:IsContains(c) then return end
CUNGUI.RegisteredCards:AddCard(c)
if (c:GetOriginalType() & TYPE_QUICKPLAY)>0 then return end
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_ADD_TYPE)
e3:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e3:SetCondition(CUNGUI.setcond)
e3:SetValue(TYPE_QUICKPLAY)
e3:SetRange(LOCATION_SZONE)
c:RegisterEffect(e3,true)
e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_QP_ACT_IN_SET_TURN)
c:RegisterEffect(e3,true)
end
function CUNGUI.setcond(e)
return e:GetHandler():IsFacedown() and Duel.GetTurnPlayer()==1-e:GetHandler():GetControler()
end
CUNGUI.RuleCard={}
function CUNGUI.RegisterCardRule(tp)
local c=Duel.CreateToken(tp,55557574)
Duel.Remove(c,POS_FACEUP,REASON_RULE)
CUNGUI.RuleCard[tp]=c
--synchro
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(50091196,1))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_synchro)
e1:SetOperation(CUNGUI.ruleop_synchro)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(5352328,1))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_xyz)
e1:SetOperation(CUNGUI.ruleop_xyz)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(65741786,0))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_link)
e1:SetOperation(CUNGUI.ruleop_link)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(1264319,0))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_fusion)
e1:SetOperation(CUNGUI.ruleop_fusion)
--c:RegisterEffect(e1)
e1=aux.AddRitualProcUltimate(c,aux.TRUE,Card.GetLevel,"Greater",nil,nil,nil,true)
e1:SetDescription(aux.Stringid(34834619,0))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
local tgt=e1:GetTarget()
e1:SetTarget(CUNGUI.ruletg_ritual(tgt))
--c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(15939229,1))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_sset)
e1:SetOperation(CUNGUI.ruleop_sset)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_QP_ACT_IN_NTPHAND)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(aux.TRUE)
e1:SetTargetRange(LOCATION_HAND,0)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(19041767,0))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_summon)
e1:SetOperation(CUNGUI.ruleop_summon)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(45803070,0))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_spsummon)
e1:SetOperation(CUNGUI.ruleop_spsummon)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(1163)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_pendsummon)
e1:SetOperation(CUNGUI.ruleop_pendsummon)
c:RegisterEffect(e1)
end
function CUNGUI.ruletg_pendsummonfiltercond(e,c,og)
if c==nil then return true end
local tp=c:GetControler()
local eset={Duel.IsPlayerAffectedByEffect(tp,EFFECT_EXTRA_PENDULUM_SUMMON)}
if Auxiliary.PendulumChecklist&(0x1<<tp)~=0 and #eset==0 then
return false
end
local rpz=Duel.GetFieldCard(tp,LOCATION_PZONE,1)
if rpz==nil or c==rpz or not rpz:IsStatus(STATUS_EFFECT_ENABLED) then
return false
end
local lscale=c:GetLeftScale()
local rscale=rpz:GetRightScale()
if lscale>rscale then lscale,rscale=rscale,lscale end
local loc=0
if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then loc=loc+LOCATION_HAND end
if Duel.GetLocationCountFromEx(tp,tp,nil,TYPE_PENDULUM)>0 then loc=loc+LOCATION_EXTRA end
if loc==0 then return false end
local g=nil
if og then
g=og:Filter(Card.IsLocation,nil,loc)
else
g=Duel.GetFieldGroup(tp,loc,0)
end
return g:IsExists(CUNGUI.pc_filter,1,nil,e,tp,lscale,rscale,eset)
end
function CUNGUI.pc_filter(c,e,tp,lscale,rscale,eset)
local lv=0
if c.pendulum_level then
lv=c.pendulum_level
else
lv=c:GetLevel()
end
local bool=Auxiliary.PendulumSummonableBool(c)
return (c:IsLocation(LOCATION_HAND) or (c:IsFaceup() and c:IsType(TYPE_PENDULUM)))
and lv>lscale and lv<rscale and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_PENDULUM,tp,bool,bool)
and not c:IsForbidden()
and (Auxiliary.PendulumChecklist&(0x1<<tp)==0 or Auxiliary.PConditionExtraFilter(c,e,tp,lscale,rscale,eset))
end
function CUNGUI.ruletg_pendsummonfilter(c,e,tp)
local lpz=Duel.GetFieldCard(tp,LOCATION_PZONE,0)
if lpz==nil or not lpz:IsStatus(STATUS_EFFECT_ENABLED) then return false end
return CUNGUI.ruletg_pendsummonfiltercond(e,lpz,Group.FromCards(c))
end
function CUNGUI.ruletg_pendsummon(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then
return Duel.IsExistingMatchingCard(CUNGUI.ruletg_pendsummonfilter,tp,LOCATION_HAND+LOCATION_EXTRA,0,1,nil,e,tp)
and Duel.GetFieldGroupCount(tp,LOCATION_PZONE,0)>1
and c:GetFlagEffect(66666666)==0
end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
end
function CUNGUI.ruleop_pendsummon(e,tp,eg,ep,ev,re,r,rp)
local lpz=Duel.GetFieldCard(tp,LOCATION_PZONE,0)
if lpz==nil then return end
local g=Duel.GetFieldGroup(tp,LOCATION_HAND+LOCATION_EXTRA,0)
if #g==0 then return end
local sg=Group.CreateGroup()
local pop=aux.PendOperation()
pop(e,tp,eg,ep,ev,re,r,rp,lpz,sg,g)
Duel.SpecialSummon(sg,SUMMON_TYPE_PENDULUM,tp,tp,false,false,POS_FACEUP)
end
function CUNGUI.ruletg_spsummonfilter(c)
if not CUNGUI.SPSummonProcs[c] then return false end
for i,e in pairs(CUNGUI.SPSummonProcs[c]) do
local cond = e:GetCondition()
local op = e:GetOperation()
local prop = e:GetProperty()
local tgs,tgo = e:GetTargetRange()
local tp = c:GetControler()
local sumtyp,zone = e:GetValue()
local sump = tp
if (prop & EFFECT_FLAG_SPSUM_PARAM)==0 then
tgs = POS_FACEUP
else
tgs = tgs or POS_FACEUP
if tgo==1 then
sump = 1-tp
end
end
sumtype = sumtyp or 0
zone = zone or 0xff
if e:CheckCountLimit(tp) and cond(e,c,sumtyp)
and c:IsCanBeSpecialSummoned(e,sumtyp,tp,true,false,tgs,sump,zone) then return true end
end -- c,e,sumtyp
end
function CUNGUI.ruletg_spsummon(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return
Duel.GetMZoneCount(tp)>0 and
Duel.IsExistingMatchingCard(CUNGUI.ruletg_spsummonfilter,tp,LOCATION_HAND,0,1,nil,nil) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function CUNGUI.ruleop_spsummon(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetMZoneCount(tp)<1 then return end
local tc
local g=Duel.SelectMatchingCard(tp,CUNGUI.ruletg_spsummonfilter,tp,LOCATION_HAND,0,1,1,nil)
if #g>0 then
tc=g:GetFirst()
local procs={}
local procs_desc={}
for i,e in pairs(CUNGUI.SPSummonProcs[tc]) do
local cond = e:GetCondition()
local op = e:GetOperation()
local prop = e:GetProperty()
local tgs,tgo = e:GetTargetRange()
local tp = tc:GetControler()
local sumtyp,zone = e:GetValue()
local sump = tp
if (prop & EFFECT_FLAG_SPSUM_PARAM)==0 then
tgs = POS_FACEUP
else
tgs = tgs or POS_FACEUP
if tgo==1 then
sump = 1-tp
end
end
sumtype = sumtyp or 0
zone = zone or 0xff
local condyes = cond(e,tc,sumtyp)
if e:CheckCountLimit(tp) and condyes and tc:IsCanBeSpecialSummoned(e,sumtyp,tp,true,false,tgs,sump,zone) then
table.insert(procs,e)
local desc = e:GetDescription()
if not desc or desc==0 then desc = aux.Stringid(82301904,0) end
table.insert(procs_desc, desc)
end
end
local opt = 1
if #procs_desc>1 then
opt = Duel.SelectOption(tp,table.unpack(procs_desc))+1
end
local te=procs[opt]
local tecond = e:GetCondition() or aux.TRUE
local teop = e:GetOperation() or aux.TRUE
local teprop = e:GetProperty() or 0
local tetgs,tetgo = e:GetTargetRange()
local tetp = tc:GetControler()
local tesumtyp,tezone = e:GetValue()
local tesump = tetp
if (teprop & EFFECT_FLAG_SPSUM_PARAM)==0 then
tetgs = POS_FACEUP
else
tetgs = tetgs or POS_FACEUP
if tetgo==1 then
tesump = 1-tetp
end
end
tesumtype = tesumtyp or 0
tezone = tezone or 0xff
teop(te,tetp,tc,tp,0,te,REASON_RULE,tp,tc)
Duel.SpecialSummon(tc,tesumtyp,tetp,tesump,true,false,tetgs,tezone)
local _,cl2=te:GetCountLimit()
if not cl2 then cl2 = 0 end
te:UseCountLimit(tp,1,(cl2 & EFFECT_FLAG_OATH)>0)
tc:CompleteProcedure()
end
end
function CUNGUI.ruletg_summonfilter(c)
if not c:IsSummonableCard() then return false end
return (c:IsSummonable(false,nil) or c:IsMSetable(false,nil))
end
function CUNGUI.ruletg_summon(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(CUNGUI.ruletg_summonfilter,tp,LOCATION_HAND,0,1,nil,nil) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function CUNGUI.ruleop_summon(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.SelectMatchingCard(tp,CUNGUI.ruletg_summonfilter,tp,LOCATION_HAND,0,1,1,nil)
if #g>0 then
local tc=g:GetFirst()
local s1=tc:IsSummonable(false,nil)
local s2=tc:IsMSetable(false,nil)
if (s1 and s2 and Duel.SelectPosition(tp,tc,POS_FACEUP_ATTACK+POS_FACEDOWN_DEFENSE)==POS_FACEUP_ATTACK) or not s2 then
Duel.Summon(tp,tc,false,nil)
else
Duel.MSet(tp,tc,false,nil)
end
end
end
function CUNGUI.ruletg_ssetfilter(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable()
end
function CUNGUI.ruletg_sset(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(CUNGUI.ruletg_ssetfilter,tp,LOCATION_HAND,0,1,nil,nil) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function CUNGUI.ruleop_sset(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.SelectMatchingCard(tp,CUNGUI.ruletg_ssetfilter,tp,LOCATION_HAND,0,1,99,nil)
if #g>0 then
Duel.SSet(tp,g,tp,false)
end
end
function CUNGUI.ruletg_synchro(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsSynchroSummonable,tp,LOCATION_EXTRA,0,1,nil,nil) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function CUNGUI.ruleop_synchro(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(Card.IsSynchroSummonable,tp,LOCATION_EXTRA,0,nil,nil)
if #g>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:Select(tp,1,1,nil)
Duel.SynchroSummon(tp,sg:GetFirst(),nil)
end
end
function CUNGUI.ruletg_xyz(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsXyzSummonable,tp,LOCATION_EXTRA,0,1,nil,nil) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function CUNGUI.ruleop_xyz(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(Card.IsXyzSummonable,tp,LOCATION_EXTRA,0,nil,nil)
if #g>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:Select(tp,1,1,nil)
Duel.XyzSummon(tp,sg:GetFirst(),nil)
end
end
function CUNGUI.ruletg_link(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsLinkSummonable,tp,LOCATION_EXTRA,0,1,nil,nil) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function CUNGUI.ruleop_link(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(Card.IsLinkSummonable,tp,LOCATION_EXTRA,0,nil,nil)
if #g>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:Select(tp,1,1,nil)
Duel.LinkSummon(tp,sg:GetFirst(),nil)
end
end
function CUNGUI.fusion_filter1(c,e)
return not c:IsImmuneToEffect(e)
end
function CUNGUI.fusion_filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
end
function CUNGUI.ruletg_fusion(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then
if c:GetFlagEffect(66666666)>0 then return false end
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp)
local res=Duel.IsExistingMatchingCard(CUNGUI.fusion_filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf)
if not res then
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
local mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(CUNGUI.fusion_filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf)
end
end
return res
end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function CUNGUI.ruleop_fusion(e,tp,eg,ep,ev,re,r,rp)
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp):Filter(CUNGUI.fusion_filter1,nil,e)
local sg1=Duel.GetMatchingGroup(CUNGUI.fusion_filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
local mg2=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(CUNGUI.fusion_filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf)
end
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then
local sg=sg1:Clone()
if sg2 then sg:Merge(sg2) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=sg:Select(tp,1,1,nil)
local tc=tg:GetFirst()
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
tc:SetMaterial(mat1)
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
else
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
tc:CompleteProcedure()
end
end
function CUNGUI.ruletg_ritual(f)
if f==nil then f=aux.TRUE end
return function(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return f(e,tp,eg,ep,ev,re,r,rp,chk) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
f(e,tp,eg,ep,ev,re,r,rp,chk)
end
end
\ No newline at end of file
--村规决斗:汉诺之塔 Finale
--后攻玩家开局时抽1张卡;先攻第1回合可以进入战斗阶段。
--所有1速效果在自己·对方回合都能发动。
--※要把速攻魔法·灵摆卡以外的1速魔法在对方回合发动的场合,必须先在场上盖放。
--※并不意味着变成了2速,因此旋风可以直接按死想要发动的通常魔法卡。
--开局时,双方将1张神速召唤(55557574)从卡组外表侧表示除外。
--这场决斗中这张卡不是表侧表示除外的场合,这张卡表侧表示除外。
--这张卡得到以下效果。
--自己·对方回合,这张卡在除外的状态才能从下列效果中选1个发动。
--这个效果的发动和效果不会被无效化,同1个连锁只能发动1次。
--·进行1次同调召唤。
--·进行1次XYZ召唤。
--·进行1次连接召唤。
--·进行1次灵摆召唤。(注:需要消耗自己正常灵摆召唤的次数)
--·从自己的手卡将1只怪兽通常召唤(注:需要消耗自己的通常召唤次数)
--·履行特殊召唤的手续,将1只怪兽(如坏兽)从手卡特殊召唤。
--·从自己的手卡将任意数量的魔法·陷阱卡盖放。
CUNGUI = {}
CUNGUI.SPSummonProcs={}
CUNGUI.SPSummonProcTargetRanges={}
Debug.ReloadFieldBegin(DUEL_ATTACK_FIRST_TURN,5)
OrigTargetRange = Effect.SetTargetRange
Effect.SetTargetRange = function(e,s,o)
CUNGUI.SPSummonProcTargetRanges[e]={s,o}
OrigTargetRange(e,s,o)
end
Effect.GetTargetRange = function(e)
if not CUNGUI.SPSummonProcTargetRanges[e] then return nil,nil end
return CUNGUI.SPSummonProcTargetRanges[e][1],CUNGUI.SPSummonProcTargetRanges[e][2]
end
OrigRegister = Card.RegisterEffect
Card.RegisterEffect = function(c,e,forced)
local typ = e:GetType()
if typ and (typ & EFFECT_TYPE_IGNITION)>0 then
e:SetType(EFFECT_TYPE_QUICK_O)
e:SetCode(EVENT_FREE_CHAIN)
local cat = e:GetCategory()
if cat and (cat & (CATEGORY_ATKCHANGE+CATEGORY_DEFCHANGE+CATEGORY_NEGATE))>0 then
local prop = e:GetProperty()
if not prop then prop = 0 end
prop = prop | (EFFECT_FLAG_DAMAGE_CAL+EFFECT_FLAG_DAMAGE_STEP)
e:SetProperty(prop)
end
end
if typ and (typ & EFFECT_TYPE_ACTIVATE)>0 then
local prop = e:GetProperty()
if not prop then prop = 0 end
e:SetProperty(prop,EFFECT_FLAG2_COF)
local cond = e:GetCondition()
e:SetCondition(CUNGUI.ReworkSpellCondition(cond))
end
local code = e:GetCode()
if code == EFFECT_SPSUMMON_PROC then
if not CUNGUI.SPSummonProcs[c] then CUNGUI.SPSummonProcs[c] = {} end
table.insert(CUNGUI.SPSummonProcs[c],e)
end
return OrigRegister(c,e,forced)
end
function CUNGUI.ReworkSpellCondition(f)
return function(e,tp,eg,ep,ev,re,r,rp)
if not f then f=aux.TRUE end
local ot = e:GetHandler():GetOriginalType()
if (ot & TYPE_SPELL+TYPE_PENDULUM)==0 or (ot & TYPE_QUICKPLAY)>0 then return f(e,tp,eg,ep,ev,re,r,rp) end
return Duel.GetCurrentChain()<1 and f(e,tp,eg,ep,ev,re,r,rp)
end
end
function Auxiliary.PreloadUds()
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetOperation(CUNGUI.AdjustOperation)
Duel.RegisterEffect(e1,0)
end
CUNGUI.RegisteredCards = Group.CreateGroup()
function CUNGUI.AdjustOperation()
if not CUNGUI.INIT then
CUNGUI.INIT = true
CUNGUI.RegisterCardRule(0)
CUNGUI.RegisterCardRule(1)
Duel.Draw(1,1,REASON_RULE)
end
if CUNGUI.RuleCard[0] and (not CUNGUI.RuleCard[0]:IsLocation(LOCATION_REMOVED) or not CUNGUI.RuleCard[0]:IsFaceup()) then
Duel.Remove(CUNGUI.RuleCard[0],POS_FACEUP,REASON_RULE)
end
if CUNGUI.RuleCard[1] and (not CUNGUI.RuleCard[1]:IsLocation(LOCATION_REMOVED) or not CUNGUI.RuleCard[1]:IsFaceup()) then
Duel.Remove(CUNGUI.RuleCard[1],POS_FACEUP,REASON_RULE)
end
if CUNGUI.RuleCard[0] and not CUNGUI.RuleCard[0]:IsFaceup() then
Duel.ChangePosition(CUNGUI.RuleCard[0],POS_FACEUP)
end
if CUNGUI.RuleCard[1] and not CUNGUI.RuleCard[1]:IsFaceup() then
Duel.ChangePosition(CUNGUI.RuleCard[1],POS_FACEUP)
end
local g = Duel.GetMatchingGroup(Card.IsType,0,LOCATION_HAND,LOCATION_HAND,nil,TYPE_PENDULUM+TYPE_SPELL)
g:ForEach(CUNGUI.RegisterSpecialEffects)
end
function CUNGUI.RegisterSpecialEffects(c)
if CUNGUI.RegisteredCards:IsContains(c) then return end
CUNGUI.RegisteredCards:AddCard(c)
if (c:GetOriginalType() & TYPE_QUICKPLAY)>0 then return end
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_ADD_TYPE)
e3:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e3:SetCondition(CUNGUI.setcond)
e3:SetValue(TYPE_QUICKPLAY)
e3:SetRange(LOCATION_SZONE)
c:RegisterEffect(e3,true)
e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_QP_ACT_IN_SET_TURN)
c:RegisterEffect(e3,true)
end
function CUNGUI.setcond(e)
return e:GetHandler():IsFacedown() and Duel.GetTurnPlayer()==1-e:GetHandler():GetControler()
end
CUNGUI.RuleCard={}
function CUNGUI.RegisterCardRule(tp)
local c=Duel.CreateToken(tp,55557574)
Duel.Remove(c,POS_FACEUP,REASON_RULE)
CUNGUI.RuleCard[tp]=c
--synchro
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(50091196,1))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_synchro)
e1:SetOperation(CUNGUI.ruleop_synchro)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(5352328,1))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_xyz)
e1:SetOperation(CUNGUI.ruleop_xyz)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(65741786,0))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_link)
e1:SetOperation(CUNGUI.ruleop_link)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(1264319,0))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_fusion)
e1:SetOperation(CUNGUI.ruleop_fusion)
--c:RegisterEffect(e1)
e1=aux.AddRitualProcUltimate(c,aux.TRUE,Card.GetLevel,"Greater",nil,nil,nil,true)
e1:SetDescription(aux.Stringid(34834619,0))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
local tgt=e1:GetTarget()
e1:SetTarget(CUNGUI.ruletg_ritual(tgt))
--c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(15939229,1))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_sset)
e1:SetOperation(CUNGUI.ruleop_sset)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_QP_ACT_IN_NTPHAND)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(aux.TRUE)
e1:SetTargetRange(LOCATION_HAND,0)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(19041767,0))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_summon)
e1:SetOperation(CUNGUI.ruleop_summon)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(45803070,0))
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_spsummon)
e1:SetOperation(CUNGUI.ruleop_spsummon)
c:RegisterEffect(e1)
e1=Effect.CreateEffect(c)
e1:SetDescription(1163)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetTarget(CUNGUI.ruletg_pendsummon)
e1:SetOperation(CUNGUI.ruleop_pendsummon)
c:RegisterEffect(e1)
end
function CUNGUI.ruletg_pendsummonfiltercond(e,c,og)
if c==nil then return true end
local tp=c:GetControler()
local eset={Duel.IsPlayerAffectedByEffect(tp,EFFECT_EXTRA_PENDULUM_SUMMON)}
if Auxiliary.PendulumChecklist&(0x1<<tp)~=0 and #eset==0 then
return false
end
local rpz=Duel.GetFieldCard(tp,LOCATION_PZONE,1)
if rpz==nil or c==rpz or not rpz:IsStatus(STATUS_EFFECT_ENABLED) then
return false
end
local lscale=c:GetLeftScale()
local rscale=rpz:GetRightScale()
if lscale>rscale then lscale,rscale=rscale,lscale end
local loc=0
if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then loc=loc+LOCATION_HAND end
if Duel.GetLocationCountFromEx(tp,tp,nil,TYPE_PENDULUM)>0 then loc=loc+LOCATION_EXTRA end
if loc==0 then return false end
local g=nil
if og then
g=og:Filter(Card.IsLocation,nil,loc)
else
g=Duel.GetFieldGroup(tp,loc,0)
end
return g:IsExists(CUNGUI.pc_filter,1,nil,e,tp,lscale,rscale,eset)
end
function CUNGUI.pc_filter(c,e,tp,lscale,rscale,eset)
local lv=0
if c.pendulum_level then
lv=c.pendulum_level
else
lv=c:GetLevel()
end
local bool=Auxiliary.PendulumSummonableBool(c)
return (c:IsLocation(LOCATION_HAND) or (c:IsFaceup() and c:IsType(TYPE_PENDULUM)))
and lv>lscale and lv<rscale and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_PENDULUM,tp,bool,bool)
and not c:IsForbidden()
and (Auxiliary.PendulumChecklist&(0x1<<tp)==0 or Auxiliary.PConditionExtraFilter(c,e,tp,lscale,rscale,eset))
end
function CUNGUI.ruletg_pendsummonfilter(c,e,tp)
local lpz=Duel.GetFieldCard(tp,LOCATION_PZONE,0)
if lpz==nil or not lpz:IsStatus(STATUS_EFFECT_ENABLED) then return false end
return CUNGUI.ruletg_pendsummonfiltercond(e,lpz,Group.FromCards(c))
end
function CUNGUI.ruletg_pendsummon(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then
return Duel.IsExistingMatchingCard(CUNGUI.ruletg_pendsummonfilter,tp,LOCATION_HAND+LOCATION_EXTRA,0,1,nil,e,tp)
and Duel.GetFieldGroupCount(tp,LOCATION_PZONE,0)>1
and c:GetFlagEffect(66666666)==0
end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
end
function CUNGUI.ruleop_pendsummon(e,tp,eg,ep,ev,re,r,rp)
local lpz=Duel.GetFieldCard(tp,LOCATION_PZONE,0)
if lpz==nil then return end
local g=Duel.GetFieldGroup(tp,LOCATION_HAND+LOCATION_EXTRA,0)
if #g==0 then return end
local sg=Group.CreateGroup()
local pop=aux.PendOperation()
pop(e,tp,eg,ep,ev,re,r,rp,lpz,sg,g)
Duel.SpecialSummon(sg,SUMMON_TYPE_PENDULUM,tp,tp,false,false,POS_FACEUP)
end
function CUNGUI.ruletg_spsummonfilter(c,e,tp,eg,ep,ev,re,r,rp)
if not CUNGUI.SPSummonProcs[c] then return false end
for i,e in pairs(CUNGUI.SPSummonProcs[c]) do
local cond = e:GetCondition() or aux.TRUE
local tg = e:GetTarget() or aux.TRUE
local op = e:GetOperation()
local prop = e:GetProperty()
local tgs,tgo = e:GetTargetRange()
local tp = c:GetControler()
local sumtyp,zone = e:GetValue()
local sump = tp
if (prop & EFFECT_FLAG_SPSUM_PARAM)==0 then
tgs = POS_FACEUP
else
tgs = tgs or POS_FACEUP
if tgo==1 then
sump = 1-tp
end
end
sumtyp = sumtyp or 0
zone = zone or 0xff
if e:CheckCountLimit(tp) and cond(e,c,sumtyp) and tg(e,tp,eg,ep,ev,re,r,rp,0,c)
and c:IsCanBeSpecialSummoned(e,sumtyp,tp,true,false,tgs,sump,zone) then return true end
end -- c,e,sumtyp
end
function CUNGUI.ruletg_spsummon(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return
Duel.GetMZoneCount(tp)>0 and
Duel.IsExistingMatchingCard(CUNGUI.ruletg_spsummonfilter,tp,LOCATION_HAND,0,1,nil,e,tp,eg,ep,ev,re,r,rp) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function CUNGUI.ruleop_spsummon(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetMZoneCount(tp)<1 then return end
local tc
local g=Duel.SelectMatchingCard(tp,CUNGUI.ruletg_spsummonfilter,tp,LOCATION_HAND,0,1,1,nil,e,tp,eg,ep,ev,re,r,rp)
if #g>0 then
tc=g:GetFirst()
local procs={}
local procs_desc={}
for i,e in pairs(CUNGUI.SPSummonProcs[tc]) do
local cond = e:GetCondition()
local op = e:GetOperation()
local prop = e:GetProperty()
local tgs,tgo = e:GetTargetRange()
local tp = tc:GetControler()
local sumtyp,zone = e:GetValue()
local sump = tp
if (prop & EFFECT_FLAG_SPSUM_PARAM)==0 then
tgs = POS_FACEUP
else
tgs = tgs or POS_FACEUP
if tgo==1 then
sump = 1-tp
end
end
sumtyp = sumtyp or 0
zone = zone or 0xff
local condyes = cond(e,tc,sumtyp)
if e:CheckCountLimit(tp) and condyes and tc:IsCanBeSpecialSummoned(e,sumtyp,tp,true,false,tgs,sump,zone) then
table.insert(procs,e)
local desc = e:GetDescription()
if not desc or desc==0 then desc = aux.Stringid(82301904,0) end
table.insert(procs_desc, desc)
end
end
local opt = 1
if #procs_desc>1 then
opt = Duel.SelectOption(tp,table.unpack(procs_desc))+1
end
local te=procs[opt]
local tecond = e:GetCondition() or aux.TRUE
local tetg = e:GetTarget() or aux.TRUE
local teop = e:GetOperation() or aux.TRUE
local teprop = e:GetProperty() or 0
local tetgs,tetgo = e:GetTargetRange()
local tetp = tc:GetControler()
local tesumtyp,tezone = e:GetValue()
local tesump = tetp
if (teprop & EFFECT_FLAG_SPSUM_PARAM)==0 then
tetgs = POS_FACEUP
else
tetgs = tetgs or POS_FACEUP
if tetgo==1 then
tesump = 1-tetp
end
end
tesumtyp = tesumtyp or 0
tezone = tezone or 0xff
Duel.DisableActionCheck(true)
tetg(te,tetp,tc,tp,0,te,REASON_RULE,tp,1,tc)
teop(te,tetp,tc,tp,0,te,REASON_RULE,tp,tc)
Duel.DisableActionCheck(false)
Duel.SpecialSummon(tc,tesumtyp,tetp,tesump,true,false,tetgs,tezone)
local _,cl2=te:GetCountLimit()
if not cl2 then cl2 = 0 end
te:UseCountLimit(tp,1,(cl2 & EFFECT_FLAG_OATH)>0)
tc:CompleteProcedure()
end
end
function CUNGUI.ruletg_summonfilter(c)
if not c:IsSummonableCard() then return false end
return (c:IsSummonable(false,nil) or c:IsMSetable(false,nil))
end
function CUNGUI.ruletg_summon(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(CUNGUI.ruletg_summonfilter,tp,LOCATION_HAND,0,1,nil,nil) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function CUNGUI.ruleop_summon(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.SelectMatchingCard(tp,CUNGUI.ruletg_summonfilter,tp,LOCATION_HAND,0,1,1,nil)
if #g>0 then
local tc=g:GetFirst()
local s1=tc:IsSummonable(false,nil)
local s2=tc:IsMSetable(false,nil)
if (s1 and s2 and Duel.SelectPosition(tp,tc,POS_FACEUP_ATTACK+POS_FACEDOWN_DEFENSE)==POS_FACEUP_ATTACK) or not s2 then
Duel.Summon(tp,tc,false,nil)
else
Duel.MSet(tp,tc,false,nil)
end
end
end
function CUNGUI.ruletg_ssetfilter(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable()
end
function CUNGUI.ruletg_sset(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(CUNGUI.ruletg_ssetfilter,tp,LOCATION_HAND,0,1,nil,nil) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function CUNGUI.ruleop_sset(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.SelectMatchingCard(tp,CUNGUI.ruletg_ssetfilter,tp,LOCATION_HAND,0,1,99,nil)
if #g>0 then
Duel.SSet(tp,g,tp,false)
end
end
function CUNGUI.ruletg_synchro(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsSynchroSummonable,tp,LOCATION_EXTRA,0,1,nil,nil) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function CUNGUI.ruleop_synchro(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(Card.IsSynchroSummonable,tp,LOCATION_EXTRA,0,nil,nil)
if #g>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:Select(tp,1,1,nil)
Duel.SynchroSummon(tp,sg:GetFirst(),nil)
end
end
function CUNGUI.ruletg_xyz(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsXyzSummonable,tp,LOCATION_EXTRA,0,1,nil,nil) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function CUNGUI.ruleop_xyz(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(Card.IsXyzSummonable,tp,LOCATION_EXTRA,0,nil,nil)
if #g>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:Select(tp,1,1,nil)
Duel.XyzSummon(tp,sg:GetFirst(),nil)
end
end
function CUNGUI.ruletg_link(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsLinkSummonable,tp,LOCATION_EXTRA,0,1,nil,nil) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function CUNGUI.ruleop_link(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(Card.IsLinkSummonable,tp,LOCATION_EXTRA,0,nil,nil)
if #g>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:Select(tp,1,1,nil)
Duel.LinkSummon(tp,sg:GetFirst(),nil)
end
end
function CUNGUI.fusion_filter1(c,e)
return not c:IsImmuneToEffect(e)
end
function CUNGUI.fusion_filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
end
function CUNGUI.ruletg_fusion(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then
if c:GetFlagEffect(66666666)>0 then return false end
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp)
local res=Duel.IsExistingMatchingCard(CUNGUI.fusion_filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf)
if not res then
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
local mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(CUNGUI.fusion_filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf)
end
end
return res
end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function CUNGUI.ruleop_fusion(e,tp,eg,ep,ev,re,r,rp)
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp):Filter(CUNGUI.fusion_filter1,nil,e)
local sg1=Duel.GetMatchingGroup(CUNGUI.fusion_filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
local mg2=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(CUNGUI.fusion_filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf)
end
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then
local sg=sg1:Clone()
if sg2 then sg:Merge(sg2) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=sg:Select(tp,1,1,nil)
local tc=tg:GetFirst()
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
tc:SetMaterial(mat1)
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
else
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
tc:CompleteProcedure()
end
end
function CUNGUI.ruletg_ritual(f)
if f==nil then f=aux.TRUE end
return function(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return f(e,tp,eg,ep,ev,re,r,rp,chk) and c:GetFlagEffect(66666666)==0 end
c:RegisterFlagEffect(66666666,RESET_CHAIN,0,1)
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
f(e,tp,eg,ep,ev,re,r,rp,chk)
end
end
\ No newline at end of file
--村规决斗:真假猴王
--开局时,双方将1张高尚仪式术(36350300)从卡组外表侧表示除外。
--这场决斗中这张卡不是表侧表示除外的场合,这张卡表侧表示除外。
--这张卡得到以下效果。
--1回合1次,自己主要阶段才能处理这个效果。这个效果的处理不会被无效化。
--从卡组外将1张有任意卡名记述的随机仪式魔法卡加入手卡,那些记述的卡名各2张从卡组外加入手卡。
CUNGUI = {}
CUNGUI.RandomCard = {7986397,8198712,8955148,9236985,9786492,9845733,11398951,14094090,14735698,16494704,17888577,18803791,20071842,21082832,22398665,23459650,23965037,27383110,28429121,30392583,31002402,31066283,32828635,33031674,34767865,34834619,36350300,37626500,38784726,39399168,39996157,41182875,41426869,43417563,43694075,44221928,45410988,45948430,46052429,46159582,47435107,51124303,52913738,54539105,55761792,58827995,59820352,60234913,60365591,60369732,60921537,62835876,69035382,72446038,73055622,76792184,76806714,77454922,78577570,79306385,80566312,80811661,81756897,81933259,85327820,86758915,94377247,94666032,96420087,97211663}
function Auxiliary.PreloadUds()
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetOperation(CUNGUI.AdjustOperation)
Duel.RegisterEffect(e1,0)
Duel.LoadScript("random.lua")
math.randomseed(_G.RANDOMSEED)
for i=1,10 do
math.random(1000)
end
end
function CUNGUI.AdjustOperation()
if not CUNGUI.INIT then
CUNGUI.INIT = true
CUNGUI.RegisterCardRule(0)
CUNGUI.RegisterCardRule(1)
end
if CUNGUI.RuleCard[0] and (not CUNGUI.RuleCard[0]:IsLocation(LOCATION_REMOVED) or not CUNGUI.RuleCard[0]:IsFaceup()) then
Duel.Remove(CUNGUI.RuleCard[0],POS_FACEUP,REASON_RULE)
end
if CUNGUI.RuleCard[1] and (not CUNGUI.RuleCard[1]:IsLocation(LOCATION_REMOVED) or not CUNGUI.RuleCard[1]:IsFaceup()) then
Duel.Remove(CUNGUI.RuleCard[1],POS_FACEUP,REASON_RULE)
end
if CUNGUI.RuleCard[0] and not CUNGUI.RuleCard[0]:IsFaceup() then
Duel.ChangePosition(CUNGUI.RuleCard[0],POS_FACEUP)
end
if CUNGUI.RuleCard[1] and not CUNGUI.RuleCard[1]:IsFaceup() then
Duel.ChangePosition(CUNGUI.RuleCard[1],POS_FACEUP)
end
end
CUNGUI.RuleCard={}
function CUNGUI.RegisterCardRule(tp)
local c=Duel.CreateToken(tp,36350300)
Duel.Remove(c,POS_FACEUP,REASON_RULE)
CUNGUI.RuleCard[tp]=c
--forbid
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(66666004,4))
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetCondition(CUNGUI.rulecond)
e1:SetOperation(CUNGUI.ruleop)
c:RegisterEffect(e1)
end
function CUNGUI.rulecond(e,tp,eg,ep,ev,re,r,rp)
return (Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2) and Duel.GetCurrentChain()<1
end
function CUNGUI.CheckCard(c)
return c.card_code_list ~= nil
end
function CUNGUI.ruleop(e,tp,eg,ep,ev,re,r,rp)
local rand = math.random(#CUNGUI.RandomCard)
local code = CUNGUI.RandomCard[rand]
local card = Duel.CreateToken(tp,code)
while not CUNGUI.CheckCard(card) do
table.remove(CUNGUI.RandomCard,rand)
rand = math.random(#CUNGUI.RandomCard)
code = CUNGUI.RandomCard[rand]
card = Duel.CreateToken(tp,code)
end
Duel.SendtoHand(card,nil,REASON_RULE)
for lcode,_ in pairs(card.card_code_list) do
local tc=Duel.CreateToken(tp,lcode)
Duel.SendtoHand(tc,tp,REASON_EFFECT)
tc=Duel.CreateToken(tp,lcode)
Duel.SendtoHand(tc,tp,REASON_EFFECT)
end
end
--村规决斗:七战之才
--开局时,双方将1张胜利龙(44910027)从卡组外表侧表示除外。
--这场决斗中这张卡不是表侧表示除外的场合,这张卡表侧表示除外。
--这张卡得到以下效果。
--1回合1次,对方这个回合发动过怪兽·魔法·陷阱卡效果的场合,自己主要阶段才能处理这个效果。这个效果的处理不会被无效化。
--从卡组外选【鹰身女郎的羽毛扫】【雷击】【心变】【爱恶作剧的双子恶魔】【强欲之壶】【天使的施舍】【遗言状】中的任意1张加入手卡。
CUNGUI = {}
function Auxiliary.PreloadUds()
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetOperation(CUNGUI.AdjustOperation)
Duel.RegisterEffect(e1,0)
end
function CUNGUI.AdjustOperation()
if not CUNGUI.INIT then
CUNGUI.INIT = true
CUNGUI.RegisterCardRule(0)
CUNGUI.RegisterCardRule(1)
end
if CUNGUI.RuleCard[0] and (not CUNGUI.RuleCard[0]:IsLocation(LOCATION_REMOVED) or not CUNGUI.RuleCard[0]:IsFaceup()) then
Duel.Remove(CUNGUI.RuleCard[0],POS_FACEUP,REASON_RULE)
end
if CUNGUI.RuleCard[1] and (not CUNGUI.RuleCard[1]:IsLocation(LOCATION_REMOVED) or not CUNGUI.RuleCard[1]:IsFaceup()) then
Duel.Remove(CUNGUI.RuleCard[1],POS_FACEUP,REASON_RULE)
end
if CUNGUI.RuleCard[0] and not CUNGUI.RuleCard[0]:IsFaceup() then
Duel.ChangePosition(CUNGUI.RuleCard[0],POS_FACEUP)
end
if CUNGUI.RuleCard[1] and not CUNGUI.RuleCard[1]:IsFaceup() then
Duel.ChangePosition(CUNGUI.RuleCard[1],POS_FACEUP)
end
end
CUNGUI.RuleCard={}
function CUNGUI.RegisterCardRule(tp)
local c=Duel.CreateToken(tp,44910027)
Duel.Remove(c,POS_FACEUP,REASON_RULE)
CUNGUI.RuleCard[tp]=c
--forbid
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(66666004,4))
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1)
e1:SetProperty(EFFECT_FLAG_CANNOT_INACTIVATE+EFFECT_FLAG_CANNOT_NEGATE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_REMOVED)
e1:SetCondition(CUNGUI.rulecond)
e1:SetOperation(CUNGUI.ruleop)
c:RegisterEffect(e1)
Duel.AddCustomActivityCounter(66666004,ACTIVITY_CHAIN,aux.FALSE)
end
function CUNGUI.rulecond(e,tp,eg,ep,ev,re,r,rp)
return (Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2) and Duel.GetCurrentChain()<1
and Duel.GetCustomActivityCount(66666004,1-tp,ACTIVITY_CHAIN)~=0
end
function CUNGUI.ruleop(e,tp,eg,ep,ev,re,r,rp)
local list = {18144506,12580477,4031928,44763025,55144522,79571449,85602018}
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CODE)
local code=Duel.AnnounceCard(tp,18144506,OPCODE_ISCODE,12580477,OPCODE_ISCODE,OPCODE_OR,4031928,
OPCODE_ISCODE,OPCODE_OR,44763025,OPCODE_ISCODE,OPCODE_OR,55144522,OPCODE_ISCODE,OPCODE_OR,79571449,OPCODE_ISCODE,OPCODE_OR,85602018,OPCODE_ISCODE,OPCODE_OR)
local tc=Duel.CreateToken(tp,code)
Duel.SendtoHand(tc,nil,REASON_RULE)
end
--村规决斗:互助联盟
--所有卡得到以下效果:
--自己场上的卡被战斗·效果破坏的场合,可以作为代替把自己场上1张卡破坏。
CUNGUI = {}
function Auxiliary.PreloadUds()
--adjust
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetCode(EVENT_ADJUST)
e1:SetOperation(CUNGUI.AdjustOperation)
Duel.RegisterEffect(e1,0)
end
CUNGUI.RegisteredMonsters = Group.CreateGroup()
function CUNGUI.AdjustOperation(e,tp,eg,ep,ev,re,r,rp)
local g = Duel.GetMatchingGroup(nil,0,LOCATION_DECK+LOCATION_HAND+LOCATION_EXTRA,LOCATION_DECK+LOCATION_HAND+LOCATION_EXTRA,nil)
g:ForEach(CUNGUI.RegisterMonsterSpecialEffects)
end
function CUNGUI.RegisterMonsterSpecialEffects(c)
if CUNGUI.RegisteredMonsters:IsContains(c) then return end
CUNGUI.RegisteredMonsters:AddCard(c)
--destroy replace
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_DESTROY_REPLACE)
e1:SetRange(LOCATION_ONFIELD)
e1:SetTarget(CUNGUI.desreptg)
e1:SetValue(CUNGUI.desrepval)
e1:SetOperation(CUNGUI.desrepop)
c:RegisterEffect(e1)
end
function CUNGUI.repfilter(c,tp)
return c:IsControler(tp) and c:IsLocation(LOCATION_ONFIELD)
and c:IsReason(REASON_BATTLE+REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
end
function CUNGUI.desfilter(c,e,tp)
return c:IsFaceup() and c:IsControler(tp) and c:IsLocation(LOCATION_ONFIELD)
and c:IsDestructable(e) and not c:IsStatus(STATUS_DESTROY_CONFIRMED+STATUS_BATTLE_DESTROYED)
end
function CUNGUI.desreptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return eg:IsExists(CUNGUI.repfilter,1,nil,tp)
and Duel.IsExistingMatchingCard(CUNGUI.desfilter,tp,LOCATION_ONFIELD,0,1,nil,e,tp) end
if Duel.SelectEffectYesNo(tp,e:GetHandler(),96) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESREPLACE)
local g=Duel.SelectMatchingCard(tp,CUNGUI.desfilter,tp,LOCATION_ONFIELD,0,1,1,nil,e,tp)
e:SetLabelObject(g:GetFirst())
g:GetFirst():SetStatus(STATUS_DESTROY_CONFIRMED,true)
return true
end
return false
end
function CUNGUI.desrepval(e,c)
return CUNGUI.repfilter(c,e:GetHandlerPlayer())
end
function CUNGUI.desrepop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_CARD,0,2881864)
local tc=e:GetLabelObject()
tc:SetStatus(STATUS_DESTROY_CONFIRMED,false)
Duel.Destroy(tc,REASON_EFFECT+REASON_REPLACE)
end
--村规决斗:无证驾驶
--进行各种选卡动作时,
--不再过滤特定的卡。
--每个回合把手卡抽到5张(最少为1)。
--细则:
--大部分情况下,并不改变卡片的发动条件;
--只是在选取对象和处理卡的选择时可以任意选。
--不会扩大选取范围。
CUNGUI = {}
local SelectMatchingCard = Duel.SelectMatchingCard
Duel.SelectMatchingCard = function(tp,f,tp2,s,o,min,max,ex,...)
return SelectMatchingCard(tp,aux.TRUE,tp2,s,o,min,max,nil,...)
end
local SelectTarget = Duel.SelectTarget
Duel.SelectTarget = function(tp,f,tp2,s,o,min,max,ex,...)
return SelectTarget(tp,aux.TRUE,tp2,s,o,min,max,nil,...)
end
local DiscardHand = Duel.DiscardHand
Duel.DiscardHand = function(tp,f,min,max,reason)
return DiscardHand(tp,aux.TRUE,min,max,reason)
end
local SelectReleaseGroup = Duel.SelectReleaseGroup
Duel.SelectReleaseGroup = function(tp,f,min,max,ex,...)
return SelectReleaseGroup(tp,aux.TRUE,min,max,nil,...)
end
local SelectReleaseGroupEx = Duel.SelectReleaseGroupEx
Duel.SelectReleaseGroupEx = function(tp,f,min,max,ex,...)
return SelectReleaseGroupEx(tp,aux.TRUE,min,max,nil,...)
end
local SelectSubGroup = Group.SelectSubGroup
Group.SelectSubGroup = function(g,tp,f,cancelable,min,max,...)
return SelectSubGroup(g,tp,aux.TRUE,cancelable,min,max,...)
end
local GetFirstMatchingCard = Duel.GetFirstMatchingCard
Duel.GetFirstMatchingCard = function(f,tp,s,o,ex,...)
return SelectMatchingCard(tp,aux.TRUE,tp,s,o,1,1,nil,...)
end
function Auxiliary.PreloadUds()
--Draw
local e2=Effect.GlobalEffect()
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_DRAW_COUNT)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetTargetRange(1,1)
e2:SetValue(CUNGUI.DrawCount)
Duel.RegisterEffect(e2,0)
end
function CUNGUI.DrawCount(e)
if Duel.GetTurnCount()==1 then return 0 end
local p=Duel.GetTurnPlayer()
local ct=Duel.GetFieldGroupCount(p,LOCATION_HAND,0)
if ct>4 then return 1
else return 5-ct 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