a place for all your custom card needs you can post scripts pics and request for card to be made also please donate to the funding for a new server made for custom card duels
 
HomePortalCalendarFAQSearchMemberlistUsergroupsRegisterLog in

Share | .
 

 Help with custom card

View previous topic View next topic Go down 
AuthorMessage
kurosawa Riku

avatar


Member Title : chronicler
Posts : 2
Join date : 2014-02-05

PostSubject: Help with custom card   Mon Mar 03, 2014 5:06 pm

Not sure if this is the right place to ask this (if not can someone tell me the right place). I want to make a card with the following effect "if a monster you control would be removed from the field by a card or effect, negate that card's effect and destroy it." but this is the only way i can get it to work
Code:
function c22236549.initial_effect(c)
 --Destroy
 local e1=Effect.CreateEffect(c)
 e1:SetType(EFFECT_TYPE_ACTIVATE)
 e1:SetCode(EVENT_CHAINING)
 e1:SetCondition(c22236549.condition)
 e1:SetTarget(c22236549.target)
 e1:SetOperation(c22236549.activate)
 c:RegisterEffect(e1)
 --to hand
 local e2=Effect.CreateEffect(c)
 e2:etType(EFFECT_TYPE_ACTIVATE)
 e2:SetCode(EVENT_CHAINING)
 e2:SetCondition(c22236549.hcondition)
 e2:SetTarget(c22236549.target)
 e2:SetOperation(c22236549.activate)
 c:RegisterEffect(e2)
 --to deck
 local e3=Effect.CreateEffect(c)
 e3:SetType(EFFECT_TYPE_ACTIVATE)
 e3:SetCode(EVENT_CHAINING)
 e3:SetCondition(c22236549.dcondition)
 e3:SetTarget(c22236549.target)
 e3:SetOperation(c22236549.activate)
 c:RegisterEffect(e3)
 --remove
 local e4=Effect.CreateEffect(c)
 e4:SetType(EFFECT_TYPE_ACTIVATE)
 e4:SetCode(EVENT_CHAINING)
 e4:SetCondition(c22236549.rcondition)
 e4:SetTarget(c22236549.target)
 e4:SetOperation(c22236549.activate)
 c:RegisterEffect(e4)
 --to grave
 local e5=Effect.CreateEffect(c)
 e5:SetType(EFFECT_TYPE_ACTIVATE)
 e5:SetCode(EVENT_CHAINING)
 e5:SetCondition(c22236549.gcondition)
 e5:SetTarget(c22236549.target)
 e5:SetOperation(c22236549.activate)
 c:RegisterEffect(e5)
end
function c22236549.condition(e,tp,eg,ep,ev,re,r,rp)
 if not re:IsHasType(EFFECT_TYPE_ACTIVATE) or not Duel.IsChainNegatable(ev) then return false end
 local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
 if not g or g:GetCount()~=1 then return false end
 local gc=g:GetFirst()
 if not gc:IsControler(tp) or not gc:IsLocation(LOCATION_MZONE) then return false end
 local ex,tg,tc=Duel.GetOperationInfo(ev,CATEGORY_DESTROY)
 return ex and tg~=nil and tg:GetCount()==1 and tg:GetFirst()==gc
end
function c22236549.hcondition(e,tp,eg,ep,ev,re,r,rp)
 if not re:IsHasType(EFFECT_TYPE_ACTIVATE) or not Duel.IsChainNegatable(ev) then return false end
 local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
 if not g or g:GetCount()~=1 then return false end
 local gc=g:GetFirst()
 if not gc:IsControler(tp) or not gc:IsLocation(LOCATION_MZONE) then return false end
 local ex,tg,tc=Duel.GetOperationInfo(ev,CATEGORY_TOHAND)
 return ex and tg~=nil and tg:GetCount()==1 and tg:GetFirst()==gc
end
function c22236549.dcondition(e,tp,eg,ep,ev,re,r,rp)
 if not re:IsHasType(EFFECT_TYPE_ACTIVATE) or not Duel.IsChainNegatable(ev) then return false end
 local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
 if not g or g:GetCount()~=1 then return false end
 local gc=g:GetFirst()
 if not gc:IsControler(tp) or not gc:IsLocation(LOCATION_MZONE) then return false end
 local ex,tg,tc=Duel.GetOperationInfo(ev,CATEGORY_TODECK)
 return ex and tg~=nil and tg:GetCount()==1 and tg:GetFirst()==gc
