Destiny
Once per turn, during your Standby Phase: You can target 1 "Destiny HERO" monster in your Graveyard that was destroyed by battle since your last Standby Phase, if you controlled this face-up card when the target was destroyed; Special Summon that target.
local SETCARD_ID_0 = 0xc008 --Destiny

local SETCARD_ID_0 = 0xc008 --Destiny
local s, id, o = GetID()
function s.initial_effect(c)
	--spsummon
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCode(EVENT_BATTLE_DESTROYED)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
	local g = Group.CreateGroup()
	g:KeepAlive()
	e1:SetLabelObject(g)
	--spsummon
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCountLimit(1)
	e2:SetCode(EVENT_PHASE + PHASE_STANDBY)
	e2:SetCondition(s.spcon)
	e2:SetTarget(s.sptg)
	e2:SetOperation(s.spop)
	e2:SetLabelObject(g)
	c:RegisterEffect(e2)
end
function s.filter(c, e, tp)
	return c:IsLocation(LOCATION_GRAVE) and c:IsReason(REASON_BATTLE) and c:IsPreviousControler(tp) and c:IsSetCard(SETCARD_ID_0)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local g = eg:Filter(s.filter, nil, e, tp)
	if g:GetCount() == 0 then
		return
	end
	local sg = e:GetLabelObject()
	local c = e:GetHandler()
	if c:GetFlagEffect(id) == 0 then
		sg:Clear()
		c:RegisterFlagEffect(id, RESET_EVENT + 0x3fe0000 + RESET_PHASE + PHASE_STANDBY + RESET_SELF_TURN, 0, 1)
	end
	sg:Merge(g)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return Duel.GetTurnPlayer() == tp and e:GetHandler():GetFlagEffect(id) ~= 0
end
function s.spfilter(c, e, tp)
	return c:IsLocation(LOCATION_GRAVE) and c:IsReason(REASON_BATTLE) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and c:IsCanBeEffectTarget(e)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return e:GetLabelObject():IsContains(chkc) and s.spfilter(chkc, e, tp)
	end
	if chk == 0 then
		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetLabelObject():IsExists(s.spfilter, 1, nil, e, tp)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local g = e:GetLabelObject():FilterSelect(tp, s.spfilter, 1, 1, nil, e, tp)
	Duel.SetTargetCard(g)
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) then
		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
	end
end


Destiny
Once per turn, during your Standby Phase: You can target 1 "Destiny HERO" monster in your Graveyard that was destroyed by battle since your last Standby Phase, if you controlled this face-up card when the target was destroyed; Special Summon that target.
-- Destiny
local SETCARD_ID_0 = 0xc008 --Destiny
local s, id, o = GetID()
function s.initial_effect(c)
	--spsummon
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCode(EVENT_BATTLE_DESTROYED)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
	local g = Group.CreateGroup()
	g:KeepAlive()
	e1:SetLabelObject(g)
	--spsummon
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCountLimit(1)
	e2:SetCode(EVENT_PHASE + PHASE_STANDBY)
	e2:SetCondition(s.spcon)
	e2:SetTarget(s.sptg)
	e2:SetOperation(s.spop)
	e2:SetLabelObject(g)
	c:RegisterEffect(e2)
end
function s.filter(c, e, tp)
	return c:IsLocation(LOCATION_GRAVE) and c:IsReason(REASON_BATTLE) and c:IsPreviousControler(tp) and c:IsSetCard(SETCARD_ID_0)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local g = eg:Filter(s.filter, nil, e, tp)
	if g:GetCount() == 0 then
		return
	end
	local sg = e:GetLabelObject()
	local c = e:GetHandler()
	if c:GetFlagEffect(id) == 0 then
		sg:Clear()
		c:RegisterFlagEffect(id, RESET_EVENT + 0x3fe0000 + RESET_PHASE + PHASE_STANDBY + RESET_SELF_TURN, 0, 1)
	end
	sg:Merge(g)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return Duel.GetTurnPlayer() == tp and e:GetHandler():GetFlagEffect(id) ~= 0
end
function s.spfilter(c, e, tp)
	return c:IsLocation(LOCATION_GRAVE) and c:IsReason(REASON_BATTLE) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and c:IsCanBeEffectTarget(e)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return e:GetLabelObject():IsContains(chkc) and s.spfilter(chkc, e, tp)
	end
	if chk == 0 then
		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetLabelObject():IsExists(s.spfilter, 1, nil, e, tp)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local g = e:GetLabelObject():FilterSelect(tp, s.spfilter, 1, 1, nil, e, tp)
	Duel.SetTargetCard(g)
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) then
		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
	end
end

