Noobyhead99
2014-11-25T07:15:32Z
Hey guys, I'm having an issue with a card that I made.

UserPostedImage

The Fortress of the Fallen Ones
Spell/Field

This card's name is treated as "The Sanctuary in the Sky". Once per turn, if you have a "The Agent" monster in your Graveyard: You can banish 1 LIGHT Fairy-Type monster from your Graveyard, then target 1 LIGHT Fairy-Type monster in your Graveyard; Special Summon it. If this card is destroyed and sent to the Graveyard: Target as many of your banished non-Effect Fairy-Type monsters as possible, but not more than 3; shuffle them into the Deck. You can only use this effect of "The Fortress of the Fallen Ones" once per Duel.

--ザフォートラスアヴザフォーランワンズ 
function c87907534.initial_effect(c)
	--Activate
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	c:RegisterEffect(e1)
	--spsummon
	local e2=Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(87907534,0))
	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e2:SetType(EFFECT_TYPE_IGNITION)
	e2:SetRange(LOCATION_SZONE)
	e2:SetCountLimit(1)
	e2:SetCondition(c87907534.spcon)
	e2:SetTarget(c87907534.sptg)
	e2:SetOperation(c87907534.spop)
	c:RegisterEffect(e2)
	--todeck
	local e3=Effect.CreateEffect(c)
	e3:SetDescription(aux.Stringid(87907534,1))
	e3:SetCategory(CATEGORY_TODECK)
	e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
	e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
	e3:SetCode(EVENT_TO_GRAVE)
	e3:SetCountLimit(1,87907534+EFFECT_COUNT_CODE_DUEL)
	e3:SetCondition(c87907534.retcon)
	e3:SetTarget(c87907534.rettg)
	e3:SetOperation(c87907534.retop)
	c:RegisterEffect(e3)
end
function c87907534.spcon(e,tp,eg,ep,ev,re,r,rp)
	return Duel.IsExistingMatchingCard(Card.IsSetCard,tp,LOCATION_GRAVE,0,1,nil,0x44)
end
function c87907534.costfilter(c,e,tp)
	return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsRace(RACE_FAIRY) and c:IsAbleToRemoveAsCost()
		and Duel.IsExistingTarget(c87907534.spfilter,tp,LOCATION_GRAVE,0,1,c,e,tp)
