name: Destiny
card_text: 1 "Destiny HERO" Fusion Monster + 1 "Destiny HERO" monster
  If this card is Fusion Summoned: You can Fusion Summon 1 Fusion Monster from your Extra Deck, using monsters from your hand or field as Fusion Material. Once per turn (Quick Effect): You can target 1 monster on the field; until the end of this turn, it cannot be destroyed by battle or card effects, and neither player takes any battle damage from attacks involving that monster.
external_ids: local SETCARD_ID_0 = 0xc008 --Destiny
  
lua: local SETCARD_ID_0 = 0xc008 --Destiny
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddFusionProcFun2(c, s.matfilter, aux.FilterBoolFunction(Card.IsFusionSetCard, SETCARD_ID_0), true)
  	--fusion success
  	local e1 = FusionSpell.CreateSummonEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetTarget(s.indtg)
  	e2:SetOperation(s.indop)
  	c:RegisterEffect(e2)
  end
  
  s.material_setcode = 0xc008
  
  function s.matfilter(c)
  	return c:IsFusionType(TYPE_FUSION) and c:IsFusionSetCard(SETCARD_ID_0)
  end
  
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  
  function s.indtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(nil, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, nil, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  end
  
  function s.indop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  		tc:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		e3:SetCode(EFFECT_NO_BATTLE_DAMAGE)
  		tc:RegisterEffect(e3)
  		local e4 = e1:Clone()
  		e4:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  		tc:RegisterEffect(e4)
  	end
  end
  
  
source_text: Destiny
  1 "Destiny HERO" Fusion Monster + 1 "Destiny HERO" monster
  If this card is Fusion Summoned: You can Fusion Summon 1 Fusion Monster from your Extra Deck, using monsters from your hand or field as Fusion Material. Once per turn (Quick Effect): You can target 1 monster on the field; until the end of this turn, it cannot be destroyed by battle or card effects, and neither player takes any battle damage from attacks involving that monster.
target_text: -- Destiny
  local SETCARD_ID_0 = 0xc008 --Destiny
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddFusionProcFun2(c, s.matfilter, aux.FilterBoolFunction(Card.IsFusionSetCard, SETCARD_ID_0), true)
  	--fusion success
  	local e1 = FusionSpell.CreateSummonEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--indes
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetTarget(s.indtg)
  	e2:SetOperation(s.indop)
  	c:RegisterEffect(e2)
  end
  
  s.material_setcode = 0xc008
  
  function s.matfilter(c)
  	return c:IsFusionType(TYPE_FUSION) and c:IsFusionSetCard(SETCARD_ID_0)
  end
  
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_FUSION)
  end
  
  function s.indtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(nil, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, nil, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  end
  
  function s.indop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  		tc:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		e3:SetCode(EFFECT_NO_BATTLE_DAMAGE)
  		tc:RegisterEffect(e3)
  		local e4 = e1:Clone()
  		e4:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  		tc:RegisterEffect(e4)
  	end
  end
  
  