Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions pre-release/c101403031.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ function s.initial_effect(c)
c:RegisterEffect(e0a)
--Must be either Fusion Summoned, or Special Summoned (from your Extra Deck) to your opponent's Main Monster Zone by sending the above cards from either field to the GY, but if you Special Summon this card with the second method, you can only Special Summon once for the rest of this turn
c:AddMustBeFusionSummoned()
local e0b=Fusion.CreateContactProc(c,s.contactfil,s.contactop,nil,nil,1,aux.Stringid(id,0),false)
e0b:SetProperty(EFFECT_FLAG_SPSUM_PARAM+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e0b:SetTargetRange(POS_FACEUP,1)
e0b:SetValue(function(e,c)
return 1,ZONES_MMZ
end)
c:RegisterEffect(e0b)
Fusion.AddContactProc({
handler=c,
materialFilter=s.contactfil,
materialOperation=s.contactop,
sumtype=1,
desc=aux.Stringid(id,0),
summonToPlayer=1,
summonToZones=ZONES_MMZ
})
--You can only Special Summon "The Sun God's Steelcage - Lava Golem" once per turn this way, no matter which method you use
local e0c=Effect.CreateEffect(c)
e0c:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
Expand Down Expand Up @@ -96,4 +98,4 @@ end
function s.damop(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Damage(p,d,REASON_EFFECT)
end
end
69 changes: 48 additions & 21 deletions proc_fusion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ if not Fusion then
Fusion = aux.FusionProcedure
end

local ForcedUseZone=nil
local function GetForcedZone(chkfnf)
local zone=(chkfnf>>40)&0xff
if zone==0 then zone=0xff end
return zone
end

--The current reason effect that corresponds to the effect that is performing the fusion summon
Fusion.SummonEffect=nil
local function returnAndClearSummonEffect(value)
Expand Down Expand Up @@ -98,6 +105,7 @@ function Fusion.ConditionMix(insf,sub,...)
end
Fusion.SummonEffect=summonEff
local chkf=chkfnf&0xff
ForcedUseZone=GetForcedZone(chkfnf)
local notfusion=(chkfnf&FUSPROC_NOTFUSION)~=0
local contact=(chkfnf&FUSPROC_CONTACTFUS)~=0
local listedmats=(chkfnf&FUSPROC_LISTEDMATS)~=0
Expand Down Expand Up @@ -130,6 +138,7 @@ function Fusion.OperationMix(insf,sub,...)
return function(e,tp,eg,ep,ev,re,r,rp,gc,chkfnf,summonEff)
Fusion.SummonEffect=summonEff
local chkf=chkfnf&0xff
ForcedUseZone=GetForcedZone(chkfnf)
local c=e:GetHandler()
local tp=c:GetControler()
local notfusion=(chkfnf&FUSPROC_NOTFUSION)~=0
Expand Down Expand Up @@ -216,7 +225,7 @@ Fusion.CheckAdditional=nil
function Fusion.CheckMixGoal(tp,sg,fc,sub,sub2,contact,sumtype,chkf,...)
local g=Group.CreateGroup()
return sg:IsExists(Fusion.CheckMix,1,nil,sg,g,fc,sub,sub2,contact,sumtype,tp,...) and
(chkf==PLAYER_NONE or (fc:IsLocation(LOCATION_EXTRA) and Duel.GetLocationCountFromEx(tp,tp,sg,fc) or Duel.GetMZoneCount(tp,sg,tp))>0)
(chkf==PLAYER_NONE or (fc:IsLocation(LOCATION_EXTRA) and Duel.GetLocationCountFromEx(chkf,tp,sg,fc,ForcedUseZone) or Duel.GetMZoneCount(chkf,sg,tp))>0)
and (not Fusion.CheckAdditional or Fusion.CheckAdditional(tp,sg,fc,sumtype,tp))
end
function Fusion.SelectMix(c,tp,mg,sg,mustg,fc,sub,sub2,contact,sumtype,chkf,...)
Expand Down Expand Up @@ -321,6 +330,7 @@ function Fusion.ConditionMixRep(insf,sub,fun1,minc,maxc,...)
end
Fusion.SummonEffect=summonEff
local chkf=chkfnf&0xff
ForcedUseZone=GetForcedZone(chkfnf)
local notfusion=(chkfnf&FUSPROC_NOTFUSION)~=0
local contact=(chkfnf&FUSPROC_CONTACTFUS)~=0
local listedmats=(chkfnf&FUSPROC_LISTEDMATS)~=0
Expand Down Expand Up @@ -353,6 +363,7 @@ function Fusion.OperationMixRep(insf,sub,fun1,minc,maxc,...)
return function(e,tp,eg,ep,ev,re,r,rp,gc,chkfnf,summonEff)
Fusion.SummonEffect=summonEff
local chkf=chkfnf&0xff
ForcedUseZone=GetForcedZone(chkfnf)
local c=e:GetHandler()
local tp=c:GetControler()
local notfusion=(chkfnf&FUSPROC_NOTFUSION)~=0
Expand Down Expand Up @@ -427,7 +438,7 @@ end
function Fusion.CheckMixRepGoal(tp,sg,mustg,fc,sub,sub2,contact,sumtype,chkf,fun1,minc,maxc,...)
if #sg<minc+#{...} or #sg>maxc+#{...} then return false end
local g=Group.CreateGroup()
return Fusion.CheckMixRep(sg,g,fc,sub,sub2,contact,sumtype,chkf,tp,fun1,minc,maxc,...) and (chkf==PLAYER_NONE or Duel.GetLocationCountFromEx(tp,tp,sg,fc)>0)
return Fusion.CheckMixRep(sg,g,fc,sub,sub2,contact,sumtype,chkf,tp,fun1,minc,maxc,...) and (chkf==PLAYER_NONE or Duel.GetLocationCountFromEx(chkf,tp,sg,fc,ForcedUseZone)>0)
and (not Fusion.CheckAdditional or Fusion.CheckAdditional(tp,sg,fc,sumtype,tp))
end
function Fusion.CheckMixRepTemplate(c,cond,tp,mg,sg,mustg,g,fc,sub,sub2,contact,sumtype,chkf,fun1,minc,maxc,...)
Expand Down Expand Up @@ -465,7 +476,7 @@ function Fusion.CheckMixRepSelected(c,...)
end
function Fusion.CheckSelectMixRep(tp,mg,sg,mustg,g,fc,sub,sub2,contact,sumtype,chkf,fun1,minc,maxc,...)
if Fusion.CheckAdditional and not Fusion.CheckAdditional(tp,g,fc,sumtype,tp) then return false end
if chkf==PLAYER_NONE or Duel.GetLocationCountFromEx(tp,tp,g,fc)>0 then
if chkf==PLAYER_NONE or Duel.GetLocationCountFromEx(chkf,tp,g,fc,ForcedUseZone)>0 then
if minc<=0 and #{...}==0 and g:Includes(mustg) then return true end
return mg:IsExists(Fusion.CheckSelectMixRepAll,1,g,tp,mg,sg,mustg,g,fc,sub,sub2,contact,sumtype,chkf,fun1,minc,maxc,...)
else
Expand Down Expand Up @@ -614,6 +625,7 @@ function Fusion.ConditionMixRepUnfix(insf,sub,minc,maxc,...)
end
Fusion.SummonEffect=summonEff
local chkf=chkfnf&0xff
ForcedUseZone=GetForcedZone(chkfnf)
local c=e:GetHandler()
local tp=c:GetControler()
local notfusion=(chkfnf&FUSPROC_NOTFUSION)~=0
Expand Down Expand Up @@ -645,6 +657,7 @@ function Fusion.OperationMixRepUnfix(insf,sub,minc,maxc,...)
return function(e,tp,eg,ep,ev,re,r,rp,gc,chkfnf,summonEff)
Fusion.SummonEffect=summonEff
local chkf=chkfnf&0xff
ForcedUseZone=GetForcedZone(chkfnf)
local c=e:GetHandler()
local tp=c:GetControler()
local notfusion=(chkfnf&FUSPROC_NOTFUSION)~=0
Expand Down Expand Up @@ -754,7 +767,7 @@ function Fusion.CheckMixRepUnfixSelected(c,...)
end
function Fusion.CheckSelectMixRepUnfix(tp,mg,sg,mustg,g,fc,sub,sub2,chkf,minc,maxc,...)
if Fusion.CheckAdditional and not Fusion.CheckAdditional(tp,g,fc,sumtype,tp) then return false end
if chkf==PLAYER_NONE or Duel.GetLocationCountFromEx(tp,tp,g,fc)>0 then
if chkf==PLAYER_NONE or Duel.GetLocationCountFromEx(chkf,tp,g,fc,ForcedUseZone)>0 then
if minc<=0 and g:Includes(mustg) then return true end
return mg:IsExists(Fusion.CheckSelectMixRepUnfixAll,1,g,tp,mg,sg,mustg,g,fc,sub,sub2,chkf,minc,maxc,...)
else
Expand Down Expand Up @@ -864,8 +877,8 @@ function Fusion.SelectMixRepUnfix(c,tp,mg,sg,mustg,fc,sub,sub2,minc,maxc,chkf,..
return res
end


function Fusion.CreateContactProc(c,group,op,sumcon,condition,sumtype,desc,cannotBeLizard)
Fusion.CreateContactProc = aux.FunctionWithNamedArgs(
function(c,group,op,sumcon,condition,sumtype,desc,cannotBeLizard,summonToPlayer,summonToZones)
if c:IsStatus(STATUS_COPYING_EFFECT) then return nil end
local mt=c.__index
local t={}
Expand All @@ -882,13 +895,23 @@ function Fusion.CreateContactProc(c,group,op,sumcon,condition,sumtype,desc,canno
e1:SetDescription(desc)
end
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
local effectFlag=EFFECT_FLAG_UNCOPYABLE
e1:SetRange(LOCATION_EXTRA)
if sumtype then
if summonToPlayer then
e1:SetTargetRange(POS_FACEUP,summonToPlayer)
effectFlag=effectFlag|EFFECT_FLAG_SPSUM_PARAM
end
e1:SetProperty(effectFlag)
if summonToZones then
sumtype=sumtype or 0
e1:SetValue(function(e,c)
return sumtype,summonToZones,true
end)
elseif sumtype then
e1:SetValue(sumtype)
end
e1:SetCondition(Fusion.ContactCon(group,condition))
e1:SetTarget(Fusion.ContactTg(group))
e1:SetCondition(Fusion.ContactCon(group,condition,summonToPlayer,summonToZones))
e1:SetTarget(Fusion.ContactTg(group,summonToPlayer,summonToZones))
e1:SetOperation(Fusion.ContactOp(op))
local e2=nil
if sumcon then
Expand All @@ -906,27 +929,32 @@ function Fusion.CreateContactProc(c,group,op,sumcon,condition,sumtype,desc,canno
Auxiliary.addLizardCheck(c)
end
return e1,e2
end
function Fusion.AddContactProc(c,group,op,sumcon,condition,sumtype,desc,cannotBeLizard)
local e1,e2=Fusion.CreateContactProc(c,group,op,sumcon,condition,sumtype,desc,cannotBeLizard)
end,"handler","materialFilter","materialOperation","sumcon","condition","sumtype","desc","cannotBeLizard","summonToPlayer","summonToZones")

function Fusion.AddContactProc(c,...)
local tab=type(c)=="table"
local e1,e2=Fusion.CreateContactProc(tab and c or c,...)
c=(tab and c["handler"] or c)
if e1 then c:RegisterEffect(e1) end
if e2 then c:RegisterEffect(e2) end
end
function Fusion.ContactCon(f,fcon)
function Fusion.ContactCon(f,fcon,summonToPlayer,summonToZones)
return function(e,c)
if c==nil then return true end
local m=f(e:GetHandlerPlayer())
local chkf=c:GetControler()|FUSPROC_CONTACTFUS
return c:IsFacedown() and c:CheckFusionMaterial(m,nil,chkf) and (not fcon or fcon(e:GetHandlerPlayer()))
local chkp=summonToPlayer==1 and (1-c:GetControler()) or c:GetControler()
local chkf=chkp|FUSPROC_CONTACTFUS|((summonToZones and summonToZones or 0)<<40)
local res=c:IsFacedown() and c:CheckFusionMaterial(m,nil,chkf) and (not fcon or fcon(e:GetHandlerPlayer()))
return res
end
end
function Fusion.ContactTg(f)
function Fusion.ContactTg(f,summonToPlayer,summonToZones)
return function(e,tp,eg,ep,ev,re,r,rp)
local m=f(tp)
local chkf=tp|FUSPROC_CONTACTFUS
local chkp=summonToPlayer==1 and (1-tp) or tp
local chkf=chkp|FUSPROC_CONTACTFUS|((summonToZones and summonToZones or 0)<<40)
local sg=Duel.SelectFusionMaterial(tp,e:GetHandler(),m,nil,chkf)
if #sg>0 then
sg:KeepAlive()
e:SetLabelObject(sg)
return true
else return false end
Expand All @@ -937,7 +965,6 @@ function Fusion.ContactOp(f)
local g=e:GetLabelObject()
c:SetMaterial(g)
f(g,tp,c)
g:DeleteGroup()
end
end
--Fusion monster, name + name
Expand Down Expand Up @@ -1041,4 +1068,4 @@ function Fusion.UnionFusOp(g,tp)
Duel.SendtoDeck(g,nil,SEQ_DECKBOTTOM,REASON_COST+REASON_MATERIAL)
local og=Duel.GetOperatedGroup():Filter(Card.IsLocation,nil,LOCATION_DECK)
if #og>1 then Duel.SortDeckbottom(tp,tp,#og) end
end
end