end
function c87907534.spfilter(c,e,tp)
	return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsRace(RACE_FAIRY) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c87907534.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
	if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c87907534.spfilter(chkc,e,tp) end
	if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
		and Duel.IsExistingMatchingCard(c87907534.costfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
	local g=Duel.SelectMatchingCard(tp,c87907534.costfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
	Duel.Remove(g,POS_FACEUP,REASON_COST)
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
	local g=Duel.SelectTarget(tp,c87907534.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
	Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c87907534.spop(e,tp,eg,ep,ev,re,r,rp)
	if not e:GetHandler():IsRelateToEffect(e) then return end
	local tc=Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) then
		Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
	end
end
function c87907534.retcon(e,tp,eg,ep,ev,re,r,rp)
	return e:GetHandler():IsReason(REASON_DESTROY)
end
function c87907534.retfilter(c,e,tp)
	return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsRace(RACE_FAIRY) and (not c:IsType(TYPE_EFFECT))
		and c:IsControler(tp) and c:IsAbleToDeck()
end
function c87907534.rettg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
	if chkc then return c:IsLocation(LOCATION_REMOVED) and c87907534.retfilter(chkc,e,tp) end
	if chk==0 then return Duel.IsExistingTarget(c87907534.retfilter,tp,LOCATION_REMOVED,0,1,e:GetHandler(),e,tp) end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
	local ct=Duel.GetMatchingGroupCount(c87907534.retfilter,tp,LOCATION_REMOVED,0,nil)
	if ct > 3 then ct = 3 end
	local g=Duel.SelectTarget(tp,c87907534.retfilter,tp,LOCATION_REMOVED,LOCATION_REMOVED,ct,ct,nil)
	Duel.SetOperationInfo(0,CATEGORY_TODECK,g,g:GetCount(),0,0)
end
function c87907534.retop(e,tp,eg,ep,ev,re,r,rp)
	local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
	local sg=g:Filter(Card.IsRelateToEffect,nil,e)
	Duel.SendtoDeck(sg,nil,2,REASON_EFFECT)
end
The issue is that, while dueling against the AI, the last effect will not resolve or target under any circumstances, though it will activate without effect. The strange part is that the effect works fine in a Duel Puzzle, however breaks when in an actual duel.

I was wondering if anyone could suggest a fix. You can download this version of the card added to the cdb with the image here  (1.033.2 V2).

I was also wondering about what the purpose of the following parts of code are, and I would very much appreciate it if anyone could give an in-depth explanation:
  • Duel.IsExistingTarget(c87907534.spfilter,tp,LOCATION_GRAVE,0,1,c,e,tp)
  • if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c87907534.spfilter(chkc,e,tp) end
  • if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
    and Duel.IsExistingMatchingCard(c87907534.costfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
  • The operation function in general

Thanks!
Freddx
2014-11-26T06:37:31Z
Try this:


function c87907534.rettg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
    if chkc then return c:IsLocation(LOCATION_REMOVED) and c87907534.retfilter(chkc,e,tp) end
    if chk==0 then return Duel.IsExistingTarget(c87907534.retfilter,tp,LOCATION_REMOVED,0,1,nil,e,tp) end
    Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
    local ct=Duel.GetMatchingGroupCount(c87907534.retfilter,tp,LOCATION_REMOVED,0,nil)
    local t = 0
    if ct > 3 then t = 3 end
    local g=Duel.SelectTarget(tp,c87907534.retfilter,tp,LOCATION_REMOVED,LOCATION_REMOVED,t,t,nil)
    Duel.SetOperationInfo(0,CATEGORY_TODECK,g,g:GetCount(),0,0)
end

I think you can't change the ct value, but well I'm not sure.

And you do a little error here, but is not so important
Quote:


Duel.IsExistingTarget(c87907534.retfilter,tp,LOCATION_REMOVED,0,1,e:GetHandler(),e,tp)

Quote:



Tthat mean "Exist 1 Target in the removed zone that is "Fairy", "LIGHT", "Non-Effect" but not e:GetHandler(), e:GetHandler() is The Fortress of the Fallen Ones.



Sorry for gramar errors, my english isn't the best.
Noobyhead99
2014-11-26T08:18:16Z
Cheers for both, I'll give your solution a go the next time I can and report back here with the results.

EDIT: I haven't tested it yet, but are you sure that will work? Judging by the code, the number of targets will always be 0 unless there are more than 3.
Freddx
2014-11-26T13:48:07Z
Originally Posted by: Noobyhead99 

Cheers for both, I'll give your solution a go the next time I can and report back here with the results.

EDIT: I haven't tested it yet, but are you sure that will work? Judging by the code, the number of targets will always be 0 unless there are more than 3.



Yes, was my error

function c87907534.rettg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return c:IsLocation(LOCATION_REMOVED) and c87907534.retfilter(chkc,e,tp) end
if chk==0 then return Duel.IsExistingTarget(c87907534.retfilter,tp,LOCATION_REMOVED,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local ct=Duel.GetMatchingGroupCount(c87907534.retfilter,tp,LOCATION_REMOVED,0,nil)
local t = 0
if ct > 3 then t = 3 else t = ct end
local g=Duel.SelectTarget(tp,c87907534.retfilter,tp,LOCATION_REMOVED,LOCATION_REMOVED,t,t,nil)
Duel.SetOperationInfo(0,CATEGORY_TODECK,g,g:GetCount(),0,0)
end

I will try use your card to find the error.
Freddx
2014-11-26T14:29:11Z
Ok, now works fine for me.

Try this:


function c87907534.retfilter(c,e,tp)
    return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsRace(RACE_FAIRY) and c:IsAbleToDeck()
	and not c:IsType(TYPE_EFFECT)
end
function c87907534.rettg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
    if chkc then return c:IsLocation(LOCATION_REMOVED) and c87907534.retfilter(chkc,e,tp) end
    if chk==0 then return Duel.IsExistingTarget(c94000001.retfilter,tp,LOCATION_REMOVED,0,1,nil,e,tp) end
    Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
    local ct=Duel.GetMatchingGroupCount(c87907534.retfilter,tp,LOCATION_REMOVED,0,nil)
    local t = 0 
	if ct >= 3 then 
	t = 3
	else
	t = ct 
	end 
    local g=Duel.SelectTarget(tp,c87907534.retfilter,tp,LOCATION_REMOVED,0,t,t,nil,e,tp)
    Duel.SetOperationInfo(0,CATEGORY_TODECK,g,g:GetCount(),0,0)
end


I add the local t but well I think is no necesary, the error was in the filter "c:IsControler(tp)"
Noobyhead99
2014-11-28T06:00:11Z
Thanks, fiddling around with c:IsControler(tp) worked. I also fixed my other error in which I specified both Graveyards in Duel.SelectTarget rather than just the one I wanted, which I think was also part of the issue.

If you guys want the updated version of the card, you can download it here . Copy the contents of that zip into your expansions folder, and you're good to go.

On a side note, I only just found out what the expansions folder is for. Wow.