name: Nekroz
card_text: You can Ritual Summon this card with any "Nekroz" Ritual Spell Card. Must be Ritual Summoned without using "Nekroz of Catastor", and cannot be Special Summoned by other ways. You can discard this card, then target 1 "Nekroz" monster in your Graveyard; Special Summon it. You can only use this effect of "Nekroz of Catastor" once per turn. At the start of the Damage Step, if a "Nekroz" monster you control battles an opponent's face-up monster that was Special Summoned from the Extra Deck: Destroy that monster.
external_ids: local SETCARD_ID_0 = 0xb4 --Nekroz
  
lua: local SETCARD_ID_0 = 0xb4 --Nekroz
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.ritlimit)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.spcost)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_BATTLE_START)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.condition)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  end
  function s.mat_filter(c)
  	return not c:IsCode(id)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsDiscardable()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST + REASON_DISCARD)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	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
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetAttacker()
  	local bc = Duel.GetAttackTarget()
  	if not bc then
  		return false
  	end
  	if tc:IsControler(1 - tp) then
  		tc, bc = bc, tc
  	end
  	if tc:IsSetCard(SETCARD_ID_0) and bc:IsSummonLocation(LOCATION_EXTRA) then
  		e:SetLabelObject(bc)
  		return true
  	else
  		return false
  	end
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local bc = e:GetLabelObject()
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, bc, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local bc = e:GetLabelObject()
  	if bc:IsRelateToBattle() then
  		Duel.Destroy(bc, REASON_EFFECT)
  	end
  end
  
  
source_text: Nekroz
  You can Ritual Summon this card with any "Nekroz" Ritual Spell Card. Must be Ritual Summoned without using "Nekroz of Catastor", and cannot be Special Summoned by other ways. You can discard this card, then target 1 "Nekroz" monster in your Graveyard; Special Summon it. You can only use this effect of "Nekroz of Catastor" once per turn. At the start of the Damage Step, if a "Nekroz" monster you control battles an opponent's face-up monster that was Special Summoned from the Extra Deck: Destroy that monster.
target_text: -- Nekroz
  local SETCARD_ID_0 = 0xb4 --Nekroz
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(aux.ritlimit)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.spcost)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_BATTLE_START)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.condition)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  end
  function s.mat_filter(c)
  	return not c:IsCode(id)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsDiscardable()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST + REASON_DISCARD)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	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
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetAttacker()
  	local bc = Duel.GetAttackTarget()
  	if not bc then
  		return false
  	end
  	if tc:IsControler(1 - tp) then
  		tc, bc = bc, tc
  	end
  	if tc:IsSetCard(SETCARD_ID_0) and bc:IsSummonLocation(LOCATION_EXTRA) then
  		e:SetLabelObject(bc)
  		return true
  	else
  		return false
  	end
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local bc = e:GetLabelObject()
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, bc, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local bc = e:GetLabelObject()
  	if bc:IsRelateToBattle() then
  		Duel.Destroy(bc, REASON_EFFECT)
  	end
  end
  
  