Commit 2c2cbb79 authored by Tachibana's avatar Tachibana

E

parent b47595b0
...@@ -134,7 +134,7 @@ function cm.initial_effect(c) ...@@ -134,7 +134,7 @@ function cm.initial_effect(c)
--local e1=rsef.QO(c,nil,{m,1},nil,"rec","ptg",LOCATION_HAND+LOCATION_MZONE,nil,rsds.cost1,rsop.target(800,"rec"),cm.recop) --local e1=rsef.QO(c,nil,{m,1},nil,"rec","ptg",LOCATION_HAND+LOCATION_MZONE,nil,rsds.cost1,rsop.target(800,"rec"),cm.recop)
local e2=rsef.QO(c,nil,{m,2},nil,"sp",nil,LOCATION_HAND+LOCATION_MZONE,nil,rsds.cost1,rsop.target2(cm.resetfun,cm.spfilter,"sp",LOCATION_HAND),cm.spop) local e2=rsef.QO(c,nil,{m,2},nil,"sp",nil,LOCATION_HAND+LOCATION_MZONE,nil,rsds.cost1,rsop.target2(cm.resetfun,cm.spfilter,"sp",LOCATION_HAND),cm.spop)
--local e3=rsef.QO(c,nil,{m,3},nil,"rm",nil,LOCATION_HAND+LOCATION_MZONE,nil,rsds.cost1,rsop.target2(cm.resetfun,cm.rmfilter,"rm",LOCATION_MZONE,LOCATION_MZONE),cm.rmop) --local e3=rsef.QO(c,nil,{m,3},nil,"rm",nil,LOCATION_HAND+LOCATION_MZONE,nil,rsds.cost1,rsop.target2(cm.resetfun,cm.rmfilter,"rm",LOCATION_MZONE,LOCATION_MZONE),cm.rmop)
local e3=rsef.QO(c,nil,{m,4},nil,"atl,def",nil,LOCATION_HAND+LOCATION_MZONE,nil,rsds.cost1,rsop.target2(cm.resetfun,cm.atkfilter,nil,LOCATION_MZONE,LOCATION_MZONE),cm.atkop) local e3=rsef.QO(c,nil,{m,4},nil,"atk,def",nil,LOCATION_HAND+LOCATION_MZONE,nil,rsds.cost1,rsop.target2(cm.resetfun,cm.atkfilter,nil,LOCATION_MZONE,LOCATION_MZONE),cm.atkop)
--local e4=rsef.FTF(c,EVENT_LEAVE_FIELD,{m,0},{2,m},"th",nil,LOCATION_REMOVED,cm.embthcon,rscost.regflag2(),rsop.target(Card.IsAbleToHand,"th"),cm.embthop) --local e4=rsef.FTF(c,EVENT_LEAVE_FIELD,{m,0},{2,m},"th",nil,LOCATION_REMOVED,cm.embthcon,rscost.regflag2(),rsop.target(Card.IsAbleToHand,"th"),cm.embthop)
local e4=rsef.FTF(c,EVENT_LEAVE_FIELD,{m,0},nil,"th",nil,LOCATION_REMOVED,cm.embthcon,cm.embthcost,rsop.target(Card.IsAbleToHand,"th"),cm.embthop) local e4=rsef.FTF(c,EVENT_LEAVE_FIELD,{m,0},nil,"th",nil,LOCATION_REMOVED,cm.embthcon,cm.embthcost,rsop.target(Card.IsAbleToHand,"th"),cm.embthop)
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
if not pcall(function() require("expansions/script/c10199991") end) then require("script/c10199991") end if not pcall(function() require("expansions/script/c10199991") end) then require("script/c10199991") end
local m = 10199990 local m = 10199990
local vm = 10199991 local vm = 10199991
local Version_Number = 20210618 local Version_Number = 20220810
if rsv.Library_Switch then return end if rsv.Library_Switch then return end
rsv.Library_Switch = true rsv.Library_Switch = true
-----------------------"Part_Effect_Base"----------------------- -----------------------"Part_Effect_Base"-----------------------
...@@ -493,7 +493,6 @@ function rsef.Register(reg_list, eff_type, eff_code, desc_list, lim_list, cate, ...@@ -493,7 +493,6 @@ function rsef.Register(reg_list, eff_type, eff_code, desc_list, lim_list, cate,
end end
-------------------"Part_Effect_SingleValue"------------------- -------------------"Part_Effect_SingleValue"-------------------
--Single Val Effect: Base set --Single Val Effect: Base set
function rsef.SV(reg_list, code, val, range, con, reset_list, flag, desc_list, lim_list) function rsef.SV(reg_list, code, val, range, con, reset_list, flag, desc_list, lim_list)
local reg_owner, reg_handler = rsef.GetRegisterCard(reg_list) local reg_owner, reg_handler = rsef.GetRegisterCard(reg_list)
...@@ -586,7 +585,6 @@ function rsef.SV_CannotDisable_NoEffect(reg_list, con, reset_list, flag, desc_li ...@@ -586,7 +585,6 @@ function rsef.SV_CannotDisable_NoEffect(reg_list, con, reset_list, flag, desc_li
end end
--Single Val Effect: Utility Procedure Materials --Single Val Effect: Utility Procedure Materials
function rsef.SV_UtilityXyzMaterial(reg_list, val, con, reset_list, flag, desc_list, lim_list, range) function rsef.SV_UtilityXyzMaterial(reg_list, val, con, reset_list, flag, desc_list, lim_list, range)
rssf.EnableSpecialXyzProcedure()
val = val or 2 val = val or 2
range = range or LOCATION_HAND + LOCATION_ONFIELD + LOCATION_EXTRA + LOCATION_DECK + LOCATION_GRAVE range = range or LOCATION_HAND + LOCATION_ONFIELD + LOCATION_EXTRA + LOCATION_DECK + LOCATION_GRAVE
local e1 = rsef.SV(reg_list, rscode.Utility_Xyz_Material, val, range, con, reset_list, flag, desc_list, lim_list) local e1 = rsef.SV(reg_list, rscode.Utility_Xyz_Material, val, range, con, reset_list, flag, desc_list, lim_list)
...@@ -729,13 +727,13 @@ end ...@@ -729,13 +727,13 @@ end
function rsef.FV_ExtraMaterial_Self(reg_list, mat_list, val_list, tg, tg_range_list, con, reset_list, flag, desc_list, lim_list) function rsef.FV_ExtraMaterial_Self(reg_list, mat_list, val_list, tg, tg_range_list, con, reset_list, flag, desc_list, lim_list)
local code_list_1 = { "syn", "xyz", "link" } local code_list_1 = { "syn", "xyz", "link" }
local code_list_2 = { rscode.Extra_Synchro_Material, rscode.Extra_Xyz_Material, EFFECT_EXTRA_LINK_MATERIAL } local code_list_2 = { rscode.Extra_Synchro_Material, rscode.Extra_Xyz_Material, EFFECT_EXTRA_LINK_MATERIAL }
val_list = val_list or { function(e, c, mg) return c == e:GetHandler() end } val_list = val_list or { function(e, c, mg) return c == e:GetHandler(), true end }
tg_range_list = tg_range_list or { LOCATION_HAND, 0 } tg_range_list = tg_range_list or { LOCATION_HAND, 0 }
local flag2 = rsef.GetRegisterProperty(reg_list, flag) | EFFECT_FLAG_IGNORE_IMMUNE + EFFECT_FLAG_SET_AVAILABLE + EFFECT_FLAG_UNCOPYABLE local flag2 = rsef.GetRegisterProperty(reg_list, flag) | EFFECT_FLAG_IGNORE_IMMUNE + EFFECT_FLAG_SET_AVAILABLE + EFFECT_FLAG_UNCOPYABLE
local code_list, val_list2 = rsof.Table_Suit(mat_list, code_list_1, code_list_2, val_list) local code_list, val_list2 = rsof.Table_Suit(mat_list, code_list_1, code_list_2, val_list)
local eff_list = { } local eff_list = { }
for idx, eff_code in ipairs(code_list) do for idx, eff_code in ipairs(code_list) do
local e1 = rsef.FV(reg_list, eff_code, val_list2[idx], tg, tg_range_list, LOCATION_EXTRA, con, reset_list, flag2, desc_list, lim_list) local e1 = rsef.FV(reg_list, eff_code, val_list2[idx], nil, tg_range_list, LOCATION_EXTRA, con, reset_list, flag2, desc_list, lim_list)
table.insert(eff_list, e1) table.insert(eff_list, e1)
end end
return table.unpack(eff_list) return table.unpack(eff_list)
...@@ -910,195 +908,113 @@ function rstg.FC_DestroyReplace(repfilter, tg) ...@@ -910,195 +908,113 @@ function rstg.FC_DestroyReplace(repfilter, tg)
return false return false
end end
end end
--Field Continues: Attach an extra effect
--Field Continues: Attach an extra effect when base effect is activating function rsef.Enable_Attach_Effect()
function rsef.FC_AttachEffect_Activate(reg_list, desc_list, lim_list, flag, range, attach_con, attach_op, reset_list, force) if rsef.SV_AttachEffect_Switch then return end
return rsef.FC_AttachEffect(reg_list, force, 0x1, desc_list, lim_list, flag, range, attach_con, attach_op, reset_list) rsef.SV_AttachEffect_Switch = true
end local e2 = rsef.FC_Global(0,EVENT_CHAIN_SOLVING, rscode.Attach_Effect, nil, rsef.SV_AttachEffect_OP)
--Field Continues: Attach an extra effect before the base effect solving
function rsef.FC_AttachEffect_BeforeResolve(reg_list, desc_list, lim_list, flag, range, attach_con, attach_op, reset_list, force)
return rsef.FC_AttachEffect(reg_list, force, 0x2, desc_list, lim_list, flag, range, attach_con, attach_op, reset_list)
end end
--Field Continues: Attach an extra effect after the base effect solving function rsef.AttachEffect_Hint(ae, tp)
function rsef.FC_AttachEffect_Resolve(reg_list, desc_list, lim_list, flag, range, attach_con, attach_op, reset_list, force) rsef.AttachEffect_Hint2(ae:GetHandler())
return rsef.FC_AttachEffect(reg_list, force, 0x4, desc_list, lim_list, flag, range, attach_con, attach_op, reset_list) Duel.Hint(HINT_OPSELECTED, 1 - tp, ae:GetDescription())
end end
function rsef.FC_AttachEffect(reg_list, force, attach_time, desc_list, lim_list, flag, range, attach_con, attach_op, reset_list) function rsef.AttachEffect_Hint2(c)
local reg_owner, reg_handler = rsef.GetRegisterCard(reg_list) if c:IsLocation(LOCATION_ONFIELD + LOCATION_GRAVE + LOCATION_REMOVED) and c:IsFaceup() then
range = range or rsef.GetRegisterRange(reg_list) Duel.HintSelection(Group.FromCards(c))
local attach_code = rscode.Extra_Effect_Activate
if attach_time == 0x2 then attach_code = rscode.Extra_Effect_BSolve end
if attach_time == 0x4 then attach_code = rscode.Extra_Effect_ASolve end
local e0 = rsef.I(reg_list, nil, lim_list, nil, flag, range, aux.FALSE, nil, nil, nil, reset_list)
local e1 = rsef.FC(reg_list, attach_code, desc_list, nil, flag, range, rsef.FC_AttachEffect_Con(e0, attach_con), rsef.FC_AttachEffect_Op(e0, force), reset_list)
e1:SetValue(attach_op)
e1:SetLabelObject(e0)
local desc = not desc_list and 0 or rsef.RegisterDescription(nil, desc_list, nil, true)
if aux.GetValueType(reg_handler) == "Card" then
reg_handler:RegisterFlagEffect(attach_code, reset, EFFECT_FLAG_CLIENT_HINT, reset_tct, e1:GetFieldID(), desc)
else else
local e1 = Effect.CreateEffect(reg_owner) Duel.Hint(HINT_CARD, 0, c:GetOriginalCode())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(0x10000000 + attach_code)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_CLIENT_HINT)
e1:SetDescription(desc)
e1:SetTargetRange(1, 0)
e1:SetReset(reset, reset_tct)
Duel.RegisterEffect(e1, reg_handler)
end
if rsef.FC_AttachEffect_Switch then return e1 end
rsef.FC_AttachEffect_Switch = true
for p = 0, 1 do
local e2 = Effect.GlobalEffect()
e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_CHAIN_SOLVING)
e2:SetOperation(rsef.FC_AttachEffect_ChangeOp)
e2:SetOwnerPlayer(p)
Duel.RegisterEffect(e2, p)
end
rsef.ChangeChainOperation = Duel.ChangeChainOperation
Duel.ChangeChainOperation = rsef.ChangeChainOperation2
return e1
end
function rsef.FC_AttachEffect_Con(e0, attach_con)
return function(e, tp, eg, ep, ev, re, r, rp)
if not e0:CheckCountLimit(tp) then return false end
return not attach_con or attach_con(e, tp, eg, ep, ev, re, r, rp)
end end
end end
function rsef.FC_AttachEffect_Op(e0, force) function rsef.SV_AttachEffect_OP(e, p, eg, ep, ev, re, r, rp)
return function(e, tp, eg, ep, ev, re, r, rp) rsef.attach_before_arr[ev] = { }
rsef.attacheffect[ev] = rsef.attacheffect[ev] or { } rsef.attach_after_arr[ev] = { }
rsef.attacheffectf[ev] = rsef.attacheffectf[ev] or { } rsef.attach_base_arr[ev] = { }
if force then table.insert(rsef.attacheffectf[ev], e) local parr = { [0] = Duel.GetTurnPlayer(), [1] = 1 - Duel.GetTurnPlayer() }
else local attach_desc = { [0] = { }, [1] = { } }
table.insert(rsef.attacheffect[ev], e) local attach_op = { [0] = { }, [1] = { } }
local attach_e = { }
local attach_op_final = { }
local attach_op_force_final = { }
local sel_group = { [0] = Group.CreateGroup(), [1] = Group.CreateGroup() }
local ap, arr, ac
for p = 0, 1 do
ap = parr[p]
arr = { Duel.IsPlayerAffectedByEffect(ap, rscode.Attach_Effect) }
for _, ae in pairs(arr) do
ac = ae:GetHandler()
local av = ae:GetValue()
local con, op, force= av(ae, ap, re, rp)
if con then
if force then
rsef.AttachEffect_Hint(ae, ap)
ae:UseCountLimit(ap)
table.insert(attach_op_force_final, op)
else
attach_desc[ac] = attach_desc[ac] or { }
attach_op[ac] = attach_op[ac] or { }
attach_e[ac] = attach_e[ac] or { }
table.insert(attach_desc[ac], ae:GetDescription())
table.insert(attach_op[ac], op)
table.insert(attach_e[ac], ae)
sel_group[ap]:AddCard(ac)
end
end
end end
end end
end local sel_group_x = Group.CreateGroup()
function rsef.FC_AttachEffect_GetGroup(sel_list) local ac, opt
local attach_group = Group.CreateGroup() for p = 0, 1 do
local attach_eff_list = { } ap = parr[p]
for _, ae in pairs(sel_list) do if #(sel_group[ap]) > 0 then
local tc = ae:GetOwner() Duel.ConfirmCards(ap, sel_group[ap])
attach_group:AddCard(tc) repeat
attach_eff_list[tc] = attach_eff_list[tc] or { } Duel.Hint(HINT_SELECTMSG, ap, rshint.attach_card)
table.insert(attach_eff_list[tc], ae) ac = sel_group[ap]:SelectUnselect(sel_group_x, tp, true, true, 1, 1)
if ac then
rsef.AttachEffect_Hint2(ac)
Duel.Hint(HINT_SELECTMSG, ap, rshint.attach_effect)
opt = Duel.SelectOption(ap, table.unpack(attach_desc[ac])) + 1
table.insert(attach_op_final, attach_op[ac][opt])
Duel.Hint(HINT_OPSELECTED, 1 - ap, attach_desc[ac][opt])
attach_e[ac][opt]:UseCountLimit(ap)
table.remove(attach_op[ac],opt)
table.remove(attach_desc[ac],opt)
if #attach_op[ac] == 0 then
sel_group[ap]:RemoveCard(ac)
end
end
until #sel_group[ap] == 0 or not ac
end
end
if #attach_op_force_final > 0 or #attach_op_final > 0 then
Duel.ChangeChainOperation(ev, rsef.SV_AttachEffect_Change_OP(re:GetOperation() or aux.TRUE, attach_op_force_final, attach_op_final))
end end
return attach_group, attach_eff_list
end
function rsef.ChangeChainOperation2(ev, changeop, ischange)
rsef.ChangeChainOperation(ev, changeop)
if ischange then return end
rsop.baseop[ev] = changeop
end
function rsef.FC_AttachEffect_ChangeOp(e, tp, eg, ep, ev, re, r, rp)
local baseop = re:GetOperation() or aux.TRUE
baseop = rsop.baseop[ev] or baseop
local e1 = rsef.FC({ true, 0 }, EVENT_CHAIN_SOLVED, nil, nil, nil, nil, nil, rsef.FC_AttachEffect_Reset(re, baseop), RESET_CHAIN)
rsef.ChangeChainOperation2(ev, rsef.FC_AttachEffect_ChangeOp2(baseop), true)
end end
function rsef.FC_AttachEffect_Reset(re1, baseop) function rsef.SV_AttachEffect_Change_OP(op, a_f_op, a_op)
return function(e, tp, eg, ep, ev, re, r, rp) return function(e, tp, eg, ep, ev0, re, r, rp)
if re1 ~= re then return end
rsef.attacheffect[ev] = nil
rsef.attacheffectf[ev] = nil
rsef.solveeffect[ev] = nil
rsop.baseop[ev] = nil
local rc = re:GetHandler()
local res1 = re:IsHasType(EFFECT_TYPE_ACTIVATE) and rc:IsType(TYPE_PENDULUM + TYPE_FIELD + TYPE_CONTINUOUS + TYPE_EQUIP)
local res2 = #({ rc:IsHasEffect(EFFECT_REMAIN_FIELD) }) > 0
--what is ev2 ??
if (res1 or res2) then--and not rsop.baseop[ev2] then
re:SetOperation(baseop)
rc:CancelToGrave(true)
end
end
end
function rsef.FC_AttachEffect_Solve(solve_eff_list, attach_time, e, tp, eg, ep, ev, re, r, rp)
local act_use_list = { }
local ev2 = Duel.GetCurrentChain()
local attach_code = rscode.Extra_Effect_Activate
if attach_time == 0x2 then attach_code = rscode.Extra_Effect_BSolve end
if attach_time == 0x4 then attach_code = rscode.Extra_Effect_ASolve end
Duel.RaiseEvent(e:GetHandler(), attach_code, e, 0, tp, tp, ev2)
local force_list = rsef.attacheffectf[ev2] or { }
local sel_tab_list = rsef.attacheffect[ev2] or { }
for _, ae in pairs(force_list) do
local tc = ae:GetOwner()
if tc:IsOnField() then
Duel.HintSelection(rsgf.Mix2(tc))
else
Duel.Hint(HINT_CARD, 0, tc:GetOriginalCodeRule())
end
Duel.Hint(HINT_OPSELECTED, 1 - tp, ae:GetDescription())
table.insert(act_use_list, ae)
ae:GetLabelObject():UseCountLimit(tp, 1)
if attach_time ~= 0x1 then
table.insert(solve_eff_list, ae)
ae:GetValue()(e, tp, eg, ep, ev, re, r, rp)
end
end
local attach_group, attach_eff_list = rsef.FC_AttachEffect_GetGroup(sel_tab_list)
local sel_hint = 8
if attach_time == 0x2 then sel_hint = 9 end
if attach_time == 0x4 then sel_hint = 10 end
if #attach_group > 0 and Duel.SelectYesNo(tp, aux.Stringid(m, sel_hint)) then
::Select::
rshint.Select(tp, HINTMSG_TARGET)
local tc = attach_group:Select(tp, 1, 1, nil):GetFirst()
if tc:IsOnField() then
Duel.HintSelection(rsgf.Mix2(tc))
else
Duel.Hint(HINT_CARD, 0, tc:GetOriginalCodeRule())
end
local hint_list = { }
for _, ae in pairs(attach_eff_list[tc]) do
local hint = ae:GetDescription()
table.insert(hint_list, hint)
end
local opt = Duel.SelectOption(tp, table.unpack(hint_list)) + 1
local ae = attach_eff_list[tc][opt]
Duel.Hint(HINT_OPSELECTED, 1 - tp, ae:GetDescription())
table.insert(act_use_list, ae)
ae:GetLabelObject():UseCountLimit(tp, 1)
if attach_time ~= 0x1 then
table.insert(solve_eff_list, ae)
ae:GetValue()(e, tp, eg, ep, ev, re, r, rp)
end
local _, idx = rsof.Table_List(sel_tab_list, ae)
table.remove(sel_tab_list, idx)
attach_group, attach_eff_list = rsef.FC_AttachEffect_GetGroup(sel_tab_list)
if #attach_group > 0 and Duel.SelectYesNo(tp, aux.Stringid(m, 11)) then goto Select end
end
rsef.attacheffect[ev2] = nil
rsef.attacheffectf[ev2] = nil
return act_use_list
end
function rsef.FC_AttachEffect_ChangeOp2(baseop)
return function(e, tp, eg, ep, ev, re, r, rp)
local ev2 = Duel.GetCurrentChain()
local c = e:GetHandler() local c = e:GetHandler()
if (c:IsType(TYPE_FIELD) or c:IsType(TYPE_CONTINUOUS) or c:IsLocation(LOCATION_PZONE)) and not c:IsRelateToEffect(e) then if e:IsHasType(EFFECT_TYPE_ACTIVATE) and c:IsType(TYPE_CONTINUOUS + TYPE_EQUIP + TYPE_PENDULUM) then
return c:CancelToGrave(true)
end end
rsef.solveeffect[ev2] = { } local ev = Duel.GetCurrentChain()
--baseop record for _, aop in pairs(a_f_op) do
table.insert(rsef.solveeffect[ev2], baseop) aop(e, tp, eg, ep, ev, re, r, rp, 0)
--activate select table.insert(rsef.attach_before_arr[ev], aop)
local act_use_list = rsef.FC_AttachEffect_Solve(rsef.solveeffect[ev2], 0x1, e, tp, eg, ep, ev, re, r, rp) end
--before solve for _, aop in pairs(a_op) do
rsef.FC_AttachEffect_Solve(rsef.solveeffect[ev2], 0x2, e, tp, eg, ep, ev, re, r, rp) aop(e, tp, eg, ep, ev, re, r, rp, 0)
--baseop solve table.insert(rsef.attach_before_arr[ev], aop)
baseop(e, tp, eg, ep, ev, re, r, rp) end
--activate solve op(e, tp, eg, ep, ev, re, r, rp)
for _, ae in pairs(act_use_list) do table.insert(rsef.attach_base_arr[ev], op)
table.insert(rsef.solveeffect[ev2], ae) for _, aop in pairs(a_f_op) do
ae:GetValue()(e, tp, eg, ep, ev, re, r, rp) aop(e, tp, eg, ep, ev, re, r, rp, 1)
ae:GetLabelObject():UseCountLimit(tp, 1) table.insert(rsef.attach_after_arr[ev], aop)
end end
--after solve for _, aop in pairs(a_op) do
rsef.FC_AttachEffect_Solve(rsef.solveeffect[ev2], 0x4, e, tp, eg, ep, ev, re, r, rp) aop(e, tp, eg, ep, ev, re, r, rp, 1)
table.insert(rsef.attach_after_arr[ev], aop)
end
end end
end end
...@@ -1530,14 +1446,24 @@ function rssf.SpecialSummonToken(e, tp, tk_code_or_fun, minct, maxct, sum_pos, t ...@@ -1530,14 +1446,24 @@ function rssf.SpecialSummonToken(e, tp, tk_code_or_fun, minct, maxct, sum_pos, t
local res_ct = 0 local res_ct = 0
local res = rssf.CheckTokenSummonable(e, tp, tk_code_or_fun, sum_pos, tg_p, sum_zone, ...) local res = rssf.CheckTokenSummonable(e, tp, tk_code_or_fun, sum_pos, tg_p, sum_zone, ...)
if not res then return res_ct end if not res then return res_ct end
local tk_code, tk_set, tk_type, tk_atk, tk_def, tk_lv, tk_race, tk_att, sum_pos2, sp, sum_type
if type(tk_code_or_fun) == "number" then
tk_code = tk_code_or_fun
elseif type(tk_code_or_fun) == "function" then
tk_code, tk_set, tk_type, tk_atk, tk_def, tk_lv, tk_race, tk_att, sum_pos2, sp, sum_type = tk_code_or_fun(e, tp, ...)
else
tk_code, tk_set, tk_type, tk_atk, tk_def, tk_lv, tk_race, tk_att, sum_pos2, sp, sum_type = table.unpack(tk_code_or_fun)
end
sp = sp or tg_p or tp
sum_pos = sum_pos2 or sum_pos or POS_FACEUP
sum_type = sum_type or 0
local ft = Duel.GetLocationCount(sp, LOCATION_MZONE, tp) local ft = Duel.GetLocationCount(sp, LOCATION_MZONE, tp)
if ft <= 0 then return false end if ft <= 0 then return res_ct end
local sum_min, sum_max = minct, math.min(maxct, ft)
if rssf.CheckBlueEyesSpiritDragon(tp) and type(minct) == "number" and minct > 1 then return res_ct end if rssf.CheckBlueEyesSpiritDragon(tp) and type(minct) == "number" and minct > 1 then return res_ct end
if type(minct) == "number" and ft < minct then return res_ct end if type(minct) == "number" and ft < minct then return res_ct end
if rsof.Check_Boolean(minct) then local sum_min, sum_max
sum_min= ft sum_min = rsof.Check_Boolean(minct) and ft or (minct or 1)
end sum_max = math.min(maxct or sum_min, ft)
if rssf.CheckBlueEyesSpiritDragon(tp) then if rssf.CheckBlueEyesSpiritDragon(tp) then
sum_min, sum_max = 1, 1 sum_min, sum_max = 1, 1
end end
...@@ -1550,17 +1476,6 @@ function rssf.SpecialSummonToken(e, tp, tk_code_or_fun, minct, maxct, sum_pos, t ...@@ -1550,17 +1476,6 @@ function rssf.SpecialSummonToken(e, tp, tk_code_or_fun, minct, maxct, sum_pos, t
end end
sp_ct = Duel.AnnounceNumber(tp, table.unpack(list)) sp_ct = Duel.AnnounceNumber(tp, table.unpack(list))
end end
local tk_code, tk_set, tk_type, tk_atk, tk_def, tk_lv, tk_race, tk_att, sum_pos2, sp, sum_type
if type(tk_code_or_fun) == "number" then
tk_code = tk_code_or_fun
elseif type(tk_code_or_fun) == "function" then
tk_code, tk_set, tk_type, tk_atk, tk_def, tk_lv, tk_race, tk_att, sum_pos2, sp, sum_type = tk_code_or_fun(e, tp, ...)
else
tk_code, tk_set, tk_type, tk_atk, tk_def, tk_lv, tk_race, tk_att, sum_pos2, sp, sum_type = table.unpack(tk_code_or_fun)
end
sp = sp or tg_p or tp
sum_pos = sum_pos2 or sum_pos or POS_FACEUP
sum_type = sum_type or 0
for idx = 1, sp_ct do for idx = 1, sp_ct do
tk = Duel.CreateToken(tp, tk_code) tk = Duel.CreateToken(tp, tk_code)
if type(tk_code_or_fun) ~= "number" then if type(tk_code_or_fun) ~= "number" then
...@@ -2645,7 +2560,7 @@ function rsop.disneg(dn_type, dn_str, ex_op) ...@@ -2645,7 +2560,7 @@ function rsop.disneg(dn_type, dn_str, ex_op)
local c = e:GetHandler() local c = e:GetHandler()
local rc = re:GetHandler() local rc = re:GetHandler()
local res = not ex_op and true or ex_op(e, tp, eg, ep, ev, re, r, rp, 0) local res = not ex_op and true or ex_op(e, tp, eg, ep, ev, re, r, rp, 0)
if rsof.Check_Boolean(res,true) or type(res) == "nil" then if rsof.Check_Boolean(res,true) then
if dn_type == "dis" then if dn_type == "dis" then
res = Duel.NegateEffect(ev) res = Duel.NegateEffect(ev)
else else
...@@ -3166,6 +3081,31 @@ function rsop.SSet(corg, sp, tp, confirm) ...@@ -3166,6 +3081,31 @@ function rsop.SSet(corg, sp, tp, confirm)
tp = tp or sp tp = tp or sp
return rsop.Operation(Duel.SSet, sp, sg, tp, confirm) return rsop.Operation(Duel.SSet, sp, sg, tp, confirm)
end end
--Operation: Disable cards
function rsop.DisableCards(corg, dise, force, reset)
reset = reset or rsrst.std
force = force or false
local disc = dise:GetHandler()
local sg = rsgf.Mix2(corg)
local dg = Group.CreateGroup()
if rsop.chk == 0 then
return #sg > 0 and sg:FilterCount(aux.NegateAnyFilter, nil) == #sg
end
for tc in aux.Next(sg) do
Duel.NegateRelatedChain(tc,RESET_TURN_SET)
local e1,e2 = rscf.QuickBuff_ND({disc,tc,force}, "dis,dise",1,"rst", reset)
if not force then
e2:SetValue(RESET_TURN_SET)
end
if tc:IsType(TYPE_TRAPMONSTER) then
local e3 = rscf.QuickBuff_ND({disc,tc,force}, "distm",1, "rst", reset)
end
if force or not tc:IsImmuneToEffect(dise) then
dg:AddCard(tc)
end
end
return #dg, dg, dg:GetFirst(), e1, e2, e3
end
--Operation: Dummy --Operation: Dummy
function rsop.DummyOperate(corg) function rsop.DummyOperate(corg)
local sg = rsgf.Mix2(corg) local sg = rsgf.Mix2(corg)
...@@ -3661,203 +3601,36 @@ Card.CheckOriginalSetCard = rscf.CheckOriginalSetCard ...@@ -3661,203 +3601,36 @@ Card.CheckOriginalSetCard = rscf.CheckOriginalSetCard
function rscf.CheckPreviousSetCard(c, series1, ...) function rscf.CheckPreviousSetCard(c, series1, ...)
return rscf.CheckSetCardMainSet(c, "pre", series1, ...) return rscf.CheckSetCardMainSet(c, "pre", series1, ...)
end end
Card.CheckPreviousSetCard = rscf.CheckPreviousSetCard Card.CheckPreviousSetCard = rscf.CheckPreviousSetCard
--Card / Summon effect:Record Summon Procedure
function rssf.EnableSpecialProcedure()
if rssf.EnableSpecialProcedure_Switch then return end
local e1 = rsef.FC({ true, 0 }, EVENT_ADJUST)
e1:SetOperation(rssf.EnableSpecialProcedure_Op)
rssf.EnableSpecialProcedure_Switch = e1
end
function rssf.EnableSpecialProcedure_Op(e, tp)
local g = Duel.GetMatchingGroup(Card.IsType, 0, 0xff, 0xff, nil, TYPE_SYNCHRO + TYPE_XYZ + TYPE_LINK)
local f6 = aux.AddSynchroProcedure
local f7 = aux.AddSynchroMixProcedure
local f8 = aux.AddXyzProcedure
local f9 = aux.AddXyzProcedureLevelFree
local f10 = aux.AddLinkProcedure
aux.AddSynchroProcedure = rscf.GetBaseSynchroProduce1
aux.AddSynchroMixProcedure = rscf.GetBaseSynchroProduce2
aux.AddXyzProcedure = rscf.GetBaseXyzProduce1
aux.AddXyzProcedureLevelFree = rscf.GetBaseXyzProduce2
aux.AddLinkProcedure = rscf.GetBaseLinkProduce1
Card.RegisterEffect = rscf.RegisterEffect2
local e1 = Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTarget(rssf.EnableSpecialProcedure_Op_regop)
e1:SetTargetRange(1, 1)
Duel.RegisterEffect(e1, 0)
for tc in aux.Next(g) do
tc:IsSpecialSummonable()
local cid = tc:CopyEffect(tc:GetOriginalCode(), 0, 1)
end
aux.AddSynchroProcedure = f6
aux.AddSynchroMixProcedure = f7
aux.AddXyzProcedure = f8
aux.AddXyzProcedureLevelFree = f9
aux.AddLinkProcedure = f10
Card.RegisterEffect = rscf.RegisterEffect
e:Reset()
end
function rssf.EnableSpecialProcedure_Op_regop(e, c, tp, st, sp, stp, se)
if not c:IsType(rscf.extype) or c:IsType(TYPE_FUSION) then return false end
rscf.ssproce[c] = rscf.ssproce[c] or { [1] = { }, [2] = { } }
if se and se:GetCode() == EFFECT_SPSUMMON_PROC and not rsof.Table_List(rscf.ssproce[c][1], se) then
c:RegisterFlagEffect(rscode.Special_Procedure, 0, 0, 1)
table.insert(rscf.ssproce[c][1], se)
table.insert(rscf.ssproce[c][1], se:GetCondition() or aux.TRUE)
end
if se and rscf.ssproce[se] then return false end
return se and se:GetCode() == EFFECT_SPSUMMON_PROC
end
rscf.RegisterEffect = Card.RegisterEffect
function rscf.RegisterEffect2(c, e, ignore)
rscf.ssproce[c] = rscf.ssproce[c] or { [1] = { }, [2] = { } }
if e:GetCode() == EFFECT_SPSUMMON_PROC then
local flag1, flag2 = e:GetProperty()
local flag1_uc = flag1
if flag1 & EFFECT_FLAG_UNCOPYABLE ~=0 then
flag1_uc = flag1 - EFFECT_FLAG_UNCOPYABLE
end
e:SetProperty(flag1_uc, flag2)
rscf.RegisterEffect(c, e, ignore)
e:SetProperty(flag1, flag2)
rscf.ssproce[e] = true
table.insert(rscf.ssproce[c][2], e)
table.insert(rscf.ssproce[c][2], e:GetCondition() or aux.TRUE)
end
return
end
function rscf.SwitchSpecialProcedure_filter(c)
return c:GetFlagEffect(rscode.Special_Procedure) > 0
end
function rssf.SwitchSpecialProcedure(dis_idx, enb_idx)
end
function rscf.GetBaseSynchroProduce1(c, f1, f2, minc, maxc)
if c.dark_synchro == true then
rscf.AddSynchroProcedureSpecial(c, aux.NonTuner(f1), nil, nil, rscf.DarkTuner(f2), minc, maxc or 99)
else
rscf.AddSynchroProcedureSpecial(c, aux.Tuner(f1), nil, nil, f2, minc, maxc or 99)
end
end
function rscf.GetBaseSynchroProduce2(c, f1, f2, f3, f4, minc, maxc, gc)
rscf.AddSynchroProcedureSpecial(c, f1, f2, f3, f4, minc, maxc or 99, gc)
end
function rscf.XyzProcedure_TransformLv(xyzc, lv)
return function(g)
return g:FilterCount(Card.IsXyzLevel, nil, xyzc, lv) == #g
end
end
function rscf.GetBaseXyzProduce1(c, f, lv, ct, alterf, desc, maxct, op)
rscf.AddXyzProcedureSpecial(c, f, rscf.XyzProcedure_TransformLv(c, lv), ct, maxct or ct, alterf, desc, op)
end
function rscf.GetBaseXyzProduce2(c, f, gf, minc, maxc, alterf, desc, op)
rscf.AddXyzProcedureSpecial(c, f, gf, minc, maxc or minc, alterf, desc, op)
end
function rscf.GetBaseLinkProduce1(c, f, min, max, gf)
rscf.AddLinkProcedureSpecial(c, f, min, max, gf)
end
--Check is matg exist syncard's right materials
function rscf.GetLocationCountFromEx(...)
return 1
end
function rscf.CheckSynchroMaterial(sync, tp, smat, matg, min, max, checkft, checkmust, checkpend)
max = max or 99
local proce = sync.rs_synchro_parammeter[1]
if not proce then return false end
local con = proce:GetCondition()
local f = Duel.GetLocationCountFromEx
Duel.GetLocationCountFromEx = checkft and Duel.GetLocationCountFromEx or rscf.GetLocationCountFromEx
local f2 = aux.MustMaterialCheck
aux.MustMaterialCheck = checkmust and aux.MustMaterialCheck or aux.TRUE
local ctype = TYPE_PENDULUM
TYPE_PENDULUM = checkpend and TYPE_PENDULUM or TYPE_SPELL
local res= not con or con(nil, sync, smat, matg, min, max)
Duel.GetLocationCountFromEx = f
aux.MustMaterialCheck = f2
TYPE_PENDULUM = ctype
return res
end
--Select syncard's right materials
function rsgf.SelectSynchroMaterial(sync, tp, smat, matg, min, max, checkft, checkmust, checkpend)
max = max or 99
local proce = sync.rs_synchro_parammeter[1]
if not proce then return false end
local tg = proce:GetTarget()
local f = Duel.GetLocationCountFromEx
Duel.GetLocationCountFromEx = checkft and Duel.GetLocationCountFromEx or rscf.GetLocationCountFromEx
local f2 = aux.MustMaterialCheck
local ctype = TYPE_PENDULUM
TYPE_PENDULUM = checkpend and TYPE_PENDULUM or TYPE_SPELL
aux.MustMaterialCheck = checkmust and aux.MustMaterialCheck or aux.TRUE
local e1 = rsef.SV({ sync, nil, true }, rscode.Synchro_Material, nil, 0xff)
tg(e1, tp, nil, nil, nil, nil, nil, nil, 1, sync, smat, matg, min, max)
local g = e1:GetLabelObject()
Duel.GetLocationCountFromEx = f
aux.MustMaterialCheck = f2
TYPE_PENDULUM = ctype
if not g then e1:Reset() return false end
local og = g:Clone()
og:KeepAlive()
e1:Reset()
return og
end
--Card / Summon function: Custom Synchro Procedure --Card / Summon function: Custom Synchro Procedure
rscf.AddSynchroProcedure = aux.AddSynchroProcedure function rssf.AddSynchroProcedureSpecial(c,f1,f2,f3,f4,minc,maxc,gc)
function rscf.AddSynchroProcedureSpecial(c, f1, f2, f3, f4, minc, maxc, gc) local e1=Effect.CreateEffect(c)
local mt = getmetatable(c)
if not rscf.AddSynchroProcedureSpecial_Switch then
rscf.AddSynchroProcedureSpecial_Switch = true
rscf.GetSynMaterials = aux.GetSynMaterials
aux.GetSynMaterials = rscf.GetSynMaterials2
rscf.SynMixCheckGoal = aux.SynMixCheckGoal
aux.SynMixCheckGoal = rscf.SynMixCheckGoal2
rscf.SynMixCondition = aux.SynMixCondition
aux.SynMixCondition = rscf.SynMixCondition2
rscf.SynMixTarget = aux.SynMixTarget
aux.SynMixTarget = rscf.SynMixTarget2
rscf.SynMixOperation = aux.SynMixOperation
aux.SynMixOperation = rscf.SynMixOperation2
end
local e1 = Effect.CreateEffect(c)
e1:SetDescription(1164) e1:SetDescription(1164)
e1:SetType(EFFECT_TYPE_FIELD) e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE + EFFECT_FLAG_IGNORE_IMMUNE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetRange(LOCATION_EXTRA) e1:SetRange(LOCATION_EXTRA)
e1:SetCondition(rscf.SynMixCondition2(f1, f2, f3, f4, minc, maxc, gc)) e1:SetCondition(rssf.SynMixCondition(f1,f2,f3,f4,minc,maxc,gc))
e1:SetTarget(Auxiliary.SynMixTarget(f1, f2, f3, f4, minc, maxc, gc)) e1:SetTarget(rssf.SynMixTarget(f1,f2,f3,f4,minc,maxc,gc))
e1:SetOperation(Auxiliary.SynMixOperation(f1, f2, f3, f4, minc, maxc, gc)) e1:SetOperation(rssf.SynMixOperation(f1,f2,f3,f4,minc,maxc,gc))
e1:SetValue(SUMMON_TYPE_SYNCHRO) e1:SetValue(SUMMON_TYPE_SYNCHRO)
c:RegisterEffect(e1) c:RegisterEffect(e1)
if not c:IsStatus(STATUS_COPYING_EFFECT) and not c.rs_synchro_parammeter then
mt.rs_synchro_parammeter = { e1, f1, f2, f3, f4, minc, maxc or minc, gc }
end
return e1 return e1
end end
--Get synchro materials, fix for special material function rsgf.GetSynMaterials(tp, syncard)
function rscf.GetSynMaterials2(tp, syncard) local mg1 = rsgf.GetSynMaterials_R(tp, syncard)
local mg1 = rscf.GetSynMaterials(tp, syncard) local mg2 = Duel.GetMatchingGroup(rscf.SExtraFilter, tp, 0xff, 0xff, mg1, syncard, tp)
local mg2 = Duel.GetMatchingGroup(rscf.ExtraSynMaterialsFilter, tp, 0xff, 0xff, mg1, syncard, tp) return mg1 + mg2
if #mg2 > 0 then mg1:Merge(mg2) end
return mg1
end
function rscf.ExtraSynMaterialsFilter(c, sc, tp)
if c:IsOnField() and not c:IsFaceup() then return false end
return c:IsHasEffect(rscode.Extra_Synchro_Material, tp) and c:IsCanBeSynchroMaterial(sc)
end end
function rscf.SCheckOtherMaterial(c, mg, sc, tp) function rscf.SExtraFilter(c, sc, tp)
local le = { c:IsHasEffect(rscode.Extra_Synchro_Material, tp) } if c:IsOnField() and c:IsFacedown() then return false end
if #le == 0 then return true end if not c:IsCanBeSynchroMaterial(sc) then return false end
for _, te in pairs(le) do local le={c:IsHasEffect(rscode.Extra_Synchro_Material,tp)}
local f = te:GetValue() for _,te in pairs(le) do
if not f or f(te, sc, mg) then return true end local tf = te:GetValue()
local related, valid=tf(te, sc, nil, c, tp)
if related then return true end
end end
return false return false
end end
...@@ -3865,15 +3638,23 @@ function rscf.SUncompatibilityFilter(c, sg, sc, tp) ...@@ -3865,15 +3638,23 @@ function rscf.SUncompatibilityFilter(c, sg, sc, tp)
local mg = sg:Filter(aux.TRUE, c) local mg = sg:Filter(aux.TRUE, c)
return not rscf.SCheckOtherMaterial(c, mg, sc, tp) return not rscf.SCheckOtherMaterial(c, mg, sc, tp)
end end
function rscf.SynMixCheckGoal2(tp, sg, minc, ct, syncard, sg1, smat, gc, mgchk) function rscf.SCheckOtherMaterial(c, mg, sc, tp)
mgchk= mgchk or rssf.synchro_material_group_check local le={c:IsHasEffect(rscode.Extra_Synchro_Material,tp)}
local res1=false
local res2=true
for _, te in pairs(le) do
local f = te:GetValue()
local related, valid = f(te,sc,mg,c,tp)
if related then res2 = false end
if related and valid then res1 = true end
end
return res1 or res2
end
function rssf.SynMixCheckGoal(tp, sg, minc, ct, syncard, sg1, smat, gc, mgchk)
local mg = rsgf.Mix2(sg, sg1) local mg = rsgf.Mix2(sg, sg1)
--step 1, check extra material --step 1, check extra material
if mg:IsExists(rscf.SUncompatibilityFilter, 1, nil, mg, syncard, tp) then return false end if mg:IsExists(rscf.SUncompatibilityFilter, 1, nil, mg, syncard, tp) then return false end
--step 2, check material group filter function --step 2, check level fo dark_synchro and non - level_synchro
--useless
--if syncard.rs_synchro_material_check and not syncard.rs_synchro_material_check(mg, syncard, tp) then return false end
--step 3, check level fo dark_synchro and non - level_synchro
local f = Card.GetLevel local f = Card.GetLevel
local darktunerg = mg:Filter(Card.IsType, nil, TYPE_TUNER) local darktunerg = mg:Filter(Card.IsType, nil, TYPE_TUNER)
local darktunerlv = darktunerg:GetSum(Card.GetSynchroLevel, syncard) local darktunerlv = darktunerg:GetSum(Card.GetSynchroLevel, syncard)
...@@ -3885,132 +3666,86 @@ function rscf.SynMixCheckGoal2(tp, sg, minc, ct, syncard, sg1, smat, gc, mgchk) ...@@ -3885,132 +3666,86 @@ function rscf.SynMixCheckGoal2(tp, sg, minc, ct, syncard, sg1, smat, gc, mgchk)
else return f(sc) else return f(sc)
end end
end end
--step 4, check Ladian 1, use material's custom lv (if any) --step 3, check Ladian 1, use material's custom lv (if any)
local f2 = Card.GetSynchroLevel local f2 = Card.GetSynchroLevel
Card.GetSynchroLevel = function(sc, sc2) Card.GetSynchroLevel = function(c, sc2)
local lvcheck = syncard.rs_synchro_ladian local lvcheck = syncard.rs_synchro_ladian
if type(lvcheck) == "number" then return lvcheck if lvcheck then
elseif type(lvcheck) == "function" then local lvable, lv = syncard.rs_synchro_ladian(c, sc2, tp)
local lv = lvcheck(sc, mg, sc2, tp) return lvable and lv or f2(c, sc2)
if type(lv) == "number" then return lv else
else return f2(sc, sc2) return f2(c, sc2)
end
end end
end end
local bool1 = rscf.SynMixCheckGoal(tp, sg, minc, ct, syncard, sg1, smat, gc, mgchk) local bool1 = rssf.SynMixCheckGoal_R(tp, sg, minc, ct, syncard, sg1, smat, gc, mgchk)
Card.GetSynchroLevel = f2 Card.GetSynchroLevel = f2
--step 5, check Ladian 2, use material's base lv --step 4, check Ladian 2, use material's base lv
local bool2 = rscf.SynMixCheckGoal(tp, sg, minc, ct, syncard, sg1, smat, gc, mgchk) local bool2 = rssf.SynMixCheckGoal_R(tp, sg, minc, ct, syncard, sg1, smat, gc, mgchk)
Card.GetLevel = f Card.GetLevel = f
return bool1 or bool2 return bool1 or bool2
end end
function rscf.SynMixCondition2(f1, f2, f3, f4, minc, maxc, gc) rsgf.GetSynMaterials_R = aux.GetSynMaterials
return function(e, c, smat, mg1, min, max) function rssf.SynMixCondition(f1,f2,f3,f4,minc,maxc,gc)
if mg1 and aux.GetValueType(mg1) ~= "Group" then return false end return function(e,c,smat,mg1,min,max)
return rscf.SynMixCondition(f1, f2, f3, f4, minc, maxc, gc)(e, c, smat, mg1, min, max) --rsgf.GetSynMaterials_R = aux.GetSynMaterials
end aux.GetSynMaterials = rsgf.GetSynMaterials
rssf.SynMixCheckGoal_R = aux.SynMixCheckGoal
aux.SynMixCheckGoal = rssf.SynMixCheckGoal
local res = aux.SynMixCondition(f1,f2,f3,f4,minc,maxc,gc)(e,c,smat,mg1,min,max)
aux.GetSynMaterials = rsgf.GetSynMaterials_R
aux.SynMixCheckGoal = rssf.SynMixCheckGoal_R
return res
end
end end
function rscf.SynMixTarget2(f1, f2, f3, f4, minc, maxc, gc) function rssf.SynMixTarget(f1,f2,f3,f4,minc,maxc,gc)
return function(e, tp, eg, ep, ev, re, r, rp, chk, c, smat, mg1, min, max) return function(e,tp,eg,ep,ev,re,r,rp,chk,c,smat,mg1,min,max)
rssf.synchro_material_group_check = nil rsgf.GetSynMaterials_R = aux.GetSynMaterials
if mg1 then aux.GetSynMaterials = rsgf.GetSynMaterials
rssf.synchro_material_group_check = true rssf.SynMixCheckGoal_R = aux.SynMixCheckGoal
end aux.SynMixCheckGoal = rssf.SynMixCheckGoal
return rscf.SynMixTarget(f1, f2, f3, f4, minc, maxc, gc)(e, tp, eg, ep, ev, re, r, rp, chk, c, smat, mg1, min, max) local res = aux.SynMixTarget(f1,f2,f3,f4,minc,maxc,gc)(e,tp,eg,ep,ev,re,r,rp,chk,c,smat,mg1,min,max)
end aux.GetSynMaterials = rsgf.GetSynMaterials_R
aux.SynMixCheckGoal = rssf.SynMixCheckGoal_R
return res
end
end end
function rscf.SynMixOperation2(f1, f2, f3, f4, minct, maxc, gc) function rssf.SynMixOperation(f1, f2, f3, f4, minct, maxc, gc)
return function(e, tp, eg, ep, ev, re, r, rp, c, smat, mg, min, max) return function(e, tp, eg, ep, ev, re, r, rp, c, smat, mg, min, max)
local g = e:GetLabelObject() local mg = e:GetLabelObject()
rscf.SynchroCustomOperation(g, c, e, tp) rssf.SExtraMaterialCount(mg, c, tp)
g:DeleteGroup() local res
--case 1, Summon Effect Custom
if rssf.SynchroMaterialAction then
res = rssf.SynchroMaterialAction(mg, c, e, tp)
rssf.SynchroMaterialAction = nil
--case 2, Summon Procedure Custom
elseif c.rs_synchro_material_action then
res = c.rs_synchro_material_action(mg, c, e, tp)
--case 3, Base Summon Procedure
else
c:SetMaterial(mg)
res = Duel.SendtoGrave(mg, REASON_SYNCHRO + REASON_MATERIAL)
end
mg:DeleteGroup()
return res
end end
end end
function rscf.SynchroCustomOperation(mg, c, e, tp) function rssf.SExtraMaterialCount(mg, sc, tp)
c:SetMaterial(mg)
rscf.SExtraMaterialCount(mg, sync, tp)
--case 1, Summon Effect Custom
if rssf.SynchroMaterialAction then
rssf.SynchroMaterialAction(mg, c, e, tp)
rssf.SynchroMaterialAction = nil
--case 2, Summon Procedure Custom
elseif c.rs_synchro_material_action then
c.rs_synchro_material_action(mg, c, e, tp)
--case 3, Base Summon Procedure
else
Duel.SendtoGrave(mg, REASON_SYNCHRO + REASON_MATERIAL)
end
end
function rscf.SExtraMaterialCount(mg, sync, tp)
for tc in aux.Next(mg) do for tc in aux.Next(mg) do
local le = { tc:IsHasEffect(rscode.Extra_Synchro_Material, tp) } local le = { tc:IsHasEffect(rscode.Extra_Synchro_Material, tp) }
for _, te in pairs(le) do for _, te in pairs(le) do
local sg = mg:Filter(aux.TRUE, tc) local sg=mg:Filter(aux.TRUE, tc)
local f = te:GetValue() local f = te:GetValue()
if not f or f(te, sync, sg) then local related,valid=f(te, sc, sg, tc, tp)
if related and valid then
te:UseCountLimit(tp) te:UseCountLimit(tp)
end end
end end
end end
end end
--Card / Summon function: Special Synchro Summon Procedure
--Force a synchro level for a synchro monster's synchro procedure
function rscf.AddSynchroProcedureSpecial_SynchroLevel(c, lv, ...)
if c:IsStatus(STATUS_COPYING_EFFECT) then return end
if not c.rs_synchro_level then
local mt = getmetatable(c)
mt.rs_synchro_level = lv
end
local e1 = rscf.AddSynchroProcedureSpecial(c, ...)
return e1
end
--Dark Synchro Procedure
function rscf.AddSynchroProcedureSpecial_DarkSynchro(c, ...)
if c:IsStatus(STATUS_COPYING_EFFECT) then return end
if not c.dark_synchro then
local mt = getmetatable(c)
mt.dark_synchro = true
end
local e1 = rscf.AddSynchroProcedureSpecial(c, ...)
return e1
end
--Ladian's Synchro Procedure (treat tuner as another lv)
function rscf.AddSynchroProcedureSpecial_Ladian(c, f1, lv, f2, f3, f4, minc, maxc, extrafilter)
if c:IsStatus(STATUS_COPYING_EFFECT) then return end
if not c.rs_synchro_ladian then
local mt = getmetatable(c)
mt.rs_synchro_ladian = { lv, extrafilter }
end
local e1 = rscf.AddSynchroProcedureSpecial(c, f1, f2, f3, f4, minc, maxc)
return e1
end
--Custom Synchro Materials' Action
function rscf.AddSynchroProcedureSpecial_CustomAction(c, actionfun, ...)
if c:IsStatus(STATUS_COPYING_EFFECT) then return end
if not c.rs_synchro_material_action then
local mt = getmetatable(c)
mt.rs_synchro_material_action = actionfun
end
local e1 = rscf.AddSynchroProcedureSpecial(c, ...)
return e1
end
--Card / Summon function: Custom Xyz Procedure --Card / Summon function: Custom Xyz Procedure
function rscf.AddXyzProcedureSpecial(c, f, gf, minc, maxc, alterf, desc, op) function rscf.AddXyzProcedureSpecial(c, f, gf, minc, maxc, alterf, desc, op)
local mt = getmetatable(c)
if not rscf.AddXyzProcedureSpecial_Switch then
rscf.AddXyzProcedureSpecial_Switch = true
rscf.XyzLevelFreeCondition2 = aux.XyzLevelFreeCondition2
aux.XyzLevelFreeCondition2 = rscf.XyzLevelFreeCondition22
rscf.XyzLevelFreeTarget2 = aux.XyzLevelFreeCondition2
aux.XyzLevelFreeTarget2 = rscf.XyzLevelFreeTarget22
rscf.XyzLevelFreeOperation2 = aux.XyzLevelFreeOperation2
aux.XyzLevelFreeOperation2 = rscf.XyzLevelFreeOperation22
rscf.XyzLevelFreeGoal = aux.XyzLevelFreeGoal
rscf.XyzLevelFreeFilter = aux.XyzLevelFreeFilter
aux.XyzLevelFreeFilter = rscf.XyzLevelFreeFilter2
end
--aux.XyzLevelFreeGoal = rscf.XyzLevelFreeGoal2(minc, maxc or minc)
alterf = alterf or aux.FALSE alterf = alterf or aux.FALSE
local e1 = Effect.CreateEffect(c) local e1 = Effect.CreateEffect(c)
e1:SetDescription(1165) e1:SetDescription(1165)
...@@ -4020,9 +3755,9 @@ function rscf.AddXyzProcedureSpecial(c, f, gf, minc, maxc, alterf, desc, op) ...@@ -4020,9 +3755,9 @@ function rscf.AddXyzProcedureSpecial(c, f, gf, minc, maxc, alterf, desc, op)
e1:SetRange(LOCATION_EXTRA) e1:SetRange(LOCATION_EXTRA)
--if alterf then --if alterf then
maxc= maxc or minc maxc= maxc or minc
e1:SetCondition(rscf.XyzLevelFreeCondition22(f, gf, minc, maxc, alterf, desc, op)) e1:SetCondition(rssf.XyzLevelFreeCondition2(f, gf, minc, maxc, alterf, desc, op))
e1:SetTarget(rscf.XyzLevelFreeTarget22(f, gf, minc, maxc, alterf, desc, op)) e1:SetTarget(rssf.XyzLevelFreeTarget2(f, gf, minc, maxc, alterf, desc, op))
e1:SetOperation(rscf.XyzLevelFreeOperation22(f, gf, minc, maxc, alterf, desc, op)) e1:SetOperation(rssf.XyzLevelFreeOperation2(f, gf, minc, maxc, alterf, desc, op))
--[[else --[[else
e1:SetCondition(Auxiliary.XyzLevelFreeCondition(f, gf, minc, maxc)) e1:SetCondition(Auxiliary.XyzLevelFreeCondition(f, gf, minc, maxc))
e1:SetTarget(Auxiliary.XyzLevelFreeTarget(f, gf, minc, maxc)) e1:SetTarget(Auxiliary.XyzLevelFreeTarget(f, gf, minc, maxc))
...@@ -4030,36 +3765,26 @@ function rscf.AddXyzProcedureSpecial(c, f, gf, minc, maxc, alterf, desc, op) ...@@ -4030,36 +3765,26 @@ function rscf.AddXyzProcedureSpecial(c, f, gf, minc, maxc, alterf, desc, op)
--end --end
e1:SetValue(SUMMON_TYPE_XYZ) e1:SetValue(SUMMON_TYPE_XYZ)
c:RegisterEffect(e1) c:RegisterEffect(e1)
if not c:IsStatus(STATUS_COPYING_EFFECT) and not c.rs_xyz_parammeter then
mt.rs_xyz_parammeter = { e1, f1, f2, f3, f4, maxc, gc }
end
return e1 return e1
end end
function rscf.XCheckUtilityMaterial(c, mg, xyzc, tp) function rsgf.GetXyzMaterials_X(tp, xyzc)
local le = { c:IsHasEffect(rscode.Utility_Xyz_Material, tp) } return function(...)
if #le == 0 then return 1, { 1} end return rsgf.GetXyzMaterials(tp, xyzc)
local maxreduce = 1
local reducelist = { 1}
for _, te in pairs(le) do
local val = te:GetValue()
local reduce = 1
if type(val) == "number" then reduce = val end
if type(val) == "function" then reduce = val(te, xyzc, mg, tp) end
maxreduce = math.max(maxreduce, reduce or 2)
table.insert(reducelist, reduce or 2)
end end
return maxreduce, reducelist
end end
function rscf.XUncompatibilityFilter(c, sg, xyzc, tp) function rsgf.GetXyzMaterials(tp, xyzc)
local mg = sg:Filter(aux.TRUE, c) local mg1 = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_MZONE, 0, nil)
return not rscf.XCheckOtherMaterial(c, mg, xyzc, tp, sg) local mg2 = Duel.GetMatchingGroup(rscf.XExtraFilter, tp, 0xff, 0xff, mg1, xyzc, tp)
return (mg1 + mg2):Filter(rscf.IsCanBeXyzMaterial,nil,xyzc)
end end
function rscf.XCheckOtherMaterial(c, mg, xyzc, tp, sg) function rscf.XExtraFilter(c, xc, tp)
local le = { c:IsHasEffect(rscode.Extra_Xyz_Material, tp) } if c:IsOnField() and c:IsFacedown() then return false end
if #le == 0 then return true end if not rscf.IsCanBeXyzMaterial(c, xc) then return false end
for _, te in pairs(le) do local le={c:IsHasEffect(rscode.Extra_Xyz_Material,tp)}
local f = te:GetValue() for _,te in pairs(le) do
if not f or f(te, xyzc, mg, sg) then return true end local tf = te:GetValue()
local related, valid = tf(te, xc, nil, c, tp)
if related then return true end
end end
return false return false
end end
...@@ -4075,23 +3800,33 @@ function rscf.IsCanBeXyzMaterial(c, xyzc) ...@@ -4075,23 +3800,33 @@ function rscf.IsCanBeXyzMaterial(c, xyzc)
end end
return true return true
end end
function rscf.XyzLevelFreeFilter2(c, xyzc, f) function rscf.XyzLevelFreeFilter(c, xyzc, f)
return (not c:IsOnField() or c:IsFaceup()) and rscf.IsCanBeXyzMaterial(c, xyzc) and (not f or f(c, xyzc)) return (not c:IsOnField() or c:IsFaceup()) and rscf.IsCanBeXyzMaterial(c, xyzc) and (not f or f(c, xyzc))
end end
function rscf.ExtraXyzMaterialsFilter(c, xyzc, tp, f) function rssf.XyzLevelFreeCondition2(f, gf, minct, maxct, alterf, desc, op)
if c:IsType(TYPE_TOKEN) then return false end return function(e, c, og, min, max)
if c:IsOnField() and not c:IsFaceup() then return false end rsgf.XyzLevelFreeGoal_R = aux.XyzLevelFreeGoal
return c:IsHasEffect(rscode.Extra_Xyz_Material, tp) and rscf.IsCanBeXyzMaterial(c, xyzc) and (not f or f(c)) aux.XyzLevelFreeGoal = rsgf.XyzLevelFreeGoal(minct, maxct, og)
rsgf.GetFieldGroup_R = Duel.GetFieldGroup
Duel.GetFieldGroup = rsgf.GetXyzMaterials_X(e:GetHandlerPlayer(), c)
rscf.XyzLevelFreeFilter_R = aux.XyzLevelFreeFilter
aux.XyzLevelFreeFilter = rscf.XyzLevelFreeFilter
local res = aux.XyzLevelFreeCondition2(f, gf, 1, maxct, alterf, desc, op)(e, c, og, min, max)
aux.XyzLevelFreeGoal = rsgf.XyzLevelFreeGoal_R
Duel.GetFieldGroup = rsgf.GetFieldGroup_R
aux.XyzLevelFreeFilter = rscf.XyzLevelFreeFilter_R
return res
end
end end
function rscf.XyzLevelFreeGoal2(minct, maxct, og) function rsgf.XyzLevelFreeGoal(minct, maxct, og)
return function(g, tp, xyzc, gf) return function(g, tp, xyzc, gf)
--case 1, extra material check --case 1, extra material check
if not og and g:IsExists(rscf.XUncompatibilityFilter, 1, nil, g, xyzc, tp) then return false end if g:IsExists(rscf.XUncompatibilityFilter, 1, nil, g, xyzc, tp) then return false end
--case 2, normal check --case 2, normal check
if (gf and not gf(g, og, tp, xyzc)) or Duel.GetLocationCountFromEx(tp, tp, g, xyzc) <= 0 then return false end if not ((not gf or gf(g, og, tp, xyzc)) and Duel.GetLocationCountFromEx(tp, tp, g, xyzc)>0) then return false end
--if #g < minct then return false end --case 3
if #g > maxct then return false end if #g > maxct then return false end
--case 3, utility check, separate mg and ug for easy calculate --case 4, utility check
local ug = g:Filter(Card.IsHasEffect, nil, rscode.Utility_Xyz_Material, tp) local ug = g:Filter(Card.IsHasEffect, nil, rscode.Utility_Xyz_Material, tp)
local mg = g:Clone() local mg = g:Clone()
mg:Sub(ug) mg:Sub(ug)
...@@ -4117,258 +3852,130 @@ function rscf.XyzLevelFreeGoal2(minct, maxct, og) ...@@ -4117,258 +3852,130 @@ function rscf.XyzLevelFreeGoal2(minct, maxct, og)
return false return false
end end
end end
function rscf.XyzLevelFreeCondition22(f, gf, minct, maxct, alterf, desc, op) function rscf.XUncompatibilityFilter(c, sg, xc, tp)
return function(e, c, og, min, max) local mg = sg:Filter(aux.TRUE, c)
if c == nil then return true end return not rscf.XCheckOtherMaterial(c, mg, xc, tp)
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
local tp = c:GetControler()
local mg = nil
--other material
local mgextra = nil
if og then
mg = og
else
mg = Duel.GetFieldGroup(tp, LOCATION_MZONE, 0)
mgextra = Duel.GetMatchingGroup(rscf.ExtraXyzMaterialsFilter, tp, 0xff, 0xff, mg, c, tp, f)
end
local altg = mg:Filter(Auxiliary.XyzAlterFilter, nil, alterf, c, e, tp, op):Filter(Auxiliary.MustMaterialCheck, nil, tp, EFFECT_MUST_BE_XMATERIAL)
if (not min or min <= 1) and altg:GetCount() > 0 then
return true
end
local minc = minct
local maxc = maxct
if min then
if min > minc then minc = min end
if max < maxc then maxc = max end
--if minc > maxc then return false end
end
mg = mg:Filter(rscf.XyzLevelFreeFilter2, nil, c, f)
if mgextra and #mgextra > 0 then mg:Merge(mgextra) end
local sg = Auxiliary.GetMustMaterialGroup(tp, EFFECT_MUST_BE_XMATERIAL)
if sg:IsExists(Auxiliary.MustMaterialCounterFilter, 1, nil, mg) then return false end
Duel.SetSelectedCard(sg)
Auxiliary.GCheckAdditional = Auxiliary.TuneMagicianCheckAdditionalX(EFFECT_TUNE_MAGICIAN_X)
--minc to 1 for utility xyz material
local res = mg:CheckSubGroup(rscf.XyzLevelFreeGoal2(minc, maxc, og), 1, maxc, tp, c, gf)
Auxiliary.GCheckAdditional = nil
return res
end
end end
function rscf.XyzLevelFreeTarget22(f, gf, minct, maxct, alterf, desc, op) function rscf.XCheckOtherMaterial(c, mg, xc, tp)
local le={ c:IsHasEffect(rscode.Extra_Xyz_Material, tp) }
local res1=false
local res2=true
for _, te in pairs(le) do
local f = te:GetValue()
local related, valid = f(te, xc, mg, c, tp)
if related then res2 = false end
if related and valid then res1 = true end
end
return res1 or res2
end
function rscf.XCheckUtilityMaterial(c, mg, xyzc, tp)
local le = { c:IsHasEffect(rscode.Utility_Xyz_Material, tp) }
if #le == 0 then return 1, { 1 } end
local max_reduce = 1
local reduce_arr = { 1}
for _, te in pairs(le) do
local val = te:GetValue()
local reduce = 1
if type(val) == "number" then reduce = val end
if type(val) == "function" then reduce = val(te, xyzc, mg, tp) end
max_reduce = math.max(max_reduce, reduce or 2)
table.insert(reduce_arr, reduce or 2)
end
table.sort(reduce_arr)
return max_reduce, reduce_arr
end
function rssf.XyzLevelFreeTarget2(f, gf, minct, maxct, alterf, desc, op)
return function(e, tp, eg, ep, ev, re, r, rp, chk, c, og, min, max) return function(e, tp, eg, ep, ev, re, r, rp, chk, c, og, min, max)
if og and not min then rsgf.XyzLevelFreeGoal_R = aux.XyzLevelFreeGoal
return true aux.XyzLevelFreeGoal = rsgf.XyzLevelFreeGoal(minct, maxct, og)
end rsgf.GetFieldGroup_R = Duel.GetFieldGroup
local minc = minct Duel.GetFieldGroup = rsgf.GetXyzMaterials_X(tp, c)
local maxc = maxct rscf.XyzLevelFreeFilter_R = aux.XyzLevelFreeFilter
if min then aux.XyzLevelFreeFilter = rscf.XyzLevelFreeFilter
if min > minc then minc = min end local res = aux.XyzLevelFreeTarget2(f, gf, 1, maxct, alterf, desc, op)(e, tp, eg, ep, ev, re, r, rp, chk, c, og, min, max)
if max < maxc then maxc = max end aux.XyzLevelFreeGoal = rsgf.XyzLevelFreeGoal_R
end Duel.GetFieldGroup = rsgf.GetFieldGroup_R
local mg = nil aux.XyzLevelFreeFilter = rscf.XyzLevelFreeFilter_R
--other material return res
local mg3 = nil
if og then
mg = og
mg3 = og
else
mg = Duel.GetFieldGroup(tp, LOCATION_MZONE, 0)
mg3 = Duel.GetMatchingGroup(rscf.ExtraXyzMaterialsFilter, tp, 0xff, 0xff, mg, c, tp, f)
end
local sg = Auxiliary.GetMustMaterialGroup(tp, EFFECT_MUST_BE_XMATERIAL)
local mg2 = mg:Filter(rscf.XyzLevelFreeFilter2, nil, c, f)
mg3:Merge(mg2)
--other material
Duel.SetSelectedCard(sg)
local b1 = mg3:CheckSubGroup(rscf.XyzLevelFreeGoal2(minc, maxc, og), 1, maxc, tp, c, gf)
local b2 = (not min or min <= 1) and mg:IsExists(Auxiliary.XyzAlterFilter, 1, nil, alterf, c, e, tp, op)
local g = nil
if b2 and (not b1 or Duel.SelectYesNo(tp, desc)) then
e:SetLabel(1)
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
g = mg:FilterSelect(tp, Auxiliary.XyzAlterFilter, 1, 1, nil, alterf, c, e, tp, op)
if op then op(e, tp, 1, g:GetFirst()) end
else
e:SetLabel(0)
Duel.SetSelectedCard(sg)
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
local cancel = Duel.IsSummonCancelable()
Auxiliary.GCheckAdditional = Auxiliary.TuneMagicianCheckAdditionalX(EFFECT_TUNE_MAGICIAN_X)
g = mg3:SelectSubGroup(tp, rscf.XyzLevelFreeGoal2(minc, maxc, og), cancel, 1, maxc, tp, c, gf)
Auxiliary.GCheckAdditional = nil
end
if g and g:GetCount() > 0 then
g:KeepAlive()
e:SetLabelObject(g)
return true
else return false end
end end
end end
function rscf.XyzLevelFreeOperation22(f, gf, minct, maxct, alterf, desc, op) function rssf.XyzLevelFreeOperation2(f, gf, minct, maxct, alterf, desc, op)
return function(e, tp, eg, ep, ev, re, r, rp, c, og, min, max) return function(e, tp, eg, ep, ev, re, r, rp, c, og, min, max)
if og and not min then local res
rscf.XyzCustomOperation(og, c, e, tp, false) local mg = e:GetLabelObject()
else rssf.XExtraMaterialCount(mg, c, tp)
local mg = e:GetLabelObject() if not rssf.XyzMaterialAction and not c.rs_xyz_material_action then
rscf.XyzCustomOperation(mg, c, e, tp, true) res = aux.XyzLevelFreeOperation2(f, gf, 1, maxct, alterf, desc, op)(e, tp, eg, ep, ev, re, r, rp, c, og, min, max)
else
if rssf.XyzMaterialAction then
res = rssf.XyzMaterialAction(mg, c, e, tp)
rssf.XyzMaterialAction = nil
elseif c.rs_xyz_material_action then
res = xc.rs_xyz_material_action(mg, c, e, tp)
end end
end end
end local sf = function(hc, hp)
function rscf.XyzCustomOperation(mg, c, e, tp, checkog) return hc:IsPreviousLocation(LOCATION_HAND) and hc:IsPreviousControler(hp)
c:SetMaterial(mg) end
if checkog then for hp = 0, 1 do
rscf.XExtraMaterialCount(mg, c, tp) if mg:IsExists(sf, 1, nil, hp) then
end Duel.ShuffleHand(hp)
local sg = Group.CreateGroup() end
local tc = mg:GetFirst() end
while tc do mg:DeleteGroup()
local sg1 = tc:GetOverlayGroup() return res
sg:Merge(sg1)
tc = mg:GetNext()
end
--case 1, Summon Effect Custom (Book of Cain)
if rssf.XyzMaterialAction then
rssf.XyzMaterialAction(mg, sg, c, e, tp)
rssf.XyzMaterialAction = nil
--case 2, Summon Procedure Custom
elseif c.rs_xyz_material_action then
c.rs_xyz_material_action(mg, sg, c, e, tp)
--case 3, Base Alterf Xyz Procedure
elseif e:GetLabel() == 1 then
if #sg > 0 then
Duel.Overlay(c, sg)
end
Duel.Overlay(c, mg)
--case 4, Base Normal Xyz Procedure
else
Duel.SendtoGrave(sg, REASON_RULE)
Duel.Overlay(c, mg)
end
--if used hand material, shuffle hand
if mg:IsExists(Card.IsPreviousLocation, 1, nil, LOCATION_HAND) then
Duel.ShuffleHand(tp)
end end
mg:DeleteGroup()
end end
function rscf.XExtraMaterialCount(mg, xyzc, tp) function rssf.XExtraMaterialCount(mg, xc, tp)
for tc in aux.Next(mg) do for tc in aux.Next(mg) do
local le = { tc:IsHasEffect(rscode.Extra_Xyz_Material, tp) } local le = { tc:IsHasEffect(rscode.Extra_Xyz_Material, tp) }
for _, te in pairs(le) do for _, te in pairs(le) do
local sg = mg:Filter(aux.TRUE, tc) local sg=mg:Filter(aux.TRUE, tc)
local f = te:GetValue() local f = te:GetValue()
if not f or f(te, xyzc, sg, mg) then local related,valid=f(te, xc, sg, tc, tp)
if related and valid then
te:UseCountLimit(tp) te:UseCountLimit(tp)
end end
end end
end end
end end
--Card / Summon function: Special Xyz Summon Procedure
--Custom Xyz Materials' Action
function rscf.AddXyzProcedureSpecial_CustomAction(c, actionfun, ...)
if c:IsStatus(STATUS_COPYING_EFFECT) then return end
if not c.rs_xyz_material_action then
local mt = getmetatable(c)
mt.rs_xyz_material_action = actionfun
end
local e1 = rscf.AddXyzProcedureSpecial(c, ...)
return e1
end
function rscf.XyzMaterialAction(c, actionfun)
if c:IsStatus(STATUS_COPYING_EFFECT) then return end
if not c.rs_xyz_material_action then
local mt = getmetatable(c)
mt.rs_xyz_material_action = actionfun
end
end
--Card / Summon function: Custom Link Procedure --Card / Summon function: Custom Link Procedure
function rscf.AddLinkProcedureSpecial(c, f, min, max, gf) function rscf.AddLinkProcedureSpecial(c, f, min, max, gf)
if not rscf.AddLinkProcedureSpecial_Switch then local e1=Effect.CreateEffect(c)
rscf.AddLinkProcedureSpecial_Switch = true
rscf.LCheckOtherMaterial = aux.LCheckOtherMaterial
aux.LCheckOtherMaterial = rscf.LCheckOtherMaterial2
rscf.GetLinkMaterials = aux.GetLinkMaterials
aux.GetLinkMaterials = rscf.GetLinkMaterials2
rscf.LinkOperation = aux.LinkOperation
aux.LinkOperation = rscf.LinkOperation2
end
local e1 = Effect.CreateEffect(c)
e1:SetDescription(1166) e1:SetDescription(1166)
e1:SetType(EFFECT_TYPE_FIELD) e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE + EFFECT_FLAG_IGNORE_IMMUNE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetRange(LOCATION_EXTRA) e1:SetRange(LOCATION_EXTRA)
if max == nil then max = c:GetLink() end if max == nil then max = c:GetLink() end
e1:SetCondition(Auxiliary.LinkCondition(f, min, max, gf)) e1:SetCondition(Auxiliary.LinkCondition(f, min, max, gf))
e1:SetTarget(Auxiliary.LinkTarget(f, min, max, gf)) e1:SetTarget(Auxiliary.LinkTarget(f, min, max, gf))
e1:SetOperation(rscf.LinkOperation2(f, min, max, gf)) e1:SetOperation(rssf.LinkOperation(f, min, max, gf))
e1:SetValue(SUMMON_TYPE_LINK) e1:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e1) c:RegisterEffect(e1)
if not c:IsStatus(STATUS_COPYING_EFFECT) and not c.rs_link_parammeter then
local mt = getmetatable(c)
mt.rs_link_parammeter = { e1, f, min, max, gf }
end
return e1 return e1
end end
function rscf.GetLinkMaterials2(tp, f, lc) function rssf.LinkOperation(f, minc, maxc, gf)
local mg = Duel.GetMatchingGroup(Auxiliary.LConditionFilter, tp, LOCATION_MZONE, 0, nil, f, lc)
local mg2 = Duel.GetMatchingGroup(Auxiliary.LExtraFilter, tp, 0xff, 0xff, nil, f, lc, tp)
if mg2:GetCount() > 0 then mg:Merge(mg2) end
return mg
end
function rscf.LinkOperation2(f, minc, maxc, gf)
return function(e, tp, eg, ep, ev, re, r, rp, c, og, lmat, min, max) return function(e, tp, eg, ep, ev, re, r, rp, c, og, lmat, min, max)
local g = e:GetLabelObject() local g=e:GetLabelObject()
rscf.LinkCustomOperation(g, c, e, tp, og) Auxiliary.LExtraMaterialCount(g,c,tp)
local res
--case 1, Summon Effect Custom
if rssf.LinkMaterialAction then
res = rssf.LinkMaterialAction(g, c, e, tp)
rssf.LinkMaterialAction = nil
--case 2, Summon Procedure Custom
elseif c.rs_link_material_action then
res = c.rs_link_material_action(g, c, e, tp)
--case 3, Base Summon Procedure
else
c:SetMaterial(g)
res = Duel.SendtoGrave(g, REASON_LINK + REASON_MATERIAL)
end
g:DeleteGroup() g:DeleteGroup()
end end
end end
function rscf.LinkCustomOperation(mg, c, e, tp, checkog)
c:SetMaterial(mg)
if checkog then
Auxiliary.LExtraMaterialCount(mg, c, tp)
end
--case 1, Summon Effect Custom
if rssf.LinkMaterialAction then
rssf.LinkMaterialAction(mg, c, e, tp, checkog)
rssf.LinkMaterialAction = nil
--case 2, Summon Procedure Custom
elseif c.rs_link_material_action then
c.rs_link_material_action(mg, c, e, tp, checkog)
--case 3, Base Summon Procedure
else
Duel.SendtoGrave(mg, REASON_LINK + REASON_MATERIAL)
end
end
--Change aux function to repair bug in multiple other material link
function rscf.LCheckOtherMaterial2(c, mg, lc, tp)
local le = { c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL, tp) }
if #le == 0 then return true end
for _, te in pairs(le) do
local f = te:GetValue()
if not f or f(te, lc, mg) then return true end
end
return false
end
--Card / Summon function: Special Link Summon Procedure
--Custom Link Materials' Action
function rscf.AddLinkProcedureSpecial_CustomAction(c, actionfun, ...)
if c:IsStatus(STATUS_COPYING_EFFECT) then return end
if not c.rs_link_material_action then
local mt = getmetatable(c)
mt.rs_link_material_action = actionfun
end
local e1 = rscf.AddLinkProcedureSpecial(c, ...)
return e1
end
function rscf.LinkMaterialAction(c, actionfun)
if c:IsStatus(STATUS_COPYING_EFFECT) then return end
if not c.rs_link_material_action then
local mt = getmetatable(c)
mt.rs_link_material_action = actionfun
end
end
--Card effect: Set field info --Card effect: Set field info
function rscf.SetFieldInfo(c) function rscf.SetFieldInfo(c)
...@@ -4498,13 +4105,13 @@ end ...@@ -4498,13 +4105,13 @@ end
function rscf.spfilter(f, ...) function rscf.spfilter(f, ...)
local ext_paramms = { ... } local ext_paramms = { ... }
return function(c, e, tp) return function(c, e, tp)
return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and (not f or f(c, table.unpack(rsof.Table_Mix(ext_paramms, { e, tp })))) and c:IsType(TYPE_MONSTER) return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and (not f or f(c, table.unpack(rsof.Table_Mix(ext_paramms, { e, tp })))) and c:GetOriginalType() & TYPE_MONSTER > 0
end end
end end
function rscf.spfilter2(f, ...) function rscf.spfilter2(f, ...)
local ext_paramms = { ... } local ext_paramms = { ... }
return function(c, e, tp) return function(c, e, tp)
return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and (not f or f(c, table.unpack(rsof.Table_Mix(ext_paramms, { e, tp })))) and rszsf.GetUseAbleMZoneCount(c, tp) > 0 and c:IsType(TYPE_MONSTER) return c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and (not f or f(c, table.unpack(rsof.Table_Mix(ext_paramms, { e, tp })))) and rszsf.GetUseAbleMZoneCount(c, tp) > 0 and c:GetOriginalType() & TYPE_MONSTER > 0
end end
end end
--Card filter function : Face - up from Remove --Card filter function : Face - up from Remove
...@@ -4832,14 +4439,24 @@ function rsof.Table_List_Base(check_type, base_tab, check_val1, ...) ...@@ -4832,14 +4439,24 @@ function rsof.Table_List_Base(check_type, base_tab, check_val1, ...)
local exist_res, exist_idx = rsof.Table_List_Single(base_tab, check_val) local exist_res, exist_idx = rsof.Table_List_Single(base_tab, check_val)
if check_type == "normal" then if check_type == "normal" then
table.insert(res_list, exist_res) table.insert(res_list, exist_res)
table.insert(res_list, exist_idx)
elseif check_type == "or" then elseif check_type == "or" then
res_list[1] = res_list[1] or exist_res if exist_res then
return true
end
elseif check_type == "and" then elseif check_type == "and" then
res_list[1] = res_list[1] and exist_res if not exist_res then
return false
end
end end
table.insert(res_list, exist_idx)
end end
return table.unpack(res_list) if check_type == "normal" then
return table.unpack(res_list)
elseif check_type == "or" then
return false
elseif check_type == "and" then
return true
end
end end
--other function: Find correct element in table --other function: Find correct element in table
function rsof.Table_List(base_tab, check_val1, ...) function rsof.Table_List(base_tab, check_val1, ...)
...@@ -4903,9 +4520,5 @@ function rsof.Check_Boolean(check_val, bool_val) ...@@ -4903,9 +4520,5 @@ function rsof.Check_Boolean(check_val, bool_val)
end end
-------------------"Hape"--------------------- -------------------"Hape"---------------------
rsof.Escape_Old_Functions() rsof.Escape_Old_Functions()
--directly enable will cause bugs, but i am lazy to find what cards i have used this function
--rssf.EnableSpecialProcedure()
rsof.Get_Cate_Hint_Op_List() rsof.Get_Cate_Hint_Op_List()
if not rsof.SelectHint then rsef.Enable_Attach_Effect()
rsof.SelectHint=rshint.Select \ No newline at end of file
end
\ No newline at end of file
...@@ -31,12 +31,12 @@ rscost.costinfo = { } --"Cost information, for record cost value" ...@@ -31,12 +31,12 @@ rscost.costinfo = { } --"Cost information, for record cost value"
rsop.opinfo = { } --"Operation information, for record something" rsop.opinfo = { } --"Operation information, for record something"
rsef.relationinfo = { } --"Field,Pendulum,Continous leave field" rsef.relationinfo = { } --"Field,Pendulum,Continous leave field"
rstg.targetlist = { } --"Target group list, for rstg.GetTargetAttribute" rstg.targetlist = { } --"Target group list, for rstg.GetTargetAttribute"
rsef.attacheffect = { } --"Effect information for attach effects" rscf.proc_record = { }
rsef.attacheffectf = { }
rsef.solveeffect ={ }
rsop.baseop = { }
rscf.ssproce = { }
rstg.tk_list = { } rstg.tk_list = { }
rscf.fieldinfo = { }
rsef.attach_before_arr = { } --"record attach effects, for 10170008 to repeat"
rsef.attach_after_arr = { }
rsef.attach_base_arr = { }
rsef.effet_no_register = false rsef.effet_no_register = false
...@@ -73,9 +73,7 @@ rsrst.std_ep = rsrst.std + rsrst.ep ...@@ -73,9 +73,7 @@ rsrst.std_ep = rsrst.std + rsrst.ep
rsrst.ret = RESET_EVENT + RESETS_REDIRECT rsrst.ret = RESET_EVENT + RESETS_REDIRECT
--Code Variable --Code Variable
rscode.Extra_Effect_Activate = m + 100 --"Attach Effect" rscode.Attach_Effect = m + 100 --"Attach Effect"
rscode.Extra_Effect_BSolve = m + 101
rscode.Extra_Effect_ASolve = m + 102
rscode.Phase_Leave_Flag = m + 200 --"Summon Flag for SummonBuff" rscode.Phase_Leave_Flag = m + 200 --"Summon Flag for SummonBuff"
rscode.Extra_Synchro_Material = m + 300 --"Extra Synchro Material" rscode.Extra_Synchro_Material = m + 300 --"Extra Synchro Material"
...@@ -106,6 +104,10 @@ rshint.sdrct = aux.Stringid(m,5) --"select draw number" ...@@ -106,6 +104,10 @@ rshint.sdrct = aux.Stringid(m,5) --"select draw number"
rshint.darktuner = aux.Stringid(m,14) --"treat as dark tuner" rshint.darktuner = aux.Stringid(m,14) --"treat as dark tuner"
rshint.darksynchro = aux.Stringid(m,15) --"treat as dark synchro" rshint.darksynchro = aux.Stringid(m,15) --"treat as dark synchro"
rshint.scl_exproc = aux.Stringid(m,12) -- "special extra monster spsummon proc"
rshint.attach_card = aux.Stringid(m, 8)
rshint.attach_effect = aux.Stringid(m, 9)
--Effect type Variable --Effect type Variable
rsef.type_list = { rsef.type_list = {
...@@ -126,7 +128,7 @@ rsflag.list = { ...@@ -126,7 +128,7 @@ rsflag.list = {
, ["sp"] = EFFECT_FLAG_SPSUM_PARAM, ["ep"] = EFFECT_FLAG_EVENT_PLAYER, ["oa"] = EFFECT_FLAG_OATH , ["ntr"] = EFFECT_FLAG_NO_TURN_RESET , ["sp"] = EFFECT_FLAG_SPSUM_PARAM, ["ep"] = EFFECT_FLAG_EVENT_PLAYER, ["oa"] = EFFECT_FLAG_OATH , ["ntr"] = EFFECT_FLAG_NO_TURN_RESET
, ["neg~"] = EFFECT_FLAG_CANNOT_INACTIVATE , ["neg~"] = EFFECT_FLAG_CANNOT_INACTIVATE
, ["cn"] = EFFECT_FLAG_CANNOT_NEGATE, ["dise~"] = EFFECT_FLAG_CANNOT_NEGATE , ["cn"] = EFFECT_FLAG_CANNOT_NEGATE, ["dise~"] = EFFECT_FLAG_CANNOT_NEGATE
, ["cd"] = EFFECT_FLAG_CANNOT_DISABLE , ["dis~"] = EFFECT_FLAG_CANNOT_DISABLE, , ["cd"] = EFFECT_FLAG_CANNOT_DISABLE , ["dis~"] = EFFECT_FLAG_CANNOT_DISABLE
} }
...@@ -202,7 +204,7 @@ function rsof.Get_Cate_Hint_Op_List() ...@@ -202,7 +204,7 @@ function rsof.Get_Cate_Hint_Op_List()
, ["ctrl"] = { "Get Control", CATEGORY_CONTROL, HINTMSG_CONTROL, { 4941482,0 }, nil, { rsop.GetControl, 5, sg, tp, 0, 0, 0xff } } , ["ctrl"] = { "Get Control", CATEGORY_CONTROL, HINTMSG_CONTROL, { 4941482,0 }, nil, { rsop.GetControl, 5, sg, tp, 0, 0, 0xff } }
, ["sctrl"] = { "Switch Control", CATEGORY_CONTROL, HINTMSG_CONTROL, { 36331074,0 } } , ["sctrl"] = { "Switch Control", CATEGORY_CONTROL, HINTMSG_CONTROL, { 36331074,0 } }
, ["dis"] = { "Disable Effect", CATEGORY_DISABLE, HINTMSG_DISABLE, { 39185163,1 }, { 25166510,2 } } , ["dis"] = { "Disable Effect", CATEGORY_DISABLE, HINTMSG_DISABLE, { 39185163,1 }, { 25166510,2 }, { rsop.DisableCards, 4, sg, e, false, rsrst.std } }
, ["diss"] = { "Disable Summon", CATEGORY_DISABLE_SUMMON, 0, { m,1 } } , ["diss"] = { "Disable Summon", CATEGORY_DISABLE_SUMMON, 0, { m,1 } }
, ["neg"] = { "Negate Activation", CATEGORY_NEGATE, 0, { 19502505,1 } } , ["neg"] = { "Negate Activation", CATEGORY_NEGATE, 0, { 19502505,1 } }
...@@ -293,6 +295,7 @@ rscf.sum_list = { ...@@ -293,6 +295,7 @@ rscf.sum_list = {
--Location Variable --Location Variable
rsloc.hd = LOCATION_HAND+LOCATION_DECK rsloc.hd = LOCATION_HAND+LOCATION_DECK
rsloc.hm = LOCATION_HAND+LOCATION_MZONE
rsloc.ho = LOCATION_HAND+LOCATION_ONFIELD rsloc.ho = LOCATION_HAND+LOCATION_ONFIELD
rsloc.hg = LOCATION_HAND+LOCATION_GRAVE rsloc.hg = LOCATION_HAND+LOCATION_GRAVE
rsloc.dg = LOCATION_DECK+LOCATION_GRAVE rsloc.dg = LOCATION_DECK+LOCATION_GRAVE
......
...@@ -3,6 +3,7 @@ local m=1102081 ...@@ -3,6 +3,7 @@ local m=1102081
local cm=_G["c"..m] local cm=_G["c"..m]
Duel.LoadScript("c81000000.lua") Duel.LoadScript("c81000000.lua")
function cm.initial_effect(c) function cm.initial_effect(c)
aux.AddCodeList(c,1102000)
--Negate --Negate
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DISABLE+CATEGORY_DESTROY) e1:SetCategory(CATEGORY_DISABLE+CATEGORY_DESTROY)
......
--骰娘炼成·补完式 --骰娘炼成·补完式
if not pcall(function() require("expansions/script/c44000001") end) then require("script/c44000001") end
local id,s = rscf.DefineCard(44000032,"MrsDice_Taught") local id,s = rscf.DefineCard(44000032,"MrsDice_Taught")
function s.initial_effect(c) function s.initial_effect(c)
--Activate --Activate
......
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