danryba17
2014-10-01T22:51:37Z
I am trying to script the unconfirmed effect of Merlin and i made a success in first effect (tribute to special summon)
But really confused with second and third
The thing is, that in second effect i don't know how to make it indestructible by NK effects
And the third effect works perfectly6 if i put in initial settype(ignition), but since it is during either's player turn i need to put there settype(quick_o). Unfortunately, with these changings i cannot even target a NK monster on my field. Here is the script:

function c501002003.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1,501002003)
e1:SetCost(c501002003.cost)
e1:SetTarget(c501002003.target)
e1:SetOperation(c501002003.operation)
c:RegisterEffect(e1)
--preventfrombeingdestroy
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetRange(LOCATION_GRAVE)
e2:SetCountLimit(1,501002003)
e2:SetCost(c501002003.indcost)
e2:SetOperation(c501002003.indop)
c:RegisterEffect(e2)
--xyzchanging
local e3=Effect.CreateEffect(c)
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetCode(EVENT_FREE_CHAIN)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetRange(LOCATION_GRAVE)
e3:SetCountLimit(1,501002003)
e3:SetCost(c501002003.spcost)
e3:SetTarget(c501002003.sptg)
e3:SetOperation(c501002003.spop)
c:RegisterEffect(e3)
end
function c501002003.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsReleasable() end
Duel.Release(e:GetHandler(),REASON_COST)
end
function c501002003.filter(c,e,tp)
return c:IsSetCard(0x107a) and c:IsRace(RACE_WARRIOR) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c501002003.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1
and Duel.IsExistingMatchingCard(c501002003.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c501002003.operation(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c501002003.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetTargetRange(1,0)
e1:SetTarget(c501002003.splimit)
Duel.RegisterEffect(e1,tp)
end
function c501002003.splimit(e,c,sump,sumtype,sumpos,targetp,se)
return not c:IsSetCard(0x107a)
end
function c501002003.indcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST)
end
function c501002003.infilter(c,e,tp)
return c:IsFaceup() and c:IsType(TYPE_SPELL)
end
function c501002003.indop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(c501002003.infilter,tp,LOCATION_SZONE,0,nil)
local tc=g:GetFirst()
while tc do
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e1:SetValue(1)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
tc=g:GetNext()
end
end
function c501002003.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST)
end
function c501002003.filter1(c,e,tp)
return c:IsFaceup() and c:IsSetCard(0x107a)
and Duel.IsExistingMatchingCard(c501002003.filter2,tp,LOCATION_EXTRA,0,1,nil,c:GetCode(),e,tp)
end
function c501002003.filter2(c,e,tp)
return c:IsType(TYPE_XYZ) and c:IsSetCard(0x107a)
end
function c501002003.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and c501002003.filter1(chkc) end
if chk==0 then return --Duel.GetLocationCount(tp,LOCATION_MZONE)>-1and
Duel.IsExistingTarget(c501002003.filter1,tp,LOCATION_MZONE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
Duel.SelectTarget(tp,c501002003.filter1,tp,LOCATION_MZONE,0,1,1,nil,e,tp)
--Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function c501002003.spop(e,tp,eg,ep,ev,re,r,rp)
--if Duel.GetLocationCount(tp,LOCATION_MZONE)<0 then return end
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c501002003.filter2,tp,LOCATION_EXTRA,0,1,1,nil,tc:GetCode(),e,tp)
local sc=g:GetFirst()
if sc then
local mg=tc:GetOverlayGroup()
if mg:GetCount()~=0 then
Duel.Overlay(sc,mg)
end
Duel.Overlay(sc,Group.FromCards(tc))
Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP)
sc:CompleteProcedure()
end
end
end


Really hope for some help
Users browsing this topic