| | Author | Message |
---|
kurosawa Riku
Member Title : chronicler Posts : 2 Join date : 2014-02-05
| Subject: 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. |
| | | outlaw1994
Admin
Member Title : Red-Eyes Lord Posts : 797 Join date : 2013-07-09 Age : 29 Location : bundaberg qld australia
| Subject: 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 |
| | | kurosawa Riku
Member Title : chronicler Posts : 2 Join date : 2014-02-05
| Subject: Re: Help with custom card Tue Mar 04, 2014 11:58 am | |
| That's perfect, thank you for that, i owe you one. |
| | | outlaw1994
Admin
Member Title : Red-Eyes Lord Posts : 797 Join date : 2013-07-09 Age : 29 Location : bundaberg qld australia
| Subject: 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 |
| | | Sponsored content
| Subject: Re: Help with custom card | |
| |
| | | |
Similar topics | |
|
| Permissions in this forum: | You cannot reply to topics in this forum
| |
| |
| Who is online? | In total there are 2 users online :: 0 Registered, 0 Hidden and 2 Guests None Most users ever online was 270 on Sun Apr 11, 2021 4:35 pm |
Latest topics | » Goodbye allMon Aug 08, 2016 7:53 pm by Zenas» [PLEASE READ] [VERY IMPORTANT] MACKPRO REVIVALMon Aug 08, 2016 7:47 pm by Zenas» D.D. Dragons vs KozmosSun Jul 10, 2016 11:02 pm by cane_63106» Where's everyone?!Sat May 28, 2016 2:58 am by cane_63106» Mech Archetype (crappy it be, maybe you guys would like it)Sun May 15, 2016 1:11 pm by barti02» My Assassin ArchetypeSun May 15, 2016 1:10 pm by barti02» SO I have a "NEW ARCHETYPE THE "WolfPack"Sun May 15, 2016 12:35 pm by barti02» Fusion monster doesn't appear in extra deck? Sat Apr 30, 2016 9:02 pm by Marc1» Mackpro update 10/6/2015Sat Apr 02, 2016 6:36 pm by Hulkty» Bionicle Cards AKA Japanese Children's Cardgames on Swedish Toy RobotsSun Mar 06, 2016 9:37 am by Utso |
|