DM999
  • DM999
  • Newbie Topic Starter
2021-05-25T04:04:52Z
I'm surprised no one made a topic on this before, but anyways I wanted to make a version of De-Fusion and De-Synchro but for Xyz monsters. The effect is simple and straightforward:

Target 1 face-up Xyz monster on the field; return it to the extra deck, then if all the Xyz materials that were used to Xyz Summon that monster are in the graveyard, you can Special Summon them.

...but I had trouble with scripting. I copied based off the script from De-Synchro and De-Fusion but it wouldn't work.

--De-Xyz
function c3711929.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TODECK+CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c3711929.target)
e1:SetOperation(c3711929.activate)
c:RegisterEffect(e1)
end
function c3711929.filter(c)
return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:IsAbleToExtra()
end
function c3711929.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c3711929.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c3711929.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectTarget(tp,c3711929.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TODECK,g,1,0,0)
end
function c3711929.mgfilter(c,e,tp,xyz)
return c:IsControler(tp) and c:IsLocation(LOCATION_GRAVE)
and bit.band(c:GetReason(),0x120008)==0x120008 and c:GetReasonCard()==xyz
and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c3711929.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsFacedown() or not tc:IsRelateToEffect(e) then return end
local mg=tc:GetMaterial()
local ct=mg:GetCount()
local sumtype=tc:GetSummonType()
if Duel.SendtoDeck(tc,nil,0,REASON_EFFECT)~=0 and sumtype==SUMMON_TYPE_XYZ
and ct>0 and not Duel.IsPlayerAffectedByEffect(tp,59822133)
and ct<=Duel.GetLocationCount(tp,LOCATION_MZONE)
and mg:FilterCount(aux.NecroValleyFilter(c3711929.mgfilter),nil,e,tp,tc)==ct
and Duel.SelectYesNo(tp,aux.Stringid(3711929,0)) then
Duel.BreakEffect()
Duel.SpecialSummon(mg,0,tp,tp,false,false,POS_FACEUP)
end
end

I'm going to assume the problem is somewhere in this part, but I'm not sure how to fix it:

function c3711929.mgfilter(c,e,tp,xyz)
return c:IsControler(tp) and c:IsLocation(LOCATION_GRAVE)
and bit.band(c:GetReason(),0x120008)==0x120008 and c:GetReasonCard()==xyz
and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end

Since De-Fusion says 0x40008 and De-Synchro says 0x80008 I thought something like 0x120008 would be for Xyz Materials but it doesn't work. Does anyone know how to fix this?
Users browsing this topic