end
function c22236549.rcondition(e,tp,eg,ep,ev,re,r,rp)
 if not re:IsHasType(EFFECT_TYPE_ACTIVATE) or not Duel.IsChainNegatable(ev) then return false end
 local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
 if not g or g:GetCount()~=1 then return false end
 local gc=g:GetFirst()
 if not gc:IsControler(tp) or not gc:IsLocation(LOCATION_MZONE) then return false end
 local ex,tg,tc=Duel.GetOperationInfo(ev,CATEGORY_REMOVE)
 return ex and tg~=nil and tg:GetCount()==1 and tg:GetFirst()==gc
end
function c22236549.gcondition(e,tp,eg,ep,ev,re,r,rp)
 if not re:IsHasType(EFFECT_TYPE_ACTIVATE) or not Duel.IsChainNegatable(ev) then return false end
 local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
 if not g or g:GetCount()~=1 then return false end
 local gc=g:GetFirst()
 if not gc:IsControler(tp) or not gc:IsLocation(LOCATION_MZONE) then return false end
 local ex,tg,tc=Duel.GetOperationInfo(ev,CATEGORY_TOGRAVE)
 return ex and tg~=nil and tg:GetCount()==1 and tg:GetFirst()==gc
end
function c22236549.target(e,tp,eg,ep,ev,re,r,rp,chk)
 if chk==0 then return true end
 Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
 if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
 Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0)
 end
end
function c22236549.activate(e,tp,eg,ep,ev,re,r,rp)
 Duel.NegateActivation(ev)
 if re:GetHandler():IsRelateToEffect(re) then
 Duel.Destroy(eg,REASON_EFFECT)
 end
end

and i was wondering if there was a more efficient way of coding it, any help would be appreciated
thanks in advance.
Back to top Go down
View user profile
outlaw1994

avatar
Admin
Admin

Member Title : Red-Eyes Lord
Posts : 797
Join date : 2013-07-09
Age : 23
Location : bundaberg qld australia

PostSubject: Re: Help with custom card   Tue Mar 04, 2014 8:57 am

here you go

Code:
function c22236549.initial_effect(c)
 --negate
 local e1=Effect.CreateEffect(c)
 e1:SetType(EFFECT_TYPE_ACTIVATE)
 e1:SetCode(EVENT_CHAINING)
 e1:SetCondition(c22236549.condition)
 e1:SetTarget(c22236549.target)
 e1:SetOperation(c22236549.activate)
 c:RegisterEffect(e1)
end

function c22236549.condition(e,tp,eg,ep,ev,re,r,rp)
   local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
   if not g or g:GetCount()~=1 then return false end
   local tc=g:GetFirst()
 return (re:IsActiveType(TYPE_MONSTER) or (re:IsActiveType(TYPE_TRAP) and re:IsHasType(EFFECT_TYPE_ACTIVATE))
  or (re:IsActiveType(TYPE_SPELL) and re:IsHasType(EFFECT_TYPE_ACTIVATE))) and (re:IsHasCategory(CATEGORY_DESTROY)
  or re:IsHasCategory(CATEGORY_TOGRAVE) or re:IsHasCategory(CATEGORY_TOHAND) or re:IsHasCategory(CATEGORY_TODECK)
    or re:IsHasCategory(CATEGORY_REMOVE)) and tc:IsControler(tp) and tc:IsType(TYPE_MONSTER) and Duel.IsChainNegatable(ev)
end

function c22236549.target(e,tp,eg,ep,ev,re,r,rp,chk)
 if chk==0 then return true end
 Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
 if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
 Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0)
 end
end
function c22236549.activate(e,tp,eg,ep,ev,re,r,rp)
 Duel.NegateActivation(ev)
 if re:GetHandler():IsRelateToEffect(re) then
 Duel.Destroy(eg,REASON_EFFECT)
 end
end
Back to top Go down
View user profile http://mackpro.userboard.net
kurosawa Riku

avatar


Member Title : chronicler
Posts : 2
Join date : 2014-02-05

PostSubject: Re: Help with custom card   Tue Mar 04, 2014 11:58 am

That's perfect, thank you for that, i owe you one.
Back to top Go down
View user profile
outlaw1994

avatar
Admin
Admin

Member Title : Red-Eyes Lord
Posts : 797
Join date : 2013-07-09
Age : 23
Location : bundaberg qld australia

PostSubject: Re: Help with custom card   Tue Mar 04, 2014 12:00 pm

No problem I will be active again soon and hopefully get all these cards coded
Back to top Go down
View user profile http://mackpro.userboard.net
Sponsored content





PostSubject: Re: Help with custom card   

Back to top Go down
 

Help with custom card

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Mackpro :: MackPro :: Requests-